5#ifndef QQMLCHANGESET_P_H
6#define QQMLCHANGESET_P_H
19#include <QtQmlIntegration/qqmlintegration.h>
20#include <QtCore/qdebug.h>
21#include <QtCore/qvector.h>
22#include <QtQmlModels/private/qtqmlmodelsglobal_p.h>
24#include <QtCore/qhashfunctions.h>
36 MoveKey(
int moveId,
int offset) : moveId(moveId), offset(offset) {}
41 friend size_t qHash(MoveKey key, size_t seed = 0)
noexcept
42 {
return qHashMulti(seed, key.moveId, key.offset); }
56 struct Change: ChangeData
64 Change(
int index,
int count,
int moveId = -1,
int offset = 0) {
67 this->moveId = moveId;
68 this->offset = offset;
71 bool isMove()
const {
return moveId >= 0; }
73 MoveKey moveKey(
int index)
const {
74 return MoveKey(moveId, index - Change::index + offset); }
76 int start()
const {
return index; }
77 int end()
const {
return index + count; }
81 QQmlChangeSet(
const QQmlChangeSet &changeSet);
84 QQmlChangeSet &operator =(
const QQmlChangeSet &changeSet);
86 const QList<Change> &removes()
const {
return m_removes; }
87 const QList<Change> &inserts()
const {
return m_inserts; }
88 const QList<Change> &changes()
const {
return m_changes; }
90 void insert(
int index,
int count);
91 void remove(
int index,
int count);
92 void move(
int from,
int to,
int count,
int moveId);
93 void change(
int index,
int count);
95 void insert(
const QList<Change> &inserts);
96 void remove(
const QList<Change> &removes, QList<Change> *inserts =
nullptr);
97 void move(
const QList<Change> &removes,
const QList<Change> &inserts);
98 void change(
const QList<Change> &changes);
99 void apply(
const QQmlChangeSet &changeSet);
101 bool isEmpty()
const {
return m_removes.empty() && m_inserts.empty() && m_changes.isEmpty(); }
111 int difference()
const {
return m_difference; }
114 void remove(QList<Change> *removes, QList<Change> *inserts);
115 void change(QList<Change> *changes);
117 QList<Change> m_removes;
118 QList<Change> m_inserts;
119 QList<Change> m_changes;
123Q_DECLARE_TYPEINFO(QQmlChangeSet::Change, Q_PRIMITIVE_TYPE);
124Q_DECLARE_TYPEINFO(QQmlChangeSet::MoveKey, Q_PRIMITIVE_TYPE);
126inline bool operator ==(
const QQmlChangeSet::MoveKey &l,
const QQmlChangeSet::MoveKey &r) {
127 return l.moveId == r.moveId && l.offset == r.offset; }
129Q_QMLMODELS_EXPORT
QDebug operator <<(QDebug debug,
const QQmlChangeSet::Change &change);
130Q_QMLMODELS_EXPORT
QDebug operator <<(QDebug debug,
const QQmlChangeSet &change);
friend bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept
Returns true if lhs and rhs are equal, otherwise returns false.
The QQmlChangeSet class stores an ordered list of notifications about changes to a linear data set.
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
QDebug operator<<(QDebug dbg, const QFileInfo &fi)