Qt 4.8
Public Functions | Protected Functions | List of all members
QAbstractProxyModel Class Referenceabstract

The QAbstractProxyModel class provides a base class for proxy item models that can do sorting, filtering or other data processing tasks. More...

#include <qabstractproxymodel.h>

Inheritance diagram for QAbstractProxyModel:
QAbstractItemModel QObject QCompletionModel QIdentityProxyModel QSortFilterProxyModel

Public Functions

QModelIndex buddy (const QModelIndex &index) const
 Reimplemented Function More...
 
bool canFetchMore (const QModelIndex &parent) const
 Reimplemented Function More...
 
QVariant data (const QModelIndex &proxyIndex, int role=Qt::DisplayRole) const
 Reimplemented Function More...
 
void fetchMore (const QModelIndex &parent)
 Reimplemented Function More...
 
Qt::ItemFlags flags (const QModelIndex &index) const
 Reimplemented Function More...
 
bool hasChildren (const QModelIndex &parent=QModelIndex()) const
 Reimplemented Function More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const
 Reimplemented Function More...
 
QMap< int, QVariantitemData (const QModelIndex &index) const
 Reimplemented Function More...
 
virtual QModelIndex mapFromSource (const QModelIndex &sourceIndex) const =0
 Reimplement this function to return the model index in the proxy model that corresponds to the sourceIndex from the source model. More...
 
virtual QItemSelection mapSelectionFromSource (const QItemSelection &selection) const
 Returns a proxy selection mapped from the specified sourceSelection. More...
 
virtual QItemSelection mapSelectionToSource (const QItemSelection &selection) const
 Returns a source selection mapped from the specified proxySelection. More...
 
virtual QModelIndex mapToSource (const QModelIndex &proxyIndex) const =0
 Reimplement this function to return the model index in the source model that corresponds to the proxyIndex in the proxy model. More...
 
QMimeDatamimeData (const QModelIndexList &indexes) const
 Reimplemented Function More...
 
QStringList mimeTypes () const
 Reimplemented Function More...
 
 QAbstractProxyModel (QObject *parent=0)
 Constructs a proxy model with the given parent. More...
 
void revert ()
 Reimplemented Function More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 Reimplemented Function More...
 
bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
 Reimplemented Function More...
 
bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 Reimplemented Function More...
 
virtual void setSourceModel (QAbstractItemModel *sourceModel)
 Sets the given sourceModel to be processed by the proxy model. More...
 
void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
 Reimplemented Function More...
 
QAbstractItemModelsourceModel () const
 Returns the model that contains the data that is available through the proxy model. More...
 
QSize span (const QModelIndex &index) const
 Reimplemented Function More...
 
bool submit ()
 Reimplemented Function More...
 
Qt::DropActions supportedDropActions () const
 Reimplemented Function More...
 
 ~QAbstractProxyModel ()
 Destroys the proxy model. More...
 
- Public Functions inherited from QAbstractItemModel
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const =0
 Returns the number of columns for the children of the given parent. 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...
 
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 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 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 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...
 
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...
 
Qt::DropActions supportedDragActions () const
 Returns the actions supported by the data in 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 QObjectListchildren () 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< QByteArraydynamicPropertyNames () 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 >
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 QMetaObjectmetaObject () 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
 
QObjectparent () 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...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Functions

 QAbstractProxyModel (QAbstractProxyModelPrivate &, QObject *parent)
 
- Protected Functions inherited from QAbstractItemModel
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...
 
QObjectsender () 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...
 

Additional Inherited Members

- Public Slots inherited from QAbstractItemModel
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QAbstractItemModel
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...
 
- 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 Slots inherited from QAbstractItemModel
void resetInternalData ()
 This slot is called just after the internal data of a model is cleared while it is being reset. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QAbstractProxyModel class provides a base class for proxy item models that can do sorting, filtering or other data processing tasks.

Since
4.1

This class defines the standard interface that proxy models must use to be able to interoperate correctly with other model/view components. It is not supposed to be instantiated directly.

All standard proxy models are derived from the QAbstractProxyModel class. If you need to create a new proxy model class, it is usually better to subclass an existing class that provides the closest behavior to the one you want to provide.

Proxy models that filter or sort items of data from a source model should be created by using or subclassing QSortFilterProxyModel.

To subclass QAbstractProxyModel, you need to implement mapFromSource() and mapToSource(). The mapSelectionFromSource() and mapSelectionToSource() functions only need to be reimplemented if you need a behavior different from the default behavior.

