Warning, file /include/QtCore/qabstractitemmodel.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005 #ifndef QABSTRACTITEMMODEL_H
0006 #define QABSTRACTITEMMODEL_H
0007
0008 #include <QtCore/qhash.h>
0009 #include <QtCore/qlist.h>
0010 #include <QtCore/qobject.h>
0011 #include <QtCore/qvariant.h>
0012
0013 QT_REQUIRE_CONFIG(itemmodel);
0014
0015 QT_BEGIN_NAMESPACE
0016
0017 class QModelRoleData
0018 {
0019 int m_role;
0020 QVariant m_data;
0021
0022 public:
0023 explicit QModelRoleData(int role) noexcept
0024 : m_role(role)
0025 {}
0026
0027 constexpr int role() const noexcept { return m_role; }
0028 constexpr QVariant &data() noexcept { return m_data; }
0029 constexpr const QVariant &data() const noexcept { return m_data; }
0030
0031 template <typename T>
0032 constexpr void setData(T &&value) noexcept(noexcept(m_data.setValue(std::forward<T>(value))))
0033 { m_data.setValue(std::forward<T>(value)); }
0034
0035 void clearData() noexcept { m_data.clear(); }
0036 };
0037
0038 Q_DECLARE_TYPEINFO(QModelRoleData, Q_RELOCATABLE_TYPE);
0039
0040 class QModelRoleDataSpan;
0041
0042 namespace QtPrivate {
0043 template <typename T, typename Enable = void>
0044 struct IsContainerCompatibleWithModelRoleDataSpan : std::false_type {};
0045
0046 template <typename T>
0047 struct IsContainerCompatibleWithModelRoleDataSpan<T, std::enable_if_t<std::conjunction_v<
0048
0049 std::is_convertible<decltype( std::data(std::declval<T &>()) ), QModelRoleData *>,
0050
0051 std::is_convertible<decltype( std::size(std::declval<T &>()) ), qsizetype>,
0052
0053 std::is_convertible<
0054 typename std::iterator_traits<decltype( std::begin(std::declval<T &>()) )>::value_type,
0055 QModelRoleData
0056 >,
0057 std::is_convertible<
0058 decltype( std::begin(std::declval<T &>()) != std::end(std::declval<T &>()) ),
0059 bool>,
0060
0061 std::negation<std::is_same<std::decay_t<T>, QModelRoleDataSpan>>
0062 >>> : std::true_type {};
0063 }
0064
0065 class QModelRoleDataSpan
0066 {
0067 QModelRoleData *m_modelRoleData = nullptr;
0068 qsizetype m_len = 0;
0069
0070 template <typename T>
0071 using if_compatible_container = std::enable_if_t<QtPrivate::IsContainerCompatibleWithModelRoleDataSpan<T>::value, bool>;
0072
0073 public:
0074 constexpr QModelRoleDataSpan() noexcept {}
0075
0076 constexpr QModelRoleDataSpan(QModelRoleData &modelRoleData) noexcept
0077 : m_modelRoleData(&modelRoleData),
0078 m_len(1)
0079 {}
0080
0081 constexpr QModelRoleDataSpan(QModelRoleData *modelRoleData, qsizetype len)
0082 : m_modelRoleData(modelRoleData),
0083 m_len(len)
0084 {}
0085
0086 template <typename Container, if_compatible_container<Container> = true>
0087 constexpr QModelRoleDataSpan(Container &c) noexcept(noexcept(std::data(c)) && noexcept(std::size(c)))
0088 : m_modelRoleData(std::data(c)),
0089 m_len(qsizetype(std::size(c)))
0090 {}
0091
0092 constexpr qsizetype size() const noexcept { return m_len; }
0093 constexpr qsizetype length() const noexcept { return m_len; }
0094 constexpr QModelRoleData *data() const noexcept { return m_modelRoleData; }
0095 constexpr QModelRoleData *begin() const noexcept { return m_modelRoleData; }
0096 constexpr QModelRoleData *end() const noexcept { return m_modelRoleData + m_len; }
0097 constexpr QModelRoleData &operator[](qsizetype index) const { return m_modelRoleData[index]; }
0098
0099 constexpr QVariant *dataForRole(int role) const
0100 {
0101 #ifdef __cpp_lib_constexpr_algorithms
0102 auto result = std::find_if(begin(), end(), [role](const QModelRoleData &roleData) {
0103 return roleData.role() == role;
0104 });
0105 #else
0106 auto result = begin();
0107 const auto e = end();
0108 for (; result != e; ++result) {
0109 if (result->role() == role)
0110 break;
0111 }
0112 #endif
0113
0114 return Q_ASSERT(result != end()), &result->data();
0115 }
0116 };
0117
0118 Q_DECLARE_TYPEINFO(QModelRoleDataSpan, Q_RELOCATABLE_TYPE);
0119
0120 class QAbstractItemModel;
0121 class QPersistentModelIndex;
0122
0123 class QModelIndex
0124 {
0125 friend class QAbstractItemModel;
0126 public:
0127 constexpr inline QModelIndex() noexcept : r(-1), c(-1), i(0), m(nullptr) {}
0128
0129 constexpr inline int row() const noexcept { return r; }
0130 constexpr inline int column() const noexcept { return c; }
0131 constexpr inline quintptr internalId() const noexcept { return i; }
0132 inline void *internalPointer() const noexcept { return reinterpret_cast<void*>(i); }
0133 inline const void *constInternalPointer() const noexcept { return reinterpret_cast<const void *>(i); }
0134 inline QModelIndex parent() const;
0135 inline QModelIndex sibling(int row, int column) const;
0136 inline QModelIndex siblingAtColumn(int column) const;
0137 inline QModelIndex siblingAtRow(int row) const;
0138 inline QVariant data(int role = Qt::DisplayRole) const;
0139 inline void multiData(QModelRoleDataSpan roleDataSpan) const;
0140 inline Qt::ItemFlags flags() const;
0141 constexpr inline const QAbstractItemModel *model() const noexcept { return m; }
0142 constexpr inline bool isValid() const noexcept { return (r >= 0) && (c >= 0) && (m != nullptr); }
0143 constexpr inline bool operator==(const QModelIndex &other) const noexcept
0144 { return (other.r == r) && (other.i == i) && (other.c == c) && (other.m == m); }
0145 constexpr inline bool operator!=(const QModelIndex &other) const noexcept
0146 { return !(*this == other); }
0147 constexpr inline bool operator<(const QModelIndex &other) const noexcept
0148 {
0149 return r < other.r
0150 || (r == other.r && (c < other.c
0151 || (c == other.c && (i < other.i
0152 || (i == other.i && std::less<const QAbstractItemModel *>()(m, other.m))))));
0153 }
0154 private:
0155 inline QModelIndex(int arow, int acolumn, const void *ptr, const QAbstractItemModel *amodel) noexcept
0156 : r(arow), c(acolumn), i(reinterpret_cast<quintptr>(ptr)), m(amodel) {}
0157 constexpr inline QModelIndex(int arow, int acolumn, quintptr id, const QAbstractItemModel *amodel) noexcept
0158 : r(arow), c(acolumn), i(id), m(amodel) {}
0159 int r, c;
0160 quintptr i;
0161 const QAbstractItemModel *m;
0162 };
0163 Q_DECLARE_TYPEINFO(QModelIndex, Q_RELOCATABLE_TYPE);
0164
0165 #ifndef QT_NO_DEBUG_STREAM
0166 Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &);
0167 #endif
0168
0169 class QPersistentModelIndexData;
0170
0171
0172 size_t qHash(const QPersistentModelIndex &index, size_t seed = 0) noexcept;
0173
0174 class Q_CORE_EXPORT QPersistentModelIndex
0175 {
0176 public:
0177 QPersistentModelIndex();
0178 QPersistentModelIndex(const QModelIndex &index);
0179 QPersistentModelIndex(const QPersistentModelIndex &other);
0180 ~QPersistentModelIndex();
0181 bool operator<(const QPersistentModelIndex &other) const noexcept;
0182 bool operator==(const QPersistentModelIndex &other) const noexcept;
0183 inline bool operator!=(const QPersistentModelIndex &other) const noexcept
0184 { return !operator==(other); }
0185 QPersistentModelIndex &operator=(const QPersistentModelIndex &other);
0186 inline QPersistentModelIndex(QPersistentModelIndex &&other) noexcept
0187 : d(std::exchange(other.d, nullptr)) {}
0188 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPersistentModelIndex)
0189 void swap(QPersistentModelIndex &other) noexcept { qt_ptr_swap(d, other.d); }
0190 bool operator==(const QModelIndex &other) const noexcept;
0191 bool operator!=(const QModelIndex &other) const noexcept;
0192 QPersistentModelIndex &operator=(const QModelIndex &other);
0193 operator QModelIndex() const;
0194 int row() const;
0195 int column() const;
0196 void *internalPointer() const;
0197 const void *constInternalPointer() const;
0198 quintptr internalId() const;
0199 QModelIndex parent() const;
0200 QModelIndex sibling(int row, int column) const;
0201 QVariant data(int role = Qt::DisplayRole) const;
0202 void multiData(QModelRoleDataSpan roleDataSpan) const;
0203 Qt::ItemFlags flags() const;
0204 const QAbstractItemModel *model() const;
0205 bool isValid() const;
0206 private:
0207 QPersistentModelIndexData *d;
0208 friend size_t qHash(const QPersistentModelIndex &, size_t seed) noexcept;
0209 friend bool qHashEquals(const QPersistentModelIndex &a, const QPersistentModelIndex &b) noexcept
0210 { return a.d == b.d; }
0211 #ifndef QT_NO_DEBUG_STREAM
0212 friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &);
0213 #endif
0214 };
0215 Q_DECLARE_SHARED(QPersistentModelIndex)
0216
0217 inline size_t qHash(const QPersistentModelIndex &index, size_t seed) noexcept
0218 { return qHash(index.d, seed); }
0219
0220
0221 #ifndef QT_NO_DEBUG_STREAM
0222 Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &);
0223 #endif
0224
0225 typedef QList<QModelIndex> QModelIndexList;
0226
0227 class QMimeData;
0228 class QAbstractItemModelPrivate;
0229 class QTransposeProxyModelPrivate;
0230 template <class Key, class T> class QMap;
0231
0232
0233 class Q_CORE_EXPORT QAbstractItemModel : public QObject
0234 {
0235 Q_OBJECT
0236
0237 friend class QPersistentModelIndexData;
0238 friend class QAbstractItemViewPrivate;
0239 friend class QAbstractProxyModel;
0240 public:
0241
0242 explicit QAbstractItemModel(QObject *parent = nullptr);
0243 virtual ~QAbstractItemModel();
0244
0245 Q_INVOKABLE bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const;
0246 Q_INVOKABLE virtual QModelIndex index(int row, int column,
0247 const QModelIndex &parent = QModelIndex()) const = 0;
0248 Q_INVOKABLE virtual QModelIndex parent(const QModelIndex &child) const = 0;
0249
0250 Q_INVOKABLE virtual QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
0251 Q_INVOKABLE virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
0252 Q_INVOKABLE virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
0253 Q_INVOKABLE virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
0254
0255 Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
0256 Q_INVOKABLE virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
0257
0258 Q_INVOKABLE virtual QVariant headerData(int section, Qt::Orientation orientation,
0259 int role = Qt::DisplayRole) const;
0260 virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
0261 int role = Qt::EditRole);
0262
0263 virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
0264 virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
0265 virtual bool clearItemData(const QModelIndex &index);
0266
0267 virtual QStringList mimeTypes() const;
0268 virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
0269 virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
0270 int row, int column, const QModelIndex &parent) const;
0271 virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
0272 int row, int column, const QModelIndex &parent);
0273 virtual Qt::DropActions supportedDropActions() const;
0274 virtual Qt::DropActions supportedDragActions() const;
0275
0276 Q_INVOKABLE Q_REVISION(6, 4) virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
0277 Q_INVOKABLE Q_REVISION(6, 4) virtual bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
0278 Q_INVOKABLE Q_REVISION(6, 4) virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
0279 Q_INVOKABLE Q_REVISION(6, 4) virtual bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
0280 Q_INVOKABLE Q_REVISION(6, 4) virtual bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count,
0281 const QModelIndex &destinationParent, int destinationChild);
0282 Q_INVOKABLE Q_REVISION(6, 4) virtual bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count,
0283 const QModelIndex &destinationParent, int destinationChild);
0284
0285 Q_INVOKABLE Q_REVISION(6, 4) inline bool insertRow(int row, const QModelIndex &parent = QModelIndex());
0286 Q_INVOKABLE Q_REVISION(6, 4) inline bool insertColumn(int column, const QModelIndex &parent = QModelIndex());
0287 Q_INVOKABLE Q_REVISION(6, 4) inline bool removeRow(int row, const QModelIndex &parent = QModelIndex());
0288 Q_INVOKABLE Q_REVISION(6, 4) inline bool removeColumn(int column, const QModelIndex &parent = QModelIndex());
0289 Q_INVOKABLE Q_REVISION(6, 4) inline bool moveRow(const QModelIndex &sourceParent, int sourceRow,
0290 const QModelIndex &destinationParent, int destinationChild);
0291 Q_INVOKABLE Q_REVISION(6, 4) inline bool moveColumn(const QModelIndex &sourceParent, int sourceColumn,
0292 const QModelIndex &destinationParent, int destinationChild);
0293
0294 Q_INVOKABLE virtual void fetchMore(const QModelIndex &parent);
0295 Q_INVOKABLE virtual bool canFetchMore(const QModelIndex &parent) const;
0296 Q_INVOKABLE virtual Qt::ItemFlags flags(const QModelIndex &index) const;
0297 Q_INVOKABLE Q_REVISION(6, 4) virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
0298 virtual QModelIndex buddy(const QModelIndex &index) const;
0299 Q_INVOKABLE virtual QModelIndexList match(const QModelIndex &start, int role,
0300 const QVariant &value, int hits = 1,
0301 Qt::MatchFlags flags =
0302 Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
0303 virtual QSize span(const QModelIndex &index) const;
0304
0305 virtual QHash<int,QByteArray> roleNames() const;
0306
0307 using QObject::parent;
0308
0309 enum LayoutChangeHint
0310 {
0311 NoLayoutChangeHint,
0312 VerticalSortHint,
0313 HorizontalSortHint
0314 };
0315 Q_ENUM(LayoutChangeHint)
0316
0317 enum class CheckIndexOption {
0318 NoOption = 0x0000,
0319 IndexIsValid = 0x0001,
0320 DoNotUseParent = 0x0002,
0321 ParentIsInvalid = 0x0004,
0322 };
0323 Q_ENUM(CheckIndexOption)
0324 Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)
0325
0326 [[nodiscard]] bool checkIndex(const QModelIndex &index, CheckIndexOptions options = CheckIndexOption::NoOption) const;
0327
0328 virtual void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const;
0329
0330 Q_SIGNALS:
0331 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
0332 const QList<int> &roles = QList<int>());
0333 void headerDataChanged(Qt::Orientation orientation, int first, int last);
0334 void layoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
0335 void layoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint);
0336
0337 void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal);
0338 void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal);
0339
0340 void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal);
0341 void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal);
0342
0343 void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal);
0344 void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal);
0345
0346 void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal);
0347 void columnsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal);
0348
0349 void modelAboutToBeReset(QPrivateSignal);
0350 void modelReset(QPrivateSignal);
0351
0352 void rowsAboutToBeMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal);
0353 void rowsMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal);
0354
0355 void columnsAboutToBeMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal);
0356 void columnsMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal);
0357
0358 public Q_SLOTS:
0359 virtual bool submit();
0360 virtual void revert();
0361
0362 protected Q_SLOTS:
0363 virtual void resetInternalData();
0364
0365 protected:
0366 QAbstractItemModel(QAbstractItemModelPrivate &dd, QObject *parent = nullptr);
0367
0368 inline QModelIndex createIndex(int row, int column, const void *data = nullptr) const;
0369 inline QModelIndex createIndex(int row, int column, quintptr id) const;
0370
0371 void encodeData(const QModelIndexList &indexes, QDataStream &stream) const;
0372 bool decodeData(int row, int column, const QModelIndex &parent, QDataStream &stream);
0373
0374 void beginInsertRows(const QModelIndex &parent, int first, int last);
0375 void endInsertRows();
0376
0377 void beginRemoveRows(const QModelIndex &parent, int first, int last);
0378 void endRemoveRows();
0379
0380 bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow);
0381 void endMoveRows();
0382
0383 void beginInsertColumns(const QModelIndex &parent, int first, int last);
0384 void endInsertColumns();
0385
0386 void beginRemoveColumns(const QModelIndex &parent, int first, int last);
0387 void endRemoveColumns();
0388
0389 bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn);
0390 void endMoveColumns();
0391
0392 void beginResetModel();
0393 void endResetModel();
0394
0395 void changePersistentIndex(const QModelIndex &from, const QModelIndex &to);
0396 void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to);
0397 QModelIndexList persistentIndexList() const;
0398
0399 private:
0400 Q_DECLARE_PRIVATE(QAbstractItemModel)
0401 Q_DISABLE_COPY(QAbstractItemModel)
0402 };
0403
0404 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemModel::CheckIndexOptions)
0405
0406 inline bool QAbstractItemModel::insertRow(int arow, const QModelIndex &aparent)
0407 { return insertRows(arow, 1, aparent); }
0408 inline bool QAbstractItemModel::insertColumn(int acolumn, const QModelIndex &aparent)
0409 { return insertColumns(acolumn, 1, aparent); }
0410 inline bool QAbstractItemModel::removeRow(int arow, const QModelIndex &aparent)
0411 { return removeRows(arow, 1, aparent); }
0412 inline bool QAbstractItemModel::removeColumn(int acolumn, const QModelIndex &aparent)
0413 { return removeColumns(acolumn, 1, aparent); }
0414 inline bool QAbstractItemModel::moveRow(const QModelIndex &sourceParent, int sourceRow,
0415 const QModelIndex &destinationParent, int destinationChild)
0416 { return moveRows(sourceParent, sourceRow, 1, destinationParent, destinationChild); }
0417 inline bool QAbstractItemModel::moveColumn(const QModelIndex &sourceParent, int sourceColumn,
0418 const QModelIndex &destinationParent, int destinationChild)
0419 { return moveColumns(sourceParent, sourceColumn, 1, destinationParent, destinationChild); }
0420 inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, const void *adata) const
0421 { return QModelIndex(arow, acolumn, adata, this); }
0422 inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, quintptr aid) const
0423 { return QModelIndex(arow, acolumn, aid, this); }
0424
0425 class Q_CORE_EXPORT QAbstractTableModel : public QAbstractItemModel
0426 {
0427 Q_OBJECT
0428
0429 public:
0430 explicit QAbstractTableModel(QObject *parent = nullptr);
0431 ~QAbstractTableModel();
0432
0433 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
0434 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
0435 bool dropMimeData(const QMimeData *data, Qt::DropAction action,
0436 int row, int column, const QModelIndex &parent) override;
0437
0438 Qt::ItemFlags flags(const QModelIndex &index) const override;
0439
0440 using QObject::parent;
0441
0442 protected:
0443 QAbstractTableModel(QAbstractItemModelPrivate &dd, QObject *parent);
0444
0445 private:
0446 Q_DISABLE_COPY(QAbstractTableModel)
0447 QModelIndex parent(const QModelIndex &child) const override;
0448 bool hasChildren(const QModelIndex &parent) const override;
0449 };
0450
0451 class Q_CORE_EXPORT QAbstractListModel : public QAbstractItemModel
0452 {
0453 Q_OBJECT
0454
0455 public:
0456 explicit QAbstractListModel(QObject *parent = nullptr);
0457 ~QAbstractListModel();
0458
0459 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
0460 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
0461 bool dropMimeData(const QMimeData *data, Qt::DropAction action,
0462 int row, int column, const QModelIndex &parent) override;
0463
0464 Qt::ItemFlags flags(const QModelIndex &index) const override;
0465
0466 using QObject::parent;
0467
0468 protected:
0469 QAbstractListModel(QAbstractItemModelPrivate &dd, QObject *parent);
0470
0471 private:
0472 Q_DISABLE_COPY(QAbstractListModel)
0473 QModelIndex parent(const QModelIndex &child) const override;
0474 int columnCount(const QModelIndex &parent) const override;
0475 bool hasChildren(const QModelIndex &parent) const override;
0476 };
0477
0478
0479
0480 inline QModelIndex QModelIndex::parent() const
0481 { return m ? m->parent(*this) : QModelIndex(); }
0482
0483 inline QModelIndex QModelIndex::sibling(int arow, int acolumn) const
0484 { return m ? (r == arow && c == acolumn) ? *this : m->sibling(arow, acolumn, *this) : QModelIndex(); }
0485
0486 inline QModelIndex QModelIndex::siblingAtColumn(int acolumn) const
0487 { return m ? (c == acolumn) ? *this : m->sibling(r, acolumn, *this) : QModelIndex(); }
0488
0489 inline QModelIndex QModelIndex::siblingAtRow(int arow) const
0490 { return m ? (r == arow) ? *this : m->sibling(arow, c, *this) : QModelIndex(); }
0491
0492 inline QVariant QModelIndex::data(int arole) const
0493 { return m ? m->data(*this, arole) : QVariant(); }
0494
0495 inline void QModelIndex::multiData(QModelRoleDataSpan roleDataSpan) const
0496 { if (m) m->multiData(*this, roleDataSpan); }
0497
0498 inline Qt::ItemFlags QModelIndex::flags() const
0499 { return m ? m->flags(*this) : Qt::ItemFlags(); }
0500
0501 inline size_t qHash(const QModelIndex &index, size_t seed = 0) noexcept
0502 {
0503 #if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0)
0504 return qHashMulti(seed, index.row(), index.column(), index.internalId());
0505 #else
0506 return size_t((size_t(index.row()) << 4) + size_t(index.column()) + index.internalId()) ^ seed;
0507 #endif
0508 }
0509
0510 QT_END_NAMESPACE
0511
0512 QT_DECL_METATYPE_EXTERN(QModelIndexList, Q_CORE_EXPORT)
0513
0514 #endif