1 | // Copyright (C) 2018 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 QQUICKSPLITVIEW_P_H |
5 | #define QQUICKSPLITVIEW_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 <QtQuickTemplates2/private/qquickcontainer_p.h> |
19 | #include <QtQml/qqmllist.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QQuickSplitViewPrivate; |
24 | class QQuickSplitViewAttached; |
25 | class QQuickSplitViewAttachedPrivate; |
26 | class QQuickSplitHandleAttached; |
27 | class QQuickSplitHandleAttachedPrivate; |
28 | |
29 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSplitView : public QQuickContainer |
30 | { |
31 | Q_OBJECT |
32 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) |
33 | Q_PROPERTY(bool resizing READ isResizing NOTIFY resizingChanged FINAL) |
34 | Q_PROPERTY(QQmlComponent *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) |
35 | QML_NAMED_ELEMENT(SplitView) |
36 | QML_ATTACHED(QQuickSplitViewAttached) |
37 | QML_ADDED_IN_VERSION(2, 13) |
38 | |
39 | public: |
40 | explicit QQuickSplitView(QQuickItem *parent = nullptr); |
41 | ~QQuickSplitView() override; |
42 | |
43 | Qt::Orientation orientation() const; |
44 | void setOrientation(Qt::Orientation orientation); |
45 | |
46 | bool isResizing() const; |
47 | |
48 | QQmlComponent *handle(); |
49 | void setHandle(QQmlComponent *handle); |
50 | |
51 | bool isContent(QQuickItem *item) const override; |
52 | |
53 | static QQuickSplitViewAttached *qmlAttachedProperties(QObject *object); |
54 | |
55 | // Based on the same code in QMainWindow. |
56 | enum VersionMarkers { |
57 | VersionMarker = 0xff |
58 | }; |
59 | Q_INVOKABLE QVariant saveState(); |
60 | Q_INVOKABLE bool restoreState(const QVariant &state); |
61 | |
62 | Q_SIGNALS: |
63 | void orientationChanged(); |
64 | void resizingChanged(); |
65 | void handleChanged(); |
66 | |
67 | protected: |
68 | QQuickSplitView(QQuickSplitViewPrivate &dd, QQuickItem *parent); |
69 | |
70 | void componentComplete() override; |
71 | void hoverMoveEvent(QHoverEvent *event) override; |
72 | void hoverLeaveEvent(QHoverEvent *event) override; |
73 | bool childMouseEventFilter(QQuickItem *item, QEvent *event) override; |
74 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
75 | |
76 | void itemAdded(int index, QQuickItem *item) override; |
77 | void itemMoved(int index, QQuickItem *item) override; |
78 | void itemRemoved(int index, QQuickItem *item) override; |
79 | |
80 | #if QT_CONFIG(accessibility) |
81 | QAccessible::Role accessibleRole() const override; |
82 | #endif |
83 | |
84 | private: |
85 | Q_DISABLE_COPY(QQuickSplitView) |
86 | Q_DECLARE_PRIVATE(QQuickSplitView) |
87 | }; |
88 | |
89 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSplitViewAttached : public QObject |
90 | { |
91 | Q_OBJECT |
92 | Q_PROPERTY(QQuickSplitView *view READ view NOTIFY viewChanged FINAL) |
93 | Q_PROPERTY(qreal minimumWidth READ minimumWidth WRITE setMinimumWidth |
94 | RESET resetMinimumWidth NOTIFY minimumWidthChanged FINAL) |
95 | Q_PROPERTY(qreal minimumHeight READ minimumHeight WRITE setMinimumHeight |
96 | RESET resetMinimumHeight NOTIFY minimumHeightChanged FINAL) |
97 | Q_PROPERTY(qreal preferredWidth READ preferredWidth WRITE setPreferredWidth |
98 | RESET resetPreferredWidth NOTIFY preferredWidthChanged FINAL) |
99 | Q_PROPERTY(qreal preferredHeight READ preferredHeight WRITE setPreferredHeight |
100 | RESET resetPreferredHeight NOTIFY preferredHeightChanged FINAL) |
101 | Q_PROPERTY(qreal maximumWidth READ maximumWidth WRITE setMaximumWidth |
102 | RESET resetMaximumWidth NOTIFY maximumWidthChanged FINAL) |
103 | Q_PROPERTY(qreal maximumHeight READ maximumHeight WRITE setMaximumHeight |
104 | RESET resetMaximumHeight NOTIFY maximumHeightChanged FINAL) |
105 | Q_PROPERTY(bool fillHeight READ fillHeight WRITE setFillHeight NOTIFY fillHeightChanged FINAL) |
106 | Q_PROPERTY(bool fillWidth READ fillWidth WRITE setFillWidth NOTIFY fillWidthChanged FINAL) |
107 | |
108 | public: |
109 | explicit QQuickSplitViewAttached(QObject *parent = nullptr); |
110 | |
111 | QQuickSplitView *view() const; |
112 | |
113 | qreal minimumWidth() const; |
114 | void setMinimumWidth(qreal width); |
115 | void resetMinimumWidth(); |
116 | |
117 | qreal minimumHeight() const; |
118 | void setMinimumHeight(qreal height); |
119 | void resetMinimumHeight(); |
120 | |
121 | qreal preferredWidth() const; |
122 | void setPreferredWidth(qreal width); |
123 | void resetPreferredWidth(); |
124 | |
125 | qreal preferredHeight() const; |
126 | void setPreferredHeight(qreal height); |
127 | void resetPreferredHeight(); |
128 | |
129 | qreal maximumWidth() const; |
130 | void setMaximumWidth(qreal width); |
131 | void resetMaximumWidth(); |
132 | |
133 | qreal maximumHeight() const; |
134 | void setMaximumHeight(qreal height); |
135 | void resetMaximumHeight(); |
136 | |
137 | bool fillWidth() const; |
138 | void setFillWidth(bool fill); |
139 | |
140 | bool fillHeight() const; |
141 | void setFillHeight(bool fill); |
142 | |
143 | Q_SIGNALS: |
144 | void viewChanged(); |
145 | void minimumWidthChanged(); |
146 | void minimumHeightChanged(); |
147 | void preferredWidthChanged(); |
148 | void preferredHeightChanged(); |
149 | void maximumWidthChanged(); |
150 | void maximumHeightChanged(); |
151 | void fillWidthChanged(); |
152 | void fillHeightChanged(); |
153 | |
154 | private: |
155 | Q_DISABLE_COPY(QQuickSplitViewAttached) |
156 | Q_DECLARE_PRIVATE(QQuickSplitViewAttached) |
157 | }; |
158 | |
159 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSplitHandleAttached : public QObject |
160 | { |
161 | Q_OBJECT |
162 | Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL) |
163 | Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL) |
164 | QML_NAMED_ELEMENT(SplitHandle) |
165 | QML_ATTACHED(QQuickSplitHandleAttached) |
166 | QML_UNCREATABLE("" ) |
167 | QML_ADDED_IN_VERSION(2, 13) |
168 | |
169 | public: |
170 | explicit QQuickSplitHandleAttached(QObject *parent = nullptr); |
171 | |
172 | bool isHovered() const; |
173 | bool isPressed() const; |
174 | |
175 | static QQuickSplitHandleAttached *qmlAttachedProperties(QObject *object); |
176 | |
177 | Q_SIGNALS: |
178 | void hoveredChanged(); |
179 | void pressedChanged(); |
180 | |
181 | private: |
182 | Q_DISABLE_COPY(QQuickSplitHandleAttached) |
183 | Q_DECLARE_PRIVATE(QQuickSplitHandleAttached) |
184 | }; |
185 | |
186 | QT_END_NAMESPACE |
187 | |
188 | QML_DECLARE_TYPE(QQuickSplitView) |
189 | |
190 | QML_DECLARE_TYPE(QQuickSplitHandleAttached) |
191 | |
192 | #endif // QQUICKSPLITVIEW_P_H |
193 | |