From 024a52d0d12aaceffd67d0a1423408fb1f377d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Martsum?= Date: Fri, 26 Jun 2015 06:36:54 +0200 Subject: QHeaderView - fix broken stretchLastSection In setStretchLastSection we restore a default section size if we no longer use stretch. That size was however not sufficient - we should restore the actual size. Furthermore we should also always stretch the last section (last visible index) - and not leave a section with a huge size and stretch another. This patch refactors stretch handling and keeps track of the last section and its size in eg. moveSection, swapSection, hideSection, showSection etc. There is an auto test showing and guarding its behavior. [ChangeLog][QtWidgets][QHeaderView] Fixed some issues (e.g QTBUG-39010) with restoring of section size after a section is no longer the last visible section (in stretchLastSection mode). Task-number: QTBUG-39010 Change-Id: Id47075b5a9dfeb250027374ecbd10eb8babbf9ef Reviewed-by: David Faure --- src/widgets/itemviews/qheaderview_p.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/widgets/itemviews/qheaderview_p.h') diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index 60542e297a..d1982d4777 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -90,6 +90,7 @@ public: minimumSectionSize(-1), maximumSectionSize(-1), lastSectionSize(0), + lastSectionLogicalIdx(-1), // Only trust when we stretch last section sectionIndicatorOffset(0), sectionIndicator(0), globalResizeMode(QHeaderView::Interactive), @@ -99,6 +100,9 @@ public: int lastVisibleVisualIndex() const; + void restoreSizeOnPrevLastSection(); + void setNewLastSection(int visualIndexForLastSection); + void maybeRestorePrevLastSectionAndStretchLast(); int sectionHandleAt(int position); void setupSectionIndicator(int section, int position); void updateSectionIndicator(int section, int position); @@ -281,7 +285,8 @@ public: int defaultSectionSize; int minimumSectionSize; int maximumSectionSize; - int lastSectionSize; // $$$ + int lastSectionSize; + int lastSectionLogicalIdx; // Only trust if we stretch LastSection int sectionIndicatorOffset; Qt::Alignment defaultAlignment; QLabel *sectionIndicator; -- cgit v1.2.3