diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-07-11 00:12:29 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-12-07 13:41:13 +0000 |
commit | 1264c22b8670a0d999ab5f7983407838e3766126 (patch) | |
tree | b2668ffcee3bb1bd0c030a2167bdf839aab488ef /src/widgets | |
parent | c7b26e632efb1e3a1296970eb82ad5d58986432b (diff) |
QAbstractItemView: replace a QPair with a dedicated struct
In a QPair, the member names {first, second} have no semantic
value. A simple struct, while not as featureful as QPair, can
be given meaningful member names, {rect, index}, in this case.
Change-Id: If1e289ecee82a1cb020ac3a854efd2ec1096493b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 7 | ||||
-rw-r--r-- | src/widgets/itemviews/qabstractitemview_p.h | 8 | ||||
-rw-r--r-- | src/widgets/itemviews/qlistview.cpp | 3 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 2f7b2a43c4..639f18c4bc 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -4339,7 +4339,8 @@ QItemViewPaintPairs QAbstractItemViewPrivate::draggablePaintPairs(const QModelIn const QModelIndex &index = indexes.at(i); const QRect current = q->visualRect(index); if (current.intersects(viewportRect)) { - ret += qMakePair(current, index); + QItemViewPaintPair p = { current, index }; + ret += p; rect |= current; } } @@ -4359,8 +4360,8 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes, QStyleOptionViewItem option = viewOptionsV1(); option.state |= QStyle::State_Selected; for (int j = 0; j < paintPairs.count(); ++j) { - option.rect = paintPairs.at(j).first.translated(-r->topLeft()); - const QModelIndex ¤t = paintPairs.at(j).second; + option.rect = paintPairs.at(j).rect.translated(-r->topLeft()); + const QModelIndex ¤t = paintPairs.at(j).index; adjustViewOptionsForIndex(&option, current); delegateForIndex(current)->paint(&painter, option, current); } diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index 861a0f9ff1..cb74586fab 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -73,7 +73,13 @@ struct QEditorInfo { typedef QHash<QWidget *, QPersistentModelIndex> QEditorIndexHash; typedef QHash<QPersistentModelIndex, QEditorInfo> QIndexEditorHash; -typedef QPair<QRect, QModelIndex> QItemViewPaintPair; +struct QItemViewPaintPair { + QRect rect; + QModelIndex index; +}; +template <> +class QTypeInfo<QItemViewPaintPair> : public QTypeInfoMerger<QItemViewPaintPair, QRect, QModelIndex> {}; + typedef QVector<QItemViewPaintPair> QItemViewPaintPairs; class QEmptyModel : public QAbstractItemModel diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index ed1f1f2e98..7745004774 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -654,7 +654,8 @@ QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList const QModelIndex &index = indexes.at(i); if (visibleIndexes.contains(index)) { const QRect current = q->visualRect(index); - ret += qMakePair(current, index); + QItemViewPaintPair p = { current, index }; + ret += p; rect |= current; } } |