44 #ifndef QT_NO_STANDARDITEMMODEL 46 #include <QtCore/qdatetime.h> 47 #include <QtCore/qlist.h> 48 #include <QtCore/qmap.h> 49 #include <QtCore/qpair.h> 50 #include <QtCore/qvariant.h> 51 #include <QtCore/qvector.h> 52 #include <QtCore/qstringlist.h> 53 #include <QtCore/qbitarray.h> 54 #include <QtCore/qmimedata.h> 56 #include <private/qstandarditemmodel_p.h> 96 child->d_func()->setModel(0);
101 parent->d_func()->childDeleted(q_func());
110 int idx = par->d_func()->childIndex(q_func());
113 return QPair<int, int>(idx / par->columnCount(), idx % par->columnCount());
127 qWarning(
"QStandardItem::setChild: Can't make an item a child of itself %p",
131 if ((row < 0) || (column < 0))
134 q->setRowCount(row + 1);
135 if (columns <= column)
136 q->setColumnCount(column + 1);
137 int index = childIndex(row, column);
143 if (item->d_func()->
parent == 0) {
144 item->d_func()->setParentAndModel(q, model);
146 qWarning(
"QStandardItem::setChild: Ignoring duplicate insertion of item %p",
152 oldItem->d_func()->setModel(0);
154 children.replace(index, item);
155 if (emitChanged && model)
156 model->d_func()->itemChanged(item);
166 Qt::ItemFlags flags = q->flags();
179 int index = childIndex(child);
181 children.replace(index, 0);
194 for (it = roles.
begin(); it != roles.
end(); ++
it) {
207 model->d_func()->itemChanged(q);
219 result.
insert((*it).role, (*it).value);
229 if (column >= columnCount())
236 unsortable.
reserve(rowCount());
238 for (
int row = 0; row < rowCount(); ++row) {
254 QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo;
256 for (
int i = 0; i < rowCount(); ++i) {
257 int r = (i < sortable.
count()
258 ? sortable.
at(i).second
259 : unsortable.
at(i - sortable.
count()));
260 for (
int c = 0;
c < columnCount(); ++
c) {
262 sorted_children[childIndex(i,
c)] = itm;
265 if (model->d_func()->persistent.indexes.contains(from)) {
267 changedPersistentIndexesFrom.append(from);
268 changedPersistentIndexesTo.append(to);
274 children = sorted_children;
277 model->changePersistentIndexList(changedPersistentIndexesFrom, changedPersistentIndexesTo);
281 for (it = children.begin(); it != children.end(); ++
it) {
283 (*it)->d_func()->sortChildren(column, order);
293 if (children.isEmpty()) {
295 model->d_func()->invalidatePersistentIndex(model->indexFromItem(q_ptr));
302 if (itm->d_func()->
model) {
305 itm->d_func()->
model = mod;
307 for (
int i = 0; i < childList.
count(); ++i) {
355 for (
int row = topLeft.
row(); row <= bottomRight.
row(); ++row) {
356 for (
int column = topLeft.
column(); column <= bottomRight.
column(); ++column) {
359 emit q->itemChanged(item);
370 if ((row < 0) || (row > rowCount()))
372 int count = items.
count();
374 model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1);
375 if (rowCount() == 0) {
376 if (columnCount() == 0)
377 q->setColumnCount(1);
378 children.resize(columnCount() * count);
382 int index = childIndex(row, 0);
386 for (
int i = 0; i < items.
count(); ++i) {
388 item->d_func()->
model = model;
389 item->d_func()->
parent = q;
390 int index = childIndex(i + row, 0);
394 model->d_func()->rowsInserted(q, row, count);
401 if ((count < 1) || (row < 0) || (row > rowCount()))
404 model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1);
405 if (rowCount() == 0) {
406 children.resize(columnCount() * count);
410 int index = childIndex(row, 0);
415 int index = childIndex(row, 0);
416 int limit =
qMin(items.
count(), columnCount() * count);
417 for (
int i = 0; i < limit; ++i) {
420 if (item->d_func()->
parent == 0) {
421 item->d_func()->setParentAndModel(q, model);
423 qWarning(
"QStandardItem::insertRows: Ignoring duplicate insertion of item %p",
433 model->d_func()->rowsInserted(q, row, count);
443 if ((count < 1) || (column < 0) || (column > columnCount()))
446 model->d_func()->columnsAboutToBeInserted(q, column, column + count - 1);
447 if (columnCount() == 0) {
448 children.resize(rowCount() * count);
452 int index = childIndex(0, column);
453 for (
int row = 0; row < rowCount(); ++row) {
455 index += columnCount();
459 int limit =
qMin(items.
count(), rowCount() * count);
460 for (
int i = 0; i < limit; ++i) {
463 if (item->d_func()->
parent == 0) {
464 item->d_func()->setParentAndModel(q, model);
466 qWarning(
"QStandardItem::insertColumns: Ignoring duplicate insertion of item %p",
472 int c = column + (i % count);
473 int index = childIndex(r, c);
478 model->d_func()->columnsInserted(q, column, count);
488 if (item->d_func()->
parent == 0) {
501 emit q->dataChanged(index, index);
513 q->beginInsertRows(index, start, end);
524 q->beginInsertColumns(index, start, end);
535 q->beginRemoveRows(index, start, end);
546 q->beginRemoveColumns(index, start, end);
565 int column,
int count)
570 q->endInsertColumns();
581 for (
int i = row; i < row + count; ++i) {
584 oldItem->d_func()->setModel(0);
596 int column,
int count)
600 for (
int i = column; i < column + count; ++i) {
603 oldItem->d_func()->setModel(0);
608 q->endRemoveColumns();
776 d->values = other.d_func()->values;
796 if (!
d->model || (
d->model->d_func()->root.data() !=
d->parent))
819 for (it =
d->values.begin(); it !=
d->values.end(); ++
it) {
820 if ((*it).role == role) {
822 if ((*it).value.type() == value.
type() && (*it).value == value)
829 d->model->d_func()->itemChanged(
this);
835 d->model->d_func()->itemChanged(
this);
850 for (it =
d->values.begin(); it !=
d->values.end(); ++
it) {
851 if ((*it).role == role)
876 d->model->d_func()->itemChanged(
this);
908 return Qt::ItemFlags(v.
toInt());
1372 #ifndef QT_NO_DRAGANDDROP 1436 #endif // QT_NO_DRAGANDDROP 1479 return d->model ?
d->model->indexFromItem(
this) :
QModelIndex();
1521 return d->rowCount();
1549 return d->columnCount();
1565 d->insertRows(row, 1, items);
1578 d->insertRows(row, items);
1594 d->insertColumns(column, 1, items);
1729 if ((count < 1) || (row < 0) || ((row + count) >
rowCount()))
1732 d->model->d_func()->rowsAboutToBeRemoved(
this, row, row + count - 1);
1733 int i =
d->childIndex(row, 0);
1734 int n = count *
d->columnCount();
1735 for (
int j = i; j < n+i; ++j) {
1738 oldItem->d_func()->setModel(0);
1741 d->children.remove(
qMax(i, 0), n);
1744 d->model->d_func()->rowsRemoved(
this, row, count);
1756 if ((count < 1) || (column < 0) || ((column + count) >
columnCount()))
1759 d->model->d_func()->columnsAboutToBeRemoved(
this, column, column + count - 1);
1760 for (
int row =
d->rowCount() - 1;
row >= 0; --
row) {
1761 int i =
d->childIndex(
row, column);
1762 for (
int j=i; j<i+count; ++j) {
1765 oldItem->d_func()->setModel(0);
1768 d->children.remove(i, count);
1770 d->columns -= count;
1772 d->model->d_func()->columnsRemoved(
this, column, count);
1795 d->setChild(row, column, item,
true);
1814 int index =
d->childIndex(row, column);
1817 return d->children.at(index);
1834 int index =
d->childIndex(row, column);
1836 item =
d->children.at(index);
1838 item->d_func()->setParentAndModel(0, 0);
1839 d->children.replace(index, 0);
1854 if ((row < 0) || (row >=
rowCount()))
1857 d->model->d_func()->rowsAboutToBeRemoved(
this, row, row);
1859 int index =
d->childIndex(row, 0);
1861 int col_count =
d->columnCount();
1865 ch->d_func()->setParentAndModel(0, 0);
1868 d->children.remove(index, col_count);
1872 d->model->d_func()->rowsRemoved(
this, row, 1);
1889 d->model->d_func()->columnsAboutToBeRemoved(
this, column, column);
1892 for (
int row =
d->rowCount() - 1;
row >= 0; --
row) {
1896 ch->d_func()->setParentAndModel(0, 0);
1897 d->children.remove(index);
1902 d->model->d_func()->columnsRemoved(
this, column, 1);
1927 return l.
toInt() < r.toInt();
1929 return l.
toUInt() < r.toUInt();
1935 return l.
toFloat() < r.toFloat();
1937 return l.
toDouble() < r.toDouble();
1939 return l.
toChar() < r.toChar();
1941 return l.
toDate() < r.toDate();
1943 return l.
toTime() < r.toTime();
1964 if ((column < 0) || (
rowCount() == 0))
1967 emit d->model->layoutAboutToBeChanged();
1968 d->sortChildren(column, order);
1970 emit d->model->layoutChanged();
2000 #ifndef QT_NO_DATASTREAM 2068 #endif // QT_NO_DATASTREAM 2167 d->root->d_func()->setModel(
this);
2179 d->root->insertColumns(0, columns);
2180 d->columnHeaderItems.insert(0, columns, 0);
2181 d->root->insertRows(0, rows);
2182 d->rowHeaderItems.insert(0, rows, 0);
2183 d->root->d_func()->setModel(
this);
2213 d->root->d_func()->setModel(
this);
2215 d->columnHeaderItems.clear();
2217 d->rowHeaderItems.clear();
2246 if ((index.
row() < 0) || (index.
column() < 0) || (index.
model() !=
this))
2254 item =
d->createItem();
2277 if (item && item->d_func()->
parent) {
2299 d->root->setRowCount(rows);
2317 d->root->setColumnCount(columns);
2336 d->root->d_func()->setChild(row, column, item,
true);
2358 return d->root->child(row, column);
2380 return d->root.data();
2405 if (item == oldItem)
2409 if (item->
model() == 0) {
2410 item->d_func()->setModel(
this);
2412 qWarning(
"QStandardItem::setHorizontalHeaderItem: Ignoring duplicate insertion of item %p",
2419 oldItem->d_func()->setModel(0);
2422 d->columnHeaderItems.replace(column, item);
2442 return d->columnHeaderItems.at(column);
2467 if (item == oldItem)
2471 if (item->
model() == 0) {
2472 item->d_func()->setModel(
this);
2474 qWarning(
"QStandardItem::setVerticalHeaderItem: Ignoring duplicate insertion of item %p",
2481 oldItem->d_func()->setModel(0);
2484 d->rowHeaderItems.replace(row, item);
2502 if ((row < 0) || (row >=
rowCount()))
2504 return d->rowHeaderItems.at(row);
2523 for (
int i = 0; i < labels.
count(); ++i) {
2526 item =
d->createItem();
2549 for (
int i = 0; i < labels.
count(); ++i) {
2552 item =
d->createItem();
2580 if (
d->itemPrototype != item) {
2581 delete d->itemPrototype;
2582 d->itemPrototype =
item;
2601 return d->itemPrototype;
2614 Qt::MatchFlags
flags,
int column)
const 2619 for (
int i = 0; i < indexes.
size(); ++i)
2723 return d->root->takeChild(row, column);
2742 return d->root->takeRow(row);
2761 return d->root->takeColumn(column);
2783 headerItem->d_func()->setParentAndModel(0, 0);
2784 d->columnHeaderItems.replace(column, 0);
2804 if ((row < 0) || (row >=
rowCount()))
2808 headerItem->d_func()->setParentAndModel(0, 0);
2809 d->rowHeaderItems.replace(row, 0);
2864 if (!
d->indexValid(index))
2865 return d->root->flags();
2868 return item->
flags();
2899 headerItem =
d->columnHeaderItems.at(section);
2901 headerItem =
d->rowHeaderItems.at(section);
2902 return headerItem ? headerItem->
data(role)
2926 if ((parentItem == 0)
2976 if (!
d->indexValid(child))
2989 if ((item == 0) || (count < 1) || (column < 0) || ((column + count) > item->
columnCount()))
3002 if ((item == 0) || (count < 1) || (row < 0) || ((row + count) > item->
rowCount()))
3015 return item ? item->
rowCount() : 0;
3045 headerItem =
d->columnHeaderItems.at(section);
3046 if (headerItem == 0) {
3047 headerItem =
d->createItem();
3048 headerItem->d_func()->setModel(
this);
3049 d->columnHeaderItems.replace(section, headerItem);
3052 headerItem =
d->rowHeaderItems.at(section);
3053 if (headerItem == 0) {
3054 headerItem =
d->createItem();
3055 headerItem->d_func()->setModel(
this);
3056 d->rowHeaderItems.replace(section, headerItem);
3060 headerItem->
setData(value, role);
3074 item->d_func()->setItemData(roles);
3084 d->root->sortChildren(column, order);
3120 for (
int i = 0; i < indexes.
count(); ++i) {
3136 for (
int i = 0; i < childList.
count(); ++i) {
3140 if (it != itemsSet.
end()) {
3158 stream << item->
row() << item->
column();
3165 stream << dummy << 0 << 0;
3169 data->
setData(format, encoded);
3180 int colCount, childCount;
3182 stream >> colCount >> childCount;
3183 item->setColumnCount(colCount);
3185 int childPos = childCount;
3187 while(childPos > 0) {
3190 decodeDataRecursive(stream, child);
3191 item->setChild( childPos / colCount, childPos % colCount, child);
3232 while (!stream.
atEnd()) {
3236 d->decodeDataRecursive(stream, item);
3242 left =
qMin(c, left);
3243 bottom =
qMax(r, bottom);
3244 right =
qMax(c, right);
3249 int dragRowCount = 0;
3250 int dragColumnCount = right - left + 1;
3254 for (
int i = 0; i < rows.
count(); ++i)
3255 rowsToInsert[rows.
at(i)] = 1;
3256 for (
int i = 0; i < rowsToInsert.
count(); ++i) {
3257 if (rowsToInsert[i] == 1){
3258 rowsToInsert[i] = dragRowCount;
3262 for (
int i = 0; i < rows.
count(); ++i)
3263 rows[i] = top + rowsToInsert[rows[i]];
3265 QBitArray isWrittenTo(dragRowCount * dragColumnCount);
3269 if (colCount < dragColumnCount + column) {
3270 insertColumns(colCount, dragColumnCount + column - colCount, parent);
3276 column =
qMax(0, column);
3284 for (
int j = 0; j < items.
size(); ++j) {
3285 int relativeRow = rows.
at(j) - top;
3286 int relativeColumn = columns.
at(j) -
left;
3287 int destinationRow = relativeRow + row;
3288 int destinationColumn = relativeColumn + column;
3289 int flat = (relativeRow * dragColumnCount) + relativeColumn;
3291 if (destinationColumn >= colCount || isWrittenTo.
testBit(flat)) {
3292 destinationColumn =
qBound(column, destinationColumn, colCount - 1);
3293 destinationRow = row + dragRowCount;
3295 flat = (dragRowCount * dragColumnCount) + relativeColumn;
3296 isWrittenTo.
resize(++dragRowCount * dragColumnCount);
3298 if (!isWrittenTo.
testBit(flat)) {
3299 newIndexes[j] =
index(destinationRow, destinationColumn, parentItem->
index());
3300 isWrittenTo.
setBit(flat);
3304 for(
int k = 0; k < newIndexes.size(); k++) {
3305 if (newIndexes.at(k).isValid()) {
3306 parentItem->
setChild(newIndexes.at(k).row(), newIndexes.at(k).column(), items.
at(k));
3317 #include "moc_qstandarditemmodel.cpp" 3319 #endif // QT_NO_STANDARDITEMMODEL The QVariant class acts like a union for the most common Qt data types.
QStandardItem * verticalHeaderItem(int row) const
Returns the vertical header item for row row if one has been set; otherwise returns 0...
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 ...
QMimeData * mimeData(const QModelIndexList &indexes) const
Reimplemented Function
bool isCheckable() const
Returns whether the item is user-checkable.
void * internalPointer() const
Returns a void * pointer used by the model to associate the index with the internal data structure...
bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
void setData(const QString &mimetype, const QByteArray &data)
Sets the data associated with the MIME type given by mimeType to the specified data.
QStandardItem * horizontalHeaderItem(int column) const
Returns the horizontal header item for column if one has been set; otherwise returns 0...
QStandardItem * takeHorizontalHeaderItem(int column)
Removes the horizontal header item at column from the header without deleting it, and returns a point...
void removeRows(int row, int count)
Removes count rows at row row.
virtual ~QStandardItem()
Destructs the item.
QScopedPointer< QStandardItem > root
void appendRow(const QList< QStandardItem *> &items)
Appends a row containing items.
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.
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.
const QMap< int, QVariant > itemData() const
#define QT_END_NAMESPACE
This macro expands to.
virtual bool operator<(const QStandardItem &other) const
Returns true if this item is less than other; otherwise returns false.
void removeColumns(int column, int count)
Removes count columns at column column.
void setTristate(bool tristate)
Sets whether the item is tristate.
void rowsAboutToBeInserted(QStandardItem *parent, int start, int end)
void remove(int i)
Removes the element at index position i.
T * data() const
Returns the value of the pointer referenced by this object.
void setVerticalHeaderItem(int row, QStandardItem *item)
Sets the vertical header item for row to item.
QIcon icon() const
Returns the item's icon.
#define it(className, varName)
QStandardItemModel(QObject *parent=0)
Constructs a new item model with the given parent.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
~QStandardItemModel()
Destructs the model.
int columnCount() const
Returns the number of child item columns that the item has.
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
Reimplemented Function
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.
QStandardItem * item(int row, int column=0) const
Returns the item for the given row and column if one has been set; otherwise returns 0...
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
void setModel(QStandardItemModel *mod)
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
void setVerticalHeaderLabels(const QStringList &labels)
Sets the vertical header labels using labels.
void setRowCount(int rows)
Sets the number of child item rows to rows.
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. ...
Qt::DropActions supportedDropActions() const
QStandardItemModel supports both copy and move.
void insert(int i, const T &t)
Inserts value at index position i in the list.
virtual QStringList mimeTypes() const
Returns a list of MIME types that can be used to describe a list of model indexes.
int row() const
Returns the row where the item is located in its parent's child table, or -1 if the item has no paren...
void columnsAboutToBeRemoved(QStandardItem *parent, int start, int end)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QStandardItem * itemPrototype
QStandardItem * invisibleRootItem() const
Returns the model's invisible root item.
QStandardItem & operator=(const QStandardItem &other)
Assigns other's data and flags to this item.
The QStack class is a template class that provides a stack.
QStandardItemModelPrivate()
const Key & key() const
Returns the current item's key.
int count(const T &t) const
Returns the number of occurrences of value in the list.
bool hasChildren() const
Returns true if this item has any children; 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...
The QStandardItemModel class provides a generic model for storing custom data.
void insertRow(int row, const QList< QStandardItem *> &items)
Inserts a row at row containing items.
virtual int type() const
Returns the type of this item.
QVector< QStandardItem * > children
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
void insertRow(int row, const QList< QStandardItem *> &items)
Inserts a row at row containing items.
The QString class provides a Unicode character string.
void setChild(int row, int column, QStandardItem *item)
Sets the child item at (row, column) to item.
QList< QStandardItem * > takeColumn(int column)
Removes column without deleting the column items, and returns a list of pointers to the removed items...
bool testBit(int i) const
Returns true if the bit at index position i is 1; otherwise returns false.
The QObject class is the base class of all Qt objects.
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder)
Reimplemented Function
void rowsAboutToBeRemoved(QStandardItem *parent, int start, int end)
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 setIcon(const QIcon &icon)
Sets the item's icon to the icon specified.
void setSortRole(int role)
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)
void appendColumn(const QList< QStandardItem *> &items)
Appends a column containing items.
bool operator()(const QPair< QStandardItem *, int > &l, const QPair< QStandardItem *, int > &r) const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void setHorizontalHeaderItem(int column, QStandardItem *item)
Sets the horizontal header item for column to item.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
QStandardItem * takeVerticalHeaderItem(int row)
Removes the vertical header item at row from the header without deleting it, and returns a pointer to...
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
T pop()
Removes the top item from the stack and returns it.
virtual QStandardItem * clone() const
Returns a copy of this item.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the vector.
void setItem(int row, int column, QStandardItem *item)
Sets the item for the given row and column to item.
void columnsRemoved(QStandardItem *parent, int column, int count)
void append(const T &t)
Inserts value at the end of the list.
QList< QStandardItem * > takeRow(int row)
Removes the given row without deleting the row items, and returns a list of pointers to the removed i...
#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.
QPair< int, int > position() const
QVector< QStandardItem * > columnHeaderItems
void setEnabled(bool enabled)
Sets whether the item is enabled.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
int column() const
Returns the column where the item is located in its parent's child table, or -1 if the item has no pa...
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Reimplemented Function
bool contains(const T &value) const
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...
int columnCount(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
QStandardItemModelGreaterThan()
void childDeleted(QStandardItem *child)
bool operator()(const QPair< QStandardItem *, int > &l, const QPair< QStandardItem *, int > &r) const
bool insertColumns(int column, int count, const QList< QStandardItem *> &items)
Qt::ItemFlags flags(const QModelIndex &index) const
Reimplemented Function
int row() const
Returns the row this model index refers to.
int sortRole
the item role that is used to query the model's data when sorting items
void prepend(const T &t)
Inserts value at the beginning of the list.
const T & at(int i) const
Returns the item at index position i in the list.
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.
QString text() const
Returns the item's text.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented Function
void resize(int size)
Resizes the bit array to size bits.
bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles)
Reimplemented Function
void append(const T &t)
Inserts value at the end of the vector.
QStandardItem * takeItem(int row, int column=0)
Removes the item at (row, column) without deleting it.
bool insertRows(int row, int count, const QList< QStandardItem *> &items)
qulonglong toULongLong(bool *ok=0) const
Returns the variant as as an unsigned long long int if the variant has type() ULongLong ...
Q_CORE_EXPORT void qWarning(const char *,...)
const_iterator insert(const T &value)
void setSelectable(bool selectable)
Sets whether the item is selectable.
int rowCount(const QModelIndex &parent=QModelIndex()) const
Reimplemented Function
void setDragEnabled(bool dragEnabled)
Sets whether the item is drag enabled.
const QStandardItem * itemPrototype() const
Returns the item prototype used by the model.
QStandardItem()
Constructs an item.
virtual ~QStandardItemModelPrivate()
void setDropEnabled(bool dropEnabled)
Sets whether the item is drop enabled.
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the vector, searching forward from ind...
QStandardItem * itemFromIndex(const QModelIndex &index) const
Returns a pointer to the QStandardItem associated with the given index.
The QMimeData class provides a container for data that records information about its MIME type...
void replace(int i, const T &t)
Replaces the item at index position i with value.
QModelIndex index() const
Returns the QModelIndex associated with this item.
void _q_emitItemChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void push(const T &t)
Adds element t to the top of the stack.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QStringList mimeTypes() const
Reimplemented Function
const T & at(int i) const
Returns the item at index position i in the vector.
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
virtual void read(QDataStream &in)
Reads the item from stream in.
void setFlags(Qt::ItemFlags flags)
Sets the item flags for the item to flags.
The QAbstractItemModel class provides the abstract interface for item model classes.
QList< QStandardItem * > findItems(const QString &text, Qt::MatchFlags flags=Qt::MatchExactly, int column=0) const
Returns a list of items that match the given text, using the given flags, in the given column...
void appendRow(const QList< QStandardItem *> &items)
Appends a row containing items.
void qStableSort(RandomAccessIterator start, RandomAccessIterator end)
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
The QBitArray class provides an array of bits.
void columnsAboutToBeInserted(QStandardItem *parent, int start, int end)
void insert(int i, const T &t)
Inserts value at index position i in the vector.
virtual bool hasFormat(const QString &mimetype) const
Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns...
int rowCount() const
Returns the number of child item rows that the item has.
QDate toDate() const
Returns the variant as a QDate if the variant has type() Date , DateTime , or String ; otherwise retu...
void setCheckable(bool checkable)
Sets whether the item is user-checkable.
QDataStream & operator<<(QDataStream &out, const QStandardItem &item)
Writes the QStandardItem item to stream out.
The QMap::const_iterator class provides an STL-style const iterator for QMap and QMultiMap.
void removeRow(int row)
Removes the given row.
int userType() const
Returns the storage type of the value stored in the variant.
QVector< QStandardItem * > rowHeaderItems
int compare(const QString &s) const
void itemChanged(QStandardItem *item)
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
void appendColumn(const QList< QStandardItem *> &items)
Appends a column containing items.
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
void setItemPrototype(const QStandardItem *item)
Sets the item prototype for the model to the specified item.
QDataStream & operator>>(QDataStream &in, QStandardItem &item)
Reads a QStandardItem from stream in into item.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
void sortChildren(int column, Qt::SortOrder order=Qt::AscendingOrder)
Sorts the children of the item using the given order, by the values in the given column.
void rowsRemoved(QStandardItem *parent, int row, int count)
Type type() const
Returns the storage type of the value stored in the variant.
virtual QVariant data(int role=Qt::UserRole+1) const
Returns the item's data for the given role, or an invalid QVariant if there is no data for the role...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
void insertColumn(int column, const QList< QStandardItem *> &items)
Inserts a column at column containing items.
QObject * parent() const
Returns a pointer to the parent object.
QModelIndex indexFromItem(const QStandardItem *item) const
Returns the QModelIndex associated with the given item.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
The QModelIndex class is used to locate data in a data model.
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
int size() const
Returns the number of items in the list.
QStandardItemModelLessThan()
Qt::ItemFlags flags() const
Returns the item flags for the item.
float toFloat(bool *ok=0) const
Returns the variant as a float if the variant has type() Double , QMetaType::Float ...
QList< QStandardItem * > takeRow(int row)
Removes row without deleting the row items, and returns a list of pointers to the removed items...
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Reimplemented Function
QMap< int, QVariant > itemData(const QModelIndex &index) const
Reimplemented Function
void rowsInserted(QStandardItem *parent, int row, int count)
const T & value() const
Returns the current item's value.
void setChild(int row, int column, QStandardItem *item, bool emitChanged=false)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Reimplemented Function
void sortChildren(int column, Qt::SortOrder order)
void changeFlags(bool enable, Qt::ItemFlags f)
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex())
Reimplemented Function
virtual ~QStandardItemPrivate()
void setItemData(const QMap< int, QVariant > &roles)
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
QStandardItemModel * model() const
Returns the QStandardItemModel that this item belongs to.
void setColumnCount(int columns)
Sets the number of columns in this model to columns.
void setColumnCount(int columns)
Sets the number of child item columns to columns.
const T * const_iterator
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack...
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
void setEditable(bool editable)
Sets whether the item is editable.
The QDataStream class provides serialization of binary data to a QIODevice.
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
void reserve(int size)
Attempts to allocate memory for at least size elements.
The QStandardItem class provides an item for use with the QStandardItemModel class.
void setText(const QString &text)
Sets the item's text to the text specified.
QList< QStandardItem * > takeColumn(int column)
Removes the given column without deleting the column items, and returns a list of pointers to the rem...
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
void setHorizontalHeaderLabels(const QStringList &labels)
Sets the horizontal header labels using labels.
static const KeyPair *const end
iterator erase(iterator i)
void clear()
Removes all items (including header items) from the model and sets the number of rows and columns to ...
void removeColumn(int column)
Removes the given column.
QChar toChar() const
Returns the variant as a QChar if the variant has type() Char , Int , or UInt ; otherwise returns an ...
void insertColumn(int column, const QList< QStandardItem *> &items)
Inserts a column at column containing items.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item's data for the given role to the specified value.
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
int size() const
Returns the number of items in the vector.
void decodeDataRecursive(QDataStream &stream, QStandardItem *item)
void insertColumns(int column, int count)
Inserts count columns of child items at column column.
void setRowCount(int rows)
Sets the number of rows in this model to rows.
QScopedPointer< QStandardItemPrivate > d_ptr
void insertRows(int row, const QList< QStandardItem *> &items)
Inserts items at row.
iterator find(const T &value)
void columnsInserted(QStandardItem *parent, int column, int count)
The QMap class is a template class that provides a skip-list-based dictionary.
virtual void write(QDataStream &out) const
Writes the item to stream out.
QStandardItem * itemFromIndex(const QModelIndex &index) const
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
void reset()
Resets the model to its original state in any attached views.
int column() const
Returns the column this model index refers to.
QStandardItem * child(int row, int column=0) const
Returns the child item at (row, column) if one has been set; otherwise returns 0. ...
QStandardItem * takeChild(int row, int column=0)
Removes the child item at (row, column) without deleting it, and returns a pointer to the item...
QStandardItem * parent() const
Returns the item's parent item, or 0 if the item has no parent.
void emitDataChanged()
Causes the model associated with this item to emit a dataChanged() signal for this item...
The QIcon class provides scalable icons in different modes and states.