Note
If the source model is deleted or no source model is specified, the proxy model operates on a empty placeholder model.
See also
QSortFilterProxyModel, QAbstractItemModel, {Model/View Programming}

Definition at line 58 of file qabstractproxymodel.h.

Constructors and Destructors

◆ QAbstractProxyModel() [1/2]

QAbstractProxyModel::QAbstractProxyModel ( QObject parent = 0)

Constructs a proxy model with the given parent.

Definition at line 97 of file qabstractproxymodel.cpp.

99 {
101 }
static QAbstractItemModel * staticEmptyModel()
virtual void setSourceModel(QAbstractItemModel *sourceModel)
Sets the given sourceModel to be processed by the proxy model.
QAbstractItemModel(QObject *parent=0)
Constructs an abstract item model with the given parent.

◆ ~QAbstractProxyModel()

QAbstractProxyModel::~QAbstractProxyModel ( )

Destroys the proxy model.

Definition at line 116 of file qabstractproxymodel.cpp.

117 {
118 
119 }

◆ QAbstractProxyModel() [2/2]

QAbstractProxyModel::QAbstractProxyModel ( QAbstractProxyModelPrivate dd,
QObject parent 
)
protected
Warning
This function is not part of the public interface.

Definition at line 107 of file qabstractproxymodel.cpp.

108  : QAbstractItemModel(dd, parent)
109 {
111 }
static QAbstractItemModel * staticEmptyModel()
virtual void setSourceModel(QAbstractItemModel *sourceModel)
Sets the given sourceModel to be processed by the proxy model.
QAbstractItemModel(QObject *parent=0)
Constructs an abstract item model with the given parent.

Functions

◆ buddy()

QModelIndex QAbstractProxyModel::buddy ( const QModelIndex index) const
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 310 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

