diff options
author | Thorbjørn Martsum <tmartsum@gmail.com> | 2013-10-02 06:48:51 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-02 14:55:01 +0100 |
commit | 637f6507b4125cc81689e068e0de37dc5da61e73 (patch) | |
tree | 11f5ebb2ad76ff41ddd01fc025f27968a4701919 /src/widgets/itemviews/qheaderview_p.h | |
parent | 7bf519ec6232c197d5d387c7e1665c68aa2adc6b (diff) |
QHeaderView - move ishidden into the section
Since we already have the section there is no need to have an
extra structure. It simplifies the code itself and the code
is overall more efficient.
The benchmark seems to show overall performance increasement
various places (e.g insert, swapSection).
Change-Id: I623453b69a9a830908e8d9d5f3816ccebe073c9f
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/widgets/itemviews/qheaderview_p.h')
-rw-r--r-- | src/widgets/itemviews/qheaderview_p.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index b2af821e9b..81f1b176ee 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -171,11 +171,11 @@ public: } inline bool isVisualIndexHidden(int visual) const { - return !sectionHidden.isEmpty() && sectionHidden.at(visual); + return sectionItems.at(visual).isHidden; } inline void setVisualIndexHidden(int visual, bool hidden) { - if (!sectionHidden.isEmpty()) sectionHidden.setBit(visual, hidden); + sectionItems[visual].isHidden = hidden; } inline bool hasAutoResizeSections() const { @@ -258,7 +258,6 @@ public: mutable QVector<int> visualIndices; // visualIndex = visualIndices.at(logicalIndex) mutable QVector<int> logicalIndices; // logicalIndex = row or column in the model mutable QBitArray sectionSelected; // from logical index to bit - mutable QBitArray sectionHidden; // from visual index to bit mutable QHash<int, int> hiddenSectionSize; // from logical index to section size mutable QHash<int, int> cascadingSectionSize; // from visual index to section size mutable QSize cachedSizeHint; @@ -301,7 +300,7 @@ public: struct SectionItem { uint size : 20; - uint reservedForIsHidden : 1; + uint isHidden : 1; uint resizeMode : 5; // (holding QHeaderView::ResizeMode) uint currentlyUnusedPadding : 6; @@ -311,9 +310,9 @@ public: int tmpDataStreamSectionCount; // recalcSectionStartPos() or set sectionStartposRecalc to true }; // to ensure that calculated_startpos will be calculated afterwards. - inline SectionItem() : size(0), resizeMode(QHeaderView::Interactive) {} + inline SectionItem() : size(0), isHidden(0), resizeMode(QHeaderView::Interactive) {} inline SectionItem(int length, QHeaderView::ResizeMode mode) - : size(length), resizeMode(mode), calculated_startpos(-1) {} + : size(length), isHidden(0), resizeMode(mode), calculated_startpos(-1) {} inline int sectionSize() const { return size; } inline int calculatedEndPos() const { return calculated_startpos + size; } #ifndef QT_NO_DATASTREAM @@ -339,6 +338,23 @@ public: return len; } + QBitArray sectionsHiddenToBitVector() const + { + QBitArray sectionHidden; + if (!hiddenSectionSize.isEmpty()) { + sectionHidden.resize(sectionItems.size()); + for (int u = 0; u < sectionItems.size(); ++u) + sectionHidden[u] = sectionItems.at(u).isHidden; + } + return sectionHidden; + } + + void setHiddenSectionsFromBitVector(const QBitArray §ionHidden) { + SectionItem *sectionData = sectionItems.data(); + for (int i = 0; i < sectionHidden.count(); ++i) + sectionData[i].isHidden = sectionHidden.at(i); + } + int headerSectionSize(int visual) const; int headerSectionPosition(int visual) const; int headerVisualIndexAt(int position) const; |