From 1264c22b8670a0d999ab5f7983407838e3766126 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 11 Jul 2015 00:12:29 +0200 Subject: 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 Reviewed-by: Giuseppe D'Angelo --- src/widgets/itemviews/qabstractitemview.cpp | 7 ++++--- src/widgets/itemviews/qabstractitemview_p.h | 8 +++++++- src/widgets/itemviews/qlistview.cpp | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/widgets') 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 QEditorIndexHash; typedef QHash QIndexEditorHash; -typedef QPair QItemViewPaintPair; +struct QItemViewPaintPair { + QRect rect; + QModelIndex index; +}; +template <> +class QTypeInfo : public QTypeInfoMerger {}; + typedef QVector 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; } } -- cgit v1.2.3