~tpeeters/ubuntu-ui-toolkit/qt56fixes1

« back to all changes in this revision

Viewing changes to src/Ubuntu/UbuntuToolkit/splitview_p.h

  • Committer: Tarmac
  • Author(s): Zsombor Egri
  • Date: 2016-08-26 08:34:20 UTC
  • mfrom: (2027.5.30 columnLayout)
  • Revision ID: tarmac-20160826083420-fvf6vu7euhs7d1g7
SplitView to Ubuntu.Components.Labs.

Approved by ubuntu-sdk-build-bot, Christian Dywan.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2016 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Author: Zsombor Egri <zsombor.egri@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef SPLITVIEW_P_H
 
20
#define SPLITVIEW_P_H
 
21
 
 
22
#include <QtQuick/private/qquickpositioners_p.h>
 
23
 
 
24
#include "ubuntutoolkitglobal.h"
 
25
 
 
26
UT_NAMESPACE_BEGIN
 
27
 
 
28
class ViewColumnPrivate;
 
29
class ViewColumn : public QObject, public QQmlParserStatus
 
30
{
 
31
    Q_OBJECT
 
32
    Q_INTERFACES(QQmlParserStatus)
 
33
    Q_PRIVATE_PROPERTY(ViewColumn::d_func(), bool fillWidth MEMBER fillWidth WRITE setFillWidth NOTIFY fillWidthChanged)
 
34
    Q_PRIVATE_PROPERTY(ViewColumn::d_func(), qreal minimumWidth MEMBER minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
 
35
    Q_PRIVATE_PROPERTY(ViewColumn::d_func(), qreal maximumWidth MEMBER maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
 
36
    Q_PRIVATE_PROPERTY(ViewColumn::d_func(), qreal preferredWidth MEMBER preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
 
37
public:
 
38
    explicit ViewColumn(QObject *parent = 0);
 
39
 
 
40
    bool resize(qreal delta);
 
41
 
 
42
Q_SIGNALS:
 
43
    void minimumWidthChanged();
 
44
    void maximumWidthChanged();
 
45
    void preferredWidthChanged();
 
46
    void fillWidthChanged();
 
47
 
 
48
protected:
 
49
    // from QQmlParserStatus
 
50
    void classBegin() override {}
 
51
    void componentComplete() override;
 
52
private:
 
53
    Q_DECLARE_PRIVATE(ViewColumn)
 
54
};
 
55
 
 
56
class SplitViewLayoutPrivate;
 
57
class SplitViewLayout : public QObject
 
58
{
 
59
    Q_OBJECT
 
60
 
 
61
    Q_PRIVATE_PROPERTY(SplitViewLayout::d_func(), bool when MEMBER when NOTIFY whenChanged)
 
62
#ifdef Q_QDOC
 
63
    Q_PRIVATE_PROPERTY(SplitViewLayout::d_func(), QQmlListProperty<ViewColumn> columns READ columns NOTIFY columnsChanged DESIGNABLE false)
 
64
#else
 
65
    Q_PRIVATE_PROPERTY(SplitViewLayout::d_func(), QQmlListProperty<UT_PREPEND_NAMESPACE(ViewColumn)> columns READ columns NOTIFY columnsChanged DESIGNABLE false)
 
66
#endif
 
67
    Q_CLASSINFO("DefaultProperty", "columns")
 
68
public:
 
69
    explicit SplitViewLayout(QObject *parent = 0);
 
70
 
 
71
Q_SIGNALS:
 
72
    void whenChanged();
 
73
    void columnsChanged();
 
74
 
 
75
private:
 
76
    Q_DECLARE_PRIVATE(SplitViewLayout)
 
77
};
 
78
 
 
79
class SplitView;
 
80
class SplitViewAttachedPrivate;
 
81
class SplitViewAttached : public QObject
 
82
{
 
83
    Q_OBJECT
 
84
    Q_PRIVATE_PROPERTY(SplitViewAttached::d_func(), int column READ getColumn NOTIFY columnChanged)
 
85
#ifdef Q_QDOC
 
86
    Q_PRIVATE_PROPERTY(SplitViewAttached::d_func(), SplitView* view READ view)
 
87
    Q_PRIVATE_PROPERTY(SplitViewAttached::d_func(), ViewColumn* columnConfig READ config NOTIFY columnChanged)
 
88
#else
 
89
    Q_PRIVATE_PROPERTY(SplitViewAttached::d_func(), UT_PREPEND_NAMESPACE(SplitView*) view READ view)
 
90
    Q_PRIVATE_PROPERTY(SplitViewAttached::d_func(), UT_PREPEND_NAMESPACE(ViewColumn*) columnConfig READ config NOTIFY columnChanged)
 
91
#endif
 
92
public:
 
93
    explicit SplitViewAttached(QObject *parent = 0);
 
94
 
 
95
    static SplitViewAttached *get(QQuickItem *item);
 
96
 
 
97
    void resize(qreal delta);
 
98
 
 
99
Q_SIGNALS:
 
100
    void columnChanged();
 
101
 
 
102
private:
 
103
    Q_DECLARE_PRIVATE(SplitViewAttached)
 
104
};
 
105
 
 
106
class SplitViewPrivate;
 
107
class SplitView : public QQuickBasePositioner
 
108
{
 
109
    Q_OBJECT
 
110
#ifdef Q_QDOC
 
111
    Q_PRIVATE_PROPERTY(SplitView::d_func(), QQmlListProperty<SplitViewLayout> layouts READ layouts NOTIFY layoutsChanged DESIGNABLE false)
 
112
    Q_PRIVATE_PROPERTY(SplitView::d_func(), SplitViewLayout *activeLayout READ getActiveLayout NOTIFY activeLayoutChanged)
 
113
#else
 
114
    Q_PRIVATE_PROPERTY(SplitView::d_func(), QQmlListProperty<UT_PREPEND_NAMESPACE(SplitViewLayout)> layouts READ layouts NOTIFY layoutsChanged DESIGNABLE false)
 
115
    Q_PRIVATE_PROPERTY(SplitView::d_func(), UT_PREPEND_NAMESPACE(SplitViewLayout) *activeLayout READ getActiveLayout NOTIFY activeLayoutChanged)
 
116
#endif
 
117
    Q_PRIVATE_PROPERTY(SplitView::d_func(), QQmlComponent *handleDelegate MEMBER handleDelegate WRITE setHandle NOTIFY handleDelegateChanged)
 
118
    // overrides
 
119
    Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing2 NOTIFY spacingChanged2)
 
120
public:
 
121
    explicit SplitView(QQuickItem *parent = 0);
 
122
 
 
123
    static UT_PREPEND_NAMESPACE(SplitViewAttached) *qmlAttachedProperties(QObject*);
 
124
 
 
125
Q_SIGNALS:
 
126
    void layoutsChanged();
 
127
    void activeLayoutChanged();
 
128
    void handleDelegateChanged();
 
129
    void spacingChanged2();
 
130
 
 
131
protected:
 
132
    SplitView(SplitViewPrivate &, QQuickItem *);
 
133
    ~SplitView();
 
134
 
 
135
    // property setters
 
136
    void setSpacing2(qreal spacing, bool reset = true);
 
137
 
 
138
    // from QQuickBasePositioner
 
139
    void doPositioning(QSizeF *contentSize) override;
 
140
    void reportConflictingAnchors() override;
 
141
 
 
142
    // overrides
 
143
    void componentComplete() override;
 
144
    void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
 
145
    void itemChange(ItemChange, const ItemChangeData &) override;
 
146
private:
 
147
    // QQuickBasePositionerPrivate is not an exported API, therefore we cannot derive from it
 
148
    SplitViewPrivate* const d_ptr;
 
149
    Q_DECLARE_PRIVATE_D(d_ptr, SplitView)
 
150
    Q_PRIVATE_SLOT(d_func(), void changeLayout())
 
151
};
 
152
 
 
153
UT_NAMESPACE_END
 
154
 
 
155
QML_DECLARE_TYPE(UT_PREPEND_NAMESPACE(ViewColumn))
 
156
QML_DECLARE_TYPE(UT_PREPEND_NAMESPACE(SplitViewLayout))
 
157
QML_DECLARE_TYPE(UT_PREPEND_NAMESPACE(SplitView))
 
158
QML_DECLARE_TYPEINFO(UT_PREPEND_NAMESPACE(SplitView), QML_HAS_ATTACHED_PROPERTIES)
 
159
 
 
160
#endif // SPLITVIEW_P_H