Debian Codegraph @

src/imports/Layouts/plugin/ullayouts_p.h

raw
1 /*
2 * Copyright 2013 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 <[email protected]>
17 */
18
19 #ifndef ULLAYOUTS_P_H
20 #define ULLAYOUTS_P_H
21
22 #include "ullayouts.h"
23
24 #include <QtQml/QQmlIncubator>
25
26 #include "propertychanges_p.h"
27
28 typedef QHash<QString, QQuickItem*> LaidOutItemsMap;
29 typedef QHashIterator<QString, QQuickItem*> LaidOutItemsMapIterator;
30
31 class ULItemLayout;
32 class ULLayoutsPrivate : QQmlIncubator {
33 Q_DECLARE_PUBLIC(ULLayouts)
34 public:
35
36 ULLayoutsPrivate(ULLayouts *qq);
37
38 void validateConditionalLayouts();
39 void getLaidOutItems(QQuickItem *item);
40 void updateLayout();
41
42 static void error(QObject *item, const QString &message);
43 static void error(QObject *item, const QList<QQmlError> &errors);
44 static void warning(QObject *item, const QString &message);
45
46 protected: // QQmlIncubator stuff
47 void setInitialState(QObject *object) override;
48 void statusChanged(Status status) override;
49
50 private:
51 ULLayouts *q_ptr;
52 QList<ULConditionalLayout*> layouts;
53 ChangeList changes;
54 LaidOutItemsMap itemsToLayout;
55 QQuickItem* currentLayoutItem;
56 QQuickItem* previousLayoutItem;
57 QQuickItem* contentItem;
58 int currentLayoutIndex;
59 bool ready:1;
60
61 // callbacks for the "layouts" QQmlListProperty of ULLayouts
62 static void append_layout(QQmlListProperty<ULConditionalLayout>*, ULConditionalLayout*);
63 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
64 static qsizetype count_layouts(QQmlListProperty<ULConditionalLayout>*);
65 static ULConditionalLayout *at_layout(QQmlListProperty<ULConditionalLayout>*, qsizetype);
66 #else
67 static int count_layouts(QQmlListProperty<ULConditionalLayout>*);
68 static ULConditionalLayout *at_layout(QQmlListProperty<ULConditionalLayout>*, int);
69 #endif
70 static void clear_layouts(QQmlListProperty<ULConditionalLayout>*);
71
72 void reLayout();
73 void reparentItems();
74 QList<ULItemLayout*> collectContainers(QQuickItem *fromItem);
75 void reparentToItemLayout(LaidOutItemsMap &map, ULItemLayout *fragment);
76 };
77
78 #endif // ULLAYOUTS_P_H