diff options
Diffstat (limited to 'src/widgets/itemviews/qheaderview_p.h')
-rw-r--r-- | src/widgets/itemviews/qheaderview_p.h | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index e26c4a6475..9d7d97f582 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -97,7 +97,8 @@ public: lastSectionSize(0), sectionIndicatorOffset(0), sectionIndicator(0), - globalResizeMode(QHeaderView::Interactive) + globalResizeMode(QHeaderView::Interactive), + sectionStartposRecalc(true) {} @@ -281,22 +282,24 @@ public: QLabel *sectionIndicator; QHeaderView::ResizeMode globalResizeMode; QList<QPersistentModelIndex> persistentHiddenSections; - + mutable bool sectionStartposRecalc; // header section spans struct SectionSpan { int size; - int count; + mutable int calculated_startpos; QHeaderView::ResizeMode resizeMode; - inline SectionSpan() : size(0), count(0), resizeMode(QHeaderView::Interactive) {} - inline SectionSpan(int length, int sections, QHeaderView::ResizeMode mode) - : size(length), count(sections), resizeMode(mode) {} - inline int sectionSize() const { return (count > 0 ? size / count : 0); } + inline SectionSpan() : size(0), resizeMode(QHeaderView::Interactive) {} + inline SectionSpan(int length, QHeaderView::ResizeMode mode) + : size(length), calculated_startpos(-1), resizeMode(mode) {} + inline int sectionSize() const { return size; } + inline int calculatedEndPos() const { return calculated_startpos + size; } #ifndef QT_NO_DATASTREAM + int tmpDataStreamSectionCount; inline void write(QDataStream &out) const - { out << size; out << count; out << (int)resizeMode; } + { out << size; out << 1; out << (int)resizeMode; } inline void read(QDataStream &in) - { in >> size; in >> count; int m; in >> m; resizeMode = (QHeaderView::ResizeMode)m; } + { in >> size; in >> tmpDataStreamSectionCount; int m; in >> m; resizeMode = (QHeaderView::ResizeMode)m; } #endif }; @@ -306,12 +309,10 @@ public: void removeSectionsFromSpans(int start, int end); void resizeSectionSpan(int visualIndex, int oldSize, int newSize); void setDefaultSectionSize(int size); + void recalcSectionStartPos() const; // not really const inline int headerSectionCount() const { // for debugging - int count = 0; - for (int i = 0; i < sectionSpans.count(); ++i) - count += sectionSpans.at(i).count; - return count; + return sectionSpans.count(); } inline int headerLength() const { // for debugging @@ -329,12 +330,8 @@ public: } inline int sectionSpanIndex(int visual) const { - int section_start = 0; - for (int i = 0; i < sectionSpans.count(); ++i) { - int section_end = section_start + sectionSpans.at(i).count - 1; - if (visual >= section_start && visual <= section_end) - return i; - section_start = section_end + 1; + if (visual < sectionSpans.count() && visual >= 0) { + return visual; } return -1; } |