From 3d6132ae9224b9374285d9eda062a815c4582f7c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 9 Oct 2009 10:45:00 +1000 Subject: No need for temporary currentItem --- src/declarative/fx/qfxgridview.cpp | 15 +++------------ src/declarative/fx/qfxlistview.cpp | 19 ++++--------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index a8b27f4..2d25d56 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -149,7 +149,7 @@ class QFxGridViewPrivate : public QFxFlickablePrivate public: QFxGridViewPrivate() - : model(0), currentItem(0), tmpCurrent(0), flow(QFxGridView::LeftToRight) + : model(0), currentItem(0), flow(QFxGridView::LeftToRight) , visiblePos(0), visibleIndex(0) , currentIndex(-1) , cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1) , highlightComponent(0), highlight(0), trackedItem(0) @@ -298,7 +298,6 @@ public: QList visibleItems; QHash unrequestedItems; FxGridItem *currentItem; - QFxItem *tmpCurrent; QFxGridView::Flow flow; int visiblePos; int visibleIndex; @@ -640,10 +639,6 @@ void QFxGridViewPrivate::updateCurrent(int modelIndex) return; } - if (tmpCurrent) { - delete tmpCurrent; - tmpCurrent = 0; - } FxGridItem *oldCurrentItem = currentItem; currentIndex = modelIndex; currentItem = createItem(modelIndex); @@ -821,12 +816,8 @@ void QFxGridView::setCurrentIndex(int index) QFxItem *QFxGridView::currentItem() { Q_D(QFxGridView); - if (!d->currentItem) { - // Always return something valid - if (!d->tmpCurrent) - d->tmpCurrent = new QFxItem(viewport()); - return d->tmpCurrent; - } + if (!d->currentItem) + return 0; return d->currentItem->item; } diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 1247021..5afd881 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -170,15 +170,15 @@ class QFxListViewPrivate : public QFxFlickablePrivate public: QFxListViewPrivate() - : model(0), currentItem(0), tmpCurrent(0), orient(Qt::Vertical) + : model(0), currentItem(0), orient(Qt::Vertical) , visiblePos(0), visibleIndex(0) , averageSize(100.0), currentIndex(-1), requestedIndex(-1) , highlightRangeStart(0), highlightRangeEnd(0) , highlightComponent(0), highlight(0), trackedItem(0) , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0.0) + , highlightMoveSpeed(400), highlightResizeSpeed(400) , ownModel(false), wrap(false), autoHighlight(true) , haveHighlightRange(false), strictHighlightRange(false) - , highlightMoveSpeed(400), highlightResizeSpeed(400) {} void init(); @@ -371,7 +371,6 @@ public: QList visibleItems; QHash unrequestedItems; FxListItem *currentItem; - QFxItem *tmpCurrent; Qt::Orientation orient; int visiblePos; int visibleIndex; @@ -752,10 +751,6 @@ void QFxListViewPrivate::updateCurrent(int modelIndex) return; } - if (tmpCurrent) { - delete tmpCurrent; - tmpCurrent = 0; - } FxListItem *oldCurrentItem = currentItem; currentIndex = modelIndex; currentItem = createItem(modelIndex); @@ -991,14 +986,8 @@ void QFxListView::setCurrentIndex(int index) QFxItem *QFxListView::currentItem() { Q_D(QFxListView); - if (!d->currentItem) { - // Always return something valid - if (!d->tmpCurrent) { - d->tmpCurrent = new QFxItem; - d->tmpCurrent->setParent(viewport()); - } - return d->tmpCurrent; - } + if (!d->currentItem) + return 0; return d->currentItem->item; } -- cgit v0.12