diff options
Diffstat (limited to 'src/widgets/itemviews/qheaderview_p.h')
-rw-r--r-- | src/widgets/itemviews/qheaderview_p.h | 94 |
1 files changed, 39 insertions, 55 deletions
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index 59879e0838..8b214e1d03 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QHEADERVIEW_P_H #define QHEADERVIEW_P_H @@ -52,6 +16,7 @@ // #include <QtWidgets/private/qtwidgetsglobal_p.h> +#include "qheaderview.h" #include "private/qabstractitemview_p.h" #include "QtCore/qbitarray.h" @@ -60,6 +25,8 @@ #include "QtWidgets/qlabel.h" #endif +#include <array> + QT_REQUIRE_CONFIG(itemviews); QT_BEGIN_NAMESPACE @@ -73,15 +40,17 @@ public: QHeaderViewPrivate() : state(NoState), - offset(0), + headerOffset(0), sortIndicatorOrder(Qt::DescendingOrder), sortIndicatorSection(0), sortIndicatorShown(false), + sortIndicatorClearable(false), lastPos(-1), firstPos(-1), originalSize(-1), section(-1), target(-1), + firstPressed(-1), pressed(-1), hover(-1), length(0), @@ -119,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; @@ -154,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(); @@ -200,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) { @@ -212,7 +185,7 @@ public: } inline void clearCascadingSections() { - firstCascadingSection = sectionItems.count(); + firstCascadingSection = sectionItems.size(); lastCascadingSection = 0; cascadingSectionSize.clear(); } @@ -246,17 +219,25 @@ 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; void cascadingResize(int visual, int newSize); enum State { NoState, ResizeSection, MoveSection, SelectSections, NoClear } state; - int offset; + int headerOffset; Qt::Orientation orientation; Qt::SortOrder sortIndicatorOrder; int sortIndicatorSection; bool sortIndicatorShown; + bool sortIndicatorClearable; mutable QList<int> visualIndices; // visualIndex = visualIndices.at(logicalIndex) mutable QList<int> logicalIndices; // logicalIndex = row or column in the model @@ -274,6 +255,7 @@ public: int originalSize; int section; // used for resizing and moving sections int target; + int firstPressed; int pressed; int hover; @@ -335,8 +317,9 @@ public: SectionItem section; }; QList<LayoutChangeItem> layoutChangePersistentSections; + std::array<QMetaObject::Connection, 8> modelConnections; - void createSectionItems(int start, int end, int size, QHeaderView::ResizeMode mode); + void createSectionItems(int start, int end, int sectionSize, QHeaderView::ResizeMode mode); void removeSectionsFromSectionItems(int start, int end); void resizeSectionItem(int visualIndex, int oldSize, int newSize); void setDefaultSectionSize(int size); @@ -363,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); } @@ -380,6 +363,7 @@ public: int viewSectionSizeHint(int logical) const; int adjustedVisualIndex(int visualIndex) const; void setScrollOffset(const QScrollBar *scrollBar, QAbstractItemView::ScrollMode scrollMode); + void updateSectionsBeforeAfter(int logical); #ifndef QT_NO_DATASTREAM void write(QDataStream &out) const; @@ -388,7 +372,7 @@ public: }; Q_DECLARE_TYPEINFO(QHeaderViewPrivate::SectionItem, Q_PRIMITIVE_TYPE); -Q_DECLARE_TYPEINFO(QHeaderViewPrivate::LayoutChangeItem, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QHeaderViewPrivate::LayoutChangeItem, Q_RELOCATABLE_TYPE); QT_END_NAMESPACE |