1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKHEADERVIEW_P_P_H
5#define QQUICKHEADERVIEW_P_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QAbstractItemModel>
19#include <QtCore/QPointer>
20#if QT_CONFIG(transposeproxymodel)
21#include <QtCore/QTransposeProxyModel>
22#endif
23#include <QtQuick/private/qquicktableview_p_p.h>
24#include <private/qquickheaderview_p.h>
25
26QT_BEGIN_NAMESPACE
27
28class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QHeaderDataProxyModel : public QAbstractItemModel
29{
30 Q_OBJECT
31 Q_DISABLE_COPY(QHeaderDataProxyModel)
32 Q_PROPERTY(QAbstractItemModel *sourceModel READ sourceModel)
33public:
34 explicit QHeaderDataProxyModel(QObject *parent = nullptr);
35 ~QHeaderDataProxyModel();
36
37 void setSourceModel(QAbstractItemModel *newSourceModel);
38 QPointer<QAbstractItemModel> sourceModel() const;
39 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
40 QModelIndex parent(const QModelIndex &child) const override;
41 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
42 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
43 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
44 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
45 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
46 bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
47
48 inline QVariant variantValue() const;
49 inline Qt::Orientation orientation() const;
50 inline void setOrientation(Qt::Orientation o);
51
52private:
53 inline void connectToModel();
54 inline void disconnectFromModel();
55 QPointer<QAbstractItemModel> m_model = nullptr;
56 Qt::Orientation m_orientation = Qt::Horizontal;
57};
58
59class QQuickHeaderViewBasePrivate : public QQuickTableViewPrivate
60{
61 Q_DECLARE_PUBLIC(QQuickHeaderViewBase)
62public:
63 QQuickHeaderViewBasePrivate();
64 ~QQuickHeaderViewBasePrivate();
65
66 Qt::Orientation orientation() const;
67 void setOrientation(Qt::Orientation orientation);
68 const QPointer<QQuickItem> delegateItemAt(int row, int col) const;
69 QVariant modelImpl() const override;
70 void setModelImpl(const QVariant &newModel) override;
71 void syncModel() override;
72 void syncSyncView() override;
73
74protected:
75 QHeaderDataProxyModel m_headerDataProxyModel;
76#if QT_CONFIG(transposeproxymodel)
77 QTransposeProxyModel m_transposeProxyModel;
78#endif
79 struct SectionSize
80 {
81 int section;
82 qreal previousSize;
83 };
84 QStack<SectionSize> m_hiddenSectionSizes;
85 bool m_modelExplicitlySetByUser = false;
86 QString m_textRole;
87};
88
89class QQuickHorizontalHeaderViewPrivate : public QQuickHeaderViewBasePrivate
90{
91 Q_DECLARE_PUBLIC(QQuickHorizontalHeaderView)
92public:
93 QQuickHorizontalHeaderViewPrivate();
94 ~QQuickHorizontalHeaderViewPrivate();
95};
96
97class QQuickVerticalHeaderViewPrivate : public QQuickHeaderViewBasePrivate
98{
99 Q_DECLARE_PUBLIC(QQuickVerticalHeaderView)
100public:
101 QQuickVerticalHeaderViewPrivate();
102 ~QQuickVerticalHeaderViewPrivate();
103};
104
105QT_END_NAMESPACE
106
107#endif // QQUICKHEADERVIEW_P_P_H
108

source code of qtdeclarative/src/quicktemplates/qquickheaderview_p_p.h