1 | /* |
2 | * SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org> |
3 | * |
4 | * SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #pragma once |
8 | |
9 | #include "columnview.h" |
10 | |
11 | #include <QPointer> |
12 | #include <QQuickItem> |
13 | |
14 | class QPropertyAnimation; |
15 | class QQmlComponent; |
16 | namespace Kirigami |
17 | { |
18 | namespace Platform |
19 | { |
20 | class Units; |
21 | } |
22 | } |
23 | |
24 | class QmlComponentsPool : public QObject |
25 | { |
26 | Q_OBJECT |
27 | |
28 | public: |
29 | QmlComponentsPool(QQmlEngine *engine); |
30 | ~QmlComponentsPool() override; |
31 | |
32 | QQmlComponent *m_leadingSeparatorComponent = nullptr; |
33 | QQmlComponent *m_trailingSeparatorComponent = nullptr; |
34 | Kirigami::Platform::Units *m_units = nullptr; |
35 | |
36 | Q_SIGNALS: |
37 | void gridUnitChanged(); |
38 | void longDurationChanged(); |
39 | |
40 | private: |
41 | QObject *m_instance = nullptr; |
42 | }; |
43 | |
44 | class ContentItem : public QQuickItem |
45 | { |
46 | Q_OBJECT |
47 | |
48 | public: |
49 | ContentItem(ColumnView *parent = nullptr); |
50 | ~ContentItem() override; |
51 | |
52 | void layoutItems(); |
53 | void layoutPinnedItems(); |
54 | qreal childWidth(QQuickItem *child); |
55 | void updateVisibleItems(); |
56 | void forgetItem(QQuickItem *item); |
57 | QQuickItem *ensureLeadingSeparator(QQuickItem *item); |
58 | QQuickItem *ensureTrailingSeparator(QQuickItem *item); |
59 | |
60 | void setBoundedX(qreal x); |
61 | void animateX(qreal x); |
62 | void snapToItem(); |
63 | |
64 | void (QQuickItem *, QQuickItem *); |
65 | void (QQuickItem *, QQuickItem *); |
66 | |
67 | inline qreal viewportLeft() const; |
68 | inline qreal viewportRight() const; |
69 | |
70 | protected: |
71 | void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override; |
72 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
73 | |
74 | private Q_SLOTS: |
75 | void syncItemsOrder(); |
76 | void updateRepeaterModel(); |
77 | |
78 | private: |
79 | ColumnView *m_view; |
80 | QQuickItem *; |
81 | QQuickItem *; |
82 | QPropertyAnimation *m_slideAnim; |
83 | QList<QQuickItem *> m_items; |
84 | QList<QObject *> m_visibleItems; |
85 | QPointer<QQuickItem> m_viewAnchorItem; |
86 | QHash<QQuickItem *, QQuickItem *> m_leadingSeparators; |
87 | QHash<QQuickItem *, QQuickItem *> m_trailingSeparators; |
88 | QHash<QObject *, QObject *> m_models; |
89 | |
90 | qreal m_leftPinnedSpace = 361; |
91 | qreal m_rightPinnedSpace = 0; |
92 | |
93 | qreal m_columnWidth = 0; |
94 | qreal m_lastDragDelta = 0; |
95 | ColumnView::ColumnResizeMode m_columnResizeMode = ColumnView::FixedColumns; |
96 | bool m_shouldAnimate = false; |
97 | bool m_creationInProgress = true; |
98 | friend class ColumnView; |
99 | }; |
100 | |