summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-09-19 14:59:25 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-24 18:01:07 +0200
commit05aa8c6c12509cce87d1a3811c5ea1dd83fa0898 (patch)
tree86e17e828a08bee5914f9d045e03f87fc39bb6a1 /src/widgets
parent3e9f27929004b7a5f44f14068b521e0d90c7b9c2 (diff)
Implement viewOptions() logic in QListViewPrivate.
The private method is called in several places in QListViewPrivate, but before this patch, the implementation in QAbstractItemView was called. This meant that the options were not set properly, resulting, for example, in icons in icon mode being laid out in list mode (on the left and small). This is a regression resulting from 8eab9cbce2014ffc6186dd6b6fb73da85956ee86 and 3578e05b293c1cc53582109001b20f02c7a1eeb7. Other views are not affected in a similar way. Change-Id: I753cb99410e367266753eaf2fa43361b9212ab96 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qlistview.cpp18
-rw-r--r--src/widgets/itemviews/qlistview_p.h2
2 files changed, 14 insertions, 6 deletions
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 5be0bebe54..097802c909 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -900,14 +900,20 @@ void QListView::startDrag(Qt::DropActions supportedActions)
QStyleOptionViewItem QListView::viewOptions() const
{
Q_D(const QListView);
- QStyleOptionViewItem option = QAbstractItemView::viewOptions();
- if (!d->iconSize.isValid()) { // otherwise it was already set in abstractitemview
- int pm = (d->viewMode == ListMode
- ? style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, this)
- : style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, this));
+ return d->viewOptions();
+}
+
+QStyleOptionViewItem QListViewPrivate::viewOptions() const
+{
+ Q_Q(const QListView);
+ QStyleOptionViewItem option = QAbstractItemViewPrivate::viewOptions();
+ if (!iconSize.isValid()) { // otherwise it was already set in abstractitemview
+ int pm = (viewMode == QListView::ListMode
+ ? q->style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, q)
+ : q->style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, q));
option.decorationSize = QSize(pm, pm);
}
- if (d->viewMode == IconMode) {
+ if (viewMode == QListView::IconMode) {
option.showDecorationSelected = false;
option.decorationPosition = QStyleOptionViewItem::Top;
option.displayAlignment = Qt::AlignCenter;
diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h
index ea9f31a62a..6084479e6a 100644
--- a/src/widgets/itemviews/qlistview_p.h
+++ b/src/widgets/itemviews/qlistview_p.h
@@ -394,6 +394,8 @@ public:
}
}
+ QStyleOptionViewItem viewOptions() const;
+
void scrollElasticBandBy(int dx, int dy);
QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;