311 {
312  Q_D(const QAbstractProxyModel);
313  return mapFromSource(d->model->buddy(mapToSource(index)));
314 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const =0
Reimplement this function to return the model index in the proxy model that corresponds to the source...
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ canFetchMore()

bool QAbstractProxyModel::canFetchMore ( const QModelIndex parent) const
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 320 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

321 {
322  Q_D(const QAbstractProxyModel);
323  return d->model->canFetchMore(mapToSource(parent));
324 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ data()

QVariant QAbstractProxyModel::data ( const QModelIndex proxyIndex,
int  role = Qt::DisplayRole 
) const
virtual

Reimplemented Function

Implements QAbstractItemModel.

Reimplemented in QCompletionModel, and QSortFilterProxyModel.

Definition at line 232 of file qabstractproxymodel.cpp.

233 {
234  Q_D(const QAbstractProxyModel);
235  return d->model->data(mapToSource(proxyIndex), role);
236 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ fetchMore()

void QAbstractProxyModel::fetchMore ( const QModelIndex parent)
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 330 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

331 {
333  d->model->fetchMore(mapToSource(parent));
334 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ flags()

Qt::ItemFlags QAbstractProxyModel::flags ( const QModelIndex index) const
virtual

Reimplemented Function

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 266 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

267 {
268  Q_D(const QAbstractProxyModel);
269  return d->model->flags(mapToSource(index));
270 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ hasChildren()

bool QAbstractProxyModel::hasChildren ( const QModelIndex parent = QModelIndex()) const
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QCompletionModel, and QSortFilterProxyModel.

Definition at line 360 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

361 {
362  Q_D(const QAbstractProxyModel);
363  return d->model->hasChildren(mapToSource(parent));
364 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ headerData()

QVariant QAbstractProxyModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const
virtual

Reimplemented Function

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 241 of file qabstractproxymodel.cpp.

Referenced by QSortFilterProxyModel::headerData(), and QAbstractItemModel::sibling().

242 {
243  Q_D(const QAbstractProxyModel);
244  int sourceSection;
245  if (orientation == Qt::Horizontal) {
246  const QModelIndex proxyIndex = index(0, section);
247  sourceSection = mapToSource(proxyIndex).column();
248  } else {
249  const QModelIndex proxyIndex = index(section, 0);
250  sourceSection = mapToSource(proxyIndex).row();
251  }
252  return d->model->headerData(sourceSection, orientation, role);
253 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
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...
int row() const
Returns the row this model index refers to.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...
The QModelIndex class is used to locate data in a data model.
int column() const
Returns the column this model index refers to.

◆ itemData()

QMap< int, QVariant > QAbstractProxyModel::itemData ( const QModelIndex index) const
virtual

Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 258 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

259 {
260  return QAbstractItemModel::itemData(proxyIndex);
261 }
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...

◆ mapFromSource()

QModelIndex QAbstractProxyModel::mapFromSource ( const QModelIndex sourceIndex) const
pure virtual

Reimplement this function to return the model index in the proxy model that corresponds to the sourceIndex from the source model.

See also
mapToSource()

Implemented in QCompletionModel, QSortFilterProxyModel, and QIdentityProxyModel.

Referenced by buddy(), and mapSelectionFromSource().

◆ mapSelectionFromSource()

QItemSelection QAbstractProxyModel::mapSelectionFromSource ( const QItemSelection sourceSelection) const
virtual

Returns a proxy selection mapped from the specified sourceSelection.

Reimplement this method to map source selections to proxy selections.

Reimplemented in QSortFilterProxyModel, and QIdentityProxyModel.

Definition at line 216 of file qabstractproxymodel.cpp.

Referenced by QSortFilterProxyModel::mapSelectionFromSource().

217 {
218  QModelIndexList sourceIndexes = sourceSelection.indexes();
219  QItemSelection proxySelection;
220  for (int i = 0; i < sourceIndexes.size(); ++i) {
221  const QModelIndex srcIdx = mapFromSource(sourceIndexes.at(i));
222  if (!srcIdx.isValid())
223  continue;
224  proxySelection << QItemSelectionRange(srcIdx);
225  }
226  return proxySelection;
227 }
The QItemSelectionRange class manages information about a range of selected items in a model...
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const =0
Reimplement this function to return the model index in the proxy model that corresponds to the source...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QItemSelection class manages information about selected items in a model.
The QModelIndex class is used to locate data in a data model.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QModelIndexList indexes() const
Returns a list of model indexes that correspond to the selected items.

◆ mapSelectionToSource()

QItemSelection QAbstractProxyModel::mapSelectionToSource ( const QItemSelection proxySelection) const
virtual

Returns a source selection mapped from the specified proxySelection.

Reimplement this method to map proxy selections to source selections.

Reimplemented in QSortFilterProxyModel, and QIdentityProxyModel.

Definition at line 198 of file qabstractproxymodel.cpp.

Referenced by QSortFilterProxyModel::mapSelectionToSource().

199 {
200  QModelIndexList proxyIndexes = proxySelection.indexes();
201  QItemSelection sourceSelection;
202  for (int i = 0; i < proxyIndexes.size(); ++i) {
203  const QModelIndex proxyIdx = mapToSource(proxyIndexes.at(i));
204  if (!proxyIdx.isValid())
205  continue;
206  sourceSelection << QItemSelectionRange(proxyIdx);
207  }
208  return sourceSelection;
209 }
The QItemSelectionRange class manages information about a range of selected items in a model...
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QItemSelection class manages information about selected items in a model.
The QModelIndex class is used to locate data in a data model.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QModelIndexList indexes() const
Returns a list of model indexes that correspond to the selected items.

◆ mapToSource()

QModelIndex QAbstractProxyModel::mapToSource ( const QModelIndex proxyIndex) const
pure virtual

Reimplement this function to return the model index in the source model that corresponds to the proxyIndex in the proxy model.

See also
mapFromSource()

Implemented in QCompletionModel, QSortFilterProxyModel, and QIdentityProxyModel.

Referenced by buddy(), canFetchMore(), data(), fetchMore(), flags(), hasChildren(), headerData(), mapSelectionToSource(), mimeData(), setData(), setHeaderData(), and span().

◆ mimeData()

QMimeData * QAbstractProxyModel::mimeData ( const QModelIndexList indexes) const
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 370 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

371 {
372  Q_D(const QAbstractProxyModel);
373  QModelIndexList list;
374  foreach(const QModelIndex &index, indexes)
375  list << mapToSource(index);
376  return d->model->mimeData(list);
377 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
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...
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...
The QModelIndex class is used to locate data in a data model.

◆ mimeTypes()

QStringList QAbstractProxyModel::mimeTypes ( ) const
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 383 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

384 {
385  Q_D(const QAbstractProxyModel);
386  return d->model->mimeTypes();
387 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ revert()

void QAbstractProxyModel::revert ( )
virtual

Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 162 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

163 {
165  d->model->revert();
166 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ setData()

bool QAbstractProxyModel::setData ( const QModelIndex index,
const QVariant value,
int  role = Qt::EditRole 
)
virtual

Reimplemented Function

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 275 of file qabstractproxymodel.cpp.

276 {
278  return d->model->setData(mapToSource(index), value, role);
279 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ setHeaderData()

bool QAbstractProxyModel::setHeaderData ( int  section,
Qt::Orientation  orientation,
const QVariant value,
int  role = Qt::EditRole 
)
virtual

Reimplemented Function

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 292 of file qabstractproxymodel.cpp.

Referenced by QSortFilterProxyModel::setHeaderData(), and QAbstractItemModel::sibling().

293 {
295  int sourceSection;
296  if (orientation == Qt::Horizontal) {
297  const QModelIndex proxyIndex = index(0, section);
298  sourceSection = mapToSource(proxyIndex).column();
299  } else {
300  const QModelIndex proxyIndex = index(section, 0);
301  sourceSection = mapToSource(proxyIndex).row();
302  }
303  return d->model->setHeaderData(sourceSection, orientation, value, role);
304 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
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...
int row() const
Returns the row this model index refers to.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...
The QModelIndex class is used to locate data in a data model.
int column() const
Returns the column this model index refers to.

◆ setItemData()

bool QAbstractProxyModel::setItemData ( const QModelIndex index,
const QMap< int, QVariant > &  roles 
)
virtual

Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 284 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

285 {
286  return QAbstractItemModel::setItemData(index, roles);
287 }
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...

◆ setSourceModel()

void QAbstractProxyModel::setSourceModel ( QAbstractItemModel sourceModel)
virtual

Sets the given sourceModel to be processed by the proxy model.

Reimplemented in QCompletionModel, QSortFilterProxyModel, and QIdentityProxyModel.

Definition at line 124 of file qabstractproxymodel.cpp.

Referenced by QCompletionModel::modelDestroyed(), QAbstractProxyModel(), QFileDialog::setProxyModel(), QIdentityProxyModel::setSourceModel(), QSortFilterProxyModel::setSourceModel(), and QCompletionModel::setSourceModel().

125 {
127  if (d->model)
128  disconnect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed()));
129 
130  if (sourceModel) {
131  d->model = sourceModel;
132  connect(d->model, SIGNAL(destroyed()), this, SLOT(_q_sourceModelDestroyed()));
133  } else {
135  }
136  d->roleNames = d->model->roleNames();
137 }
double d
Definition: qnumeric_p.h:62
static QAbstractItemModel * staticEmptyModel()
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
QAbstractItemModel * sourceModel() const
Returns the model that contains the data that is available through the proxy model.
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 rece...
Definition: qobject.cpp:2580
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...
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.
Definition: qobject.cpp:2895

◆ sort()

void QAbstractProxyModel::sort ( int  column,
Qt::SortOrder  order = Qt::AscendingOrder 
)
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 340 of file qabstractproxymodel.cpp.

341 {
343  d->model->sort(column, order);
344 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ sourceModel()

QAbstractItemModel * QAbstractProxyModel::sourceModel ( ) const

Returns the model that contains the data that is available through the proxy model.

Definition at line 142 of file qabstractproxymodel.cpp.

Referenced by QCompleterPrivate::_q_complete(), QUnsortedModelEngine::buildIndices(), QCompletionEngine::filter(), QSortedModelEngine::filter(), QUnsortedModelEngine::filter(), QCompletionEngine::filterHistory(), QUnsortedModelEngine::filterOnDemand(), QSortedModelEngine::indexHint(), setSourceModel(), QIdentityProxyModel::setSourceModel(), QCompletionModel::setSourceModel(), and QSortedModelEngine::sortOrder().

143 {
144  Q_D(const QAbstractProxyModel);
146  return 0;
147  return d->model;
148 }
double d
Definition: qnumeric_p.h:62
static QAbstractItemModel * staticEmptyModel()
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ span()

QSize QAbstractProxyModel::span ( const QModelIndex index) const
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 350 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

351 {
352  Q_D(const QAbstractProxyModel);
353  return d->model->span(mapToSource(index));
354 }
double d
Definition: qnumeric_p.h:62
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ submit()

bool QAbstractProxyModel::submit ( )
virtual

Reimplemented Function

Reimplemented from QAbstractItemModel.

Definition at line 153 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

154 {
156  return d->model->submit();
157 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

◆ supportedDropActions()

Qt::DropActions QAbstractProxyModel::supportedDropActions ( ) const
virtual

Reimplemented Function

Since
4.8

Reimplemented from QAbstractItemModel.

Reimplemented in QSortFilterProxyModel.

Definition at line 393 of file qabstractproxymodel.cpp.

Referenced by QAbstractItemModel::sibling().

394 {
395  Q_D(const QAbstractProxyModel);
396  return d->model->supportedDropActions();
397 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...

The documentation for this class was generated from the following files: