summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-10-28 03:30:10 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-10-28 03:30:10 (GMT)
commit84bc6c6f25c88a84455dfb74e23a8a7e5b9493a5 (patch)
tree1d40f1307c545d251b69d930e8df6c6bc737a6bc /src/declarative/fx
parentc3663202dade896078d3466fccdcbac11909f2ba (diff)
downloadQt-84bc6c6f25c88a84455dfb74e23a8a7e5b9493a5.zip
Qt-84bc6c6f25c88a84455dfb74e23a8a7e5b9493a5.tar.gz
Qt-84bc6c6f25c88a84455dfb74e23a8a7e5b9493a5.tar.bz2
QT-2382
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/qfxlistview.cpp72
-rw-r--r--src/declarative/fx/qfxlistview.h8
2 files changed, 41 insertions, 39 deletions
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index fbb91b1..18aa5d2 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -141,15 +141,15 @@ public:
}
~FxListItem() {}
- qreal position() const { return (view->orientation() == Qt::Vertical ? item->y() : item->x()); }
- int size() const { return (view->orientation() == Qt::Vertical ? item->height() : item->width()); }
+ qreal position() const { return (view->orientation() == QFxListView::Vertical ? item->y() : item->x()); }
+ int size() const { return (view->orientation() == QFxListView::Vertical ? item->height() : item->width()); }
qreal endPosition() const {
- return (view->orientation() == Qt::Vertical
+ return (view->orientation() == QFxListView::Vertical
? item->y() + (item->height() > 0 ? item->height() : 1)
: item->x() + (item->width() > 0 ? item->width() : 1)) - 1;
}
void setPosition(qreal pos) {
- if (view->orientation() == Qt::Vertical) {
+ if (view->orientation() == QFxListView::Vertical) {
item->setY(pos);
} else {
item->setX(pos);
@@ -170,7 +170,7 @@ class QFxListViewPrivate : public QFxFlickablePrivate
public:
QFxListViewPrivate()
- : model(0), currentItem(0), orient(Qt::Vertical)
+ : model(0), currentItem(0), orient(QFxListView::Vertical)
, visiblePos(0), visibleIndex(0)
, averageSize(100.0), currentIndex(-1), requestedIndex(-1)
, highlightRangeStart(0), highlightRangeEnd(0)
@@ -199,18 +199,18 @@ public:
qreal position() const {
Q_Q(const QFxListView);
- return orient == Qt::Vertical ? q->viewportY() : q->viewportX();
+ return orient == QFxListView::Vertical ? q->viewportY() : q->viewportX();
}
void setPosition(qreal pos) {
Q_Q(QFxListView);
- if (orient == Qt::Vertical)
+ if (orient == QFxListView::Vertical)
q->setViewportY(pos);
else
q->setViewportX(pos);
}
qreal size() const {
Q_Q(const QFxListView);
- return orient == Qt::Vertical ? q->height() : q->width();
+ return orient == QFxListView::Vertical ? q->height() : q->width();
}
qreal startPosition() const {
@@ -378,7 +378,7 @@ public:
QList<FxListItem*> visibleItems;
QHash<QFxItem*,int> unrequestedItems;
FxListItem *currentItem;
- Qt::Orientation orient;
+ QFxListView::Orientation orient;
int visiblePos;
int visibleIndex;
qreal averageSize;
@@ -454,7 +454,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex)
model->completeItem();
listItem->item->setZValue(1);
listItem->item->setParent(q->viewport());
- if (orient == Qt::Vertical)
+ if (orient == QFxListView::Vertical)
QObject::connect(listItem->item, SIGNAL(heightChanged()), q, SLOT(itemResized()));
else
QObject::connect(listItem->item, SIGNAL(widthChanged()), q, SLOT(itemResized()));
@@ -470,8 +470,8 @@ void QFxListViewPrivate::releaseItem(FxListItem *item)
if (!item)
return;
if (trackedItem == item) {
- const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
+ const char *notifier1 = orient == QFxListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
+ const char *notifier2 = orient == QFxListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
trackedItem = 0;
@@ -479,7 +479,7 @@ void QFxListViewPrivate::releaseItem(FxListItem *item)
if (model->release(item->item) == 0) {
// item was not destroyed, and we no longer reference it.
unrequestedItems.insert(item->item, model->indexOf(item->item, q));
- if (orient == Qt::Vertical)
+ if (orient == QFxListView::Vertical)
QObject::disconnect(item->item, SIGNAL(heightChanged()), q, SLOT(itemResized()));
else
QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized()));
@@ -553,7 +553,7 @@ void QFxListViewPrivate::refill(qreal from, qreal to)
updateAverage();
if (!sectionExpression.isEmpty())
updateCurrentSection();
- if (orient == Qt::Vertical)
+ if (orient == QFxListView::Vertical)
q->setViewportHeight(endPosition() - startPosition());
else
q->setViewportWidth(endPosition() - startPosition());
@@ -597,7 +597,7 @@ void QFxListViewPrivate::updateUnrequestedPositions()
for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) {
if (visibleItem(*it))
continue;
- if (orient == Qt::Vertical)
+ if (orient == QFxListView::Vertical)
it.key()->setY(positionAt(*it));
else
it.key()->setX(positionAt(*it));
@@ -613,8 +613,8 @@ void QFxListViewPrivate::updateTrackedItem()
FxListItem *oldTracked = trackedItem;
- const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
+ const char *notifier1 = orient == QFxListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
+ const char *notifier2 = orient == QFxListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
if (trackedItem && item != trackedItem) {
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
@@ -669,16 +669,16 @@ void QFxListViewPrivate::createHighlight()
if (item) {
item->setZValue(0);
highlight = new FxListItem(item, q);
- if (orient == Qt::Vertical)
+ if (orient == QFxListView::Vertical)
highlight->item->setHeight(currentItem->item->height());
else
highlight->item->setWidth(currentItem->item->width());
- const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x");
+ const QLatin1String posProp(orient == QFxListView::Vertical ? "y" : "x");
highlightPosAnimator = new QmlEaseFollow(q);
highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp));
highlightPosAnimator->setVelocity(highlightMoveSpeed);
highlightPosAnimator->setEnabled(autoHighlight);
- const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width");
+ const QLatin1String sizeProp(orient == QFxListView::Vertical ? "height" : "width");
highlightSizeAnimator = new QmlEaseFollow(q);
highlightSizeAnimator->setVelocity(highlightResizeSpeed);
highlightSizeAnimator->setTarget(QmlMetaProperty(highlight->item, sizeProp));
@@ -696,7 +696,7 @@ void QFxListViewPrivate::updateHighlight()
// auto-update highlight
highlightPosAnimator->setSourceValue(currentItem->position());
highlightSizeAnimator->setSourceValue(currentItem->size());
- if (orient == Qt::Vertical) {
+ if (orient == QFxListView::Vertical) {
if (highlight->item->width() == 0)
highlight->item->setWidth(currentItem->item->width());
} else {
@@ -792,7 +792,7 @@ void QFxListViewPrivate::updateAverage()
void QFxListViewPrivate::fixupPosition()
{
- if (orient == Qt::Vertical)
+ if (orient == QFxListView::Vertical)
fixupY();
else
fixupX();
@@ -801,7 +801,7 @@ void QFxListViewPrivate::fixupPosition()
void QFxListViewPrivate::fixupY()
{
QFxFlickablePrivate::fixupY();
- if (orient == Qt::Horizontal)
+ if (orient == QFxListView::Horizontal)
return;
if (haveHighlightRange && highlightRange == QFxListView::StrictlyEnforceRange) {
@@ -816,7 +816,7 @@ void QFxListViewPrivate::fixupY()
void QFxListViewPrivate::fixupX()
{
QFxFlickablePrivate::fixupX();
- if (orient == Qt::Vertical)
+ if (orient == QFxListView::Vertical)
return;
if (haveHighlightRange && highlightRange == QFxListView::StrictlyEnforceRange) {
@@ -1298,18 +1298,18 @@ void QFxListView::setSpacing(qreal spacing)
Horizontal Example:
\image ListViewHorizontal.png
*/
-Qt::Orientation QFxListView::orientation() const
+QFxListView::Orientation QFxListView::orientation() const
{
Q_D(const QFxListView);
return d->orient;
}
-void QFxListView::setOrientation(Qt::Orientation orientation)
+void QFxListView::setOrientation(QFxListView::Orientation orientation)
{
Q_D(QFxListView);
if (d->orient != orientation) {
d->orient = orientation;
- if (d->orient == Qt::Vertical)
+ if (d->orient == QFxListView::Vertical)
setViewportWidth(-1);
else
setViewportHeight(-1);
@@ -1466,7 +1466,7 @@ void QFxListView::viewportMoved()
qreal QFxListView::minYExtent() const
{
Q_D(const QFxListView);
- if (d->orient == Qt::Horizontal)
+ if (d->orient == QFxListView::Horizontal)
return QFxFlickable::minYExtent();
qreal extent = -d->startPosition();
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
@@ -1478,7 +1478,7 @@ qreal QFxListView::minYExtent() const
qreal QFxListView::maxYExtent() const
{
Q_D(const QFxListView);
- if (d->orient == Qt::Horizontal)
+ if (d->orient == QFxListView::Horizontal)
return QFxFlickable::maxYExtent();
qreal extent;
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
@@ -1494,7 +1494,7 @@ qreal QFxListView::maxYExtent() const
qreal QFxListView::minXExtent() const
{
Q_D(const QFxListView);
- if (d->orient == Qt::Vertical)
+ if (d->orient == QFxListView::Vertical)
return QFxFlickable::minXExtent();
qreal extent = -d->startPosition();
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
@@ -1506,7 +1506,7 @@ qreal QFxListView::minXExtent() const
qreal QFxListView::maxXExtent() const
{
Q_D(const QFxListView);
- if (d->orient == Qt::Vertical)
+ if (d->orient == QFxListView::Vertical)
return QFxFlickable::maxXExtent();
qreal extent;
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
@@ -1527,8 +1527,8 @@ void QFxListView::keyPressEvent(QKeyEvent *event)
return;
if (d->model && d->model->count() && d->interactive) {
- if ((d->orient == Qt::Horizontal && event->key() == Qt::Key_Left)
- || (d->orient == Qt::Vertical && event->key() == Qt::Key_Up)) {
+ if ((d->orient == QFxListView::Horizontal && event->key() == Qt::Key_Left)
+ || (d->orient == QFxListView::Vertical && event->key() == Qt::Key_Up)) {
if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) {
d->moveReason = QFxListViewPrivate::Key;
decrementCurrentIndex();
@@ -1538,8 +1538,8 @@ void QFxListView::keyPressEvent(QKeyEvent *event)
event->accept();
return;
}
- } else if ((d->orient == Qt::Horizontal && event->key() == Qt::Key_Right)
- || (d->orient == Qt::Vertical && event->key() == Qt::Key_Down)) {
+ } else if ((d->orient == QFxListView::Horizontal && event->key() == Qt::Key_Right)
+ || (d->orient == QFxListView::Vertical && event->key() == Qt::Key_Down)) {
if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) {
d->moveReason = QFxListViewPrivate::Key;
incrementCurrentIndex();
@@ -1930,7 +1930,7 @@ void QFxListView::createdItem(int index, QFxItem *item)
if (d->requestedIndex != index) {
item->setParentItem(viewport());
d->unrequestedItems.insert(item, index);
- if (d->orient == Qt::Vertical)
+ if (d->orient == QFxListView::Vertical)
item->setY(d->positionAt(index));
else
item->setX(d->positionAt(index));
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 0fa0fa0..b31b951 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -72,7 +72,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
+ Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged)
@@ -81,6 +81,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
Q_ENUMS(HighlightRangeMode)
+ Q_ENUMS(Orientation)
Q_CLASSINFO("DefaultProperty", "data")
public:
@@ -118,8 +119,9 @@ public:
qreal spacing() const;
void setSpacing(qreal spacing);
- Qt::Orientation orientation() const;
- void setOrientation(Qt::Orientation);
+ enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical };
+ Orientation orientation() const;
+ void setOrientation(Orientation);
bool isWrapEnabled() const;
void setWrapEnabled(bool);