Qt 4.8
qabstractitemmodel.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QABSTRACTITEMMODEL_H
43 #define QABSTRACTITEMMODEL_H
44 
45 #include <QtCore/qvariant.h>
46 #include <QtCore/qobject.h>
47 #include <QtCore/qhash.h>
48 
50 
52 
53 QT_MODULE(Core)
54 
55 class QAbstractItemModel;
57 
59 {
60  friend class QAbstractItemModel;
61  friend class QProxyModel;
62 public:
63  inline QModelIndex() : r(-1), c(-1), p(0), m(0) {}
64  inline QModelIndex(const QModelIndex &other)
65  : r(other.r), c(other.c), p(other.p), m(other.m) {}
66  inline ~QModelIndex() { p = 0; m = 0; }
67  inline int row() const { return r; }
68  inline int column() const { return c; }
69  inline void *internalPointer() const { return p; }
70  inline qint64 internalId() const { return reinterpret_cast<qint64>(p); }
71  inline QModelIndex parent() const;
72  inline QModelIndex sibling(int row, int column) const;
73  inline QModelIndex child(int row, int column) const;
74  inline QVariant data(int role = Qt::DisplayRole) const;
75  inline Qt::ItemFlags flags() const;
76  inline const QAbstractItemModel *model() const { return m; }
77  inline bool isValid() const { return (r >= 0) && (c >= 0) && (m != 0); }
78  inline bool operator==(const QModelIndex &other) const
79  { return (other.r == r) && (other.p == p) && (other.c == c) && (other.m == m); }
80  inline bool operator!=(const QModelIndex &other) const
81  { return !(*this == other); }
82  inline bool operator<(const QModelIndex &other) const
83  {
84  if (r < other.r) return true;
85  if (r == other.r) {
86  if (c < other.c) return true;
87  if (c == other.c) {
88  if (p < other.p) return true;
89  if (p == other.p) return m < other.m;
90  }
91  }
92  return false; }
93 private:
94  inline QModelIndex(int row, int column, void *ptr, const QAbstractItemModel *model);
95  int r, c;
96  void *p;
98 };
100 
101 #ifndef QT_NO_DEBUG_STREAM
103 #endif
104 
106 
108 {
109 public:
114  bool operator<(const QPersistentModelIndex &other) const;
115  bool operator==(const QPersistentModelIndex &other) const;
116  inline bool operator!=(const QPersistentModelIndex &other) const
117  { return !operator==(other); }
118  QPersistentModelIndex &operator=(const QPersistentModelIndex &other);
119  bool operator==(const QModelIndex &other) const;
120  bool operator!=(const QModelIndex &other) const;
121  QPersistentModelIndex &operator=(const QModelIndex &other);
122  operator const QModelIndex&() const;
123  int row() const;
124  int column() const;
125  void *internalPointer() const;
126  qint64 internalId() const;
127  QModelIndex parent() const;
128  QModelIndex sibling(int row, int column) const;
129  QModelIndex child(int row, int column) const;
130  QVariant data(int role = Qt::DisplayRole) const;
131  Qt::ItemFlags flags() const;
132  const QAbstractItemModel *model() const;
133  bool isValid() const;
134 private:
136  friend uint qHash(const QPersistentModelIndex &);
137 #ifndef QT_NO_DEBUG_STREAM
139 #endif
140 };
142 
144 { return qHash(index.d); }
145 
146 
147 #ifndef QT_NO_DEBUG_STREAM
149 #endif
150 
151 template<typename T> class QList;
153 
154 class QMimeData;
156 template <class Key, class T> class QMap;
157 
158 
160 {
161  Q_OBJECT
162 
165  friend class QIdentityProxyModel;
166 public:
167 
168  explicit QAbstractItemModel(QObject *parent = 0);
169  virtual ~QAbstractItemModel();
170 
171  bool hasIndex(int row, int column, const QModelIndex &parent = QModelIndex()) const;
172  virtual QModelIndex index(int row, int column,
173  const QModelIndex &parent = QModelIndex()) const = 0;
174  virtual QModelIndex parent(const QModelIndex &child) const = 0;
175 
176  inline QModelIndex sibling(int row, int column, const QModelIndex &idx) const
177  { return index(row, column, parent(idx)); }
178 
179  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
180  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
181  virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
182 
183  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
184  virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
185 
186  virtual QVariant headerData(int section, Qt::Orientation orientation,
187  int role = Qt::DisplayRole) const;
188  virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
189  int role = Qt::EditRole);
190 
191  virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
192  virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
193 
194  virtual QStringList mimeTypes() const;
195  virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
196  virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
197  int row, int column, const QModelIndex &parent);
198  virtual Qt::DropActions supportedDropActions() const;
199 
200  Qt::DropActions supportedDragActions() const;
201  void setSupportedDragActions(Qt::DropActions);
202 
203  virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
204  virtual bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
205  virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
206  virtual bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
207 
208  inline bool insertRow(int row, const QModelIndex &parent = QModelIndex());
209  inline bool insertColumn(int column, const QModelIndex &parent = QModelIndex());
210  inline bool removeRow(int row, const QModelIndex &parent = QModelIndex());
211  inline bool removeColumn(int column, const QModelIndex &parent = QModelIndex());
212 
213  virtual void fetchMore(const QModelIndex &parent);
214  virtual bool canFetchMore(const QModelIndex &parent) const;
215  virtual Qt::ItemFlags flags(const QModelIndex &index) const;
216  virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
217  virtual QModelIndex buddy(const QModelIndex &index) const;
218  virtual QModelIndexList match(const QModelIndex &start, int role,
219  const QVariant &value, int hits = 1,
220  Qt::MatchFlags flags =
221  Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
222  virtual QSize span(const QModelIndex &index) const;
223 
224  const QHash<int,QByteArray> &roleNames() const;
225 
226 #ifdef Q_NO_USING_KEYWORD
227  inline QObject *parent() const { return QObject::parent(); }
228 #else
229  using QObject::parent;
230 #endif
231 
232 Q_SIGNALS:
233  void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
234  void headerDataChanged(Qt::Orientation orientation, int first, int last);
235  void layoutChanged();
236  void layoutAboutToBeChanged();
237 
238 #if !defined(Q_MOC_RUN) && !defined(qdoc)
239 private: // can only be emitted by QAbstractItemModel
240 #endif
241  void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
242  void rowsInserted(const QModelIndex &parent, int first, int last);
243 
244  void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
245  void rowsRemoved(const QModelIndex &parent, int first, int last);
246 
247  void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last);
248  void columnsInserted(const QModelIndex &parent, int first, int last);
249 
250  void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
251  void columnsRemoved(const QModelIndex &parent, int first, int last);
252 
253  void modelAboutToBeReset();
254  void modelReset();
255 
256  void rowsAboutToBeMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow );
257  void rowsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row );
258 
259  void columnsAboutToBeMoved( const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn );
260  void columnsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column );
261 
262 
263 public Q_SLOTS:
264  virtual bool submit();
265  virtual void revert();
266 
267 protected:
269 
270  inline QModelIndex createIndex(int row, int column, void *data = 0) const;
271  inline QModelIndex createIndex(int row, int column, int id) const;
272  inline QModelIndex createIndex(int row, int column, quint32 id) const;
273 
274  void encodeData(const QModelIndexList &indexes, QDataStream &stream) const;
275  bool decodeData(int row, int column, const QModelIndex &parent, QDataStream &stream);
276 
277  void beginInsertRows(const QModelIndex &parent, int first, int last);
278  void endInsertRows();
279 
280  void beginRemoveRows(const QModelIndex &parent, int first, int last);
281  void endRemoveRows();
282 
283  bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow);
284  void endMoveRows();
285 
286  void beginInsertColumns(const QModelIndex &parent, int first, int last);
287  void endInsertColumns();
288 
289  void beginRemoveColumns(const QModelIndex &parent, int first, int last);
290  void endRemoveColumns();
291 
292  bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn);
293  void endMoveColumns();
294 
295  void reset();
296 
297  void beginResetModel();
298  void endResetModel();
299 
300  void changePersistentIndex(const QModelIndex &from, const QModelIndex &to);
301  void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to);
303 
304  void setRoleNames(const QHash<int,QByteArray> &roleNames);
305 
306 protected Q_SLOTS:
307  void resetInternalData();
308 
309 private:
312 };
313 
314 inline bool QAbstractItemModel::insertRow(int arow, const QModelIndex &aparent)
315 { return insertRows(arow, 1, aparent); }
316 inline bool QAbstractItemModel::insertColumn(int acolumn, const QModelIndex &aparent)
317 { return insertColumns(acolumn, 1, aparent); }
318 inline bool QAbstractItemModel::removeRow(int arow, const QModelIndex &aparent)
319 { return removeRows(arow, 1, aparent); }
320 inline bool QAbstractItemModel::removeColumn(int acolumn, const QModelIndex &aparent)
321 { return removeColumns(acolumn, 1, aparent); }
322 
323 inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, void *adata) const
324 { return QModelIndex(arow, acolumn, adata, this); }
325 inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, int aid) const
326 #if defined(Q_CC_MSVC)
327 #pragma warning( push )
328 #pragma warning( disable : 4312 ) // avoid conversion warning on 64-bit
329 #endif
330 { return QModelIndex(arow, acolumn, reinterpret_cast<void*>(aid), this); }
331 #if defined(Q_CC_MSVC)
332 #pragma warning( pop )
333 #endif
334 inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, quint32 aid) const
335 #if defined(Q_CC_MSVC)
336 #pragma warning( push )
337 #pragma warning( disable : 4312 ) // avoid conversion warning on 64-bit
338 #endif
339 { return QModelIndex(arow, acolumn, reinterpret_cast<void*>(aid), this); }
340 #if defined(Q_CC_MSVC)
341 #pragma warning( pop )
342 #endif
343 
344 
346 {
347  Q_OBJECT
348 
349 public:
350  explicit QAbstractTableModel(QObject *parent = 0);
352 
353  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
354  bool dropMimeData(const QMimeData *data, Qt::DropAction action,
355  int row, int column, const QModelIndex &parent);
356 protected:
358 
359 private:
361  QModelIndex parent(const QModelIndex &child) const;
362  bool hasChildren(const QModelIndex &parent) const;
363 };
364 
366 {
367  Q_OBJECT
368 
369 public:
370  explicit QAbstractListModel(QObject *parent = 0);
372 
373  QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
374  bool dropMimeData(const QMimeData *data, Qt::DropAction action,
375  int row, int column, const QModelIndex &parent);
376 protected:
378 
379 private:
381  QModelIndex parent(const QModelIndex &child) const;
382  int columnCount(const QModelIndex &parent) const;
383  bool hasChildren(const QModelIndex &parent) const;
384 };
385 
386 // inline implementations
387 
388 inline QModelIndex::QModelIndex(int arow, int acolumn, void *adata,
389  const QAbstractItemModel *amodel)
390  : r(arow), c(acolumn), p(adata), m(amodel) {}
391 
393 { return m ? m->parent(*this) : QModelIndex(); }
394 
395 inline QModelIndex QModelIndex::sibling(int arow, int acolumn) const
396 { return m ? (r == arow && c == acolumn) ? *this : m->index(arow, acolumn, m->parent(*this)) : QModelIndex(); }
397 
398 inline QModelIndex QModelIndex::child(int arow, int acolumn) const
399 { return m ? m->index(arow, acolumn, *this) : QModelIndex(); }
400 
401 inline QVariant QModelIndex::data(int arole) const
402 { return m ? m->data(*this, arole) : QVariant(); }
403 
404 inline Qt::ItemFlags QModelIndex::flags() const
405 { return m ? m->flags(*this) : Qt::ItemFlags(0); }
406 
407 inline uint qHash(const QModelIndex &index)
408 { return uint((index.row() << 4) + index.column() + index.internalId()); }
409 
411 
413 
414 #endif // QABSTRACTITEMMODEL_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
QModelIndex sibling(int row, int column, const QModelIndex &idx) const
Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no...
bool removeRow(int row, const QModelIndex &parent=QModelIndex())
Removes the given row from the child items of the parent specified.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Handles the data supplied by a drag and drop operation that ended with the given action.
unsigned char c[8]
Definition: qnumeric_p.h:62
QModelIndexList persistentIndexList() const
Returns the list of indexes stored as persistent indexes in the model.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void beginInsertColumns(const QModelIndex &parent, int first, int last)
Begins a column insertion operation.
#define QT_MODULE(x)
Definition: qglobal.h:2783
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Reimplemented Function
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
void beginRemoveColumns(const QModelIndex &parent, int first, int last)
Begins a column removal operation.
static bool match(const uchar *found, const char *target, uint len)
void columnsInserted(const QModelIndex &parent, int first, int last)
This signal is emitted after columns have been inserted into the model.
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
void fetchMore(const QModelIndex &parent)
Reimplemented Function
bool operator!=(const QModelIndex &other) const
Returns true if this model index does not refer to the same location as the other model index; otherw...
bool canFetchMore(const QModelIndex &parent) const
Reimplemented Function
bool hasIndex(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns true if the model returns a valid QModelIndex for row and column with parent, otherwise returns false.
The QAbstractListModel class provides an abstract model that can be subclassed to create one-dimensio...
bool operator!=(QBool b1, bool b2)
Definition: qglobal.h:2026
void endInsertRows()
Ends a row insertion operation.
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
#define Q_SLOTS
Definition: qobjectdefs.h:71
void columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
This signal is emitted just before columns are moved within the model.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
This signal is emitted just before rows are moved within the model.
#define Q_SIGNALS
Definition: qobjectdefs.h:72
void endMoveRows()
Ends a row move operation.
bool operator<(int priority, const QPair< QRunnable *, int > &p)
Definition: qthreadpool.cpp:50
bool decodeData(int row, int column, const QModelIndex &parent, QDataStream &stream)
void endResetModel()
Completes a model reset operation.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
Reimplemented Function
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to)
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list t...
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
virtual 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 columnsAboutToBeInserted(const QModelIndex &parent, int first, int last)
This signal is emitted just before columns are inserted into the model.
bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn)
Begins a column move operation.
SortOrder
Definition: qnamespace.h:189
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static FILE * stream
~QModelIndex()
Destroys the model index.
void rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
This signal is emitted after rows have been moved within the model.
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
void layoutAboutToBeChanged()
This signal is emitted just before the layout of a model is changed.
static void sort(T *array, int count, LessThan lessThan)
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns true if parent has any children; otherwise returns false.
void resetInternalData()
This slot is called just after the internal data of a model is cleared while it is being reset...
The QProxyModel class provides support for processing data passed between another model and a view...
Definition: qproxymodel.h:57
bool insertRow(int row, const QModelIndex &parent=QModelIndex())
Inserts a single row before the given row in the child items of the parent specified.
void revert()
Reimplemented Function
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
This signal is emitted just before rows are inserted into the model.
static bool setData(const QByteArray &data, STGMEDIUM *pmedium)
Definition: qmime_win.cpp:141
int row() const
Returns the row this model index refers to.
QModelIndex()
Creates a new empty model index.
Qt::DropActions supportedDropActions() const
Reimplemented Function
QModelIndex(const QModelIndex &other)
Creates a new model index that is a copy of the other model index.
Qt::DropActions supportedDragActions() const
Returns the actions supported by the data in this model.
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented Function
void modelAboutToBeReset()
This signal is emitted when reset() is called, before the model&#39;s internal state (e.
Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
QMap< int, QVariant > itemData(const QModelIndex &index) const
Reimplemented Function
QStringList mimeTypes() const
Reimplemented Function
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
void encodeData(const QModelIndexList &indexes, QDataStream &stream) const
bool operator==(const QModelIndex &other) const
Returns true if this model index refers to the same location as the other model index; otherwise retu...
const QAbstractItemModel * m
QPersistentModelIndexData * d
virtual 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.
const T * ptr(const T &t)
DropAction
Definition: qnamespace.h:1597
bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
void endRemoveRows()
Ends a row removal operation.
QModelIndex buddy(const QModelIndex &index) const
Reimplemented Function
void layoutChanged()
This signal is emitted whenever the layout of items exposed by the model has changed; for example...
__int64 qint64
Definition: qglobal.h:942
QSize span(const QModelIndex &index) const
Reimplemented Function
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
uint qHash(const QPersistentModelIndex &index)
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QAbstractItemModel class provides the abstract interface for item model classes.
Qt::ItemFlags flags() const
Returns the flags for the item referred to by the index.
bool removeColumn(int column, const QModelIndex &parent=QModelIndex())
Removes the given column from the child items of the parent specified.
virtual QModelIndex parent(const QModelIndex &child) const =0
Returns the parent of the model item with the given index.
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted just before columns are removed from the model.
QList< QModelIndex > QModelIndexList
QModelIndex child(int row, int column) const
Returns the child of the model index that is stored in the given row and column.
bool insertColumn(int column, const QModelIndex &parent=QModelIndex())
Inserts a single column before the given column in the child items of the parent specified.
const QHash< int, QByteArray > & roleNames() const
Returns the model&#39;s role names.
QAbstractItemModel * model() const
Returns the model that contains the data that is available through the proxy model.
void changePersistentIndex(const QModelIndex &from, const QModelIndex &to)
Changes the QPersistentModelIndex that is equal to the given from model index to the given to model i...
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles)
Reimplemented Function
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
The QPersistentModelIndex class is used to locate data in a data model.
void rowsInserted(const QModelIndex &parent, int first, int last)
This signal is emitted after rows have been inserted into the model.
QMimeData * mimeData(const QModelIndexList &indexes) const
Reimplemented Function
int rowCount(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
bool operator!=(const QPersistentModelIndex &other) const
Returns true if this persistent model index is not equal to the other persistent model index; otherwi...
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
The QModelIndex class is used to locate data in a data model.
unsigned int quint32
Definition: qglobal.h:938
virtual ~QAbstractItemModel()
Destroys the abstract item model.
void modelReset()
This signal is emitted when reset() is called, after the model&#39;s internal state (e.
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This signal is emitted whenever the data in an existing item changes.
void setSupportedDragActions(Qt::DropActions)
Sets the supported drag actions for the items in the model.
The QIdentityProxyModel class proxies its source model unmodified.
void endInsertColumns()
Ends a column insertion operation.
quint16 index
Qt::ItemFlags flags(const QModelIndex &index) const
Reimplemented Function
QAbstractItemModel(QObject *parent=0)
Constructs an abstract item model with the given parent.
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
void setRoleNames(const QHash< int, QByteArray > &roleNames)
Sets the model&#39;s role names to roleNames.
void endMoveColumns()
Ends a column move operation.
bool submit()
Reimplemented Function
static const KeyPair *const end
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted just before rows are removed from the model.
int columnCount(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
Orientation
Definition: qnamespace.h:174
#define QT_END_HEADER
Definition: qglobal.h:137
void rowsRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted after rows have been removed from the model.
void columnsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
This signal is emitted after columns have been moved within the model.
bool operator==(QBool b1, bool b2)
Definition: qglobal.h:2023
bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow)
Begins a row move operation.
void columnsRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted after columns have been removed from the model.
void beginResetModel()
Begins a model reset operation.
The QAbstractTableModel class provides an abstract model that can be subclassed to create table model...
The QMap class is a template class that provides a skip-list-based dictionary.
Definition: qdatastream.h:67
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.
int column() const
Returns the column this model index refers to.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
Q_DECLARE_TYPEINFO(QModelIndex, Q_MOVABLE_TYPE)
void endRemoveColumns()
Ends a column removal operation.
bool operator<(const QModelIndex &other) const
Returns true if this model index is smaller than the other model index; otherwise returns false...