From af7373fb542517dc6a4519ebd81e4af9d56b53dc Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 29 Nov 2017 18:17:19 +0000 Subject: [PATCH] Handle root index changing in RDHeaderView - refresh section sizes --- qrenderdoc/Widgets/Extended/RDHeaderView.cpp | 15 +++++++++++++++ qrenderdoc/Widgets/Extended/RDHeaderView.h | 1 + 2 files changed, 16 insertions(+) diff --git a/qrenderdoc/Widgets/Extended/RDHeaderView.cpp b/qrenderdoc/Widgets/Extended/RDHeaderView.cpp index 77913591d..13a109cae 100644 --- a/qrenderdoc/Widgets/Extended/RDHeaderView.cpp +++ b/qrenderdoc/Widgets/Extended/RDHeaderView.cpp @@ -467,6 +467,21 @@ void RDHeaderView::setColumnStretchHints(const QList &hints) resizeSectionsWithHints(); } +void RDHeaderView::setRootIndex(const QModelIndex &index) +{ + QHeaderView::setRootIndex(index); + + // need to enqueue this after the root index is actually processed (this function is called + // *before* the root index changes). + if(!m_sectionStretchHints.isEmpty()) + { + GUIInvoke::defer([this]() { + cacheSectionMinSizes(); + resizeSectionsWithHints(); + }); + } +} + void RDHeaderView::headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast) { if(m_customSizing) diff --git a/qrenderdoc/Widgets/Extended/RDHeaderView.h b/qrenderdoc/Widgets/Extended/RDHeaderView.h index a4b272bae..e8902addd 100644 --- a/qrenderdoc/Widgets/Extended/RDHeaderView.h +++ b/qrenderdoc/Widgets/Extended/RDHeaderView.h @@ -67,6 +67,7 @@ public: void setCustomSizing(bool sizing) { m_customSizing = sizing; } int pinnedWidth() { return m_pinnedWidth; } public slots: + void setRootIndex(const QModelIndex &index) override; void headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast); void columnsInserted(const QModelIndex &parent, int first, int last); void rowsChanged(const QModelIndex &parent, int first, int last);