17
17
#ifndef VERTICALJOURNAL_H
18
18
#define VERTICALJOURNAL_H
22
class QAbstractItemModel;
24
#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
25
class QQuickChangeSet;
26
class QQuickVisualDataModel;
29
class QQmlDelegateModel;
20
#include "abstractdashview.h"
32
22
/** A vertical journal is a view that creates delegates
33
23
* based on a model and layouts them in columns following
63
class VerticalJournal : public QQuickItem
54
class VerticalJournal : public AbstractDashView
67
Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged)
68
Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
69
58
Q_PROPERTY(qreal columnWidth READ columnWidth WRITE setColumnWidth NOTIFY columnWidthChanged)
70
Q_PROPERTY(qreal columnSpacing READ columnSpacing WRITE setColumnSpacing NOTIFY columnSpacingChanged)
71
Q_PROPERTY(qreal rowSpacing READ rowSpacing WRITE setRowSpacing NOTIFY rowSpacingChanged)
72
Q_PROPERTY(qreal delegateCreationBegin READ delegateCreationBegin
73
WRITE setDelegateCreationBegin
74
NOTIFY delegateCreationBeginChanged
75
RESET resetDelegateCreationBegin)
76
Q_PROPERTY(qreal delegateCreationEnd READ delegateCreationEnd
77
WRITE setDelegateCreationEnd
78
NOTIFY delegateCreationEndChanged
79
RESET resetDelegateCreationEnd)
81
60
friend class VerticalJournalTest;
86
QAbstractItemModel *model() const;
87
void setModel(QAbstractItemModel *model);
89
QQmlComponent *delegate() const;
90
void setDelegate(QQmlComponent *delegate);
92
65
qreal columnWidth() const;
93
66
void setColumnWidth(qreal columnWidth);
95
qreal columnSpacing() const;
96
void setColumnSpacing(qreal columnSpacing);
98
qreal rowSpacing() const;
99
void setRowSpacing(qreal rowSpacing);
101
qreal delegateCreationBegin() const;
102
void setDelegateCreationBegin(qreal);
103
void resetDelegateCreationBegin();
105
qreal delegateCreationEnd() const;
106
void setDelegateCreationEnd(qreal);
107
void resetDelegateCreationEnd();
111
void delegateChanged();
112
69
void columnWidthChanged();
113
void columnSpacingChanged();
114
void rowSpacingChanged();
115
void delegateCreationBeginChanged();
116
void delegateCreationEndChanged();
120
void componentComplete();
123
#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
124
void itemCreated(int modelIndex, QQuickItem *item);
125
void onModelUpdated(const QQuickChangeSet &changeSet, bool reset);
127
void itemCreated(int modelIndex, QObject *object);
128
void onModelUpdated(const QQmlChangeSet &changeSet, bool reset);
131
void onHeightChanged();
147
void createDelegateModel();
149
void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos);
150
void findTopModelIndexToAdd(int *modelIndex, qreal *yPos);
151
bool addVisibleItems(qreal fillFrom, qreal fillTo, bool asynchronous);
152
bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo);
153
QQuickItem *createItem(int modelIndex, bool asynchronous);
154
void positionItem(int modelIndex, QQuickItem *item);
155
void cleanupExistingItems();
156
void releaseItem(const ViewItem &item);
157
void calculateImplicitHeight();
85
void findBottomModelIndexToAdd(int *modelIndex, qreal *yPos) override;
86
void findTopModelIndexToAdd(int *modelIndex, qreal *yPos) override;
87
bool removeNonVisibleItems(qreal bufferFromY, qreal bufferToY) override;
88
void addItemToView(int modelIndex, QQuickItem *item) override;
89
void cleanupExistingItems() override;
90
void calculateImplicitHeight() override;
91
void doRelayout() override;
92
void updateItemCulling(qreal visibleFromY, qreal visibleToY) override;
159
93
#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
160
QQuickVisualDataModel *m_delegateModel;
94
void processModelRemoves(const QVector<QQuickChangeSet::Remove> &removes) override;
162
QQmlDelegateModel *m_delegateModel;
96
void processModelRemoves(const QVector<QQmlChangeSet::Remove> &removes) override;
165
// Index we are waiting because we requested it asynchronously
166
int m_asyncRequestedIndex;
168
99
QVector<QList<ViewItem>> m_columnVisibleItems;
169
100
QHash<int, int> m_indexColumnMap;
170
101
int m_columnWidth;
173
qreal m_delegateCreationBegin;
174
qreal m_delegateCreationEnd;
175
bool m_delegateCreationBeginValid;
176
bool m_delegateCreationEndValid;
177
bool m_needsRelayout;
178
bool m_delegateValidated;
179
bool m_implicitHeightDirty;