Kirigami2

delegaterecycler.h
1 /*
2  * SPDX-FileCopyrightText: 2018 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 #ifndef DELEGATERECYCLER_H
8 #define DELEGATERECYCLER_H
9 
10 #include <QQuickItem>
11 #include <QVariant>
12 #include <QPointer>
13 
14 
15 class DelegateCache;
16 
17 class DelegateRecyclerAttached : public QObject
18 {
19  Q_OBJECT
20 
21 public:
22  DelegateRecyclerAttached(QObject *parent = nullptr);
23  ~DelegateRecyclerAttached();
24 
25 
26 
27 Q_SIGNALS:
28  void pooled();
29  void reused();
30 
31 
32 };
33 
49 {
50  Q_OBJECT
51 
59  Q_PROPERTY(QQmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceComponentChanged)
60 
61 public:
62  DelegateRecycler(QQuickItem *parent = nullptr);
64 
65 
66  QQmlComponent *sourceComponent() const;
67  void setSourceComponent(QQmlComponent *component);
68  void resetSourceComponent();
69 
70  static DelegateRecyclerAttached *qmlAttachedProperties(QObject *object);
71 
72 protected:
73  void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
74  void focusInEvent(QFocusEvent *event) override;
75 
76  void updateHints();
77  void updateSize(bool parentResized);
78 
79 Q_SIGNALS:
80  void sourceComponentChanged();
81 
82 private Q_SLOTS:
83  void syncIndex();
84  void syncModel();
85  void syncModelProperties();
86  void syncModelData();
87 
88 private:
89  QPointer<QQmlComponent> m_sourceComponent;
90  QPointer<QQuickItem> m_item;
91  QObject *m_propertiesTracker = nullptr;
92  bool m_updatingSize = false;
93  bool m_widthFromItem = false;
94  bool m_heightFromItem = false;
95 };
96 
97 QML_DECLARE_TYPEINFO(DelegateRecycler, QML_HAS_ATTACHED_PROPERTIES)
98 
99 #endif
This class may be used as a delegate of a ListView or a GridView in the case the intended delegate is...
Q_SIGNALSQ_SIGNALS
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 3 2020 22:37:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.