17 #ifndef LISTVIEWWITHPAGEHEADER_H
18 #define LISTVIEWWITHPAGEHEADER_H
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-pedantic"
22 #include <private/qquickitemchangelistener_p.h>
23 #include <private/qquickflickable_p.h>
24 #pragma GCC diagnostic pop
26 class QAbstractItemModel;
27 class QQuickNumberAnimation;
28 #if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
29 class QQuickChangeSet;
30 class QQuickVisualDataModel;
33 class QQmlDelegateModel;
57 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged)
58 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
59 Q_PROPERTY(QQuickItem *pageHeader READ header WRITE setHeader NOTIFY headerChanged)
60 Q_PROPERTY(QQmlComponent *sectionDelegate READ sectionDelegate WRITE setSectionDelegate NOTIFY sectionDelegateChanged)
61 Q_PROPERTY(QString sectionProperty READ sectionProperty WRITE setSectionProperty NOTIFY sectionPropertyChanged)
62 Q_PROPERTY(
bool forceNoClip READ forceNoClip WRITE setForceNoClip NOTIFY forceNoClipChanged)
63 Q_PROPERTY(
int stickyHeaderHeight READ stickyHeaderHeight NOTIFY stickyHeaderHeightChanged)
65 friend class ListViewWithPageHeaderTest;
66 friend class ListViewWithPageHeaderTestSection;
67 friend class ListViewWithPageHeaderTestExternalModel;
73 QAbstractItemModel *model()
const;
74 void setModel(QAbstractItemModel *model);
76 QQmlComponent *delegate()
const;
77 void setDelegate(QQmlComponent *delegate);
79 QQuickItem *header()
const;
80 void setHeader(QQuickItem *header);
82 QQmlComponent *sectionDelegate()
const;
83 void setSectionDelegate(QQmlComponent *delegate);
85 QString sectionProperty()
const;
86 void setSectionProperty(
const QString &property);
88 bool forceNoClip()
const;
89 void setForceNoClip(
bool noClip);
91 int stickyHeaderHeight()
const;
93 Q_INVOKABLE
void positionAtBeginning();
94 Q_INVOKABLE
void showHeader();
95 Q_INVOKABLE QQuickItem *item(
int modelIndex)
const;
100 Q_INVOKABLE
bool maximizeVisibleArea(
int modelIndex);
101 Q_INVOKABLE
bool maximizeVisibleArea(
int modelIndex,
int itemHeight);
105 void delegateChanged();
106 void headerChanged();
107 void sectionDelegateChanged();
108 void sectionPropertyChanged();
109 void forceNoClipChanged();
110 void stickyHeaderHeightChanged();
113 void componentComplete();
114 void viewportMoved(Qt::Orientations orient);
115 qreal minYExtent()
const;
116 void itemGeometryChanged(QQuickItem *item,
const QRectF &newGeometry,
const QRectF &oldGeometry);
120 #if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
121 void itemCreated(
int modelIndex, QQuickItem *item);
123 void itemCreated(
int modelIndex, QObject *
object);
125 void onContentHeightChanged();
126 void onContentWidthChanged();
127 void onHeightChanged();
128 #if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
129 void onModelUpdated(
const QQuickChangeSet &changeSet,
bool reset);
131 void onModelUpdated(
const QQmlChangeSet &changeSet,
bool reset);
133 void onShowHeaderAnimationFinished();
139 qreal height()
const;
142 void setY(qreal newY);
145 void setCulled(
bool culled);
148 QQuickItem *m_sectionItem;
151 bool maximizeVisibleArea(ListItem *listItem,
int listItemHeight);
153 void createDelegateModel();
157 bool addVisibleItems(qreal fillFrom, qreal fillTo,
bool asynchronous);
158 bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo);
159 ListItem *createItem(
int modelIndex,
bool asynchronous);
161 void adjustMinYExtent();
162 void updateClipItem();
163 void headerHeightChanged(qreal newHeaderHeight, qreal oldHeaderHeight, qreal oldHeaderY);
164 ListItem *itemAtIndex(
int modelIndex)
const;
165 void releaseItem(ListItem *item);
166 void reallyReleaseItem(ListItem *item);
167 void updateWatchedRoles();
168 QQuickItem *getSectionItem(
int modelIndex,
bool alreadyInserted);
169 QQuickItem *getSectionItem(
const QString §ionText);
171 #if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
172 QQuickVisualDataModel *m_delegateModel;
174 QQmlDelegateModel *m_delegateModel;
178 int m_asyncRequestedIndex;
181 bool m_delegateValidated;
184 QList<ListItem *> m_visibleItems;
185 int m_firstVisibleIndex;
189 QQuickItem *m_clipItem;
193 bool m_contentHeightDirty;
195 QQuickItem *m_headerItem;
196 qreal m_previousContentY;
197 qreal m_headerItemShownHeight;
199 enum ContentYAnimationType { ContentYAnimationShowHeader, ContentYAnimationMaximizeVisibleArea };
200 ContentYAnimationType contentYAnimationType;
201 QQuickNumberAnimation *m_contentYAnimation;
203 QQmlComponent *m_sectionDelegate;
204 QString m_sectionProperty;
205 QQuickItem *m_topSectionItem;
209 bool m_inContentHeightKeepHeaderShown;
213 QList<ListItem *> m_itemsToRelease;