5#ifndef QABSTRACTITEMMODEL_H
6#define QABSTRACTITEMMODEL_H
8#include <QtCore/qhash.h>
9#include <QtCore/qlist.h>
10#include <QtCore/qobject.h>
11#include <QtCore/qvariant.h>
27 constexpr int role() const noexcept {
return m_role; }
43template <
typename T,
typename Enable =
void>
49 std::is_convertible<decltype( std::data(std::declval<T &>()) ), QModelRoleData *>,
51 std::is_convertible<decltype( std::size(std::declval<T &>()) ), qsizetype>,
54 typename std::iterator_traits<decltype( std::begin(std::declval<T &>()) )>::value_type,
58 decltype( std::begin(std::declval<T &>()) != std::end(std::declval<T &>()) ),
61 std::negation<std::is_same<std::decay_t<T>, QModelRoleDataSpan>>
62 >>> : std::true_type {};
71 using if_compatible_container = std::enable_if_t<QtPrivate::IsContainerCompatibleWithModelRoleDataSpan<T>::value,
bool>;
77 : m_modelRoleData(&modelRoleData),
82 : m_modelRoleData(modelRoleData),
86 template <
typename Container, if_compatible_container<Container> = true>
88 : m_modelRoleData(std::data(
c)),
101#ifdef __cpp_lib_constexpr_algorithms
107 const auto e =
end();
109 if (
result->role() == role)
129 constexpr inline int row() const noexcept {
return r; }
130 constexpr inline int column() const noexcept {
return c; }
140 inline Qt::ItemFlags
flags()
const;
142 constexpr inline bool isValid() const noexcept {
return (
r >= 0) && (
c >= 0) && (
m !=
nullptr); }
146 {
return !(*
this ==
other); }
152 || (
i ==
other.i && std::less<const QAbstractItemModel *>()(
m,
other.m))))));
156 :
r(arow),
c(acolumn),
i(
reinterpret_cast<quintptr>(
ptr)),
m(amodel) {}
158 :
r(arow),
c(acolumn),
i(
id),
m(amodel) {}
165#ifndef QT_NO_DEBUG_STREAM
187 :
d(std::exchange(
other.d,
nullptr)) {}
196 void *internalPointer()
const;
197 const void *constInternalPointer()
const;
203 Qt::ItemFlags
flags()
const;
205 bool isValid()
const;
210 {
return a.d ==
b.d; }
211#ifndef QT_NO_DEBUG_STREAM
221#ifndef QT_NO_DEBUG_STREAM
230template <
class Key,
class T>
class QMap;
273 virtual Qt::DropActions supportedDropActions()
const;
274 virtual Qt::DropActions supportedDragActions()
const;
283 const
QModelIndex &destinationParent,
int destinationChild);
292 const
QModelIndex &destinationParent,
int destinationChild);
302 Qt::MatchFlags(
Qt::MatchStartsWith|
Qt::MatchWrap)) const;
319 IndexIsValid = 0x0001,
320 DoNotUseParent = 0x0002,
321 ParentIsInvalid = 0x0004,
326 [[nodiscard]]
bool checkIndex(
const QModelIndex &
index, CheckIndexOptions options = CheckIndexOption::NoOption)
const;
359 virtual bool submit();
360 virtual void revert();
363 virtual void resetInternalData();
375 void endInsertRows();
378 void endRemoveRows();
384 void endInsertColumns();
387 void endRemoveColumns();
389 bool beginMoveColumns(
const QModelIndex &sourceParent,
int sourceFirst,
int sourceLast,
const QModelIndex &destinationParent,
int destinationColumn);
390 void endMoveColumns();
392 void beginResetModel();
393 void endResetModel();
406inline bool QAbstractItemModel::insertRow(
int arow,
const QModelIndex &aparent)
407{
return insertRows(arow, 1, aparent); }
408inline bool QAbstractItemModel::insertColumn(
int acolumn,
const QModelIndex &aparent)
409{
return insertColumns(acolumn, 1, aparent); }
410inline bool QAbstractItemModel::removeRow(
int arow,
const QModelIndex &aparent)
411{
return removeRows(arow, 1, aparent); }
412inline bool QAbstractItemModel::removeColumn(
int acolumn,
const QModelIndex &aparent)
413{
return removeColumns(acolumn, 1, aparent); }
484{
return m ? (
r == arow &&
c == acolumn) ? *
this :
m->sibling(arow, acolumn, *
this) :
QModelIndex(); }
487{
return m ? (
c == acolumn) ? *
this :
m->sibling(
r, acolumn, *
this) :
QModelIndex(); }
490{
return m ? (
r == arow) ? *
this :
m->sibling(arow,
c, *
this) :
QModelIndex(); }
496{
if (
m)
m->multiData(*
this, roleDataSpan); }
499{
return m ?
m->flags(*
this) : Qt::ItemFlags(); }
503#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0)
506 return size_t((
size_t(
index.row()) << 4) +
size_t(
index.column()) +
index.internalId()) ^
seed;
void rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal)
void modelAboutToBeReset(QPrivateSignal)
void columnsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been removed from the model.
LayoutChangeHint
This enum describes the way the model changes layout.
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before rows are inserted into the model.
void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before columns are inserted into the model.
void modelReset(QPrivateSignal)
Q_INVOKABLE int int const QModelIndex & destinationParent
void layoutAboutToBeChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This signal is emitted whenever the data in an existing item changes.
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
void columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal)
virtual Q_INVOKABLE QModelIndex parent(const QModelIndex &child) const =0
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before columns are removed from the model.
Q_INVOKABLE int int const QModelIndex int destinationChild
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
Q_INVOKABLE int sourceRow
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before rows are removed from the model.
void rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal)
virtual Q_INVOKABLE int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been inserted into the model.
Q_INVOKABLE int sourceColumn
void columnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal)
QModelIndex createIndex(int row, int column, const void *data=nullptr) const
Creates a model index for the given row and column with the internal pointer ptr.
void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been inserted into the model.
virtual Q_INVOKABLE QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const =0
Returns the data stored under the given role for the item referred to by the index.
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index.
void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been removed from the model.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting,...
\inmodule QtCore\reentrant
QModelIndex siblingAtColumn(int column) const
Returns the sibling at column for the current row.
constexpr bool operator==(const QModelIndex &other) const noexcept
Returns {true} if this model index refers to the same location as the other model index; otherwise re...
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
QModelIndex siblingAtRow(int row) const
Returns the sibling at row for the current column.
constexpr int row() const noexcept
Returns the row this model index refers to.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr const QAbstractItemModel * model() const noexcept
Returns a pointer to the model containing the item that this index refers to.
constexpr bool operator<(const QModelIndex &other) const noexcept
Qt::ItemFlags flags() const
constexpr QModelIndex() noexcept
Creates a new empty model index.
constexpr int column() const noexcept
Returns the column this model index refers to.
void * internalPointer() const noexcept
Returns a {void} {*} pointer used by the model to associate the index with the internal data structur...
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
void multiData(QModelRoleDataSpan roleDataSpan) const
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
const void * constInternalPointer() const noexcept
Returns a {const void} {*} pointer used by the model to associate the index with the internal data st...
constexpr bool operator!=(const QModelIndex &other) const noexcept
Returns {true} if this model index does not refer to the same location as the other model index; othe...
constexpr quintptr internalId() const noexcept
Returns a {quintptr} used by the model to associate the index with the internal data structure.
constexpr QModelRoleData & operator[](qsizetype index) const
Returns a modifiable reference to the QModelRoleData at position index in the span.
constexpr qsizetype length() const noexcept
Returns the length of the span represented by this object.
constexpr qsizetype size() const noexcept
Returns the length of the span represented by this object.
constexpr QModelRoleDataSpan(QModelRoleData &modelRoleData) noexcept
Constructs an QModelRoleDataSpan spanning over modelRoleData, seen as a 1-element array.
constexpr QVariant * dataForRole(int role) const
Returns the data associated with the first QModelRoleData in the span that has its role equal to role...
constexpr QModelRoleDataSpan(Container &c) noexcept(noexcept(std::data(c)) &&noexcept(std::size(c)))
Constructs an QModelRoleDataSpan spanning over the container c, which can be any contiguous container...
constexpr QModelRoleData * begin() const noexcept
Returns a pointer to the beginning of the span represented by this object.
constexpr QModelRoleData * end() const noexcept
Returns a pointer to the imaginary element one past the end of the span represented by this object.
constexpr QModelRoleDataSpan(QModelRoleData *modelRoleData, qsizetype len)
Constructs an QModelRoleDataSpan spanning over the array beginning at modelRoleData and with length l...
constexpr QModelRoleDataSpan() noexcept
Constructs an empty QModelRoleDataSpan.
constexpr QModelRoleData * data() const noexcept
Returns a pointer to the beginning of the span represented by this object.
constexpr const QVariant & data() const noexcept
Returns the data held by this object.
void clearData() noexcept
Clears the data held by this object.
constexpr QVariant & data() noexcept
Returns the data held by this object as a modifiable reference.
constexpr int role() const noexcept
Returns the role held by this object.
constexpr void setData(T &&value) noexcept(noexcept(m_data.setValue(std::forward< T >(value))))
Sets the data held by this object to value.
QModelRoleData(int role) noexcept
Constructs a QModelRoleData object for the given role.
QObject * parent() const
Returns a pointer to the parent object.
bool operator!=(const QPersistentModelIndex &other) const
friend bool qHashEquals(const QPersistentModelIndex &a, const QPersistentModelIndex &b) noexcept
QPersistentModelIndex(QPersistentModelIndex &&other) noexcept
Move-constructs a QPersistentModelIndex instance, making it point at the same object that other was p...
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &)
size_t qHash(const QPersistentModelIndex &index, size_t seed=0) noexcept
QList< QModelIndex > QModelIndexList
constexpr bool operator!=(const timespec &t1, const timespec &t2)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
static ControlElement< T > * ptr(QWidget *widget)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void GLsizei void void * span
GLfixed GLfixed GLint GLint order
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
#define QT_REQUIRE_CONFIG(feature)
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
model setHeaderData(0, Qt::Horizontal, tr("Name"))
QSqlQueryModel * model
[16]
beginInsertRows(parent, 2, 4)
[0]
beginMoveRows(sourceParent, 2, 4, destinationParent, 2)
[5]
std::array< QModelRoleData, 3 > roleData
[13]
beginInsertColumns(parent, 4, 6)
[2]
beginRemoveColumns(parent, 4, 6)
[4]
beginRemoveRows(parent, 2, 3)
[1]
model multiData(index, span)
mimeData setData("text/csv", csvData)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent