8#include "qml_material/export.hpp"
12struct ItemDescriptor {
15 quint64 contentRevision = 0;
16 bool operator==(
const ItemDescriptor&)
const =
default;
19class QML_MATERIAL_API ItemDataSnapshot {
21 virtual ~ItemDataSnapshot();
22 virtual int count()
const = 0;
23 virtual bool stableKeys()
const {
return true; }
24 virtual ItemDescriptor descriptorAt(
int index)
const = 0;
25 virtual std::optional<int> indexOfKey(
const QString& key)
const = 0;
26 virtual QVariant valueAt(
int index)
const = 0;
28using ItemDataSnapshotPtr = std::shared_ptr<const ItemDataSnapshot>;
31class TypedItemDataSnapshot :
public ItemDataSnapshot {
33 virtual T itemAt(
int index)
const = 0;
34 QVariant valueAt(
int index)
const final {
return QVariant::fromValue(itemAt(index)); }
41 quint64 contentRevision = 0;
44struct ItemValueUpdate {
47 std::optional<QString> reuseType;
48 quint64 contentRevision = 0;
51class ItemSnapshotRows;
53class QML_MATERIAL_API ItemSnapshot {
56 const quint64 revision;
57 int count()
const {
return m_count; }
58 bool stableKeys()
const {
return m_data && m_data->stableKeys(); }
59 const ItemDescriptor& descriptorAt(
int index)
const;
60 int indexOfKey(
const QString& key)
const;
61 QVariant valueAt(
int index)
const;
63 bool sharesValueAt(
int index,
const ItemSnapshot&,
int otherIndex)
const;
64 ItemRecord recordAt(
int index)
const;
67 friend class ItemSource;
68 ItemSnapshot(quint64, ItemDataSnapshotPtr, QVector<ItemDescriptor>);
69 ItemSnapshot(quint64,
const ItemSnapshot&,
const QVector<ItemValueUpdate>&);
70 ItemDataSnapshotPtr m_data;
71 std::shared_ptr<const ItemSnapshotRows> m_rows;
74using ItemSnapshotPtr = std::shared_ptr<const ItemSnapshot>;
76QML_MATERIAL_API ItemDataSnapshotPtr makeItemDataSnapshot(QVector<ItemRecord> rows,
77 bool stableKeys =
true,
78 const ItemSnapshotPtr& before = {});