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 QQUICKTREEVIEWDELEGATE_P_H |
5 | #define QQUICKTREEVIEWDELEGATE_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 <QtQuick/qquickitem.h> |
19 | #include <QtQuick/private/qquicktreeview_p.h> |
20 | #include <QtQuickTemplates2/private/qtquicktemplates2global_p.h> |
21 | #include <QtQuickTemplates2/private/qquickitemdelegate_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QQuickTreeViewDelegatePrivate; |
26 | |
27 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTreeViewDelegate : public QQuickItemDelegate |
28 | { |
29 | Q_OBJECT |
30 | Q_PROPERTY(qreal indentation READ indentation WRITE setIndentation NOTIFY indentationChanged FINAL) |
31 | Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged FINAL) |
32 | Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged FINAL) |
33 | |
34 | // Required properties |
35 | Q_PROPERTY(QQuickTreeView *treeView READ treeView WRITE setTreeView NOTIFY treeviewChanged REQUIRED FINAL) |
36 | Q_PROPERTY(bool isTreeNode READ isTreeNode WRITE setIsTreeNode NOTIFY isTreeNodeChanged REQUIRED FINAL) |
37 | Q_PROPERTY(bool hasChildren READ hasChildren WRITE setHasChildren NOTIFY hasChildrenChanged REQUIRED FINAL) |
38 | Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged REQUIRED FINAL) |
39 | Q_PROPERTY(int depth READ depth WRITE setDepth NOTIFY depthChanged REQUIRED FINAL) |
40 | Q_PROPERTY(bool current READ current WRITE setCurrent NOTIFY currentChanged REQUIRED FINAL REVISION(6, 4)) |
41 | Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged REQUIRED FINAL REVISION(6, 4)) |
42 | Q_PROPERTY(bool editing READ editing WRITE setEditing NOTIFY editingChanged REQUIRED FINAL REVISION(6, 5)) |
43 | |
44 | QML_NAMED_ELEMENT(TreeViewDelegate) |
45 | QML_ADDED_IN_VERSION(6, 3) |
46 | |
47 | public: |
48 | explicit QQuickTreeViewDelegate(QQuickItem *parent = nullptr); |
49 | |
50 | qreal indentation() const; |
51 | void setIndentation(qreal indentation); |
52 | |
53 | bool isTreeNode() const; |
54 | void setIsTreeNode(bool isTreeNode); |
55 | |
56 | bool hasChildren() const; |
57 | void setHasChildren(bool hasChildren); |
58 | |
59 | bool expanded() const; |
60 | void setExpanded(bool expanded); |
61 | |
62 | bool current() const; |
63 | void setCurrent(bool current); |
64 | |
65 | bool selected() const; |
66 | void setSelected(bool selected); |
67 | |
68 | bool editing() const; |
69 | void setEditing(bool editing); |
70 | |
71 | int depth() const; |
72 | void setDepth(int depth); |
73 | |
74 | QQuickTreeView *treeView() const; |
75 | void setTreeView(QQuickTreeView *treeView); |
76 | |
77 | qreal leftMargin() const; |
78 | void setLeftMargin(qreal leftMargin); |
79 | |
80 | qreal rightMargin() const; |
81 | void setRightMargin(qreal rightMargin); |
82 | |
83 | Q_SIGNALS: |
84 | void indicatorChanged(); |
85 | void indentationChanged(); |
86 | void isTreeNodeChanged(); |
87 | void hasChildrenChanged(); |
88 | void expandedChanged(); |
89 | void depthChanged(); |
90 | void treeviewChanged(); |
91 | void leftMarginChanged(); |
92 | void rightMarginChanged(); |
93 | Q_REVISION(6, 4) void currentChanged(); |
94 | Q_REVISION(6, 4) void selectedChanged(); |
95 | Q_REVISION(6, 5) void editingChanged(); |
96 | |
97 | protected: |
98 | QFont defaultFont() const override; |
99 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
100 | void componentComplete() override; |
101 | void mousePressEvent(QMouseEvent *event) override; |
102 | |
103 | private: |
104 | Q_DISABLE_COPY(QQuickTreeViewDelegate) |
105 | Q_DECLARE_PRIVATE(QQuickTreeViewDelegate) |
106 | }; |
107 | |
108 | QT_END_NAMESPACE |
109 | |
110 | #endif // QQUICKTREEVIEWDELEGATE_P_H |
111 | |