17 #ifndef LISTVIEWWITHPAGEHEADER_H
18 #define LISTVIEWWITHPAGEHEADER_H
20 #include <private/qquickitemchangelistener_p.h>
21 #include <private/qquickflickable_p.h>
23 class QAbstractItemModel;
24 class QQuickNumberAnimation;
26 class QQmlDelegateModel;
49 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged)
50 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
51 Q_PROPERTY(QQuickItem *pageHeader READ header WRITE setHeader NOTIFY headerChanged)
52 Q_PROPERTY(QQmlComponent *sectionDelegate READ sectionDelegate WRITE setSectionDelegate NOTIFY sectionDelegateChanged)
53 Q_PROPERTY(QString sectionProperty READ sectionProperty WRITE setSectionProperty NOTIFY sectionPropertyChanged)
54 Q_PROPERTY(
bool forceNoClip READ forceNoClip WRITE setForceNoClip NOTIFY forceNoClipChanged)
55 Q_PROPERTY(
int stickyHeaderHeight READ stickyHeaderHeight NOTIFY stickyHeaderHeightChanged)
57 friend class ListViewWithPageHeaderTest;
58 friend class ListViewWithPageHeaderTestSection;
59 friend class ListViewWithPageHeaderTestExternalModel;
65 QAbstractItemModel *model()
const;
66 void setModel(QAbstractItemModel *model);
68 QQmlComponent *delegate()
const;
69 void setDelegate(QQmlComponent *delegate);
71 QQuickItem *header()
const;
72 void setHeader(QQuickItem *header);
74 QQmlComponent *sectionDelegate()
const;
75 void setSectionDelegate(QQmlComponent *delegate);
77 QString sectionProperty()
const;
78 void setSectionProperty(
const QString &property);
80 bool forceNoClip()
const;
81 void setForceNoClip(
bool noClip);
83 int stickyHeaderHeight()
const;
85 Q_INVOKABLE
void positionAtBeginning();
86 Q_INVOKABLE
void showHeader();
87 Q_INVOKABLE QQuickItem *item(
int modelIndex)
const;
92 Q_INVOKABLE
bool maximizeVisibleArea(
int modelIndex);
93 Q_INVOKABLE
bool maximizeVisibleArea(
int modelIndex,
int itemHeight);
97 void delegateChanged();
99 void sectionDelegateChanged();
100 void sectionPropertyChanged();
101 void forceNoClipChanged();
102 void stickyHeaderHeightChanged();
105 void componentComplete();
106 void viewportMoved(Qt::Orientations orient);
107 qreal minYExtent()
const;
108 void itemGeometryChanged(QQuickItem *item,
const QRectF &newGeometry,
const QRectF &oldGeometry);
112 void itemCreated(
int modelIndex, QObject *
object);
113 void onContentHeightChanged();
114 void onContentWidthChanged();
115 void onHeightChanged();
116 void onModelUpdated(
const QQmlChangeSet &changeSet,
bool reset);
117 void onShowHeaderAnimationFinished();
123 qreal height()
const;
126 void setY(qreal newY);
129 void setCulled(
bool culled);
132 QQuickItem *m_sectionItem;
135 bool maximizeVisibleArea(ListItem *listItem,
int listItemHeight);
137 void createDelegateModel();
141 bool addVisibleItems(qreal fillFrom, qreal fillTo,
bool asynchronous);
142 bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo);
143 ListItem *createItem(
int modelIndex,
bool asynchronous);
145 void adjustMinYExtent();
146 void updateClipItem();
147 void headerHeightChanged(qreal newHeaderHeight, qreal oldHeaderHeight, qreal oldHeaderY);
148 ListItem *itemAtIndex(
int modelIndex)
const;
149 void releaseItem(ListItem *item);
150 void reallyReleaseItem(ListItem *item);
151 void updateWatchedRoles();
152 QQuickItem *getSectionItem(
int modelIndex,
bool alreadyInserted);
153 QQuickItem *getSectionItem(
const QString §ionText);
155 QQmlDelegateModel *m_delegateModel;
158 int m_asyncRequestedIndex;
161 bool m_delegateValidated;
164 QList<ListItem *> m_visibleItems;
165 int m_firstVisibleIndex;
169 QQuickItem *m_clipItem;
173 bool m_contentHeightDirty;
175 QQuickItem *m_headerItem;
176 qreal m_previousContentY;
177 qreal m_headerItemShownHeight;
179 enum ContentYAnimationType { ContentYAnimationShowHeader, ContentYAnimationMaximizeVisibleArea };
180 ContentYAnimationType contentYAnimationType;
181 QQuickNumberAnimation *m_contentYAnimation;
183 QQmlComponent *m_sectionDelegate;
184 QString m_sectionProperty;
185 QQuickItem *m_topSectionItem;
189 bool m_inContentHeightKeepHeaderShown;
193 QList<ListItem *> m_itemsToRelease;