43 #include <private/qabstractitemmodel_p.h> 64 if (it != indexes.
end()) {
464 #ifndef QT_NO_DEBUG_STREAM 467 #ifndef Q_BROKEN_DEBUG_STREAM 472 qWarning(
"This compiler doesn't support streaming QModelIndex to QDebug");
504 return qEmptyModel();
508 struct DefaultRoleNames :
public QHash<int, QByteArray>
525 return *qDefaultRoleNames();
578 int removed = persistent.indexes.remove(data->
index);
579 Q_ASSERT_X(removed == 1,
"QPersistentModelIndex::~QPersistentModelIndex",
580 "persistent model indexes corrupted");
586 for (
int i = persistent.moved.count() - 1; i >= 0; --i) {
587 int idx = persistent.moved[i].indexOf(data);
589 persistent.moved[i].remove(idx);
592 for (
int i = persistent.invalidated.count() - 1; i >= 0; --i) {
593 int idx = persistent.invalidated[i].indexOf(data);
595 persistent.invalidated[i].remove(idx);
606 if (first < q->rowCount(parent)) {
608 it != persistent.indexes.constEnd(); ++
it) {
612 persistent_moved.
append(data);
616 persistent.moved.push(persistent_moved);
623 int count = (last - first) + 1;
628 persistent.indexes.erase(persistent.indexes.find(old));
631 persistent.insertMultiAtEnd(data->
index, data);
633 qWarning() <<
"QAbstractItemModel::endInsertRows: Invalid index (" << old.
row() + count <<
',' << old.
column() <<
") in model" << q_func();
648 const bool sameParent = (srcParent == destinationParent);
649 const bool movingUp = (srcFirst > destinationChild);
651 for ( it = begin; it !=
end; ++
it) {
655 const bool isSourceIndex = (parent == srcParent);
656 const bool isDestinationIndex = (parent == destinationParent);
660 childPosition = index.
row();
662 childPosition = index.
column();
664 if (!index.
isValid() || !(isSourceIndex || isDestinationIndex ) )
667 if (!sameParent && isDestinationIndex) {
668 if (childPosition >= destinationChild)
669 persistent_moved_in_destination.
append(data);
673 if (sameParent && movingUp && childPosition < destinationChild)
676 if (sameParent && !movingUp && childPosition < srcFirst )
679 if (!sameParent && childPosition < srcFirst)
682 if (sameParent && (childPosition > srcLast) && (childPosition >= destinationChild ))
685 if ((childPosition <= srcLast) && (childPosition >= srcFirst)) {
686 persistent_moved_explicitly.
append(data);
688 persistent_moved_in_source.
append(data);
691 persistent.moved.push(persistent_moved_explicitly);
692 persistent.moved.push(persistent_moved_in_source);
693 persistent.moved.push(persistent_moved_in_destination);
712 for (it = begin; it !=
end; ++
it)
724 persistent.indexes.erase(persistent.indexes.find(data->
index));
725 data->
index = q_func()->index(row, column, parent);
727 persistent.insertMultiAtEnd(data->
index, data);
729 qWarning() <<
"QAbstractItemModel::endMoveRows: Invalid index (" << row <<
"," << column <<
") in model" << q_func();
740 const bool sameParent = (sourceParent == destinationParent);
741 const bool movingUp = (sourceFirst > destinationChild);
743 const int explicit_change = (!sameParent || movingUp) ? destinationChild - sourceFirst : destinationChild - sourceLast - 1 ;
744 const int source_change = (!sameParent || !movingUp) ? -1*(sourceLast - sourceFirst + 1) : sourceLast - sourceFirst + 1 ;
745 const int destination_change = sourceLast - sourceFirst + 1;
747 movePersistentIndexes(moved_explicitly, explicit_change, destinationParent, orientation);
748 movePersistentIndexes(moved_in_source, source_change, sourceParent, orientation);
749 movePersistentIndexes(moved_in_destination, destination_change, destinationParent, orientation);
760 it != persistent.indexes.constEnd(); ++
it) {
762 bool level_changed =
false;
766 if (current_parent == parent) {
767 if (!level_changed && current.
row() > last)
768 persistent_moved.
append(data);
769 else if (current.
row() <= last && current.
row() >= first)
770 persistent_invalidated.
append(data);
773 current = current_parent;
774 level_changed =
true;
778 persistent.moved.push(persistent_moved);
779 persistent.invalidated.push(persistent_invalidated);
786 int count = (last - first) + 1;
791 persistent.indexes.erase(persistent.indexes.find(old));
794 persistent.insertMultiAtEnd(data->
index, data);
796 qWarning() <<
"QAbstractItemModel::endRemoveRows: Invalid index (" << old.
row() - count <<
',' << old.
column() <<
") in model" << q_func();
803 persistent.indexes.erase(persistent.indexes.find(data->
index));
815 if (first < q->columnCount(parent)) {
817 it != persistent.indexes.constEnd(); ++
it) {
821 persistent_moved.
append(data);
824 persistent.moved.push(persistent_moved);
831 int count = (last - first) + 1;
836 persistent.indexes.erase(persistent.indexes.find(old));
839 persistent.insertMultiAtEnd(data->
index, data);
841 qWarning() <<
"QAbstractItemModel::endInsertColumns: Invalid index (" << old.
row() <<
',' << old.
column() + count <<
") in model" << q_func();
854 it != persistent.indexes.constEnd(); ++
it) {
856 bool level_changed =
false;
860 if (current_parent == parent) {
861 if (!level_changed && current.
column() > last)
862 persistent_moved.
append(data);
863 else if (current.
column() <= last && current.
column() >= first)
864 persistent_invalidated.
append(data);
867 current = current_parent;
868 level_changed =
true;
872 persistent.moved.push(persistent_moved);
873 persistent.invalidated.push(persistent_invalidated);
881 int count = (last - first) + 1;
886 persistent.indexes.erase(persistent.indexes.find(old));
889 persistent.insertMultiAtEnd(data->
index, data);
891 qWarning() <<
"QAbstractItemModel::endRemoveColumns: Invalid index (" << old.
row() <<
',' << old.
column() - count <<
") in model" << q_func();
898 persistent.indexes.erase(persistent.indexes.find(data->
index));
1504 d_func()->invalidatePersistentIndexes();
1795 if (row < 0 || column < 0)
1829 roles.
insert(i, variantData);
1897 types <<
QLatin1String(
"application/x-qabstractitemmodeldatalist");
1913 if (indexes.
count() <= 0)
1923 data->
setData(format, encoded);
1972 return decodeData(row, column, parent, stream);
2011 if (
d->supportedDragActions != -1)
2012 return d->supportedDragActions;
2029 d->supportedDragActions = actions;
2182 if (!
d->indexValid(index))
2235 Qt::MatchFlags
flags)
const 2238 uint matchType = flags & 0x0F;
2242 bool allHits = (hits == -1);
2245 int from = start.
row();
2249 for (
int i = 0; (wrap && i < 2) || (!wrap && i < 1); ++i) {
2250 for (
int r = from; (r < to) && (allHits || result.
count() < hits); ++r) {
2263 switch (matchType) {
2265 if (
QRegExp(text, cs).exactMatch(t))
2293 (allHits ? -1 : hits - result.
count()), flags);
2348 return d->roleNames;
2464 for (; it != indexes.
end(); ++
it)
2465 stream << (*it).row() << (*it).column() <<
itemData(*it);
2481 while (!stream.
atEnd()) {
2484 stream >> r >> c >> v;
2489 left =
qMin(c, left);
2490 bottom =
qMax(r, bottom);
2491 right =
qMax(c, right);
2496 int dragRowCount = 0;
2497 int dragColumnCount = right - left + 1;
2501 for (
int i = 0; i < rows.
count(); ++i)
2502 rowsToInsert[rows.
at(i)] = 1;
2503 for (
int i = 0; i < rowsToInsert.
count(); ++i) {
2504 if (rowsToInsert[i] == 1){
2505 rowsToInsert[i] = dragRowCount;
2509 for (
int i = 0; i < rows.
count(); ++i)
2510 rows[i] = top + rowsToInsert[rows[i]];
2512 QBitArray isWrittenTo(dragRowCount * dragColumnCount);
2516 if (colCount == 0) {
2517 insertColumns(colCount, dragColumnCount - colCount, parent);
2523 column =
qMax(0, column);
2527 for (
int j = 0; j < data.
size(); ++j) {
2528 int relativeRow = rows.
at(j) - top;
2529 int relativeColumn = columns.
at(j) -
left;
2530 int destinationRow = relativeRow + row;
2531 int destinationColumn = relativeColumn + column;
2532 int flat = (relativeRow * dragColumnCount) + relativeColumn;
2534 if (destinationColumn >= colCount || isWrittenTo.
testBit(flat)) {
2535 destinationColumn =
qBound(column, destinationColumn, colCount - 1);
2536 destinationRow = row + dragRowCount;
2538 flat = (dragRowCount * dragColumnCount) + relativeColumn;
2539 isWrittenTo.
resize(++dragRowCount * dragColumnCount);
2541 if (!isWrittenTo.
testBit(flat)) {
2542 newIndexes[j] =
index(destinationRow, destinationColumn, parent);
2543 isWrittenTo.
setBit(flat);
2547 for(
int k = 0; k < newIndexes.size(); k++) {
2548 if (newIndexes.at(k).isValid())
2602 d->rowsAboutToBeInserted(parent, first, last);
2656 d->rowsAboutToBeRemoved(parent, first, last);
2686 if (destinationParent == srcParent)
2687 return !(destinationStart >= start && destinationStart <= end + 1);
2689 QModelIndex destinationAncestor = destinationParent;
2692 if (destinationAncestor == srcParent) {
2693 if (pos >= start && pos <= end)
2698 if (!destinationAncestor.
isValid())
2702 destinationAncestor = destinationAncestor.
parent();
2806 Q_ASSERT(sourceLast >= sourceFirst);
2810 if (!
d->allowMove(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild,
Qt::Vertical)) {
2815 sourceChange.
needsAdjust = sourceParent.
isValid() && sourceParent.
row() >= destinationChild && sourceParent.
parent() == destinationParent;
2816 d->changes.push(sourceChange);
2817 int destinationLast = destinationChild + (sourceLast - sourceFirst);
2819 destinationChange.needsAdjust = destinationParent.
isValid() && destinationParent.
row() >= sourceLast && destinationParent.
parent() == sourceParent;
2820 d->changes.push(destinationChange);
2824 d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild,
Qt::Vertical);
2851 const int numMoved = removeChange.
last - removeChange.
first + 1;
2912 d->columnsAboutToBeInserted(parent, first, last);
2967 d->columnsAboutToBeRemoved(parent, first, last);
3029 Q_ASSERT(sourceLast >= sourceFirst);
3033 if (!
d->allowMove(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild,
Qt::Horizontal)) {
3038 sourceChange.
needsAdjust = sourceParent.
isValid() && sourceParent.
row() >= destinationChild && sourceParent.
parent() == destinationParent;
3039 d->changes.push(sourceChange);
3040 int destinationLast = destinationChild + (sourceLast - sourceFirst);
3042 destinationChange.needsAdjust = destinationParent.
isValid() && destinationParent.
row() >= sourceLast && destinationParent.
parent() == sourceParent;
3043 d->changes.push(destinationChange);
3045 d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild,
Qt::Horizontal);
3075 const int numMoved = removeChange.
last - removeChange.
first + 1;
3099 d->invalidatePersistentIndexes();
3142 d->invalidatePersistentIndexes();
3159 if (
d->persistent.indexes.isEmpty())
3163 if (it !=
d->persistent.indexes.end()) {
3165 d->persistent.indexes.erase(it);
3168 d->persistent.insertMultiAtEnd(to, data);
3192 if (
d->persistent.indexes.isEmpty())
3196 for (
int i = 0; i < from.
count(); ++i) {
3197 if (from.
at(i) == to.
at(i))
3200 if (it !=
d->persistent.indexes.end()) {
3202 d->persistent.indexes.erase(it);
3205 toBeReinserted << data;
3214 d->persistent.insertMultiAtEnd(data->
index, data);
3231 it !=
d->persistent.indexes.constEnd(); ++
it) {
3518 return parent.
isValid() ? 0 : 1;
3556 if (parent.
isValid() && row == -1 && column == -1) {
3562 while (!stream.
atEnd()) {
3565 stream >> r >> c >> v;
3570 left =
qMin(c, left);
3573 for (
int i = 0; i < data.
size(); ++i) {
3574 int r = (rows.
at(i) - top) + parent.
row();
3584 return decodeData(row, column, parent, stream);
3607 if (parent.
isValid() && row == -1 && column == -1) {
3613 while (!stream.
atEnd()) {
3616 stream >> r >> c >> v;
3621 left =
qMin(c, left);
3624 for (
int i = 0; i < data.
size(); ++i) {
3625 int r = (rows.
at(i) - top) + parent.
row();
3637 return decodeData(row, column, parent, stream);
3701 indexes.insertMulti(key, data);
3703 while (it != indexes.end() && it.
key() ==
key) {
The QVariant class acts like a union for the most common Qt data types.
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QDebug class provides an output stream for debugging information.
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 ...
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
int row() const
Returns the row this persistent model index refers to.
virtual QSize span(const QModelIndex &index) const
Returns the row and column span of the item represented by index.
bool hasChildren(const QModelIndex &) const
Returns true if parent has any children; otherwise returns false.
void setData(const QString &mimetype, const QByteArray &data)
Sets the data associated with the MIME type given by mimeType to the specified data.
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
int columnCount(const QModelIndex &parent) const
Returns the number of columns in the list with the given parent.
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.
QModelIndexList persistentIndexList() const
Returns the list of indexes stored as persistent indexes in the model.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
void setBit(int i)
Sets the bit at index position i to 1.
#define QT_END_NAMESPACE
This macro expands to.
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...
void beginInsertColumns(const QModelIndex &parent, int first, int last)
Begins a column insertion operation.
The QRegExp class provides pattern matching using regular expressions.
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
QModelIndex index(int, int, const QModelIndex &) const
Returns the index of the item in the model specified by the given row, column and parent index...
static void destroy(QPersistentModelIndexData *data)
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
QModelIndex parent(const QModelIndex &) const
Returns the parent of the model item with the given index.
#define it(className, varName)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
void columnsRemoved(const QModelIndex &parent, int first, int last)
QDebug & nospace()
Clears the stream's internal flag that records whether the last character was a space and returns a r...
int column() const
Returns the column this persistent model index refers to.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
The QByteArray class provides an array of bytes.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns the index of the data in row and column with parent.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
void beginRemoveColumns(const QModelIndex &parent, int first, int last)
Begins a column removal operation.
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...
void columnsInserted(const QModelIndex &parent, int first, int last)
This signal is emitted after columns have been inserted into the model.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the role data for the item at index to value.
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 startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
virtual QStringList mimeTypes() const
Returns a list of MIME types that can be used to describe a list of model indexes.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
virtual Qt::DropActions supportedDropActions() const
Returns the drop actions supported by this model.
int rowCount(const QModelIndex &) const
Returns the number of rows under the given parent.
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.
QByteArray data(const QString &mimetype) const
Returns the data stored in the object in the format described by the MIME type specified by mimeType...
bool ref()
Atomically increments the value of this QAtomicInt.
void endInsertRows()
Ends a row insertion operation.
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.
static bool variantLessThan(const QVariant &v1, const QVariant &v2)
This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort.
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column or an invalid QModelIndex if there is no sibling at this positi...
void * internalPointer() const
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
bool allowMove(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation)
Returns whether a move operation is valid.
bool testBit(int i) const
Returns true if the bit at index position i is 1; otherwise returns false.
The QVector class is a template class that provides a dynamic array.
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.
void columnsInserted(const QModelIndex &parent, int first, int last)
virtual bool submit()
Lets the model know that it should submit cached information to permanent storage.
void endMoveRows()
Ends a row move operation.
bool decodeData(int row, int column, const QModelIndex &parent, QDataStream &stream)
void endResetModel()
Completes a model reset operation.
static uint typeOfVariant(const QVariant &value)
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void insertMultiAtEnd(const QModelIndex &key, QPersistentModelIndexData *data)
QHash::insertMulti insert the value before the old value.
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.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
QModelIndex index(int row, int column=0, const QModelIndex &parent=QModelIndex()) const
Returns the index of the data in row and column with parent.
QVariant data(const QModelIndex &, int) const
Returns the data stored under the given role for the item referred to by the index.
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to)
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list t...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
int columnCount(const QModelIndex &) const
Returns the number of columns for the children of the given parent.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
static QPersistentModelIndexData * create(const QModelIndex &index)
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
Sorts the model by column in the given order.
virtual Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the vector.
void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last)
This signal is emitted just before columns are inserted into the model.
bool beginMoveColumns(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn)
Begins a column move operation.
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
const QAbstractItemModel * model
void rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
This signal is emitted after rows have been moved within the model.
qint64 internalId() const
Returns a qint64 used by the model to associate the index with the internal data structure.
void layoutAboutToBeChanged()
This signal is emitted just before the layout of a model is changed.
~QAbstractTableModel()
Destroys the abstract table model.
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns true if parent has any children; otherwise returns false.
void resetInternalData()
This slot is called just after the internal data of a model is cleared while it is being reset...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented Function
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
This signal is emitted just before rows are inserted into the model.
const QAbstractItemModel * model() const
Returns the model that the index belongs to.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
int row() const
Returns the row this model index refers to.
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
const T & at(int i) const
Returns the item at index position i in the list.
Qt::DropActions supportedDragActions() const
Returns the actions supported by the data in this model.
bool deref()
Atomically decrements the value of this QAtomicInt.
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
The QStringList class provides a list of strings.
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 ...
void resize(int size)
Resizes the bit array to size bits.
void append(const T &t)
Inserts value at the end of the vector.
QPersistentModelIndexData()
void modelAboutToBeReset()
This signal is emitted when reset() is called, before the model's internal state (e.
QModelIndex parent() const
Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no pare...
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
virtual QModelIndex buddy(const QModelIndex &index) const
Returns a model index for the buddy of the item represented by index.
void encodeData(const QModelIndexList &indexes, QDataStream &stream) const
void removePersistentIndexData(QPersistentModelIndexData *data)
QPersistentModelIndexData * d
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const =0
Returns the data stored under the given role for the item referred to by the index.
void endRemoveRows()
Ends a row removal operation.
virtual bool canFetchMore(const QModelIndex &parent) const
Returns true if there is more data available for parent; otherwise returns false. ...
void layoutChanged()
This signal is emitted whenever the layout of items exposed by the model has changed; for example...
const Key & key() const
Returns the current item's key as a const reference.
The QMimeData class provides a container for data that records information about its MIME type...
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
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.
int localeAwareCompare(const QString &s) const
QPersistentModelIndex & operator=(const QPersistentModelIndex &other)
Sets the persistent model index to refer to the same item in a model as the other persistent model in...
qint64 internalId() const
void qSwap(T &value1, T &value2)
const T & at(int i) const
Returns the item at index position i in the vector.
The QAbstractItemModel class provides the abstract interface for item model classes.
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 valu...
friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &)
Qt::ItemFlags flags() const
Returns the flags for the item referred to by the index.
QAbstractTableModel(QObject *parent=0)
Constructs an abstract table model for the given parent.
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
The QBitArray class provides an array of bits.
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted just before columns are removed from the model.
virtual void fetchMore(const QModelIndex &parent)
Fetches any available data for the items with the parent specified by the parent index.
QModelIndex child(int row, int column) const
Returns the child of the model index that is stored in the given row and column.
virtual bool hasFormat(const QString &mimetype) const
Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns...
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
#define Q_ASSERT_X(cond, where, what)
int userType() const
Returns the storage type of the value stored in the variant.
const QHash< int, QByteArray > & roleNames() const
Returns the model's role names.
QAbstractListModel(QObject *parent=0)
Constructs an abstract list model with the given parent.
int compare(const QString &s) const
void changePersistentIndex(const QModelIndex &from, const QModelIndex &to)
Changes the QPersistentModelIndex that is equal to the given from model index to the given to model i...
void itemsAboutToBeMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last)
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.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
bool operator<(const QPersistentModelIndex &other) const
Returns true if this persistent model index is smaller than the other persistent model index; otherwi...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
bool operator!=(const QPersistentModelIndex &other) const
Returns true if this persistent model index is not equal to the other persistent model index; otherwi...
QEmptyItemModel(QObject *parent=0)
QObject * parent() const
Returns a pointer to the parent object.
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
The QModelIndex class is used to locate data in a data model.
void rowsInserted(const QModelIndex &parent, int first, int last)
Qt::ItemFlags flags() const
Returns the flags for the item referred to by the index.
virtual ~QAbstractItemModel()
Destroys the abstract item model.
void modelReset()
This signal is emitted when reset() is called, after the model's internal state (e.
void setSupportedDragActions(Qt::DropActions)
Sets the supported drag actions for the items in the model.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented Function
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...
void endInsertColumns()
Ends a column insertion operation.
bool hasChildren(const QModelIndex &parent) const
Returns true if parent has any children; otherwise returns false.
~QAbstractListModel()
Destroys the abstract list model.
QAbstractItemModel(QObject *parent=0)
Constructs an abstract item model with the given parent.
bool operator==(const QPersistentModelIndex &other) const
Returns true if this persistent model index is equal to the other persistent model index; otherwise r...
const T * const_iterator
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack...
The QSize class defines the size of a two-dimensional object using integer point precision.
The QDataStream class provides serialization of binary data to a QIODevice.
void setRoleNames(const QHash< int, QByteArray > &roleNames)
Sets the model's role names to roleNames.
void reserve(int size)
Attempts to allocate memory for at least size elements.
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
void itemsMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation)
void endMoveColumns()
Ends a column move operation.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
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.
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
virtual void revert()
Lets the model know that it should discard cached information.
QModelIndex child(int row, int column) const
Returns the child of the model index that is stored in the given row and column.
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.
int size() const
Returns the number of items in the vector.
bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow)
Begins a row move operation.
void columnsRemoved(const QModelIndex &parent, int first, int last)
This signal is emitted after columns have been removed from the model.
void beginResetModel()
Begins a model reset operation.
void rowsRemoved(const QModelIndex &parent, int first, int last)
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...
The QMap class is a template class that provides a skip-list-based dictionary.
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
qreal toReal(bool *ok=0) const
Returns the variant as a qreal if the variant has type() Double , QMetaType::Float ...
void reset()
Resets the model to its original state in any attached views.
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.
int column() const
Returns the column this model index refers to.
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.
void endRemoveColumns()
Ends a column removal operation.
bool hasChildren(const QModelIndex &parent) const
Returns true if parent has any children; otherwise returns false.
void movePersistentIndexes(QVector< QPersistentModelIndexData *> indexes, int change, const QModelIndex &parent, Qt::Orientation orientation)
Moves persistent indexes indexes by amount change.
#define forever
This macro is provided for convenience for writing infinite loops.