summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-07-13 12:03:39 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-07-13 12:04:44 (GMT)
commit32182d107fa75e5619ecc91a81f50626f429ebe1 (patch)
tree97d8ed9480b92d053e39850b214a14f696f1ed6b /src/gui/itemviews
parentd54224252d56a50b42c8991308840ea1acde8f30 (diff)
downloadQt-32182d107fa75e5619ecc91a81f50626f429ebe1.zip
Qt-32182d107fa75e5619ecc91a81f50626f429ebe1.tar.gz
Qt-32182d107fa75e5619ecc91a81f50626f429ebe1.tar.bz2
QTreeView: now dragging lots of items is fast
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp2
-rw-r--r--src/gui/itemviews/qlistview.cpp1
-rw-r--r--src/gui/itemviews/qtreeview.cpp44
-rw-r--r--src/gui/itemviews/qtreeview_p.h2
4 files changed, 47 insertions, 2 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index a4a69c3..8887977 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -3918,7 +3918,7 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes,
QStyleOptionViewItemV4 option = viewOptionsV4();
option.state |= QStyle::State_Selected;
for (int j = 0; j < paintPairs.count(); ++j) {
- option.rect = paintPairs.at(j).first.translated(r->topLeft());
+ option.rect = paintPairs.at(j).first.translated(-r->topLeft());
const QModelIndex &current = paintPairs.at(j).second;
delegateForIndex(current)->paint(&painter, option, current);
}
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index 9a94b31..40f28d4 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -722,7 +722,6 @@ QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList
QRect &rect = *r;
const QRect viewportRect = viewport->rect();
QItemViewPaintPairs ret;
- intersectingSet(viewportRect);
const QSet<QModelIndex> visibleIndexes = intersectingSet(viewportRect).toList().toSet();
for (int i = 0; i < indexes.count(); ++i) {
const QModelIndex &index = indexes.at(i);
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index f13ff0c..7084e6d 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -1321,6 +1321,50 @@ void QTreeViewPrivate::_q_modelDestroyed()
}
/*!
+ \reimp
+
+ We have a QTreeView way of knowing what elements are on the viewport
+*/
+QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
+{
+ Q_ASSERT(r);
+ return QAbstractItemViewPrivate::draggablePaintPairs(indexes, r);
+ Q_Q(const QTreeView);
+ QRect &rect = *r;
+ const QRect viewportRect = viewport->rect();
+ int itemOffset = 0;
+ int row = firstVisibleItem(&itemOffset);
+ QPair<int, int> startEnd = startAndEndColumns(viewportRect);
+ QVector<int> columns;
+ for (int i = startEnd.first; i <= startEnd.second; ++i) {
+ int logical = header->logicalIndex(i);
+ if (!header->isSectionHidden(logical))
+ columns += logical;
+ }
+ QSet<QModelIndex> visibleIndexes;
+ for (; itemOffset < viewportRect.bottom() && row < viewItems.count(); ++row) {
+ const QModelIndex &index = viewItems.at(row).index;
+ for (int colIndex = 0; colIndex < columns.count(); ++colIndex)
+ visibleIndexes += index.sibling(index.row(), columns.at(colIndex));
+ itemOffset += itemHeight(row);
+ }
+
+ //now that we have the visible indexes, we can try to find those which are selected
+ QItemViewPaintPairs ret;
+ for (int i = 0; i < indexes.count(); ++i) {
+ const QModelIndex &index = indexes.at(i);
+ if (visibleIndexes.contains(index)) {
+ const QRect current = q->visualRect(index);
+ ret += qMakePair(current, index);
+ rect |= current;
+ }
+ }
+ rect &= viewportRect;
+ return ret;
+}
+
+
+/*!
\since 4.2
Draws the part of the tree intersecting the given \a region using the specified
\a painter.
diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h
index 6fb2e41..546dc75 100644
--- a/src/gui/itemviews/qtreeview_p.h
+++ b/src/gui/itemviews/qtreeview_p.h
@@ -89,6 +89,8 @@ public:
~QTreeViewPrivate() {}
void initialize();
+ QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
+
#ifndef QT_NO_ANIMATION
struct AnimatedOperation : public QVariantAnimation
{