diff options
Diffstat (limited to 'src/widgets/itemviews/qheaderview_p.h')
-rw-r--r-- | src/widgets/itemviews/qheaderview_p.h | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index fce525166d..8b214e1d03 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -16,6 +16,7 @@ // #include <QtWidgets/private/qtwidgetsglobal_p.h> +#include "qheaderview.h" #include "private/qabstractitemview_p.h" #include "QtCore/qbitarray.h" @@ -24,6 +25,8 @@ #include "QtWidgets/qlabel.h" #endif +#include <array> + QT_REQUIRE_CONFIG(itemviews); QT_BEGIN_NAMESPACE @@ -37,7 +40,7 @@ public: QHeaderViewPrivate() : state(NoState), - offset(0), + headerOffset(0), sortIndicatorOrder(Qt::DescendingOrder), sortIndicatorSection(0), sortIndicatorShown(false), @@ -85,13 +88,17 @@ public: void updateSectionIndicator(int section, int position); void updateHiddenSections(int logicalFirst, int logicalLast); void resizeSections(QHeaderView::ResizeMode globalMode, bool useGlobalMode = false); - void _q_sectionsRemoved(const QModelIndex &,int,int); - void _q_sectionsAboutToBeMoved(const QModelIndex &sourceParent, int logicalStart, int logicalEnd, const QModelIndex &destinationParent, int logicalDestination); - void _q_sectionsMoved(const QModelIndex &sourceParent, int logicalStart, int logicalEnd, const QModelIndex &destinationParent, int logicalDestination); - void _q_sectionsAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), - QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint); - void _q_sectionsChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), - QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint); + void sectionsRemoved(const QModelIndex &,int,int); + void sectionsAboutToBeMoved(const QModelIndex &sourceParent, int logicalStart, + int logicalEnd, const QModelIndex &destinationParent, + int logicalDestination); + void sectionsMoved(const QModelIndex &sourceParent, int logicalStart, + int logicalEnd, const QModelIndex &destinationParent, + int logicalDestination); + void sectionsAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), + QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint); + void sectionsChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), + QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint); bool isSectionSelected(int section) const; bool isFirstVisibleSection(int section) const; @@ -120,12 +127,12 @@ public: inline void prepareSectionSelected() { if (!selectionModel || !selectionModel->hasSelection()) sectionSelected.clear(); - else if (sectionSelected.count() != sectionCount() * 2) + else if (sectionSelected.size() != sectionCount() * 2) sectionSelected.fill(false, sectionCount() * 2); else sectionSelected.fill(false); } - inline int sectionCount() const {return sectionItems.count();} + inline int sectionCount() const {return sectionItems.size();} inline bool reverse() const { return orientation == Qt::Horizontal && q_func()->isRightToLeft(); @@ -166,8 +173,8 @@ public: } inline void initializeIndexMapping() const { - if (visualIndices.count() != sectionCount() - || logicalIndices.count() != sectionCount()) { + if (visualIndices.size() != sectionCount() + || logicalIndices.size() != sectionCount()) { visualIndices.resize(sectionCount()); logicalIndices.resize(sectionCount()); for (int s = 0; s < sectionCount(); ++s) { @@ -178,7 +185,7 @@ public: } inline void clearCascadingSections() { - firstCascadingSection = sectionItems.count(); + firstCascadingSection = sectionItems.size(); lastCascadingSection = 0; cascadingSectionSize.clear(); } @@ -212,6 +219,12 @@ public: } } + inline void disconnectModel() + { + for (const QMetaObject::Connection &connection : modelConnections) + QObject::disconnect(connection); + } + void clear(); void flipSortIndicator(int section); Qt::SortOrder defaultSortOrderForSection(int section) const; @@ -219,7 +232,7 @@ public: enum State { NoState, ResizeSection, MoveSection, SelectSections, NoClear } state; - int offset; + int headerOffset; Qt::Orientation orientation; Qt::SortOrder sortIndicatorOrder; int sortIndicatorSection; @@ -304,6 +317,7 @@ public: SectionItem section; }; QList<LayoutChangeItem> layoutChangePersistentSections; + std::array<QMetaObject::Connection, 8> modelConnections; void createSectionItems(int start, int end, int sectionSize, QHeaderView::ResizeMode mode); void removeSectionsFromSectionItems(int start, int end); @@ -332,7 +346,7 @@ public: void setHiddenSectionsFromBitVector(const QBitArray §ionHidden) { SectionItem *sectionData = sectionItems.data(); - for (int i = 0; i < sectionHidden.count(); ++i) + for (int i = 0; i < sectionHidden.size(); ++i) sectionData[i].isHidden = sectionHidden.at(i); } |