summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp41
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p.h8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp10
5 files changed, 62 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index e010081..d827cda 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -162,6 +162,7 @@ QmlGraphicsFlickablePrivate::QmlGraphicsFlickablePrivate()
, interactive(true), deceleration(500), maxVelocity(5000), reportedVelocitySmoothing(100)
, delayedPressEvent(0), delayedPressTarget(0), pressDelay(0)
, horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0)
+ , flickDirection(QmlGraphicsFlickable::AutoFlickDirection)
{
fixupXEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsFlickablePrivate, &QmlGraphicsFlickablePrivate::fixupX>(&_moveX, this);
fixupYEvent = QmlTimeLineEvent::timeLineEvent<QmlGraphicsFlickablePrivate, &QmlGraphicsFlickablePrivate::fixupY>(&_moveY, this);
@@ -576,6 +577,36 @@ QmlGraphicsFlickableVisibleArea *QmlGraphicsFlickable::visibleArea()
return d->visibleArea;
}
+/*!
+ \qmlproperty enumeration Flickable::flickDirection
+
+ This property determines which directions the view can be flicked.
+
+ \list
+ \o AutoFlickDirection (default) - allows flicking vertically if the
+ \e viewportHeight is not equal to the \e height of the Flickable.
+ Allows flicking horizontally if the \e viewportWidth is not equal
+ to the \e width of the Flickable.
+ \o HorizontalFlick - allows flicking horizontally.
+ \o VerticalFlick - allows flicking vertically.
+ \o HorizontalAndVerticalFlick - allows flicking in both directions.
+ \endlist
+*/
+QmlGraphicsFlickable::FlickDirection QmlGraphicsFlickable::flickDirection() const
+{
+ Q_D(const QmlGraphicsFlickable);
+ return d->flickDirection;
+}
+
+void QmlGraphicsFlickable::setFlickDirection(FlickDirection direction)
+{
+ Q_D(QmlGraphicsFlickable);
+ if (direction != d->flickDirection) {
+ d->flickDirection = direction;
+ emit flickDirectionChanged();
+ }
+}
+
void QmlGraphicsFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (interactive && timeline.isActive() && (qAbs(velocityX) > 10 || qAbs(velocityY) > 10))
@@ -1039,12 +1070,18 @@ qreal QmlGraphicsFlickable::vHeight() const
bool QmlGraphicsFlickable::xflick() const
{
- return vWidth() != width();
+ Q_D(const QmlGraphicsFlickable);
+ if (d->flickDirection == QmlGraphicsFlickable::AutoFlickDirection)
+ return vWidth() != width();
+ return d->flickDirection & QmlGraphicsFlickable::HorizontalFlick;
}
bool QmlGraphicsFlickable::yflick() const
{
- return vHeight() != height();
+ Q_D(const QmlGraphicsFlickable);
+ if (d->flickDirection == QmlGraphicsFlickable::AutoFlickDirection)
+ return vHeight() != height();
+ return d->flickDirection & QmlGraphicsFlickable::VerticalFlick;
}
bool QmlGraphicsFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
index 50248e1..9610ac1 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
@@ -70,6 +70,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsFlickable : public QmlGraphicsItem
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration)
Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
+ Q_PROPERTY(FlickDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickDirectionChanged)
Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive)
Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay)
@@ -85,6 +86,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsFlickable : public QmlGraphicsItem
Q_PROPERTY(QmlList<QmlGraphicsItem *>* flickableChildren READ flickableChildren)
Q_CLASSINFO("DefaultProperty", "flickableData")
+ Q_ENUMS(FlickDirection)
+
public:
QmlGraphicsFlickable(QmlGraphicsItem *parent=0);
~QmlGraphicsFlickable();
@@ -135,6 +138,10 @@ public:
QmlGraphicsItem *viewport();
+ enum FlickDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
+ FlickDirection flickDirection() const;
+ void setFlickDirection(FlickDirection);
+
Q_SIGNALS:
void viewportWidthChanged();
void viewportHeightChanged();
@@ -151,6 +158,7 @@ Q_SIGNALS:
void verticalVelocityChanged();
void isAtBoundaryChanged();
void pageChanged();
+ void flickDirectionChanged();
protected:
virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
index 8044ba7..5ccdaad 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
@@ -134,6 +134,7 @@ public:
int vTime;
QmlTimeLine velocityTimeline;
QmlGraphicsFlickableVisibleArea *visibleArea;
+ QmlGraphicsFlickable::FlickDirection flickDirection;
void handleMousePressEvent(QGraphicsSceneMouseEvent *);
void handleMouseMoveEvent(QGraphicsSceneMouseEvent *);
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 81128e7..4e2a366 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -327,6 +327,7 @@ void QmlGraphicsGridViewPrivate::init()
q->setFlag(QGraphicsItem::ItemIsFocusScope);
QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(sizeChange()));
QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(sizeChange()));
+ q->setFlickDirection(QmlGraphicsFlickable::VerticalFlick);
}
void QmlGraphicsGridViewPrivate::clear()
@@ -1014,10 +1015,13 @@ void QmlGraphicsGridView::setFlow(Flow flow)
Q_D(QmlGraphicsGridView);
if (d->flow != flow) {
d->flow = flow;
- if (d->flow == LeftToRight)
+ if (d->flow == LeftToRight) {
setViewportWidth(-1);
- else
+ setFlickDirection(QmlGraphicsFlickable::VerticalFlick);
+ } else {
setViewportHeight(-1);
+ setFlickDirection(QmlGraphicsFlickable::HorizontalFlick);
+ }
d->clear();
d->updateGrid();
refill();
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index 144eed7..6958f7f 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -490,6 +490,7 @@ void QmlGraphicsListViewPrivate::init()
QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(refill()));
QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(refill()));
QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped()));
+ q->setFlickDirection(QmlGraphicsFlickable::VerticalFlick);
}
void QmlGraphicsListViewPrivate::clear()
@@ -1667,10 +1668,13 @@ void QmlGraphicsListView::setOrientation(QmlGraphicsListView::Orientation orient
Q_D(QmlGraphicsListView);
if (d->orient != orientation) {
d->orient = orientation;
- if (d->orient == QmlGraphicsListView::Vertical)
+ if (d->orient == QmlGraphicsListView::Vertical) {
setViewportWidth(-1);
- else
+ setFlickDirection(VerticalFlick);
+ } else {
setViewportHeight(-1);
+ setFlickDirection(HorizontalFlick);
+ }
d->clear();
refill();
emit orientationChanged();
@@ -2131,6 +2135,8 @@ void QmlGraphicsListView::trackedPositionChanged()
pos = d->startPosition();
} else if (d->trackedItem->endPosition() > d->endPosition() - d->size() + d->highlightRangeEnd) {
pos = d->endPosition() - d->size();
+ if (pos < d->startPosition())
+ pos = d->startPosition();
} else {
if (trackedPos < viewPos + d->highlightRangeStart) {
pos = trackedPos - d->highlightRangeStart;