| 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_separatorComponent; |
| 33 | Kirigami::Platform::Units *m_units = nullptr; |
| 34 | |
| 35 | Q_SIGNALS: |
| 36 | void gridUnitChanged(); |
| 37 | void longDurationChanged(); |
| 38 | }; |
| 39 | |
| 40 | class ContentItem : public QQuickItem |
| 41 | { |
| 42 | Q_OBJECT |
| 43 | |
| 44 | public: |
| 45 | ContentItem(ColumnView *parent = nullptr); |
| 46 | ~ContentItem() override; |
| 47 | |
| 48 | void layoutItems(); |
| 49 | void layoutPinnedItems(); |
| 50 | qreal childWidth(QQuickItem *child); |
| 51 | void updateVisibleItems(); |
| 52 | void forgetItem(QQuickItem *item); |
| 53 | QQuickItem *ensureSeparator(QQuickItem *previousColumn, QQuickItem *column, QQuickItem *nextColumn); |
| 54 | |
| 55 | void setBoundedX(qreal x); |
| 56 | void animateX(qreal x); |
| 57 | void snapToItem(); |
| 58 | |
| 59 | void (QQuickItem *, QQuickItem *); |
| 60 | void (QQuickItem *, QQuickItem *); |
| 61 | |
| 62 | inline qreal viewportLeft() const; |
| 63 | inline qreal viewportRight() const; |
| 64 | |
| 65 | protected: |
| 66 | void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override; |
| 67 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
| 68 | |
| 69 | private Q_SLOTS: |
| 70 | void syncItemsOrder(); |
| 71 | void updateRepeaterModel(); |
| 72 | |
| 73 | private: |
| 74 | ColumnView *m_view; |
| 75 | QQuickItem *; |
| 76 | QQuickItem *; |
| 77 | |
| 78 | QPropertyAnimation *m_slideAnim; |
| 79 | QList<QQuickItem *> m_items; |
| 80 | QList<QQuickItem *> m_visibleItems; |
| 81 | QPointer<QQuickItem> m_viewAnchorItem; |
| 82 | QHash<QQuickItem *, QQuickItem *> m_separators; |
| 83 | QHash<QObject *, QObject *> m_models; |
| 84 | |
| 85 | qreal m_leftPinnedSpace = 361; |
| 86 | qreal m_rightPinnedSpace = 0; |
| 87 | |
| 88 | qreal m_columnWidth = 0; |
| 89 | qreal m_lastDragDelta = 0; |
| 90 | ColumnView::ColumnResizeMode m_columnResizeMode = ColumnView::FixedColumns; |
| 91 | bool m_shouldAnimate = false; |
| 92 | bool m_creationInProgress = true; |
| 93 | friend class ColumnView; |
| 94 | }; |
| 95 | |