From 937ded010b09250c6ab9a57917f2e430fb5875f5 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 28 Oct 2017 19:13:58 +0200 Subject: QListView: make sure to respect grid size during dataChanged() handling When the dataChanged() signal is handled by QIconModeViewBase, the size of the items are recalculated. During this operation the optional grid size is not taken into account which leads to a screwed up layout. This patch adds the missing check similar it is done in doStaticLayout()/doDynamicLayout(). Task-number: QTBUG-45427 Change-Id: Iba7adb44b1510c511a69c289ccb4f168992a6871 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qlistview.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 9e959c8e1e..9217fec10e 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -2874,10 +2874,19 @@ void QIconModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { if (column() >= topLeft.column() && column() <= bottomRight.column()) { - QStyleOptionViewItem option = viewOptions(); - int bottom = qMin(items.count(), bottomRight.row() + 1); + const QStyleOptionViewItem option = viewOptions(); + const int bottom = qMin(items.count(), bottomRight.row() + 1); + const bool useItemSize = !dd->grid.isValid(); for (int row = topLeft.row(); row < bottom; ++row) - items[row].resize(itemSize(option, modelIndex(row))); + { + QSize s = itemSize(option, modelIndex(row)); + if (!useItemSize) + { + s.setWidth(qMin(dd->grid.width(), s.width())); + s.setHeight(qMin(dd->grid.height(), s.height())); + } + items[row].resize(s); + } } } -- cgit v1.2.3 From b4f4c384d9ee7cf93cc3db289a7d4275ac10a618 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 28 Oct 2017 13:20:53 +0200 Subject: QHeaderView: Honor maximumSectionSize property during resizeSections() Resizing a QTreeeView section with double click or resizeColumnToContents() does not respect the maximumSectionSize when the resize mode is Interactive or Fixed. Since the documentation of maximumSectionSize states that it should honor this property for those cases either the documentation or implementation is incorrect. This patch fixes the latter. Task-number: QTBUG-64036 Change-Id: Ic14c8e444d50b9c50a117efed19d0bca7ec1cf82 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qheaderview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 213cc96b03..3af191b06c 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3364,7 +3364,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool // because it isn't stretch, determine its width and remove that from lengthToStretch int sectionSize = 0; if (resizeMode == QHeaderView::Interactive || resizeMode == QHeaderView::Fixed) { - sectionSize = headerSectionSize(i); + sectionSize = qBound(q->minimumSectionSize(), headerSectionSize(i), q->maximumSectionSize()); } else { // resizeMode == QHeaderView::ResizeToContents int logicalIndex = q->logicalIndex(i); sectionSize = qMax(viewSectionSizeHint(logicalIndex), -- cgit v1.2.3 From 2937ab9e320ea04fdfda8e3a252559d4762e811e Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 31 Oct 2017 19:47:12 +0100 Subject: QHeaderView: Skip hidden sections on cascading resize When a section is hidden, QHeaderViewPrivate::cascadingResize() does resize a section even it is hidden. This leads to space between the neighbor sections and also some unneeded calculations. Task-number: QTBUG-54601 Change-Id: Ie139417ae2c77ef25e66cf628bfe400185f88ee8 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qheaderview.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 3af191b06c..298270a785 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3539,6 +3539,8 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) // cascade the section size change for (int i = visual + 1; i < sectionCount(); ++i) { + if (isVisualIndexHidden(i)) + continue; if (!sectionIsCascadable(i)) continue; int currentSectionSize = headerSectionSize(i); @@ -3581,6 +3583,8 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) // cascade the section size change if (delta < 0 && newSize < minimumSize) { for (int i = visual - 1; i >= 0; --i) { + if (isVisualIndexHidden(i)) + continue; if (!sectionIsCascadable(i)) continue; int sectionSize = headerSectionSize(i); @@ -3595,6 +3599,8 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) // let the next section get the space from the resized section if (!sectionResized) { for (int i = visual + 1; i < sectionCount(); ++i) { + if (isVisualIndexHidden(i)) + continue; if (!sectionIsCascadable(i)) continue; int currentSectionSize = headerSectionSize(i); -- cgit v1.2.3