Qt 4.8
|
The QAbstractItemModel class provides the abstract interface for item model classes. More...
#include <qabstractitemmodel.h>
Public Slots | |
virtual void | revert () |
Lets the model know that it should discard cached information. More... | |
virtual bool | submit () |
Lets the model know that it should submit cached information to permanent storage. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals | |
void | columnsAboutToBeInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted just before columns are inserted into the model. More... | |
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. More... | |
void | columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted just before columns are removed from the model. More... | |
void | columnsInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted after columns have been inserted into the model. More... | |
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. More... | |
void | columnsRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted after columns have been removed from the model. More... | |
void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
This signal is emitted whenever the data in an existing item changes. More... | |
void | headerDataChanged (Qt::Orientation orientation, int first, int last) |
This signal is emitted whenever a header is changed. More... | |
void | layoutAboutToBeChanged () |
This signal is emitted just before the layout of a model is changed. More... | |
void | layoutChanged () |
This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. More... | |
void | modelAboutToBeReset () |
This signal is emitted when reset() is called, before the model's internal state (e. More... | |
void | modelReset () |
This signal is emitted when reset() is called, after the model's internal state (e. More... | |
void | rowsAboutToBeInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted just before rows are inserted into the model. More... | |
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. More... | |
void | rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted just before rows are removed from the model. More... | |
void | rowsInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted after rows have been inserted into the model. More... | |
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. More... | |
void | rowsRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted after rows have been removed from the model. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
virtual QModelIndex | buddy (const QModelIndex &index) const |
Returns a model index for the buddy of the item represented by index. More... | |
virtual bool | canFetchMore (const QModelIndex &parent) const |
Returns true if there is more data available for parent; otherwise returns false. More... | |
virtual int | columnCount (const QModelIndex &parent=QModelIndex()) const =0 |
Returns the number of columns for the children of the given parent. More... | |
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. More... | |
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. More... | |
virtual void | fetchMore (const QModelIndex &parent) |
Fetches any available data for the items with the parent specified by the parent index. More... | |
virtual Qt::ItemFlags | flags (const QModelIndex &index) const |
Returns the item flags for the given index. More... | |
virtual bool | hasChildren (const QModelIndex &parent=QModelIndex()) const |
Returns true if parent has any children; otherwise returns false. More... | |
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. More... | |
virtual QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
Returns the data for the given role and section in the header with the specified orientation. More... | |
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. More... | |
bool | insertColumn (int column, const QModelIndex &parent=QModelIndex()) |
Inserts a single column before the given column in the child items of the parent specified. More... | |
virtual bool | insertColumns (int column, int count, const QModelIndex &parent=QModelIndex()) |
On models that support this, inserts count new columns into the model before the given column. More... | |
bool | insertRow (int row, const QModelIndex &parent=QModelIndex()) |
Inserts a single row before the given row in the child items of the parent specified. More... | |
virtual bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
On models that support this, inserts count rows into the model before the given row. More... | |
virtual QMap< int, QVariant > | itemData (const QModelIndex &index) const |
Returns a map with values for all predefined roles in the model for the item at the given index. More... | |
virtual QModelIndexList | match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const |
Returns a list of indexes for the items in the column of the start index where data stored under the given role matches the specified value. More... | |
virtual QMimeData * | mimeData (const QModelIndexList &indexes) const |
Returns an object that contains serialized items of data corresponding to the list of indexes specified. More... | |
virtual QStringList | mimeTypes () const |
Returns a list of MIME types that can be used to describe a list of model indexes. More... | |
virtual QModelIndex | parent (const QModelIndex &child) const =0 |
Returns the parent of the model item with the given index. More... | |
QAbstractItemModel (QObject *parent=0) | |
Constructs an abstract item model with the given parent. More... | |
bool | removeColumn (int column, const QModelIndex &parent=QModelIndex()) |
Removes the given column from the child items of the parent specified. More... | |
virtual bool | removeColumns (int column, int count, const QModelIndex &parent=QModelIndex()) |
On models that support this, removes count columns starting with the given column under parent parent from the model. More... | |
bool | removeRow (int row, const QModelIndex &parent=QModelIndex()) |
Removes the given row from the child items of the parent specified. More... | |
virtual bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
On models that support this, removes count rows starting with the given row under parent parent from the model. More... | |
const QHash< int, QByteArray > & | roleNames () const |
Returns the model's role names. More... | |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const =0 |
Returns the number of rows under the given parent. More... | |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
Sets the role data for the item at index to value. More... | |
virtual bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) |
Sets the data for the given role and section in the header with the specified orientation to the value supplied. More... | |
virtual bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) |
Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole. More... | |
void | setSupportedDragActions (Qt::DropActions) |
Sets the supported drag actions for the items in the model. More... | |
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 sibling at that location. More... | |
virtual void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) |
Sorts the model by column in the given order. More... | |
virtual QSize | span (const QModelIndex &index) const |
Returns the row and column span of the item represented by index. More... | |
Qt::DropActions | supportedDragActions () const |
Returns the actions supported by the data in this model. More... | |
virtual Qt::DropActions | supportedDropActions () const |
Returns the drop actions supported by this model. More... | |
virtual | ~QAbstractItemModel () |
Destroys the abstract item model. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Slots | |
void | resetInternalData () |
This slot is called just after the internal data of a model is cleared while it is being reset. More... | |
Protected Functions | |
void | beginInsertColumns (const QModelIndex &parent, int first, int last) |
Begins a column insertion operation. More... | |
void | beginInsertRows (const QModelIndex &parent, int first, int last) |
Begins a row insertion operation. More... | |
bool | beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn) |
Begins a column move operation. More... | |
bool | beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow) |
Begins a row move operation. More... | |
void | beginRemoveColumns (const QModelIndex &parent, int first, int last) |
Begins a column removal operation. More... | |
void | beginRemoveRows (const QModelIndex &parent, int first, int last) |
Begins a row removal operation. More... | |
void | beginResetModel () |
Begins a model reset operation. More... | |
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 index. More... | |
void | changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to) |
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list to the given to model index list. More... | |
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. More... | |
QModelIndex | createIndex (int row, int column, int id) const |
Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. More... | |
QModelIndex | createIndex (int row, int column, quint32 id) const |
Creates a model index for the given row and column with the internal identifier, id. More... | |
bool | decodeData (int row, int column, const QModelIndex &parent, QDataStream &stream) |
void | encodeData (const QModelIndexList &indexes, QDataStream &stream) const |
void | endInsertColumns () |
Ends a column insertion operation. More... | |
void | endInsertRows () |
Ends a row insertion operation. More... | |
void | endMoveColumns () |
Ends a column move operation. More... | |
void | endMoveRows () |
Ends a row move operation. More... | |
void | endRemoveColumns () |
Ends a column removal operation. More... | |
void | endRemoveRows () |
Ends a row removal operation. More... | |
void | endResetModel () |
Completes a model reset operation. More... | |
QModelIndexList | persistentIndexList () const |
Returns the list of indexes stored as persistent indexes in the model. More... | |
QAbstractItemModel (QAbstractItemModelPrivate &dd, QObject *parent=0) | |
void | reset () |
Resets the model to its original state in any attached views. More... | |
void | setRoleNames (const QHash< int, QByteArray > &roleNames) |
Sets the model's role names to roleNames. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Friends | |
class | QAbstractItemViewPrivate |
class | QIdentityProxyModel |
class | QPersistentModelIndexData |
Additional Inherited Members | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QAbstractItemModel class provides the abstract interface for item model classes.
The QAbstractItemModel class defines the standard interface that item models must use to be able to interoperate with other components in the model/view architecture. It is not supposed to be instantiated directly. Instead, you should subclass it to create new models.
The QAbstractItemModel class is one of the Model/View Classes and is part of Qt's Model/View Programming{model/view framework}.
If you need a model to use with a QListView or a QTableView, you should consider subclassing QAbstractListModel or QAbstractTableModel instead of this class.
The underlying data model is exposed to views and delegates as a hierarchy of tables. If you do not make use of the hierarchy, then the model is a simple table of rows and columns. Each item has a unique index specified by a QModelIndex.
Every item of data that can be accessed via a model has an associated model index. You can obtain this model index using the index() function. Each index may have a sibling() index; child items have a parent() index.
Each item has a number of data elements associated with it and they can be retrieved by specifying a role (see Qt::ItemDataRole ) to the model's data() function. Data for all available roles can be obtained at the same time using the itemData() function.
Data for each role is set using a particular Qt::ItemDataRole . Data for individual roles are set individually with setData(), or they can be set for all roles with setItemData().
Items can be queried with flags() (see Qt::ItemFlag ) to see if they can be selected, dragged, or manipulated in other ways.
If an item has child objects, hasChildren() returns true for the corresponding index.
The model has a rowCount() and a columnCount() for each level of the hierarchy. Rows and columns can be inserted and removed with insertRows(), insertColumns(), removeRows(), and removeColumns().
The model emits signals to indicate changes. For example, dataChanged() is emitted whenever items of data made available by the model are changed. Changes to the headers supplied by the model cause headerDataChanged() to be emitted. If the structure of the underlying data changes, the model can emit layoutChanged() to indicate to any attached views that they should redisplay any items shown, taking the new structure into account.
The items available through the model can be searched for particular data using the match() function.
To sort the model, you can use sort().
When subclassing QAbstractItemModel, at the very least you must implement index(), parent(), rowCount(), columnCount(), and data(). These functions are used in all read-only models, and form the basis of editable models.
You can also reimplement hasChildren() to provide special behavior for models where the implementation of rowCount() is expensive. This makes it possible for models to restrict the amount of data requested by views, and can be used as a way to implement lazy population of model data.
To enable editing in your model, you must also implement setData(), and reimplement flags() to ensure that ItemIsEditable
is returned. You can also reimplement headerData() and setHeaderData() to control the way the headers for your model are presented.
The dataChanged() and headerDataChanged() signals must be emitted explicitly when reimplementing the setData() and setHeaderData() functions, respectively.
Custom models need to create model indexes for other components to use. To do this, call createIndex() with suitable row and column numbers for the item, and an identifier for it, either as a pointer or as an integer value. The combination of these values must be unique for each item. Custom models typically use these unique identifiers in other reimplemented functions to retrieve item data and access information about the item's parents and children. See the Simple Tree Model Example for more information about unique identifiers.
It is not necessary to support every role defined in Qt::ItemDataRole. Depending on the type of data contained within a model, it may only be useful to implement the data() function to return valid information for some of the more common roles. Most models provide at least a textual representation of item data for the Qt::DisplayRole, and well-behaved models should also provide valid information for the Qt::ToolTipRole and Qt::WhatsThisRole. Supporting these roles enables models to be used with standard Qt views. However, for some models that handle highly-specialized data, it may be appropriate to provide data only for user-defined roles.
Models that provide interfaces to resizable data structures can provide implementations of insertRows(), removeRows(), insertColumns(),and removeColumns(). When implementing these functions, it is important to notify any connected views about changes to the model's dimensions both before and after they occur:
The private signals that these functions emit give attached components the chance to take action before any data becomes unavailable. The encapsulation of the insert and remove operations with these begin and end functions also enables the model to manage persistent model indexes correctly. If you want selections to be handled properly, you must ensure that you call these functions. If you insert or remove an item with children, you do not need to call these functions for the child items. In other words, the parent item will take care of its child items.
To create models that populate incrementally, you can reimplement fetchMore() and canFetchMore(). If the reimplementation of fetchMore() adds rows to the model, QAbstractItemModel::beginInsertRows() and QAbstractItemModel::endInsertRows() must be called.
Definition at line 159 of file qabstractitemmodel.h.
|
explicit |
Constructs an abstract item model with the given parent.
Definition at line 1486 of file qabstractitemmodel.cpp.
Referenced by sibling().
|
virtual |
Destroys the abstract item model.
Definition at line 1502 of file qabstractitemmodel.cpp.
|
protected |
Definition at line 1494 of file qabstractitemmodel.cpp.
|
protected |
Begins a column insertion operation.
When reimplementing insertColumns() in a subclass, you must call this function before inserting data into the model's underlying data store.
The parent index corresponds to the parent into which the new columns are inserted; first and last are the column numbers of the new columns will have after they have been inserted.
Specify the first and last column numbers for the span of columns you want to insert into an item in a model. For example, as shown in the diagram, we insert three columns before column 4, so first is 4 and last is 6: beginInsertColumns(parent, 4, 6); This inserts the three new columns as columns 4, 5, and 6. | |
To append columns, insert them after the last column. For example, as shown in the diagram, we append three columns to a collection of six existing columns (ending in column 5), so first is 6 and last is 8: beginInsertColumns(parent, 6, 8); This appends the two new columns as columns 6, 7, and 8. |
Definition at line 2905 of file qabstractitemmodel.cpp.
Referenced by QSqlQueryModel::insertColumns(), QTableModel::insertColumns(), QTreeModel::insertColumns(), QTreeModel::setColumnCount(), and sibling().
|
protected |
Begins a row insertion operation.
When reimplementing insertRows() in a subclass, you must call this function before inserting data into the model's underlying data store.
The parent index corresponds to the parent into which the new rows are inserted; first and last are the row numbers that the new rows will have after they have been inserted.
Specify the first and last row numbers for the span of rows you want to insert into an item in a model. For example, as shown in the diagram, we insert three rows before row 2, so first is 2 and last is 4: beginInsertRows(parent, 2, 4); This inserts the three new rows as rows 2, 3, and 4. | |
To append rows, insert them after the last row. For example, as shown in the diagram, we append two rows to a collection of 4 existing rows (ending in row 3), so first is 4 and last is 5: beginInsertRows(parent, 4, 5); This appends the two new rows as rows 4 and 5. |
Definition at line 2595 of file qabstractitemmodel.cpp.
Referenced by QScriptBreakpointsModel::addBreakpoint(), QTreeModel::beginInsertItems(), QListModel::insert(), QDeclarativeFolderListModel::inserted(), QStringListModel::insertRows(), QTableModel::insertRows(), QSqlTableModel::insertRows(), QListModel::insertRows(), QTreeModel::insertRows(), QDeclarativeFolderListModel::refresh(), QSqlQueryModel::setQuery(), and sibling().
|
protected |
Begins a column move operation.
When reimplementing a subclass, this method simplifies moving entities in your model. This method is responsible for moving persistent indexes in the model, which you would otherwise be required to do yourself. Using beginMoveRows and endMoveRows is an alternative to emitting layoutAboutToBeChanged and layoutChanged directly along with changePersistentIndexes. layoutAboutToBeChanged is emitted by this method for compatibility reasons.
The sourceParent index corresponds to the parent from which the columns are moved; sourceFirst and sourceLast are the first and last column numbers of the columns to be moved. The destinationParent index corresponds to the parent into which those columns are moved. The destinationChild is the column to which the columns will be moved. That is, the index at column sourceFirst in sourceParent will become column destinationChild in destinationParent, followed by all other columns up to sourceLast.
However, when moving columns down in the same parent (sourceParent and destinationParent are equal), the columnss will be placed before the destinationChild index. That is, if you wish to move columns 0 and 1 so they will become columns 1 and 2, destinationChild should be 3. In this case, the new index for the source column i
(which is between sourceFirst and sourceLast) is equal to {
(destinationChild-sourceLast-1+i)}.
Note that if sourceParent and destinationParent are the same, you must ensure that the destinationChild is not within the range of sourceFirst and sourceLast + 1. You must also ensure that you do not attempt to move a column to one of its own children or ancestors. This method returns false if either condition is true, in which case you should abort your move operation.
Definition at line 3026 of file qabstractitemmodel.cpp.
Referenced by sibling().
|
protected |
Begins a row move operation.
When reimplementing a subclass, this method simplifies moving entities in your model. This method is responsible for moving persistent indexes in the model, which you would otherwise be required to do yourself. Using beginMoveRows and endMoveRows is an alternative to emitting layoutAboutToBeChanged and layoutChanged directly along with changePersistentIndexes. layoutAboutToBeChanged is emitted by this method for compatibility reasons.
The sourceParent index corresponds to the parent from which the rows are moved; sourceFirst and sourceLast are the first and last row numbers of the rows to be moved. The destinationParent index corresponds to the parent into which those rows are moved. The destinationChild is the row to which the rows will be moved. That is, the index at row sourceFirst in sourceParent will become row destinationChild in destinationParent, followed by all other rows up to sourceLast.
However, when moving rows down in the same parent (sourceParent and destinationParent are equal), the rows will be placed before the destinationChild index. That is, if you wish to move rows 0 and 1 so they will become rows 1 and 2, destinationChild should be 3. In this case, the new index for the source row i
(which is between sourceFirst and sourceLast) is equal to {
(destinationChild-sourceLast-1+i)}.
Note that if sourceParent and destinationParent are the same, you must ensure that the destinationChild is not within the range of sourceFirst and sourceLast + 1. You must also ensure that you do not attempt to move a row to one of its own children or ancestors. This method returns false if either condition is true, in which case you should abort your move operation.
Specify the first and last row numbers for the span of rows in the source parent you want to move in the model. Also specify the row in the destination parent to move the span to. For example, as shown in the diagram, we move three rows from row 2 to 4 in the source, so sourceFirst is 2 and sourceLast is 4. We move those items to above row 2 in the destination, so destinationChild is 2. beginMoveRows(sourceParent, 2, 4, destinationParent, 2); This moves the three rows rows 2, 3, and 4 in the source to become 2, 3 and 4 in the destination. Other affected siblings are displaced accordingly. | |
To append rows to another parent, move them to after the last row. For example, as shown in the diagram, we move three rows to a collection of 6 existing rows (ending in row 5), so destinationChild is 6: beginMoveRows(sourceParent, 2, 4, destinationParent, 6); This moves the target rows to the end of the target parent as 6, 7 and 8. | |
To move rows within the same parent, specify the row to move them to. For example, as shown in the diagram, we move one item from row 2 to row 0, so sourceFirst and sourceLast are 2 and destinationChild is 0. beginMoveRows(parent, 2, 2, parent, 0); Note that other rows may be displaced accordingly. Note also that when moving items within the same parent you should not attempt invalid or no-op moves. In the above example, item 2 is at row 2 before the move, so it can not be moved to row 2 (where it is already) or row 3 (no-op as row 3 means above row 3, where it is already) | |
To move rows within the same parent, specify the row to move them to. For example, as shown in the diagram, we move one item from row 2 to row 4, so sourceFirst and sourceLast are 2 and destinationChild is 4. beginMoveRows(parent, 2, 2, parent, 4); Note that other rows may be displaced accordingly. |
Definition at line 2803 of file qabstractitemmodel.cpp.
Referenced by QListModel::move(), and sibling().
|
protected |
Begins a column removal operation.
When reimplementing removeColumns() in a subclass, you must call this function before removing data from the model's underlying data store.
The parent index corresponds to the parent from which the new columns are removed; first and last are the column numbers of the first and last columns to be removed.
Specify the first and last column numbers for the span of columns you want to remove from an item in a model. For example, as shown in the diagram, we remove the three columns from column 4 to column 6, so first is 4 and last is 6: beginRemoveColumns(parent, 4, 6); |
Definition at line 2960 of file qabstractitemmodel.cpp.
Referenced by QSqlQueryModel::removeColumns(), QTableModel::removeColumns(), QTreeModel::setColumnCount(), and sibling().
|
protected |
Begins a row removal operation.
When reimplementing removeRows() in a subclass, you must call this function before removing data from the model's underlying data store.
The parent index corresponds to the parent from which the new rows are removed; first and last are the row numbers of the rows to be removed.
Specify the first and last row numbers for the span of rows you want to remove from an item in a model. For example, as shown in the diagram, we remove the two rows from row 2 to row 3, so first is 2 and last is 3: beginRemoveRows(parent, 2, 3); |
Definition at line 2649 of file qabstractitemmodel.cpp.
Referenced by QTreeModel::beginRemoveItems(), QDeclarativeFolderListModel::refresh(), QListModel::remove(), QScriptBreakpointsModel::removeBreakpoint(), QDeclarativeFolderListModel::removed(), QStringListModel::removeRows(), QTableModel::removeRows(), QListModel::removeRows(), QTreeModel::removeRows(), QSqlQueryModel::setQuery(), sibling(), and QListModel::take().
|
protected |
Begins a model reset operation.
A reset operation resets the model to its current state in any attached views.
When a model is reset it means that any previous data reported from the model is now invalid and has to be queried for again. This also means that the current item and any selected items will become invalid.
When a model radically changes its data it can sometimes be easier to just call this function rather than emit dataChanged() to inform other components when the underlying data source, or its structure, has changed.
You must call this function before resetting any internal data structures in your model or proxy model.
Definition at line 3125 of file qabstractitemmodel.cpp.
Referenced by QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QStringListModel::setStringList(), and sibling().
|
virtual |
Returns a model index for the buddy of the item represented by index.
When the user wants to edit an item, the view will call this function to check whether another item in the model should be edited instead. Then, the view will construct a delegate using the model index returned by the buddy item.
The default implementation of this function has each item as its own buddy.
Reimplemented in QSortFilterProxyModel, and QAbstractProxyModel.
Definition at line 2209 of file qabstractitemmodel.cpp.
Referenced by QAbstractItemViewPrivate::openEditor(), and QAbstractItemViewPrivate::sendDelegateEvent().
|
virtual |
Returns true if there is more data available for parent; otherwise returns false.
The default implementation always returns false.
If canFetchMore() returns true, QAbstractItemView will call fetchMore(). However, the fetchMore() function is only called when the model is being populated incrementally.
Reimplemented in QSortFilterProxyModel, QSqlQueryModel, QFileSystemModel, QScriptDebuggerLocalsModel, and QAbstractProxyModel.
Definition at line 2165 of file qabstractitemmodel.cpp.
Referenced by QTreeViewPrivate::expand(), QAbstractItemViewPrivate::fetchMore(), and QTreeViewPrivate::layout().
|
protected |
Changes the QPersistentModelIndex that is equal to the given from model index to the given to model index.
If no persistent model index equal to the given from model index was found, nothing is changed.
Definition at line 3156 of file qabstractitemmodel.cpp.
Referenced by sibling().
|
protected |
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list to the given to model index list.
If no persistent model indexes equal to the indexes in the given from model index list was found, nothing is changed.
Definition at line 3188 of file qabstractitemmodel.cpp.
Referenced by QListModel::ensureSorted(), QTreeModel::ensureSorted(), QTableModel::ensureSorted(), QCompletionModel::resetModel(), QTableModel::setItem(), sibling(), QStringListModel::sort(), QFileSystemModel::sort(), QListModel::sort(), QTableModel::sort(), and QTreeModel::sortItems().
|
pure virtual |
Returns the number of columns for the children of the given parent.
In most subclasses, the number of columns is independent of the parent.
For example:
Implemented in QCalendarModel, QEmptyItemModel, QAbstractListModel, QStandardItemModel, QCompletionModel, QPPDOptionsModel, QSortFilterProxyModel, QTableModel, QTreeModel, QEmptyModel, QFileSystemModel, QScriptBreakpointsModel, QScriptDebuggerScriptsModel, QDirModel, QScriptDebuggerLocalsModel, QScriptDebuggerStackModel, QProxyModel, QEmptyModel, QSqlQueryModel, QUndoModel, and QIdentityProxyModel.
Referenced by QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), QItemSelectionModelPrivate::_q_layoutAboutToBeChanged(), QHeaderViewPrivate::_q_layoutAboutToBeChanged(), QItemSelectionModelPrivate::_q_layoutChanged(), QTableViewPrivate::accessibleTable2Index(), QAccessibleTree::childAt(), QAccessibleTable2::childCount(), QAccessibleTree::childCount(), QAccessibleTable2::childFromLogical(), QAccessibleItemView::childIndex(), QAccessibleItemRow::children(), QAbstractItemViewPrivate::clearOrRemove(), QAccessibleTable2::columnCount(), QAccessibleItemView::columnCount(), QAccessibleItemView::columnIndex(), QFileDialogPrivate::createWidgets(), QTreeView::currentChanged(), decodeData(), QItemSelectionModelPrivate::expandSelection(), hasChildren(), QAbstractTableModel::hasChildren(), hasIndex(), QAccessibleTable2::indexOfChild(), QAccessibleTree::indexOfChild(), QAccessibleTable2HeaderCell::isValid(), QDataWidgetMapperPrivate::itemCount(), QAccessibleTable2::logicalIndex(), QHeaderViewPrivate::modelIsEmpty(), QHeaderViewPrivate::modelSectionCount(), QTreeView::moveCursor(), QAccessibleTree::navigate(), QListViewPrivate::prepareItemsLayout(), QAccessibleItemRow::rect(), QFileDialog::restoreState(), QFileDialogPrivate::retranslateStrings(), rowAt(), QAccessibleItemView::rowIndex(), QAbstractItemViewPrivate::selectAll(), QListViewPrivate::selectAll(), QTreeView::selectionChanged(), and QTableViewPrivate::selectRow().
|
signal |
This signal is emitted just before columns are inserted into the model.
The new items will be positioned between start and end inclusive, under the given parent item.
Referenced by beginInsertColumns(), QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted just before columns are moved within the model.
The items that will be moved are those between sourceStart and sourceEnd inclusive, under the given sourceParent item. They will be moved to destinationParent starting at the column destinationColumn.
Note: Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code.
Referenced by beginMoveColumns(), QIdentityProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted just before columns are removed from the model.
The items to be removed are those between start and end inclusive, under the given parent item.
Referenced by beginRemoveColumns(), QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted after columns have been inserted into the model.
The new items are those between start and end inclusive, under the given parent item.
Referenced by QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), endInsertColumns(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QCompletionModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted after columns have been moved within the model.
The items between sourceStart and sourceEnd inclusive, under the given sourceParent item have been moved to destinationParent starting at the column destinationColumn.
Note: Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code.
Referenced by endMoveColumns(), QIdentityProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted after columns have been removed from the model.
The removed items are those between start and end inclusive, under the given parent item.
Referenced by QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), endRemoveColumns(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QCompletionModel::setSourceModel(), and sibling().
|
inlineprotected |
Creates a model index for the given row and column with the internal pointer ptr.
When using a QSortFilterProxyModel, its indexes have their own internal pointer. It is not advisable to access this internal pointer outside of the model. Use the data() function instead.
This function provides a consistent interface that model subclasses must use to create model indexes.
Definition at line 323 of file qabstractitemmodel.h.
Referenced by QTreeModel::createIndexFromItem(), QCompletionModel::currentIndex(), QTreeModel::emitDataChanged(), endMoveColumns(), endMoveRows(), QListModel::ensureSorted(), QTreeModel::ensureSorted(), QSqlQueryModel::headerData(), QUndoModel::index(), QDirModel::index(), QScriptDebuggerLocalsModel::index(), QFileSystemModel::index(), QScriptDebuggerScriptsModel::index(), QScriptBreakpointsModel::index(), QTreeModel::index(), QListModel::index(), QPPDOptionsModel::index(), QCompletionModel::index(), QStandardItemModel::index(), QAbstractTableModel::index(), QAbstractListModel::index(), QStandardItemModel::indexFromItem(), QScriptDebuggerScriptsModel::indexFromScriptId(), QSqlQueryModel::indexInQuery(), QSqlTableModel::indexInQuery(), QIdentityProxyModel::mapFromSource(), QCompletionModel::mapFromSource(), QScriptBreakpointsModel::modifyBreakpoint(), QDirModel::parent(), QFileSystemModel::parent(), QPPDOptionsModel::parent(), QSqlQueryModel::record(), QSqlTableModel::removeRows(), QSqlTableModel::revertRow(), QUndoModel::selectedIndex(), QSqlQueryModel::setQuery(), QSqlTableModel::setRecord(), sibling(), QListModel::sort(), QTableModel::sort(), and QTreeModel::sortItems().
|
inlineprotected |
Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead.
Definition at line 325 of file qabstractitemmodel.h.
|
inlineprotected |
Creates a model index for the given row and column with the internal identifier, id.
This function provides a consistent interface that model subclasses must use to create model indexes.
Definition at line 334 of file qabstractitemmodel.h.
|
pure virtual |
Returns the data stored under the given role for the item referred to by the index.
Implemented in QCalendarModel, QEmptyItemModel, QStandardItemModel, QCompletionModel, QPPDOptionsModel, QSortFilterProxyModel, QTableModel, ControlList, QTreeModel, QListModel, QFileSystemModel, QEmptyModel, QScriptBreakpointsModel, QScriptDebuggerScriptsModel, QDeclarativeFolderListModel, QSqlRelationalTableModel, QDirModel, QScriptDebuggerLocalsModel, QAbstractProxyModel, QProxyModel, QScriptDebuggerStackModel, QSqlTableModel, QEmptyModel, QSqlQueryModel, QUndoModel, and QStringListModel.
Referenced by QInputDialogPrivate::_q_currentRowChanged(), QUnsortedModelEngine::buildIndices(), changePersistentIndex(), changePersistentIndexList(), QAbstractItemViewPrivate::checkMouseMove(), QModelIndex::data(), decodeData(), QAbstractTableModel::dropMimeData(), QAbstractListModel::dropMimeData(), QSortedModelEngine::filter(), QComboMenuDelegate::getStyleOption(), QDeclarativeVisualDataModelDataMetaObject::initialValue(), itemData(), QComboBoxPrivate::itemIcon(), QComboBoxPrivate::itemText(), QSortFilterProxyModel::lessThan(), match(), mimeData(), QCompleter::pathFromIndex(), persistentIndexList(), QStyledItemDelegate::setModelData(), QItemDelegate::setModelData(), QSortedModelEngine::sortOrder(), QAccessibleItemRow::state(), QAccessibleTable2Cell::state(), QAccessibleItemRow::text(), QAccessibleTable2Cell::text(), and QAccessibleItemRow::text_helper().
|
signal |
This signal is emitted whenever the data in an existing item changes.
If the items are of the same parent, the affected ones are those between topLeft and bottomRight inclusive. If the items do not have the same parent, the behavior is undefined.
When reimplementing the setData() function, this signal must be emitted explicitly.
Referenced by QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), QTreeModel::emitDataChanged(), QDeclarativeFolderListModel::handleDataChanged(), QCalendarModel::internalUpdate(), QTreeModel::itemChanged(), QListModel::itemChanged(), QTableModel::itemChanged(), QScriptBreakpointsModel::modifyBreakpoint(), QDeclarativeFolderListModel::QDeclarativeFolderListModel(), QTableModel::removeItem(), QSqlTableModel::revertRow(), QStringListModel::setData(), QSqlTableModel::setData(), QDirModel::setData(), QTableModel::setItem(), QSqlTableModel::setRecord(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QCompletionModel::setSourceModel(), sibling(), and QTableModel::takeItem().
|
protected |
Definition at line 2471 of file qabstractitemmodel.cpp.
Referenced by dropMimeData(), QAbstractTableModel::dropMimeData(), QAbstractListModel::dropMimeData(), and sibling().
|
virtual |
Handles the data supplied by a drag and drop operation that ended with the given action.
Returns true if the data and action can be handled by the model; otherwise returns false.
The specified row, column and parent indicate the location of an item in the model where the operation ended. It is the responsibility of the model to complete the action at the correct location.
For instance, a drop action on an item in a QTreeView can result in new items either being inserted as children of the item specified by row, column, and parent, or as siblings of the item.
When row and column are -1 it means that the dropped data should be considered as dropped directly on parent. Usually this will mean appending the data as child items of parent. If row and column are greater than or equal zero, it means that the drop occurred just before the specified row and column in the specified parent.
Reimplemented in QStandardItemModel, QAbstractListModel, QAbstractTableModel, QTableModel, QSortFilterProxyModel, QTreeModel, QListModel, QFileSystemModel, QDirModel, QUrlModel, QProxyModel, and QIdentityProxyModel.
Definition at line 1950 of file qabstractitemmodel.cpp.
Referenced by QStandardItemModel::dropMimeData().
|
protected |
Definition at line 2461 of file qabstractitemmodel.cpp.
Referenced by mimeData(), and sibling().
|
protected |
Ends a column insertion operation.
When reimplementing insertColumns() in a subclass, you must call this function after inserting data into the model's underlying data store.
Definition at line 2924 of file qabstractitemmodel.cpp.
Referenced by QSqlQueryModel::insertColumns(), QTableModel::insertColumns(), QTreeModel::insertColumns(), QTreeModel::setColumnCount(), and sibling().
|
protected |
Ends a row insertion operation.
When reimplementing insertRows() in a subclass, you must call this function after inserting data into the model's underlying data store.
Definition at line 2613 of file qabstractitemmodel.cpp.
Referenced by QScriptBreakpointsModel::addBreakpoint(), QTreeModel::endInsertItems(), QListModel::insert(), QDeclarativeFolderListModel::inserted(), QStringListModel::insertRows(), QTableModel::insertRows(), QSqlTableModel::insertRows(), QListModel::insertRows(), QTreeModel::insertRows(), QDeclarativeFolderListModel::refresh(), QSqlQueryModel::setQuery(), and sibling().
|
protected |
Ends a column move operation.
When implementing a subclass, you must call this function after moving data within the model's underlying data store.
layoutChanged is emitted by this method for compatibility reasons.
Definition at line 3065 of file qabstractitemmodel.cpp.
Referenced by sibling().
|
protected |
Ends a row move operation.
When implementing a subclass, you must call this function after moving data within the model's underlying data store.
layoutChanged is emitted by this method for compatibility reasons.
Definition at line 2841 of file qabstractitemmodel.cpp.
Referenced by QListModel::move(), and sibling().
|
protected |
Ends a column removal operation.
When reimplementing removeColumns() in a subclass, you must call this function after removing data from the model's underlying data store.
Definition at line 2978 of file qabstractitemmodel.cpp.
Referenced by QSqlQueryModel::removeColumns(), QTableModel::removeColumns(), QTreeModel::setColumnCount(), and sibling().
|
protected |
Ends a row removal operation.
When reimplementing removeRows() in a subclass, you must call this function after removing data from the model's underlying data store.
Definition at line 2667 of file qabstractitemmodel.cpp.
Referenced by QTreeModel::endRemoveItems(), QDeclarativeFolderListModel::refresh(), QListModel::remove(), QScriptBreakpointsModel::removeBreakpoint(), QDeclarativeFolderListModel::removed(), QStringListModel::removeRows(), QTableModel::removeRows(), QListModel::removeRows(), QTreeModel::removeRows(), QSqlQueryModel::setQuery(), sibling(), QListModel::take(), and QTreeWidgetItem::takeChild().
|
protected |
Completes a model reset operation.
You must call this function after resetting any internal data structure in your model or proxy model.
Definition at line 3139 of file qabstractitemmodel.cpp.
Referenced by QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QStringListModel::setStringList(), and sibling().
|
virtual |
Fetches any available data for the items with the parent specified by the parent index.
Reimplement this if you are populating your model incrementally.
The default implementation does nothing.
Reimplemented in QSortFilterProxyModel, QProxyModel, QFileSystemModel, QScriptDebuggerLocalsModel, QSqlQueryModel, and QAbstractProxyModel.
Definition at line 2148 of file qabstractitemmodel.cpp.
Referenced by QColumnView::createColumn(), QTreeViewPrivate::expand(), QAbstractItemViewPrivate::fetchMore(), and QTreeViewPrivate::layout().
|
virtual |
Returns the item flags for the given index.
The base class implementation returns a combination of flags that enables the item (ItemIsEnabled
) and allows it to be selected (ItemIsSelectable
).
Reimplemented in QCalendarModel, QStandardItemModel, QPPDOptionsModel, QSortFilterProxyModel, QTableModel, QTreeModel, QListModel, QFileSystemModel, QScriptBreakpointsModel, QProxyModel, QUrlModel, QDirModel, QScriptDebuggerLocalsModel, QAbstractProxyModel, QSqlTableModel, and QStringListModel.
Definition at line 2179 of file qabstractitemmodel.cpp.
Referenced by QLineControl::advanceToEnabledItem(), QUnsortedModelEngine::buildIndices(), QStyledItemDelegate::editorEvent(), QItemDelegate::editorEvent(), QStringListModel::flags(), QModelIndex::flags(), QDirModel::flags(), QFileSystemModel::flags(), QCalendarModel::flags(), QComboMenuDelegate::getStyleOption(), indexesFromRange(), QItemSelectionRange::isEmpty(), QColumnViewDelegate::paint(), QListView::paintEvent(), QAbstractItemViewPrivate::position(), and QAbstractItemViewPrivate::shouldEdit().
|
virtual |
Returns true if parent has any children; otherwise returns false.
Use rowCount() on the parent to find out the number of children.
Reimplemented in QEmptyItemModel, QAbstractListModel, QAbstractTableModel, QStandardItemModel, QCompletionModel, QSortFilterProxyModel, QTreeModel, QEmptyModel, QAbstractProxyModel, QFileSystemModel, QDirModel, QScriptDebuggerLocalsModel, QProxyModel, and QEmptyModel.
Definition at line 1808 of file qabstractitemmodel.cpp.
Referenced by QColumnViewPrivate::checkColumnCreation(), QColumnViewPrivate::closeColumns(), QColumnViewPrivate::createColumn(), QColumnView::currentChanged(), QTreeViewPrivate::hasVisibleChildren(), QDeclarativeVisualDataModelDataMetaObject::initialValue(), QAccessibleTable2Cell::isExpandable(), QTreeViewPrivate::layout(), match(), QColumnView::moveCursor(), and QColumnViewDelegate::paint().
bool QAbstractItemModel::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.
Definition at line 1793 of file qabstractitemmodel.cpp.
Referenced by QAbstractTableModel::dropMimeData(), QAbstractListModel::dropMimeData(), QIdentityProxyModel::index(), QListModel::index(), QAbstractTableModel::index(), QAbstractListModel::index(), and QTableWidget::setRangeSelected().
|
virtual |
Returns the data for the given role and section in the header with the specified orientation.
For horizontal headers, the section number corresponds to the column number. Similarly, for vertical headers, the section number corresponds to the row number.
Reimplemented in QStandardItemModel, QPPDOptionsModel, QSortFilterProxyModel, QTableModel, QTreeModel, QFileSystemModel, QScriptBreakpointsModel, QDirModel, QScriptDebuggerLocalsModel, QProxyModel, QSqlTableModel, QAbstractProxyModel, QScriptDebuggerStackModel, and QSqlQueryModel.
Definition at line 2388 of file qabstractitemmodel.cpp.
Referenced by QAccessibleTable2::columnDescription(), QAccessibleItemView::columnDescription(), QHeaderViewPrivate::flipSortIndicator(), QSqlQueryModel::headerData(), QDirModel::headerData(), QFileSystemModel::headerData(), QStandardItemModel::headerData(), QFileDialogPrivate::retranslateStrings(), QAccessibleTable2::rowDescription(), QAccessibleItemView::rowDescription(), QAccessibleHeader::text(), QAccessibleItemRow::text(), QAccessibleTable2HeaderCell::text(), and QAccessibleItemRow::text_helper().
|
signal |
This signal is emitted whenever a header is changed.
The orientation indicates whether the horizontal or vertical header has changed. The sections in the header from the first to the last need to be updated.
When reimplementing the setHeaderData() function, this signal must be emitted explicitly.
If you are changing the number of columns or rows you do not need to emit this signal, but use the begin/end functions (refer to the section on subclassing in the QAbstractItemModel class description for details).
Referenced by QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), QTreeModel::emitDataChanged(), QCalendarModel::internalUpdate(), QTableModel::itemChanged(), QTableModel::removeItem(), QSqlTableModel::removeRows(), QSqlQueryModel::setHeaderData(), QTableModel::setHorizontalHeaderItem(), QStandardItemModel::setHorizontalHeaderItem(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QTableModel::setVerticalHeaderItem(), QStandardItemModel::setVerticalHeaderItem(), and sibling().
|
pure virtual |
Returns the index of the item in the model specified by the given row, column and parent index.
When reimplementing this function in a subclass, call createIndex() to generate model indexes that other components can use to refer to items in your model.
Implemented in QEmptyItemModel, QAbstractListModel, QAbstractTableModel, QStandardItemModel, QCompletionModel, QPPDOptionsModel, QSortFilterProxyModel, QTableModel, QListModel, QTreeModel, QEmptyModel, QScriptBreakpointsModel, QScriptDebuggerScriptsModel, QFileSystemModel, QScriptDebuggerLocalsModel, QDirModel, QProxyModel, QEmptyModel, QIdentityProxyModel, and QUndoModel.
Referenced by QItemSelectionModelPrivate::_q_columnsAboutToBeInserted(), QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(), QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), QHeaderViewPrivate::_q_layoutAboutToBeChanged(), QItemSelectionModelPrivate::_q_layoutChanged(), QItemSelectionModelPrivate::_q_rowsAboutToBeInserted(), QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(), QFileDialogPrivate::_q_useNameFilter(), buddy(), QUnsortedModelEngine::buildIndices(), QAccessibleTable2::cellAt(), QTableWidget::cellWidget(), QModelIndex::child(), QAccessibleItemView::childCount(), QAccessibleTable2::childFromLogical(), QAccessibleItemRow::children(), QSidebar::clicked(), decodeData(), QListWidget::dropEvent(), QTreeWidget::dropEvent(), QListWidget::dropMimeData(), QTableWidget::dropMimeData(), QItemSelectionModelPrivate::expandSelection(), QAbstractItemViewPrivate::fetchMore(), QCompletionEngine::filter(), QSortedModelEngine::filter(), QCompletionEngine::filterHistory(), QAbstractProxyModel::headerData(), QAccessibleItemView::index(), QDataWidgetMapperPrivate::indexAt(), indexesFromRange(), QAccessibleTree::indexFromLogical(), QDeclarativeVisualDataModelDataMetaObject::initialValue(), QItemSelectionRange::intersect(), QItemSelectionRange::isEmpty(), QListViewPrivate::itemSize(), QTreeViewPrivate::layout(), match(), QAbstractProxyModel::mimeData(), QCommonListViewBase::modelIndex(), ModelIndexIterator::ModelIndexIterator(), QColumnView::moveCursor(), QSortFilterProxyModelLessThan::operator()(), QSortFilterProxyModelGreaterThan::operator()(), QAccessibleItemRow::rect(), QTreeViewPrivate::select(), QColumnView::selectAll(), QAbstractItemViewPrivate::selectAll(), QListViewPrivate::selectAll(), QAccessibleTable2::selectColumn(), QTableViewPrivate::selectColumn(), QAccessibleTable2::selectRow(), QTableViewPrivate::selectRow(), QSidebar::selectUrl(), QTableWidget::setCellWidget(), QComboBoxPrivate::setCurrentIndex(), QAbstractProxyModel::setHeaderData(), QFileDialogComboBox::setHistory(), QInputDialogPrivate::setListViewText(), QTableWidget::setRangeSelected(), QFileDialogComboBox::showPopup(), QModelIndex::sibling(), QSortedModelEngine::sortOrder(), QItemSelection::split(), QAccessibleTable2::unselectColumn(), QAccessibleTable2::unselectRow(), and QColumnView::visualRegionForSelection().
|
inline |
Inserts a single column before the given column in the child items of the parent specified.
Returns true if the column is inserted; otherwise returns false.
Definition at line 316 of file qabstractitemmodel.h.
Referenced by QStandardItemModel::insertColumn(), QCalendarModel::setWeekNumbersShown(), and sibling().
|
virtual |
On models that support this, inserts count new columns into the model before the given column.
The items in each new column will be children of the item represented by the parent model index.
If column is 0, the columns are prepended to any existing columns.
If column is columnCount(), the columns are appended to any existing columns.
If parent has no children, a single row with count columns is inserted.
Returns true if the columns were successfully inserted; otherwise returns false.
The base class implementation does nothing and returns false.
If you implement your own model, you can reimplement this function if you want to support insertions. Alternatively, you can provide your own API for altering the data.
Reimplemented in QCalendarModel, QStandardItemModel, QSortFilterProxyModel, QTreeModel, QTableModel, QProxyModel, QSqlQueryModel, and QIdentityProxyModel.
Definition at line 2091 of file qabstractitemmodel.cpp.
Referenced by decodeData().
|
inline |
Inserts a single row before the given row in the child items of the parent specified.
Returns true if the row is inserted; otherwise returns false.
Definition at line 314 of file qabstractitemmodel.h.
Referenced by QSqlTableModel::insertRecord(), QStandardItemModel::insertRow(), QCalendarModel::setHorizontalHeaderFormat(), QFileDialogComboBox::showPopup(), and sibling().
|
virtual |
On models that support this, inserts count rows into the model before the given row.
Items in the new row will be children of the item represented by the parent model index.
If row is 0, the rows are prepended to any existing rows in the parent.
If row is rowCount(), the rows are appended to any existing rows in the parent.
If parent has no children, a single column with count rows is inserted.
Returns true if the rows were successfully inserted; otherwise returns false.
If you implement your own model, you can reimplement this function if you want to support insertions. Alternatively, you can provide your own API for altering the data. In either case, you will need to call beginInsertRows() and endInsertRows() to notify other components that the model has changed.
Reimplemented in QCalendarModel, QStandardItemModel, QSortFilterProxyModel, QTreeModel, QListModel, QSqlTableModel, QTableModel, QProxyModel, QIdentityProxyModel, and QStringListModel.
Definition at line 2062 of file qabstractitemmodel.cpp.
Referenced by decodeData().
|
virtual |
Returns a map with values for all predefined roles in the model for the item at the given index.
Reimplement this function if you want to extend the default behavior of this function to include custom roles in the map.
Reimplemented in QStandardItemModel, QTableModel, QTreeModel, QListModel, and QAbstractProxyModel.
Definition at line 1823 of file qabstractitemmodel.cpp.
Referenced by QAbstractItemViewPrivate::clearOrRemove(), encodeData(), and QAbstractProxyModel::itemData().
|
signal |
This signal is emitted just before the layout of a model is changed.
Components connected to this signal use it to adapt to changes in the model's layout.
Subclasses should update any persistent model indexes after emitting layoutAboutToBeChanged().
Referenced by beginMoveColumns(), beginMoveRows(), QSortFilterProxyModel::clear(), QScriptDebuggerScriptsModel::commit(), QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), QListModel::ensureSorted(), QTreeModel::ensureSorted(), QTableModel::ensureSorted(), QSortFilterProxyModel::invalidate(), QPPDOptionsModel::parseItems(), QDirModel::refresh(), QCompletionModel::resetModel(), QScriptDebuggerStackModel::setContextInfos(), QDirModel::setFilter(), QTableModel::setItem(), QDirModel::setNameFilters(), QDirModel::setSorting(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), sibling(), QStringListModel::sort(), QFileSystemModel::sort(), QListModel::sort(), QTableModel::sort(), and QTreeWidgetItem::sortChildren().
|
signal |
This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted.
When this signal is received by a view, it should update the layout of items to reflect this change.
When subclassing QAbstractItemModel or QAbstractProxyModel, ensure that you emit layoutAboutToBeChanged() before changing the order of items or altering the structure of the data you expose to views, and emit layoutChanged() after changing the layout.
Subclasses should update any persistent model indexes before emitting layoutChanged(). In other words, when the structure changes:
Referenced by QSortFilterProxyModel::clear(), QScriptDebuggerScriptsModel::commit(), QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), endMoveColumns(), endMoveRows(), QListModel::ensureSorted(), QTreeModel::ensureSorted(), QTableModel::ensureSorted(), QDirModel::index(), QSortFilterProxyModel::invalidate(), QPPDOptionsModel::parseItems(), QDeclarativeFolderListModel::QDeclarativeFolderListModel(), QDirModel::refresh(), QCompletionModel::resetModel(), QScriptDebuggerStackModel::setContextInfos(), QDirModel::setFilter(), QTableModel::setItem(), QDirModel::setNameFilters(), QDirModel::setSorting(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QCompletionModel::setSourceModel(), sibling(), QStringListModel::sort(), QFileSystemModel::sort(), QListModel::sort(), QTableModel::sort(), and QTreeWidgetItem::sortChildren().
|
virtual |
Returns a list of indexes for the items in the column of the start index where data stored under the given role matches the specified value.
The way the search is performed is defined by the flags given. The list that is returned may be empty.
The search begins from the start index, and continues until the number of matching data items equals hits, the search reaches the last row, or the search reaches start again - depending on whether MatchWrap
is specified in flags. If you want to search for all matching items, use hits = -1.
By default, this function will perform a wrapping, string-based comparison on all items, searching for items that begin with the search term specified by value.
Reimplemented in QSortFilterProxyModel, QProxyModel, and QIdentityProxyModel.
Definition at line 2233 of file qabstractitemmodel.cpp.
Referenced by QStandardItemModel::findItems(), and QSortFilterProxyModel::match().
|
virtual |
Returns an object that contains serialized items of data corresponding to the list of indexes specified.
The formats used to describe the encoded data is obtained from the mimeTypes() function.
If the list of indexes is empty, or there are no supported MIME types, 0 is returned rather than a serialized empty list.
Reimplemented in QStandardItemModel, QTableModel, QSortFilterProxyModel, QTreeModel, QListModel, QFileSystemModel, QDirModel, QAbstractProxyModel, QUrlModel, and QProxyModel.
Definition at line 1911 of file qabstractitemmodel.cpp.
Referenced by QListModel::internalMimeData(), QTreeModel::internalMimeData(), QTableModel::internalMimeData(), and QStandardItemModel::mimeData().
|
virtual |
Returns a list of MIME types that can be used to describe a list of model indexes.
Reimplemented in QStandardItemModel, QSortFilterProxyModel, QTableModel, QTreeModel, QListModel, QFileSystemModel, QAbstractProxyModel, QDirModel, QUrlModel, and QProxyModel.
Definition at line 1894 of file qabstractitemmodel.cpp.
Referenced by dropMimeData(), QAbstractTableModel::dropMimeData(), QAbstractListModel::dropMimeData(), mimeData(), and QStandardItemModel::mimeTypes().
|
signal |
This signal is emitted when reset() is called, before the model's internal state (e.
g. persistent model indexes) has been invalidated.
\sa beginResetModel(), modelReset()
Referenced by beginResetModel(), reset(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted when reset() is called, after the model's internal state (e.
g. persistent model indexes) has been invalidated.
\sa endResetModel(), modelAboutToBeReset()
Referenced by QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), endResetModel(), QDeclarativeFolderListModel::QDeclarativeFolderListModel(), QSortFilterProxyModel::QSortFilterProxyModel(), reset(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QCompletionModel::setSourceModel(), and sibling().
|
pure virtual |
Returns the parent of the model item with the given index.
If the item has no parent, an invalid QModelIndex is returned.
A common convention used in models that expose tree data structures is that only items in the first column have children. For that case, when reimplementing this function in a subclass the column of the returned QModelIndex would be 0.
When reimplementing this function in a subclass, be careful to avoid calling QModelIndex member functions, such as QModelIndex::parent(), since indexes belonging to your model will simply call your implementation, leading to infinite recursion.
Implemented in QEmptyItemModel, QAbstractListModel, QAbstractTableModel, QStandardItemModel, QCompletionModel, QPPDOptionsModel, QSortFilterProxyModel, QTreeModel, QEmptyModel, QScriptBreakpointsModel, QScriptDebuggerScriptsModel, QFileSystemModel, QScriptDebuggerLocalsModel, QDirModel, QProxyModel, QIdentityProxyModel, QEmptyModel, and QUndoModel.
Referenced by QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), QModelIndex::parent(), and QModelIndex::sibling().
|
protected |
Returns the list of indexes stored as persistent indexes in the model.
Definition at line 3226 of file qabstractitemmodel.cpp.
Referenced by QListModel::ensureSorted(), QTreeModel::ensureSorted(), QTableModel::ensureSorted(), QCompletionModel::resetModel(), QTableModel::setItem(), QFileSystemModel::setNameFilters(), sibling(), QStringListModel::sort(), and QFileSystemModel::sort().
|
inline |
Removes the given column from the child items of the parent specified.
Returns true if the column is removed; otherwise returns false.
Definition at line 320 of file qabstractitemmodel.h.
Referenced by QCalendarModel::setWeekNumbersShown(), and sibling().
|
virtual |
On models that support this, removes count columns starting with the given column under parent parent from the model.
Returns true if the columns were successfully removed; otherwise returns false.
The base class implementation does nothing and returns false.
If you implement your own model, you can reimplement this function if you want to support removing. Alternatively, you can provide your own API for altering the data.
Reimplemented in QCalendarModel, QStandardItemModel, QSortFilterProxyModel, QTableModel, QSqlTableModel, QSqlRelationalTableModel, QIdentityProxyModel, and QSqlQueryModel.
Definition at line 2133 of file qabstractitemmodel.cpp.
|
inline |
Removes the given row from the child items of the parent specified.
Returns true if the row is removed; otherwise returns false.
This is a convenience function that calls removeRows(). The QAbstractItemModel implementation of removeRows() does nothing.
Definition at line 318 of file qabstractitemmodel.h.
Referenced by QUrlModel::addUrls(), QSidebar::removeEntry(), QCalendarModel::setHorizontalHeaderFormat(), and sibling().
|
virtual |
On models that support this, removes count rows starting with the given row under parent parent from the model.
Returns true if the rows were successfully removed; otherwise returns false.
The base class implementation does nothing and returns false.
If you implement your own model, you can reimplement this function if you want to support removing. Alternatively, you can provide your own API for altering the data.
Reimplemented in QCalendarModel, QStandardItemModel, QSortFilterProxyModel, QTreeModel, QListModel, QTableModel, QSqlTableModel, QIdentityProxyModel, and QStringListModel.
Definition at line 2112 of file qabstractitemmodel.cpp.
Referenced by QAbstractItemViewPrivate::clearOrRemove().
|
protected |
Resets the model to its original state in any attached views.
Definition at line 3095 of file qabstractitemmodel.cpp.
Referenced by QListModel::clear(), QTreeModel::clear(), QStandardItemModel::clear(), QTableModel::clearContents(), QCompletionModel::resetModel(), QSqlQueryModel::setQuery(), and QUndoModel::stackChanged().
|
protectedslot |
This slot is called just after the internal data of a model is cleared while it is being reset.
This slot is provided the convenience of subclasses of concrete proxy models, such as subclasses of QSortFilterProxyModel which maintain extra data.
Definition at line 1477 of file qabstractitemmodel.cpp.
Referenced by sibling().
|
virtualslot |
Lets the model know that it should discard cached information.
This function is typically used for row editing.
Reimplemented in QProxyModel, and QAbstractProxyModel.
Definition at line 2372 of file qabstractitemmodel.cpp.
const QHash< int, QByteArray > & QAbstractItemModel::roleNames | ( | ) | const |
Returns the model's role names.
Definition at line 2345 of file qabstractitemmodel.cpp.
Referenced by QDeclarativeVisualDataModelPrivate::ensureRoles(), setRoleNames(), and sibling().
|
pure virtual |
Returns the number of rows under the given parent.
When the parent is valid it means that rowCount is returning the number of children of parent.
Implemented in QCalendarModel, QEmptyItemModel, QStandardItemModel, QCompletionModel, QPPDOptionsModel, QSortFilterProxyModel, QTableModel, ControlList, QSqlTableModel, QTreeModel, QListModel, QEmptyModel, QScriptBreakpointsModel, QFileSystemModel, QScriptDebuggerScriptsModel, QDeclarativeFolderListModel, QScriptDebuggerLocalsModel, QDirModel, QScriptDebuggerStackModel, QProxyModel, QIdentityProxyModel, QEmptyModel, QSqlQueryModel, QUndoModel, and QStringListModel.
Referenced by QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(), QItemSelectionModelPrivate::_q_layoutAboutToBeChanged(), QHeaderViewPrivate::_q_layoutAboutToBeChanged(), QItemSelectionModelPrivate::_q_layoutChanged(), QFileDialogPrivate::_q_useNameFilter(), QListViewPrivate::doItemsLayout(), dropMimeData(), QAbstractListModel::dropMimeData(), QItemSelectionModelPrivate::expandSelection(), QAbstractItemViewPrivate::fetchMore(), QCompletionEngine::filter(), QUnsortedModelEngine::filter(), QCompletionEngine::filterHistory(), QUnsortedModelEngine::filterOnDemand(), hasChildren(), QAbstractTableModel::hasChildren(), QAbstractListModel::hasChildren(), hasIndex(), QTreeViewPrivate::hasVisibleChildren(), QSortedModelEngine::indexHint(), QDataWidgetMapperPrivate::itemCount(), QListViewPrivate::itemSize(), QTreeViewPrivate::layout(), match(), QDeclarativeVisualDataModelPrivate::modelCount(), QHeaderViewPrivate::modelIsEmpty(), QHeaderViewPrivate::modelSectionCount(), ModelIndexIterator::next(), QListViewPrivate::prepareItemsLayout(), QAccessibleTable2::rowCount(), QAccessibleItemView::rowCount(), QAbstractItemViewPrivate::selectAll(), QListViewPrivate::selectAll(), QTableViewPrivate::selectColumn(), QSidebar::selectUrl(), QCompleterPrivate::showPopup(), QSortedModelEngine::sortOrder(), and QAccessibleItemRow::text().
|
signal |
This signal is emitted just before rows are inserted into the model.
The new items will be positioned between start and end inclusive, under the given parent item.
Referenced by beginInsertRows(), QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted just before rows are moved within the model.
The items that will be moved are those between sourceStart and sourceEnd inclusive, under the given sourceParent item. They will be moved to destinationParent starting at the row destinationRow.
Note: Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code.
Referenced by beginMoveRows(), QIdentityProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted just before rows are removed from the model.
The items that will be removed are those between start and end inclusive, under the given parent item.
Referenced by beginRemoveRows(), QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted after rows have been inserted into the model.
The new items are those between start and end inclusive, under the given parent item.
Referenced by QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), endInsertRows(), QDeclarativeFolderListModel::QDeclarativeFolderListModel(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted after rows have been moved within the model.
The items between sourceStart and sourceEnd inclusive, under the given sourceParent item have been moved to destinationParent starting at the row destinationRow.
Note: Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code.
Referenced by endMoveRows(), QIdentityProxyModel::setSourceModel(), and sibling().
|
signal |
This signal is emitted after rows have been removed from the model.
The removed items are those between start and end inclusive, under the given parent item.
Referenced by QProxyModel::connectToModel(), QProxyModel::disconnectFromModel(), endRemoveRows(), QDeclarativeFolderListModel::QDeclarativeFolderListModel(), QUrlModel::setFileSystemModel(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), QCompletionModel::setSourceModel(), and sibling().
|
virtual |
Sets the role data for the item at index to value.
Returns true if successful; otherwise returns false.
The dataChanged() signal should be emitted if the data was successfully set.
The base class implementation returns false. This function and data() must be reimplemented for editable models.
Reimplemented in QStandardItemModel, QSortFilterProxyModel, QTableModel, QTreeModel, QListModel, QFileSystemModel, QScriptBreakpointsModel, QUrlModel, QSqlRelationalTableModel, QDirModel, QScriptDebuggerLocalsModel, QAbstractProxyModel, QProxyModel, QSqlTableModel, and QStringListModel.
Definition at line 1847 of file qabstractitemmodel.cpp.
Referenced by QDataWidgetMapperPrivate::commit(), QStyledItemDelegate::editorEvent(), QItemDelegate::editorEvent(), QSqlTableModel::setData(), setItemData(), QStyledItemDelegate::setModelData(), QItemDelegate::setModelData(), QComboBoxDelegate::setSeparator(), and QAccessibleTable2Cell::setText().
|
virtual |
Sets the data for the given role and section in the header with the specified orientation to the value supplied.
Returns true if the header's data was updated; otherwise returns false.
When reimplementing this function, the headerDataChanged() signal must be emitted explicitly.
Reimplemented in QStandardItemModel, QSortFilterProxyModel, QTableModel, QTreeModel, QAbstractProxyModel, QProxyModel, and QSqlQueryModel.
Definition at line 2408 of file qabstractitemmodel.cpp.
Referenced by QAccessibleItemRow::setText().
|
virtual |
Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole.
Returns true if successful; otherwise returns false.
Roles that are not in roles will not be modified.
Reimplemented in QStandardItemModel, QTableModel, and QAbstractProxyModel.
Definition at line 1880 of file qabstractitemmodel.cpp.
Referenced by QAbstractItemViewPrivate::clearOrRemove(), decodeData(), QAbstractTableModel::dropMimeData(), QAbstractListModel::dropMimeData(), and QAbstractProxyModel::setItemData().
|
protected |
Sets the model's role names to roleNames.
This function allows mapping of role identifiers to role property names in Declarative UI. This function must be called before the model is used. Modifying the role names after the model has been set may result in undefined behaviour.
Definition at line 2329 of file qabstractitemmodel.cpp.
Referenced by QDeclarativeFolderListModel::QDeclarativeFolderListModel(), and sibling().
void QAbstractItemModel::setSupportedDragActions | ( | Qt::DropActions | actions | ) |
Sets the supported drag actions for the items in the model.
Definition at line 2026 of file qabstractitemmodel.cpp.
Referenced by sibling().
|
inline |
Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no sibling at that location.
sibling() is just a convenience function that finds the item's parent, and uses it to retrieve the index of the child item in the specified row and column.
Definition at line 176 of file qabstractitemmodel.h.
Referenced by QModelIndex::internalId(), and QDirModel::setData().
|
virtual |
Sorts the model by column in the given order.
The base class implementation does nothing.
Reimplemented in QStandardItemModel, QSortFilterProxyModel, QTableModel, QTreeModel, QListModel, QFileSystemModel, QProxyModel, QDirModel, QSqlTableModel, QAbstractProxyModel, and QStringListModel.
Definition at line 2193 of file qabstractitemmodel.cpp.
Referenced by QTreeViewPrivate::_q_sortIndicatorChanged().
|
virtual |
Returns the row and column span of the item represented by index.
Reimplemented in QSortFilterProxyModel, QProxyModel, and QAbstractProxyModel.
Definition at line 2309 of file qabstractitemmodel.cpp.
|
virtualslot |
Lets the model know that it should submit cached information to permanent storage.
This function is typically used for row editing.
Returns true if there is no error; otherwise returns false.
Reimplemented in QProxyModel, and QAbstractProxyModel.
Definition at line 2360 of file qabstractitemmodel.cpp.
Qt::DropActions QAbstractItemModel::supportedDragActions | ( | ) | const |
Returns the actions supported by the data in this model.
The default implementation returns supportedDropActions() unless specific values have been set with setSupportedDragActions().
supportedDragActions() is used by QAbstractItemView::startDrag() as the default values when a drag occurs.
Definition at line 2007 of file qabstractitemmodel.cpp.
Referenced by sibling().
|
virtual |
Returns the drop actions supported by this model.
The default implementation returns Qt::CopyAction. Reimplement this function if you wish to support additional actions. You must also reimplement the dropMimeData() function to handle the additional operations.
Reimplemented in QStandardItemModel, QSortFilterProxyModel, QTableModel, QTreeModel, QListModel, QFileSystemModel, QDirModel, QAbstractProxyModel, QProxyModel, and QStringListModel.
Definition at line 1991 of file qabstractitemmodel.cpp.
Referenced by QAbstractItemViewPrivate::dropOn(), supportedDragActions(), and QStringListModel::supportedDropActions().
|
friend |
Definition at line 164 of file qabstractitemmodel.h.
|
friend |
Definition at line 165 of file qabstractitemmodel.h.
|
friend |
Definition at line 163 of file qabstractitemmodel.h.