diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2010-03-16 09:56:15 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2010-03-16 09:56:15 (GMT) |
commit | e0dd5b450e1b04feb6c72a3c635c586b244392da (patch) | |
tree | 719dce69a0712aa6d896d752c0d7d6b93b0e72a5 /src/gui/itemviews | |
parent | b912cac358a0a84f72f727767772caad22062a45 (diff) | |
download | Qt-e0dd5b450e1b04feb6c72a3c635c586b244392da.zip Qt-e0dd5b450e1b04feb6c72a3c635c586b244392da.tar.gz Qt-e0dd5b450e1b04feb6c72a3c635c586b244392da.tar.bz2 |
Revert "small cleanup regarding delayed layout in itemviews"
This reverts commit 8e98c4c159c38ea48b6321674105762b2d3f517b.
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 30 | ||||
-rw-r--r-- | src/gui/itemviews/qabstractitemview_p.h | 10 | ||||
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 2 | ||||
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 10 |
4 files changed, 35 insertions, 17 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 61defdc..fb6e418 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -103,7 +103,8 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() verticalScrollMode(QAbstractItemView::ScrollPerItem), horizontalScrollMode(QAbstractItemView::ScrollPerItem), currentIndexSet(false), - wrapItemText(false) + wrapItemText(false), + delayedPendingLayout(false) { } @@ -2397,8 +2398,9 @@ void QAbstractItemView::timerEvent(QTimerEvent *event) d->delayedEditing.stop(); edit(currentIndex()); } else if (event->timerId() == d->delayedLayout.timerId()) { - d->interruptDelayedItemsLayout(); + d->delayedLayout.stop(); if (isVisible()) { + d->interruptDelayedItemsLayout(); doItemsLayout(); const QModelIndex current = currentIndex(); if (current.isValid() && d->state == QAbstractItemView::EditingState) @@ -3060,7 +3062,7 @@ void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget d->addEditor(index, widget, true); widget->show(); dataChanged(index, index); // update the geometry - if (!d->delayedPendingLayout()) + if (!d->delayedPendingLayout) widget->setGeometry(visualRect(index)); } } @@ -3100,7 +3102,7 @@ void QAbstractItemView::scrollToTop() void QAbstractItemView::scrollToBottom() { Q_D(QAbstractItemView); - if (d->delayedPendingLayout()) { + if (d->delayedPendingLayout) { d->executePostedLayout(); updateGeometries(); } @@ -3145,14 +3147,14 @@ void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelInde delegate->setEditorData(editorInfo.editor, topLeft); } } - if (isVisible() && !d->delayedPendingLayout()) { + if (isVisible() && !d->delayedPendingLayout) { // otherwise the items will be update later anyway update(topLeft); } return; } d->updateEditorData(topLeft, bottomRight); - if (!isVisible() || d->delayedPendingLayout()) + if (!isVisible() || d->delayedPendingLayout) return; // no need to update d->viewport->update(); } @@ -3876,6 +3878,22 @@ bool QAbstractItemViewPrivate::shouldAutoScroll(const QPoint &pos) const || (area.right() - pos.x() < autoScrollMargin); } +void QAbstractItemViewPrivate::doDelayedItemsLayout(int delay) +{ + if (!delayedPendingLayout) { + delayedPendingLayout = true; + delayedLayout.start(delay, q_func()); + } +} + +void QAbstractItemViewPrivate::interruptDelayedItemsLayout() const +{ + delayedLayout.stop(); + delayedPendingLayout = false; +} + + + QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index, const QStyleOptionViewItem &options) { diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 3511c28..82fd1a6 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -124,10 +124,8 @@ public: bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const; bool shouldForwardEvent(QAbstractItemView::EditTrigger trigger, const QEvent *event) const; bool shouldAutoScroll(const QPoint &pos) const; - void doDelayedItemsLayout(int delay = 0) { if (!delayedPendingLayout()) delayedLayout.start(delay, q_func()); } - void interruptDelayedItemsLayout() const { delayedLayout.stop(); } - bool delayedPendingLayout() const { return delayedLayout.isActive(); } - + void doDelayedItemsLayout(int delay = 0); + void interruptDelayedItemsLayout() const; void startAutoScroll() { // ### it would be nice to make this into a style hint one day @@ -209,7 +207,7 @@ public: } inline void executePostedLayout() const { - if (delayedPendingLayout() && state != QAbstractItemView::CollapsingState) { + if (delayedPendingLayout && state != QAbstractItemView::CollapsingState) { interruptDelayedItemsLayout(); const_cast<QAbstractItemView*>(q_func())->doItemsLayout(); } @@ -418,7 +416,9 @@ public: QAbstractItemView::ScrollMode horizontalScrollMode; bool currentIndexSet; + bool wrapItemText; + mutable bool delayedPendingLayout; private: mutable QBasicTimer delayedLayout; diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index b2c8c51..b2def39 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -823,7 +823,7 @@ void QListView::timerEvent(QTimerEvent *e) void QListView::resizeEvent(QResizeEvent *e) { Q_D(QListView); - if (d->delayedPendingLayout()) + if (d->delayedPendingLayout) return; QSize delta = e->size() - e->oldSize(); diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 2acd160..4135ba0 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -668,7 +668,7 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto Q_D(QTreeView); // if we are going to do a complete relayout anyway, there is no need to update - if (d->delayedPendingLayout()) + if (d->delayedPendingLayout) return; // refresh the height cache here; we don't really lose anything by getting the size hint, @@ -742,7 +742,7 @@ void QTreeView::expand(const QModelIndex &index) Q_D(QTreeView); if (!d->isIndexValid(index)) return; - if (d->delayedPendingLayout()) { + if (d->delayedPendingLayout) { //A complete relayout is going to be performed, just store the expanded index, no need to layout. if (d->storeExpanded(index)) emit expanded(index); @@ -776,7 +776,7 @@ void QTreeView::collapse(const QModelIndex &index) //if the current item is now invisible, the autoscroll will expand the tree to see it, so disable the autoscroll d->delayedAutoScroll.stop(); - if (d->delayedPendingLayout()) { + if (d->delayedPendingLayout) { //A complete relayout is going to be performed, just un-store the expanded index, no need to layout. if (d->isPersistent(index) && d->expandedIndexes.remove(index)) emit collapsed(index); @@ -2431,7 +2431,7 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) { Q_D(QTreeView); // if we are going to do a complete relayout anyway, there is no need to update - if (d->delayedPendingLayout()) { + if (d->delayedPendingLayout) { QAbstractItemView::rowsInserted(parent, start, end); return; } @@ -3755,7 +3755,7 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, int start, int end, bool after) { // if we are going to do a complete relayout anyway, there is no need to update - if (delayedPendingLayout()) { + if (delayedPendingLayout) { _q_rowsRemoved(parent, start, end); return; } |