44 #ifndef QT_NO_IDENTITYPROXYMODEL 47 #include <private/qabstractproxymodel_p.h> 158 return d->model->dropMimeData(data, action, row, column,
mapToSource(parent));
171 const QModelIndex sourceIndex =
d->model->index(row, column, sourceParent);
183 return d->model->insertColumns(column, count,
mapToSource(parent));
193 return d->model->insertRows(row, count,
mapToSource(parent));
202 if (!
d->model || !sourceIndex.
isValid())
218 return proxySelection;
222 for ( ; it !=
end; ++
it) {
225 proxySelection.
append(range);
228 return proxySelection;
240 return sourceSelection;
244 for ( ; it !=
end; ++
it) {
247 sourceSelection.
append(range);
250 return sourceSelection;
259 if (!
d->model || !proxyIndex.
isValid())
279 for ( ; it !=
end; ++
it)
302 return d->model->removeColumns(column, count,
mapToSource(parent));
312 return d->model->removeRows(row, count,
mapToSource(parent));
334 this,
SLOT(_q_sourceRowsAboutToBeInserted(
const QModelIndex &,
int,
int)));
338 this,
SLOT(_q_sourceRowsAboutToBeRemoved(
const QModelIndex &,
int,
int)));
346 this,
SLOT(_q_sourceColumnsAboutToBeInserted(
const QModelIndex &,
int,
int)));
350 this,
SLOT(_q_sourceColumnsAboutToBeRemoved(
const QModelIndex &,
int,
int)));
358 this,
SLOT(_q_sourceModelAboutToBeReset()));
360 this,
SLOT(_q_sourceModelReset()));
366 this,
SLOT(_q_sourceLayoutAboutToBeChanged()));
368 this,
SLOT(_q_sourceLayoutChanged()));
387 SLOT(_q_sourceColumnsAboutToBeInserted(
const QModelIndex &,
int,
int)));
391 SLOT(_q_sourceColumnsAboutToBeRemoved(
const QModelIndex &,
int,
int)));
399 SLOT(_q_sourceModelAboutToBeReset()));
401 SLOT(_q_sourceModelReset()));
407 SLOT(_q_sourceLayoutAboutToBeChanged()));
409 SLOT(_q_sourceLayoutChanged()));
419 q->beginInsertColumns(q->mapFromSource(parent), start,
end);
427 q->beginMoveColumns(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest);
434 q->beginRemoveColumns(q->mapFromSource(parent), start,
end);
444 q->endInsertColumns();
467 q->endRemoveColumns();
475 q->dataChanged(q->mapFromSource(topLeft), q->mapFromSource(bottomRight));
481 q->headerDataChanged(orientation, first, last);
486 if (ignoreNextLayoutAboutToBeChanged)
492 proxyIndexes << proxyPersistentIndex;
493 Q_ASSERT(proxyPersistentIndex.isValid());
495 Q_ASSERT(srcPersistentIndex.isValid());
496 layoutChangePersistentIndexes << srcPersistentIndex;
499 q->layoutAboutToBeChanged();
504 if (ignoreNextLayoutChanged)
509 for (
int i = 0; i < proxyIndexes.size(); ++i) {
510 q->changePersistentIndex(proxyIndexes.at(i), q->mapFromSource(layoutChangePersistentIndexes.at(i)));
513 layoutChangePersistentIndexes.clear();
514 proxyIndexes.clear();
522 q->beginResetModel();
535 q->beginInsertRows(q->mapFromSource(parent), start,
end);
543 q->beginMoveRows(q->mapFromSource(sourceParent), sourceStart, sourceEnd, q->mapFromSource(destParent), dest);
550 q->beginRemoveRows(q->mapFromSource(parent), start,
end);
588 #include "moc_qidentityproxymodel.cpp" 590 #endif // QT_NO_IDENTITYPROXYMODEL The QVariant class acts like a union for the most common Qt data types.
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
void _q_sourceRowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
#define QT_END_NAMESPACE
This macro expands to.
void _q_sourceModelReset()
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
#define it(className, varName)
void _q_sourceColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
QList< QPersistentModelIndex > layoutChangePersistentIndexes
void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last)
void _q_sourceColumnsRemoved(const QModelIndex &parent, int start, int end)
QItemSelection mapSelectionFromSource(const QItemSelection &selection) const
Reimplemented Function
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
virtual void setSourceModel(QAbstractItemModel *sourceModel)
Sets the given sourceModel to be processed by the proxy model.
The QItemSelectionRange class manages information about a range of selected items in a model...
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
void columnsInserted(const QModelIndex &parent, int first, int last)
This signal is emitted after columns have been inserted into the model.
QModelIndex createIndex(int row, int column, void *data=0) const
Creates a model index for the given row and column with the internal pointer ptr. ...
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
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.
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
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.
void _q_sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
The QObject class is the base class of all Qt objects.
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.
~QIdentityProxyModel()
Destroys this identity model.
void _q_sourceRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
void _q_sourceLayoutChanged()
void endResetModel()
Completes a model reset operation.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
void _q_sourceRowsInserted(const QModelIndex &parent, int start, int end)
void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last)
This signal is emitted just before columns are inserted into the model.
friend class const_iterator
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QModelIndexList proxyIndexes
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.
void layoutAboutToBeChanged()
This signal is emitted just before the layout of a model is changed.
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...
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
This signal is emitted just before rows are inserted into the model.
int row() const
Returns the row this model index refers to.
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented Function
void _q_sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void modelAboutToBeReset()
This signal is emitted when reset() is called, before the model's internal state (e.
QIdentityProxyModelPrivate()
void layoutChanged()
This signal is emitted whenever the layout of items exposed by the model has changed; for example...
void _q_sourceRowsRemoved(const QModelIndex &parent, int start, int end)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
The QMimeData class provides a container for data that records information about its MIME type...
void _q_sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
void _q_sourceModelAboutToBeReset()
The QAbstractItemModel class provides the abstract interface for item model classes.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...
QModelIndex mapToSource(const QModelIndex &proxyIndex) const
Reimplemented Function
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted just before columns are removed from the model.
QList< QModelIndex > QModelIndexList
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.
void _q_sourceColumnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destParent, int dest)
#define Q_DECLARE_PUBLIC(Class)
The QItemSelection class manages information about selected items in a model.
bool ignoreNextLayoutAboutToBeChanged
void setSourceModel(QAbstractItemModel *sourceModel)
Reimplemented Function
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
The QPersistentModelIndex class is used to locate data in a data model.
void rowsInserted(const QModelIndex &parent, int first, int last)
This signal is emitted after rows have been inserted into the model.
QVariant data(const QModelIndex &proxyIndex, int role=Qt::DisplayRole) const
Reimplemented Function
int rowCount(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
QIdentityProxyModel(QObject *parent=0)
Constructs an identity model with the given parent.
QObject * parent() const
Returns a pointer to the parent object.
The QModelIndex class is used to locate data in a data model.
void _q_sourceLayoutAboutToBeChanged()
void modelReset()
This signal is emitted when reset() is called, after the model's internal state (e.
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This signal is emitted whenever the data in an existing item changes.
The QIdentityProxyModel class proxies its source model unmodified.
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
Reimplemented Function
Qt::ItemFlags flags(const QModelIndex &index) const
Reimplemented Function
void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
void _q_sourceColumnsInserted(const QModelIndex &parent, int start, int end)
static const KeyPair *const end
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted just before rows are removed from the model.
int columnCount(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
void rowsRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted after rows have been removed from the model.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
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.
void columnsRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted after columns have been removed from the model.
void beginResetModel()
Begins a model reset operation.
QItemSelection mapSelectionToSource(const QItemSelection &selection) const
Reimplemented Function
QModelIndexList match(const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
Reimplemented Function
void _q_sourceColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
int column() const
Returns the column this model index refers to.
The QList class is a template class that provides lists.
bool ignoreNextLayoutChanged
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...