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
14class QPropertyAnimation;
15class QQmlComponent;
16namespace Kirigami
17{
18namespace Platform
19{
20class Units;
21}
22}
23
24class QmlComponentsPool : public QObject
25{
26 Q_OBJECT
27
28public:
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
36Q_SIGNALS:
37 void gridUnitChanged();
38 void longDurationChanged();
39
40private:
41 QObject *m_instance = nullptr;
42};
43
44class ContentItem : public QQuickItem
45{
46 Q_OBJECT
47
48public:
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 connectHeader(QQuickItem *oldHeader, QQuickItem *newHeader);
65 void connectFooter(QQuickItem *oldFooter, QQuickItem *newFooter);
66
67 inline qreal viewportLeft() const;
68 inline qreal viewportRight() const;
69
70protected:
71 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
72 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
73
74private Q_SLOTS:
75 void syncItemsOrder();
76 void updateRepeaterModel();
77
78private:
79 ColumnView *m_view;
80 QQuickItem *m_globalHeaderParent;
81 QQuickItem *m_globalFooterParent;
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

source code of kirigami/src/columnview_p.h