blob: df700bdca473fe41e7a84b44938451b01fb7f995 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
// Copyright (C) 2020 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 QQUICKHEADERVIEW_P_P_H
#define QQUICKHEADERVIEW_P_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/QAbstractItemModel>
#include <QtCore/QPointer>
#include <QtQuick/private/qquicktableview_p_p.h>
#include <private/qquickheaderview_p.h>
QT_BEGIN_NAMESPACE
class Q_QUICKTEMPLATES2_EXPORT QHeaderDataProxyModel : public QAbstractItemModel
{
Q_OBJECT
Q_DISABLE_COPY(QHeaderDataProxyModel)
Q_PROPERTY(QAbstractItemModel *sourceModel READ sourceModel)
public:
explicit QHeaderDataProxyModel(QObject *parent = nullptr);
~QHeaderDataProxyModel();
void setSourceModel(QAbstractItemModel *newSourceModel);
QPointer<QAbstractItemModel> sourceModel() const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override;
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
QHash<int, QByteArray> roleNames() const override;
inline QVariant variantValue() const;
inline Qt::Orientation orientation() const;
inline void setOrientation(Qt::Orientation o);
QQuickHeaderViewBase *m_headerView = nullptr;
private:
inline void connectToModel();
inline void disconnectFromModel();
QPointer<QAbstractItemModel> m_model = nullptr;
Qt::Orientation m_orientation = Qt::Horizontal;
};
class QQuickHeaderViewBasePrivate : public QQuickTableViewPrivate
{
Q_DECLARE_PUBLIC(QQuickHeaderViewBase)
public:
QQuickHeaderViewBasePrivate();
~QQuickHeaderViewBasePrivate();
static inline QQuickHeaderViewBasePrivate *get(QQuickHeaderViewBase *q) { return q->d_func(); }
void init();
Qt::Orientation orientation() const;
void setOrientation(Qt::Orientation orientation);
const QPointer<QQuickItem> delegateItemAt(int row, int col) const;
QVariant modelImpl() const override;
void setModelImpl(const QVariant &newModel) override;
void syncModel() override;
void syncSyncView() override;
QAbstractItemModel *selectionSourceModel() override;
// QQuickTableViewPrivate interface
virtual void initItemCallback(int modelIndex, QObject *item) override;
protected:
QHeaderDataProxyModel m_headerDataProxyModel;
struct SectionSize
{
int section;
qreal previousSize;
};
QStack<SectionSize> m_hiddenSectionSizes;
bool m_modelExplicitlySet = false;
QString m_textRole;
int logicalRowIndex(const int visualIndex) const final;
int logicalColumnIndex(const int visualIndex) const final;
int visualRowIndex(const int logicalIndex) const final;
int visualColumnIndex(const int logicalIndex) const final;
};
class QQuickHorizontalHeaderViewPrivate : public QQuickHeaderViewBasePrivate
{
Q_DECLARE_PUBLIC(QQuickHorizontalHeaderView)
public:
QQuickHorizontalHeaderViewPrivate();
~QQuickHorizontalHeaderViewPrivate();
bool m_movableColumns = false;
};
class QQuickVerticalHeaderViewPrivate : public QQuickHeaderViewBasePrivate
{
Q_DECLARE_PUBLIC(QQuickVerticalHeaderView)
public:
QQuickVerticalHeaderViewPrivate();
~QQuickVerticalHeaderViewPrivate();
bool m_movableRows = false;
};
QT_END_NAMESPACE
#endif // QQUICKHEADERVIEW_P_P_H
|