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

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

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