summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-04-30 10:07:59 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-04-30 10:10:14 (GMT)
commitc70eae8288cccb92e54e3c73f0ca257af033178a (patch)
tree357a763fa1537ec6c54bedf375508d692bf06a50 /src/gui/itemviews
parent2c6fdd89086977708850043a075b2b880bd22c9e (diff)
downloadQt-c70eae8288cccb92e54e3c73f0ca257af033178a.zip
Qt-c70eae8288cccb92e54e3c73f0ca257af033178a.tar.gz
Qt-c70eae8288cccb92e54e3c73f0ca257af033178a.tar.bz2
Fixes a possible issue in itemviws where we would not scroll to the
current item on show Task-number: 252534 Reviewed-by: ogoffart
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp26
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h1
2 files changed, 17 insertions, 10 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 975decc..83e05b4 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -88,6 +88,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()
autoScroll(true),
autoScrollMargin(16),
autoScrollCount(0),
+ shouldScrollToCurrentOnShow(false),
alternatingColors(false),
textElideMode(Qt::ElideRight),
verticalScrollMode(QAbstractItemView::ScrollPerItem),
@@ -1380,8 +1381,9 @@ bool QAbstractItemView::event(QEvent *event)
d->executePostedLayout(); //make sure we set the layout properly
break;
case QEvent::Show:
- if (d->delayedPendingLayout) {
- d->executePostedLayout(); //make sure we set the layout properly
+ d->executePostedLayout(); //make sure we set the layout properly
+ if (d->shouldScrollToCurrentOnShow) {
+ d->shouldScrollToCurrentOnShow = false;
const QModelIndex current = currentIndex();
if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll))
scrollTo(current);
@@ -3163,14 +3165,18 @@ void QAbstractItemView::currentChanged(const QModelIndex &current, const QModelI
d->updateDirtyRegion();
}
}
- if (isVisible() && current.isValid() && !d->autoScrollTimer.isActive()) {
- if (d->autoScroll)
- scrollTo(current);
- d->setDirtyRegion(visualRect(current));
- d->updateDirtyRegion();
- edit(current, CurrentChanged, 0);
- if (current.row() == (d->model->rowCount(d->root) - 1))
- d->_q_fetchMore();
+ if (current.isValid() && !d->autoScrollTimer.isActive()) {
+ if (isVisible()) {
+ if (d->autoScroll)
+ scrollTo(current);
+ d->setDirtyRegion(visualRect(current));
+ d->updateDirtyRegion();
+ edit(current, CurrentChanged, 0);
+ if (current.row() == (d->model->rowCount(d->root) - 1))
+ d->_q_fetchMore();
+ } else {
+ d->shouldScrollToCurrentOnShow = d->autoScroll;
+ }
}
}
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index 37fe4a2..16bd1ab 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -359,6 +359,7 @@ public:
QBasicTimer autoScrollTimer;
int autoScrollMargin;
int autoScrollCount;
+ bool shouldScrollToCurrentOnShow; //used to know if we should scroll to current on show event
bool alternatingColors;