1 | // Copyright (C) 2021 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 QQUICKTREEVIEW_P_H |
5 | #define QQUICKTREEVIEW_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.h> |
19 | #include "qquicktableview_p.h" |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QQuickTreeViewPrivate; |
24 | |
25 | class Q_QUICK_PRIVATE_EXPORT QQuickTreeView : public QQuickTableView |
26 | { |
27 | Q_OBJECT |
28 | Q_PROPERTY(QModelIndex rootIndex READ rootIndex WRITE setRootIndex RESET resetRootIndex NOTIFY rootIndexChanged REVISION(6, 6) FINAL) |
29 | QML_NAMED_ELEMENT(TreeView) |
30 | QML_ADDED_IN_VERSION(6, 3) |
31 | |
32 | public: |
33 | QQuickTreeView(QQuickItem *parent = nullptr); |
34 | ~QQuickTreeView() override; |
35 | |
36 | QModelIndex rootIndex() const; |
37 | void setRootIndex(const QModelIndex &index); |
38 | void resetRootIndex(); |
39 | |
40 | Q_INVOKABLE int depth(int row) const; |
41 | |
42 | Q_INVOKABLE bool isExpanded(int row) const; |
43 | Q_INVOKABLE void expand(int row); |
44 | Q_INVOKABLE void collapse(int row); |
45 | Q_INVOKABLE void toggleExpanded(int row); |
46 | |
47 | Q_REVISION(6, 4) Q_INVOKABLE void expandRecursively(int row = -1, int depth = -1); |
48 | Q_REVISION(6, 4) Q_INVOKABLE void collapseRecursively(int row = -1); |
49 | Q_REVISION(6, 4) Q_INVOKABLE void expandToIndex(const QModelIndex &index); |
50 | |
51 | Q_INVOKABLE QModelIndex modelIndex(const QPoint &cell) const override; |
52 | Q_INVOKABLE QPoint cellAtIndex(const QModelIndex &index) const override; |
53 | |
54 | #if QT_DEPRECATED_SINCE(6, 4) |
55 | QT_DEPRECATED_VERSION_X_6_4("Use index(row, column) instead" ) |
56 | Q_REVISION(6, 4) Q_INVOKABLE QModelIndex modelIndex(int row, int column) const override; |
57 | #endif |
58 | |
59 | Q_SIGNALS: |
60 | void expanded(int row, int depth); |
61 | void collapsed(int row, bool recursively); |
62 | Q_REVISION(6, 6) void rootIndexChanged(); |
63 | |
64 | protected: |
65 | void keyPressEvent(QKeyEvent *event) override; |
66 | |
67 | private: |
68 | Q_DISABLE_COPY(QQuickTreeView) |
69 | Q_DECLARE_PRIVATE(QQuickTreeView) |
70 | }; |
71 | |
72 | QT_END_NAMESPACE |
73 | |
74 | QML_DECLARE_TYPE(QQuickTreeView) |
75 | |
76 | #endif // QQUICKTREEVIEW_P_H |
77 | |