QtBase  v6.3.1
qabstractitemmodel.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
5 ** Contact: https://www.qt.io/licensing/
6 **
7 ** This file is part of the QtCore module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 3 requirements
24 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 **
26 ** GNU General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU
28 ** General Public License version 2.0 or (at your option) the GNU General
29 ** Public license version 3 or any later version approved by the KDE Free
30 ** Qt Foundation. The licenses are as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 ** included in the packaging of this file. Please review the following
33 ** information to ensure the GNU General Public License requirements will
34 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 ** https://www.gnu.org/licenses/gpl-3.0.html.
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 #ifndef QABSTRACTITEMMODEL_H
42 #define QABSTRACTITEMMODEL_H
43 
44 #include <QtCore/qhash.h>
45 #include <QtCore/qlist.h>
46 #include <QtCore/qobject.h>
47 #include <QtCore/qvariant.h>
48 
49 QT_REQUIRE_CONFIG(itemmodel);
50 
52 
54 {
55  int m_role;
56  QVariant m_data;
57 
58 public:
59  explicit QModelRoleData(int role) noexcept
60  : m_role(role)
61  {}
62 
63  constexpr int role() const noexcept { return m_role; }
64  constexpr QVariant &data() noexcept { return m_data; }
65  constexpr const QVariant &data() const noexcept { return m_data; }
66 
67  template <typename T>
68  constexpr void setData(T &&value) noexcept(noexcept(m_data.setValue(std::forward<T>(value))))
69  { m_data.setValue(std::forward<T>(value)); }
70 
71  void clearData() noexcept { m_data.clear(); }
72 };
73 
75 
76 class QModelRoleDataSpan;
77 
78 namespace QtPrivate {
79 template <typename T, typename Enable = void>
80 struct IsContainerCompatibleWithModelRoleDataSpan : std::false_type {};
81 
82 template <typename T>
83 struct IsContainerCompatibleWithModelRoleDataSpan<T, std::enable_if_t<std::conjunction_v<
84  // lacking concepts and ranges, we accept any T whose std::data yields a suitable pointer ...
85  std::is_convertible<decltype( std::data(std::declval<T &>()) ), QModelRoleData *>,
86  // ... and that has a suitable size ...
87  std::is_convertible<decltype( std::size(std::declval<T &>()) ), qsizetype>,
88  // ... and it's a range as it defines an iterator-like API
89  std::is_convertible<
90  typename std::iterator_traits<decltype( std::begin(std::declval<T &>()) )>::value_type,
91  QModelRoleData
92  >,
93  std::is_convertible<
94  decltype( std::begin(std::declval<T &>()) != std::end(std::declval<T &>()) ),
95  bool>,
96  // Don't make an accidental copy constructor
97  std::negation<std::is_same<std::decay_t<T>, QModelRoleDataSpan>>
98  >>> : std::true_type {};
99 } // namespace QtPrivate
100 
102 {
103  QModelRoleData *m_modelRoleData = nullptr;
104  qsizetype m_len = 0;
105 
106  template <typename T>
108 
109 public:
110  constexpr QModelRoleDataSpan() noexcept {}
111 
112  constexpr QModelRoleDataSpan(QModelRoleData &modelRoleData) noexcept
113  : m_modelRoleData(&modelRoleData),
114  m_len(1)
115  {}
116 
117  constexpr QModelRoleDataSpan(QModelRoleData *modelRoleData, qsizetype len)
118  : m_modelRoleData(modelRoleData),
119  m_len(len)
120  {}
121 
122  template <typename Container, if_compatible_container<Container> = true>
123  constexpr QModelRoleDataSpan(Container &c) noexcept(noexcept(std::data(c)) && noexcept(std::size(c)))
124  : m_modelRoleData(std::data(c)),
125  m_len(qsizetype(std::size(c)))
126  {}
127 
128  constexpr qsizetype size() const noexcept { return m_len; }
129  constexpr qsizetype length() const noexcept { return m_len; }
130  constexpr QModelRoleData *data() const noexcept { return m_modelRoleData; }
131  constexpr QModelRoleData *begin() const noexcept { return m_modelRoleData; }
132  constexpr QModelRoleData *end() const noexcept { return m_modelRoleData + m_len; }
133  constexpr QModelRoleData &operator[](qsizetype index) const { return m_modelRoleData[index]; }
134 
135  constexpr QVariant *dataForRole(int role) const
136  {
137 #ifdef __cpp_lib_constexpr_algorithms
138  auto result = std::find_if(begin(), end(), [role](const QModelRoleData &roleData) {
139  return roleData.role() == role;
140  });
141 #else
142  auto result = begin();
143  const auto e = end();
144  for (; result != e; ++result) {
145  if (result->role() == role)
146  break;
147  }
148 #endif
149 
150  return Q_ASSERT(result != end()), &result->data();
151  }
152 };
153 
155 
156 class QAbstractItemModel;
158 
160 {
161  friend class QAbstractItemModel;
162 public:
163  constexpr inline QModelIndex() noexcept : r(-1), c(-1), i(0), m(nullptr) {}
164  // compiler-generated copy/move ctors/assignment operators are fine!
165  constexpr inline int row() const noexcept { return r; }
166  constexpr inline int column() const noexcept { return c; }
167  constexpr inline quintptr internalId() const noexcept { return i; }
168  inline void *internalPointer() const noexcept { return reinterpret_cast<void*>(i); }
169  inline const void *constInternalPointer() const noexcept { return reinterpret_cast<const void *>(i); }
170  inline QModelIndex parent() const;
171  inline QModelIndex sibling(int row, int column) const;
172  inline QModelIndex siblingAtColumn(int column) const;
173  inline QModelIndex siblingAtRow(int row) const;
174  inline QVariant data(int role = Qt::DisplayRole) const;
175  inline void multiData(QModelRoleDataSpan roleDataSpan) const;
176  inline Qt::ItemFlags flags() const;
177  constexpr inline const QAbstractItemModel *model() const noexcept { return m; }
178  constexpr inline bool isValid() const noexcept { return (r >= 0) && (c >= 0) && (m != nullptr); }
179  constexpr inline bool operator==(const QModelIndex &other) const noexcept
180  { return (other.r == r) && (other.i == i) && (other.c == c) && (other.m == m); }
181  constexpr inline bool operator!=(const QModelIndex &other) const noexcept
182  { return !(*this == other); }
183  constexpr inline bool operator<(const QModelIndex &other) const noexcept
184  {
185  return r < other.r
186  || (r == other.r && (c < other.c
187  || (c == other.c && (i < other.i
188  || (i == other.i && std::less<const QAbstractItemModel *>()(m, other.m))))));
189  }
190 private:
191  inline QModelIndex(int arow, int acolumn, const void *ptr, const QAbstractItemModel *amodel) noexcept
192  : r(arow), c(acolumn), i(reinterpret_cast<quintptr>(ptr)), m(amodel) {}
193  constexpr inline QModelIndex(int arow, int acolumn, quintptr id, const QAbstractItemModel *amodel) noexcept
194  : r(arow), c(acolumn), i(id), m(amodel) {}
195  int r, c;
196  quintptr i;
197  const QAbstractItemModel *m;
198 };
200 
201 #ifndef QT_NO_DEBUG_STREAM
202 Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &);
203 #endif
204 
206 
207 // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
208 size_t qHash(const QPersistentModelIndex &index, size_t seed = 0) noexcept;
209 
210 class Q_CORE_EXPORT QPersistentModelIndex
211 {
212 public:
217  bool operator<(const QPersistentModelIndex &other) const;
218  bool operator==(const QPersistentModelIndex &other) const;
219  inline bool operator!=(const QPersistentModelIndex &other) const
220  { return !operator==(other); }
223  : d(qExchange(other.d, nullptr)) {}
225  void swap(QPersistentModelIndex &other) noexcept { qt_ptr_swap(d, other.d); }
226  bool operator==(const QModelIndex &other) const;
227  bool operator!=(const QModelIndex &other) const;
228  QPersistentModelIndex &operator=(const QModelIndex &other);
229  operator QModelIndex() const;
230  int row() const;
231  int column() const;
232  void *internalPointer() const;
233  const void *constInternalPointer() const;
234  quintptr internalId() const;
235  QModelIndex parent() const;
236  QModelIndex sibling(int row, int column) const;
237  QVariant data(int role = Qt::DisplayRole) const;
238  void multiData(QModelRoleDataSpan roleDataSpan) const;
239  Qt::ItemFlags flags() const;
240  const QAbstractItemModel *model() const;
241  bool isValid() const;
242 private:
244  friend size_t qHash(const QPersistentModelIndex &, size_t seed) noexcept;
245  friend bool qHashEquals(const QPersistentModelIndex &a, const QPersistentModelIndex &b) noexcept
246  { return a.d == b.d; }
247 #ifndef QT_NO_DEBUG_STREAM
248  friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &);
249 #endif
250 };
252 
253 inline size_t qHash(const QPersistentModelIndex &index, size_t seed) noexcept
254 { return qHash(index.d, seed); }
255 
256 
257 #ifndef QT_NO_DEBUG_STREAM
258 Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &);
259 #endif
260 
262 
263 class QMimeData;
266 template <class Key, class T> class QMap;
267 
268 
269 class Q_CORE_EXPORT QAbstractItemModel : public QObject
270 {
271  Q_OBJECT
272 
275  friend class QAbstractProxyModel;
276 public:
277 
278  explicit QAbstractItemModel(QObject *parent = nullptr);
279  virtual ~QAbstractItemModel();
280 
281  Q_INVOKABLE bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const;
283  const QModelIndex &parent = QModelIndex()) const = 0;
284  Q_INVOKABLE virtual QModelIndex parent(const QModelIndex &child) const = 0;
285 
286  Q_INVOKABLE virtual QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
287  Q_INVOKABLE virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
288  Q_INVOKABLE virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
289  Q_INVOKABLE virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
290 
291  Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
292  Q_INVOKABLE virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
293 
294  Q_INVOKABLE virtual QVariant headerData(int section, Qt::Orientation orientation,
295  int role = Qt::DisplayRole) const;
296  virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
297  int role = Qt::EditRole);
298 
299  virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
300  virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
301  virtual bool clearItemData(const QModelIndex &index);
302 
303  virtual QStringList mimeTypes() const;
304  virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
305  virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
306  int row, int column, const QModelIndex &parent) const;
307  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
308  int row, int column, const QModelIndex &parent);
309  virtual Qt::DropActions supportedDropActions() const;
310  virtual Qt::DropActions supportedDragActions() const;
311 
312  virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
313  virtual bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
314  virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
315  virtual bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
316  virtual bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count,
317  const QModelIndex &destinationParent, int destinationChild);
318  virtual bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count,
319  const QModelIndex &destinationParent, int destinationChild);
320 
321  inline bool insertRow(int row, const QModelIndex &parent = QModelIndex());
322  inline bool insertColumn(int column, const QModelIndex &parent = QModelIndex());
323  inline bool removeRow(int row, const QModelIndex &parent = QModelIndex());
324  inline bool removeColumn(int column, const QModelIndex &parent = QModelIndex());
325  inline bool moveRow(const QModelIndex &sourceParent, int sourceRow,
326  const QModelIndex &destinationParent, int destinationChild);
327  inline bool moveColumn(const QModelIndex &sourceParent, int sourceColumn,
328  const QModelIndex &destinationParent, int destinationChild);
329 
330  Q_INVOKABLE virtual void fetchMore(const QModelIndex &parent);
331  Q_INVOKABLE virtual bool canFetchMore(const QModelIndex &parent) const;
332  Q_INVOKABLE virtual Qt::ItemFlags flags(const QModelIndex &index) const;
333  virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
334  virtual QModelIndex buddy(const QModelIndex &index) const;
335  Q_INVOKABLE virtual QModelIndexList match(const QModelIndex &start, int role,
336  const QVariant &value, int hits = 1,
337  Qt::MatchFlags flags =
338  Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
339  virtual QSize span(const QModelIndex &index) const;
340 
341  virtual QHash<int,QByteArray> roleNames() const;
342 
343  using QObject::parent;
344 
346  {
350  };
352 
353  enum class CheckIndexOption {
354  NoOption = 0x0000,
355  IndexIsValid = 0x0001,
356  DoNotUseParent = 0x0002,
357  ParentIsInvalid = 0x0004,
358  };
360  Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)
361 
362  [[nodiscard]] bool checkIndex(const QModelIndex &index, CheckIndexOptions options = CheckIndexOption::NoOption) const;
363 
364  virtual void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const;
365 
366 Q_SIGNALS:
367  void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
368  const QList<int> &roles = QList<int>());
369  void headerDataChanged(Qt::Orientation orientation, int first, int last);
372 
373  void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal);
374  void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal);
375 
376  void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal);
377  void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal);
378 
379  void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal);
380  void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal);
381 
382  void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal);
383  void columnsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal);
384 
385  void modelAboutToBeReset(QPrivateSignal);
386  void modelReset(QPrivateSignal);
387 
388  void rowsAboutToBeMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal);
389  void rowsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row, QPrivateSignal);
390 
391  void columnsAboutToBeMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal);
392  void columnsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column, QPrivateSignal);
393 
394 public Q_SLOTS:
395  virtual bool submit();
396  virtual void revert();
397 
398 protected Q_SLOTS:
399  virtual void resetInternalData();
400 
401 protected:
403 
404  inline QModelIndex createIndex(int row, int column, const void *data = nullptr) const;
405  inline QModelIndex createIndex(int row, int column, quintptr id) const;
406 
407  void encodeData(const QModelIndexList &indexes, QDataStream &stream) const;
408  bool decodeData(int row, int column, const QModelIndex &parent, QDataStream &stream);
409 
410  void beginInsertRows(const QModelIndex &parent, int first, int last);
411  void endInsertRows();
412 
413  void beginRemoveRows(const QModelIndex &parent, int first, int last);
414  void endRemoveRows();
415 
416  bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow);
417  void endMoveRows();
418 
419  void beginInsertColumns(const QModelIndex &parent, int first, int last);
420  void endInsertColumns();
421 
422  void beginRemoveColumns(const QModelIndex &parent, int first, int last);
423  void endRemoveColumns();
424 
425  bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn);
426  void endMoveColumns();
427 
428  void beginResetModel();
429  void endResetModel();
430 
431  void changePersistentIndex(const QModelIndex &from, const QModelIndex &to);
432  void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to);
434 
435 private:
436  Q_DECLARE_PRIVATE(QAbstractItemModel)
438 };
439 
440 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemModel::CheckIndexOptions)
441 
443 { return insertRows(arow, 1, aparent); }
444 inline bool QAbstractItemModel::insertColumn(int acolumn, const QModelIndex &aparent)
445 { return insertColumns(acolumn, 1, aparent); }
446 inline bool QAbstractItemModel::removeRow(int arow, const QModelIndex &aparent)
447 { return removeRows(arow, 1, aparent); }
448 inline bool QAbstractItemModel::removeColumn(int acolumn, const QModelIndex &aparent)
449 { return removeColumns(acolumn, 1, aparent); }
450 inline bool QAbstractItemModel::moveRow(const QModelIndex &sourceParent, int sourceRow,
451  const QModelIndex &destinationParent, int destinationChild)
452 { return moveRows(sourceParent, sourceRow, 1, destinationParent, destinationChild); }
453 inline bool QAbstractItemModel::moveColumn(const QModelIndex &sourceParent, int sourceColumn,
454  const QModelIndex &destinationParent, int destinationChild)
455 { return moveColumns(sourceParent, sourceColumn, 1, destinationParent, destinationChild); }
456 inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, const void *adata) const
457 { return QModelIndex(arow, acolumn, adata, this); }
458 inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, quintptr aid) const
459 { return QModelIndex(arow, acolumn, aid, this); }
460 
461 class Q_CORE_EXPORT QAbstractTableModel : public QAbstractItemModel
462 {
463  Q_OBJECT
464 
465 public:
466  explicit QAbstractTableModel(QObject *parent = nullptr);
468 
469  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
470  QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
471  bool dropMimeData(const QMimeData *data, Qt::DropAction action,
472  int row, int column, const QModelIndex &parent) override;
473 
474  Qt::ItemFlags flags(const QModelIndex &index) const override;
475 
476  using QObject::parent;
477 
478 protected:
480 
481 private:
483  QModelIndex parent(const QModelIndex &child) const override;
484  bool hasChildren(const QModelIndex &parent) const override;
485 };
486 
487 class Q_CORE_EXPORT QAbstractListModel : public QAbstractItemModel
488 {
489  Q_OBJECT
490 
491 public:
492  explicit QAbstractListModel(QObject *parent = nullptr);
494 
495  QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
496  QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
497  bool dropMimeData(const QMimeData *data, Qt::DropAction action,
498  int row, int column, const QModelIndex &parent) override;
499 
500  Qt::ItemFlags flags(const QModelIndex &index) const override;
501 
502  using QObject::parent;
503 
504 protected:
506 
507 private:
509  QModelIndex parent(const QModelIndex &child) const override;
510  int columnCount(const QModelIndex &parent) const override;
511  bool hasChildren(const QModelIndex &parent) const override;
512 };
513 
514 // inline implementations
515 
517 { return m ? m->parent(*this) : QModelIndex(); }
518 
519 inline QModelIndex QModelIndex::sibling(int arow, int acolumn) const
520 { return m ? (r == arow && c == acolumn) ? *this : m->sibling(arow, acolumn, *this) : QModelIndex(); }
521 
522 inline QModelIndex QModelIndex::siblingAtColumn(int acolumn) const
523 { return m ? (c == acolumn) ? *this : m->sibling(r, acolumn, *this) : QModelIndex(); }
524 
526 { return m ? (r == arow) ? *this : m->sibling(arow, c, *this) : QModelIndex(); }
527 
528 inline QVariant QModelIndex::data(int arole) const
529 { return m ? m->data(*this, arole) : QVariant(); }
530 
531 inline void QModelIndex::multiData(QModelRoleDataSpan roleDataSpan) const
532 { if (m) m->multiData(*this, roleDataSpan); }
533 
534 inline Qt::ItemFlags QModelIndex::flags() const
535 { return m ? m->flags(*this) : Qt::ItemFlags(); }
536 
537 inline size_t qHash(const QModelIndex &index, size_t seed = 0) noexcept
538 { return size_t((size_t(index.row()) << 4) + size_t(index.column()) + index.internalId()) ^ seed; }
539 
541 
543 
544 #endif // QABSTRACTITEMMODEL_H
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
#define value
[5]
FT_UInt idx
Definition: cffcmap.c:135
The QAbstractItemModel class provides the abstract interface for item model classes.
void rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row, QPrivateSignal)
virtual Q_INVOKABLE QModelIndex parent(const QModelIndex &child) const =0
void modelAboutToBeReset(QPrivateSignal)
virtual Q_INVOKABLE QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
virtual bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
void columnsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
Q_INVOKABLE bool hasIndex(int row, int column, const QModelIndex &parent=QModelIndex()) const
void modelReset(QPrivateSignal)
QModelIndexList persistentIndexList() const
virtual void resetInternalData()
bool removeRow(int row, const QModelIndex &parent=QModelIndex())
void changePersistentIndex(const QModelIndex &from, const QModelIndex &to)
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to)
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 >())
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const =0
void columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal)
bool moveColumn(const QModelIndex &sourceParent, int sourceColumn, const QModelIndex &destinationParent, int destinationChild)
virtual bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild)
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
bool removeColumn(int column, const QModelIndex &parent=QModelIndex())
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
bool insertColumn(int column, const QModelIndex &parent=QModelIndex())
bool moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild)
bool checkIndex(const QModelIndex &index, CheckIndexOptions options=CheckIndexOption::NoOption) const
void columnsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column, QPrivateSignal)
void headerDataChanged(Qt::Orientation orientation, int first, int last)
virtual bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn)
void encodeData(const QModelIndexList &indexes, QDataStream &stream) const
virtual bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
virtual bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
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
void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
bool decodeData(int row, int column, const QModelIndex &parent, QDataStream &stream)
QAbstractItemModel(QObject *parent=nullptr)
QModelIndex createIndex(int row, int column, const void *data=nullptr) const
void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
virtual Q_INVOKABLE QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const =0
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
The QAbstractListModel class provides an abstract model that can be subclassed to create one-dimensio...
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting,...
QModelIndex buddy(const QModelIndex &index) const override
void fetchMore(const QModelIndex &parent) override
Qt::DropActions supportedDragActions() const override
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override
QHash< int, QByteArray > roleNames() const override
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles) override
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
bool canFetchMore(const QModelIndex &parent) const override
bool clearItemData(const QModelIndex &index) override
QMap< int, QVariant > itemData(const QModelIndex &index) const override
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
Qt::DropActions supportedDropActions() const override
QStringList mimeTypes() const override
The QAbstractTableModel class provides an abstract model that can be subclassed to create table model...
char * data()
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:66
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
bool operator<(const QElapsedTimer &lhs, const QElapsedTimer &rhs) noexcept
template< typename Enum > bool operator!=(Enum lhs, QFlags< Enum > rhs)
template< typename Enum > size_t qHash(QFlags< Enum > flags, size_t seed=0) noexcept
template< typename Enum > bool operator==(Enum lhs, QFlags< Enum > rhs)
Definition: qmap.h:222
The QMimeData class provides a container for data that records information about its MIME type.
Definition: qmimedata.h:52
The QModelIndex class is used to locate data in a data model.
QModelIndex siblingAtColumn(int column) const
constexpr bool operator==(const QModelIndex &other) const noexcept
QVariant data(int role=Qt::DisplayRole) const
QModelIndex siblingAtRow(int row) const
constexpr int row() const noexcept
QModelIndex parent() const
constexpr const QAbstractItemModel * model() const noexcept
constexpr bool operator<(const QModelIndex &other) const noexcept
Qt::ItemFlags flags() const
constexpr QModelIndex() noexcept
constexpr int column() const noexcept
void * internalPointer() const noexcept
constexpr bool isValid() const noexcept
void multiData(QModelRoleDataSpan roleDataSpan) const
QModelIndex sibling(int row, int column) const
const void * constInternalPointer() const noexcept
constexpr bool operator!=(const QModelIndex &other) const noexcept
constexpr quintptr internalId() const noexcept
The QModelRoleData class holds a role and the data associated to that role.
constexpr const QVariant & data() const noexcept
void clearData() noexcept
constexpr QVariant & data() noexcept
constexpr int role() const noexcept
constexpr void setData(T &&value) noexcept(noexcept(m_data.setValue(std::forward< T >(value))))
QModelRoleData(int role) noexcept
The QModelRoleDataSpan class provides a span over QModelRoleData objects.
constexpr QModelRoleData & operator[](qsizetype index) const
constexpr qsizetype length() const noexcept
constexpr qsizetype size() const noexcept
constexpr QModelRoleDataSpan(QModelRoleData &modelRoleData) noexcept
constexpr QVariant * dataForRole(int role) const
constexpr QModelRoleDataSpan(Container &c) noexcept(noexcept(std::data(c)) &&noexcept(std::size(c)))
constexpr QModelRoleData * begin() const noexcept
constexpr QModelRoleData * end() const noexcept
constexpr QModelRoleDataSpan(QModelRoleData *modelRoleData, qsizetype len)
constexpr QModelRoleDataSpan() noexcept
constexpr QModelRoleData * data() const noexcept
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
QObject * parent() const
Definition: qobject.h:409
The QPersistentModelIndex class is used to locate data in a data model.
bool operator!=(const QPersistentModelIndex &other) const
friend bool qHashEquals(const QPersistentModelIndex &a, const QPersistentModelIndex &b) noexcept
QPersistentModelIndex(QPersistentModelIndex &&other) noexcept
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:55
The QStringList class provides a list of strings.
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
void * data()
Definition: qvariant.cpp:2464
void clear()
Definition: qvariant.cpp:1082
void setValue(T &&avalue)
Definition: qvariant.h:355
double e
auto it unsigned count const
Definition: hb-iter.hh:848
#define inline
Definition: md4c.c:45
Orientation
Definition: qnamespace.h:123
@ EditRole
Definition: qnamespace.h:1504
@ DisplayRole
Definition: qnamespace.h:1502
SortOrder
Definition: qnamespace.h:146
@ AscendingOrder
Definition: qnamespace.h:147
DropAction
Definition: qnamespace.h:1484
@ MatchWrap
Definition: qnamespace.h:1555
@ MatchStartsWith
Definition: qnamespace.h:1548
action
Definition: devices.py:78
Definition: qfloat16.h:381
void
Definition: png.h:1080
QT_REQUIRE_CONFIG(itemmodel)
Q_DECLARE_TYPEINFO(QModelRoleData, Q_RELOCATABLE_TYPE)
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 * destination
EGLStreamKHR stream
EGLOutputLayerEXT EGLint EGLAttrib value
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition: qflags.h:210
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition: qflags.h:227
size_t quintptr
Definition: qglobal.h:310
ptrdiff_t qsizetype
Definition: qglobal.h:308
#define Q_DISABLE_COPY(Class)
Definition: qglobal.h:515
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Class)
Definition: qglobal.h:563
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition: qmetatype.h:1285
GLboolean GLboolean GLboolean b
const GLfloat * m
GLboolean r
[2]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint GLuint end
GLenum GLenum GLsizei count
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLint first
GLenum GLenum GLsizei void GLsizei void * column
Definition: qopenglext.h:2747
const GLubyte * c
Definition: qopenglext.h:12701
GLenum GLsizei len
Definition: qopenglext.h:3292
GLenum GLenum GLsizei void * row
Definition: qopenglext.h:2747
GLenum GLenum GLsizei void GLsizei void void * span
Definition: qopenglext.h:2747
GLuint64EXT * result
[6]
Definition: qopenglext.h:10932
GLfixed GLfixed GLint GLint order
Definition: qopenglext.h:5206
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
#define Q_ENUM(x)
Definition: qtmetamacros.h:104
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define Q_INVOKABLE
Definition: qtmetamacros.h:112
#define Q_SLOTS
Definition: qtmetamacros.h:80
#define Q_SIGNALS
Definition: qtmetamacros.h:81
#define Q_DECLARE_SHARED(TYPE)
Definition: qtypeinfo.h:197
@ Q_RELOCATABLE_TYPE
Definition: qtypeinfo.h:156
model setHeaderData(0, Qt::Horizontal, tr("Name"))
QSqlQueryModel * model
[16]
beginResetModel()
[10]
beginInsertRows(parent, 2, 4)
[0]
beginMoveRows(sourceParent, 2, 4, destinationParent, 2)
[5]
endResetModel()
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)
QMimeData * mimeData
QSharedPointer< T > other(t)
[5]
this swap(other)
flay removeRow(2)
flay insertRow(2, "User:", le)
QLayoutItem * child
[0]
Definition: main.cpp:38
const int columnCount
Definition: testtable2.cpp:31
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent