| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2018 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #ifndef QQUICKSPLITVIEW_P_H |
| 38 | #define QQUICKSPLITVIEW_P_H |
| 39 | |
| 40 | // |
| 41 | // W A R N I N G |
| 42 | // ------------- |
| 43 | // |
| 44 | // This file is not part of the Qt API. It exists purely as an |
| 45 | // implementation detail. This header file may change from version to |
| 46 | // version without notice, or even be removed. |
| 47 | // |
| 48 | // We mean it. |
| 49 | // |
| 50 | |
| 51 | #include <QtQuickTemplates2/private/qquickcontainer_p.h> |
| 52 | #include <QtQml/qqmllist.h> |
| 53 | |
| 54 | QT_BEGIN_NAMESPACE |
| 55 | |
| 56 | class QQuickSplitViewPrivate; |
| 57 | class QQuickSplitViewAttached; |
| 58 | class QQuickSplitViewAttachedPrivate; |
| 59 | class QQuickSplitHandleAttached; |
| 60 | class QQuickSplitHandleAttachedPrivate; |
| 61 | |
| 62 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSplitView : public QQuickContainer |
| 63 | { |
| 64 | Q_OBJECT |
| 65 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) |
| 66 | Q_PROPERTY(bool resizing READ isResizing NOTIFY resizingChanged) |
| 67 | Q_PROPERTY(QQmlComponent *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) |
| 68 | |
| 69 | public: |
| 70 | explicit QQuickSplitView(QQuickItem *parent = nullptr); |
| 71 | ~QQuickSplitView() override; |
| 72 | |
| 73 | Qt::Orientation orientation() const; |
| 74 | void setOrientation(Qt::Orientation orientation); |
| 75 | |
| 76 | bool isResizing() const; |
| 77 | |
| 78 | QQmlComponent *handle(); |
| 79 | void setHandle(QQmlComponent *handle); |
| 80 | |
| 81 | bool isContent(QQuickItem *item) const override; |
| 82 | |
| 83 | static QQuickSplitViewAttached *qmlAttachedProperties(QObject *object); |
| 84 | |
| 85 | // Based on the same code in QMainWindow. |
| 86 | enum VersionMarkers { |
| 87 | VersionMarker = 0xff |
| 88 | }; |
| 89 | Q_INVOKABLE QVariant saveState(); |
| 90 | Q_INVOKABLE bool restoreState(const QVariant &state); |
| 91 | |
| 92 | Q_SIGNALS: |
| 93 | void orientationChanged(); |
| 94 | void resizingChanged(); |
| 95 | void handleChanged(); |
| 96 | |
| 97 | protected: |
| 98 | QQuickSplitView(QQuickSplitViewPrivate &dd, QQuickItem *parent); |
| 99 | |
| 100 | void componentComplete() override; |
| 101 | void hoverMoveEvent(QHoverEvent *event) override; |
| 102 | bool childMouseEventFilter(QQuickItem *item, QEvent *event) override; |
| 103 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
| 104 | |
| 105 | void itemAdded(int index, QQuickItem *item) override; |
| 106 | void itemMoved(int index, QQuickItem *item) override; |
| 107 | void itemRemoved(int index, QQuickItem *item) override; |
| 108 | |
| 109 | #if QT_CONFIG(accessibility) |
| 110 | QAccessible::Role accessibleRole() const override; |
| 111 | #endif |
| 112 | |
| 113 | private: |
| 114 | Q_DISABLE_COPY(QQuickSplitView) |
| 115 | Q_DECLARE_PRIVATE(QQuickSplitView) |
| 116 | }; |
| 117 | |
| 118 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSplitViewAttached : public QObject |
| 119 | { |
| 120 | Q_OBJECT |
| 121 | Q_PROPERTY(QQuickSplitView *view READ view NOTIFY viewChanged FINAL) |
| 122 | Q_PROPERTY(qreal minimumWidth READ minimumWidth WRITE setMinimumWidth |
| 123 | RESET resetMinimumWidth NOTIFY minimumWidthChanged FINAL) |
| 124 | Q_PROPERTY(qreal minimumHeight READ minimumHeight WRITE setMinimumHeight |
| 125 | RESET resetMinimumHeight NOTIFY minimumHeightChanged FINAL) |
| 126 | Q_PROPERTY(qreal preferredWidth READ preferredWidth WRITE setPreferredWidth |
| 127 | RESET resetPreferredWidth NOTIFY preferredWidthChanged FINAL) |
| 128 | Q_PROPERTY(qreal preferredHeight READ preferredHeight WRITE setPreferredHeight |
| 129 | RESET resetPreferredHeight NOTIFY preferredHeightChanged FINAL) |
| 130 | Q_PROPERTY(qreal maximumWidth READ maximumWidth WRITE setMaximumWidth |
| 131 | RESET resetMaximumWidth NOTIFY maximumWidthChanged FINAL) |
| 132 | Q_PROPERTY(qreal maximumHeight READ maximumHeight WRITE setMaximumHeight |
| 133 | RESET resetMaximumHeight NOTIFY maximumHeightChanged FINAL) |
| 134 | Q_PROPERTY(bool fillHeight READ fillHeight WRITE setFillHeight NOTIFY fillHeightChanged FINAL) |
| 135 | Q_PROPERTY(bool fillWidth READ fillWidth WRITE setFillWidth NOTIFY fillWidthChanged FINAL) |
| 136 | |
| 137 | public: |
| 138 | explicit QQuickSplitViewAttached(QObject *parent = nullptr); |
| 139 | |
| 140 | QQuickSplitView *view() const; |
| 141 | |
| 142 | qreal minimumWidth() const; |
| 143 | void setMinimumWidth(qreal width); |
| 144 | void resetMinimumWidth(); |
| 145 | |
| 146 | qreal minimumHeight() const; |
| 147 | void setMinimumHeight(qreal height); |
| 148 | void resetMinimumHeight(); |
| 149 | |
| 150 | qreal preferredWidth() const; |
| 151 | void setPreferredWidth(qreal width); |
| 152 | void resetPreferredWidth(); |
| 153 | |
| 154 | qreal preferredHeight() const; |
| 155 | void setPreferredHeight(qreal height); |
| 156 | void resetPreferredHeight(); |
| 157 | |
| 158 | qreal maximumWidth() const; |
| 159 | void setMaximumWidth(qreal width); |
| 160 | void resetMaximumWidth(); |
| 161 | |
| 162 | qreal maximumHeight() const; |
| 163 | void setMaximumHeight(qreal height); |
| 164 | void resetMaximumHeight(); |
| 165 | |
| 166 | bool fillWidth() const; |
| 167 | void setFillWidth(bool fill); |
| 168 | |
| 169 | bool fillHeight() const; |
| 170 | void setFillHeight(bool fill); |
| 171 | |
| 172 | Q_SIGNALS: |
| 173 | void viewChanged(); |
| 174 | void minimumWidthChanged(); |
| 175 | void minimumHeightChanged(); |
| 176 | void preferredWidthChanged(); |
| 177 | void preferredHeightChanged(); |
| 178 | void maximumWidthChanged(); |
| 179 | void maximumHeightChanged(); |
| 180 | void fillWidthChanged(); |
| 181 | void fillHeightChanged(); |
| 182 | |
| 183 | private: |
| 184 | Q_DISABLE_COPY(QQuickSplitViewAttached) |
| 185 | Q_DECLARE_PRIVATE(QQuickSplitViewAttached) |
| 186 | }; |
| 187 | |
| 188 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSplitHandleAttached : public QObject |
| 189 | { |
| 190 | Q_OBJECT |
| 191 | Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL) |
| 192 | Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL) |
| 193 | |
| 194 | public: |
| 195 | explicit QQuickSplitHandleAttached(QObject *parent = nullptr); |
| 196 | |
| 197 | bool isHovered() const; |
| 198 | bool isPressed() const; |
| 199 | |
| 200 | static QQuickSplitHandleAttached *qmlAttachedProperties(QObject *object); |
| 201 | |
| 202 | Q_SIGNALS: |
| 203 | void hoveredChanged(); |
| 204 | void pressedChanged(); |
| 205 | |
| 206 | private: |
| 207 | Q_DISABLE_COPY(QQuickSplitHandleAttached) |
| 208 | Q_DECLARE_PRIVATE(QQuickSplitHandleAttached) |
| 209 | }; |
| 210 | |
| 211 | QT_END_NAMESPACE |
| 212 | |
| 213 | QML_DECLARE_TYPE(QQuickSplitView) |
| 214 | QML_DECLARE_TYPEINFO(QQuickSplitView, QML_HAS_ATTACHED_PROPERTIES) |
| 215 | |
| 216 | QML_DECLARE_TYPE(QQuickSplitHandleAttached) |
| 217 | QML_DECLARE_TYPEINFO(QQuickSplitHandleAttached, QML_HAS_ATTACHED_PROPERTIES) |
| 218 | |
| 219 | #endif // QQUICKSPLITVIEW_P_H |
| 220 | |