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

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