6#include <QtCore/qdatetime.h>
7#include <QtCore/qlist.h>
8#include <QtCore/qmap.h>
9#include <QtCore/qpair.h>
10#include <QtCore/qvariant.h>
11#include <QtCore/qstringlist.h>
12#include <QtCore/qbitarray.h>
13#include <QtCore/qmimedata.h>
14#include <QtCore/qiodevice.h>
15#include <private/qduplicatetracker_p.h>
16#include <private/qstandarditemmodel_p.h>
36 return *(l.first) < *(
r.first);
49 return *(
r.first) < *(l.first);
59 int idx = par->d_func()->childIndex(q_func());
62 return QPair<int, int>(idx / par->columnCount(), idx % par->columnCount());
76 qWarning(
"QStandardItem::setChild: Can't make an item a child of itself %p",
83 q->setRowCount(
row + 1);
92 if (
model && emitChanged) {
97 if (
item->d_func()->parent ==
nullptr) {
100 qWarning(
"QStandardItem::setChild: Ignoring duplicate insertion of item %p",
107 if (!
item && oldItem)
108 oldItem->d_func()->setModel(
nullptr);
115 oldItem->d_func()->setModel(
nullptr);
121 if (
model && emitChanged)
124 if (emitChanged &&
model) {
141 Qt::ItemFlags
flags =
q->flags();
156 const auto modelIndex =
child->index();
163 struct ByNormalizedRole
165 static int normalizedRole(
int role)
170 bool operator()(
const QStandardItemData& standardItemData,
const std::pair<const int &, const QVariant&>& roleMapIt)
const
172 return standardItemData.
role < normalizedRole(roleMapIt.first);
174 bool operator()(
const std::pair<const int&, const QVariant &>& roleMapIt,
const QStandardItemData& standardItemData)
const
176 return normalizedRole(roleMapIt.first) < standardItemData.
role;
186 template<
class Input,
class OutputIt>
187 OutputIt roleMapStandardItemDataTransform(
Input first1,
Input last1, OutputIt d_first)
189 while (first1 != last1) {
190 if ((*first1).second.isValid())
203 template<
class Input1,
class Input2,
205 OutputIt roleMapStandardItemDataUnion(Input1 first1, Input1 last1,
206 Input2 first2, Input2 last2,
207 OutputIt d_first, Compare comp)
209 for (; first1 != last1; ++d_first) {
210 if (first2 == last2) {
211 return roleMapStandardItemDataTransform(first1, last1, d_first);
213 if (comp(*first2, *first1)) {
214 *d_first = *first2++;
216 if ((*first1).second.isValid())
218 if (!comp(*first1, *first2))
223 return std::copy(first2, last2, d_first);
235 return item1.
role < item2.role;
250 std::back_inserter(newValues), ByNormalizedRole());
252 if (newValues !=
values) {
257 bool hasEditRole =
false;
258 bool hasDisplayRole =
false;
264 hasDisplayRole =
true;
266 if (hasEditRole && !hasDisplayRole)
268 else if (!hasEditRole && hasDisplayRole)
314 std::stable_sort(sortable.
begin(), sortable.
end(), lt);
317 std::stable_sort(sortable.
begin(), sortable.
end(), gt);
320 QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo;
323 int r = (
i < sortable.
size()
324 ? sortable.
at(
i).second
325 : unsortable.
at(
i - sortable.
size()));
331 if (
model->d_func()->persistent.indexes.contains(from)) {
333 changedPersistentIndexesFrom.
append(from);
334 changedPersistentIndexesTo.
append(to);
368 if (itm->d_func()->
model) {
371 itm->d_func()->
model = mod;
373 for (
int i = 0;
i < childList.
size(); ++
i) {
439 q->setColumnCount(1);
451 item->d_func()->parent =
q;
484 if (
item->d_func()->parent ==
nullptr) {
487 qWarning(
"QStandardItem::insertRows: Ignoring duplicate insertion of item %p",
529 if (
item->d_func()->parent ==
nullptr) {
532 qWarning(
"QStandardItem::insertColumns: Ignoring duplicate insertion of item %p",
557 if (
item->d_func()->parent ==
nullptr) {
639 q->endInsertColumns();
653 oldItem->d_func()->setModel(
nullptr);
672 oldItem->d_func()->setModel(
nullptr);
677 q->endRemoveColumns();
831 d->values =
other.d_func()->values;
844 child->d_func()->setModel(
nullptr);
848 if (
d->parent &&
d->model)
849 d->parent->d_func()->childDeleted(
this);
862 if (!
d->model || (
d->model->d_func()->root.data() !=
d->parent))
887 for (
auto it =
d->values.begin();
it !=
d->values.end(); ++
it) {
888 if ((*it).role == role) {
889 if (
value.isValid()) {
890 if ((*it).value.userType() ==
value.userType() && (*it).value ==
value)
899 d->model->d_func()->itemChanged(
this, roles);
905 d->model->d_func()->itemChanged(
this, roles);
916 if (
d->values.isEmpty())
920 d->model->d_func()->itemChanged(
this,
QList<int>{});
934 for (
const auto &
value :
d->values) {
973 d->model->d_func()->itemChanged(
this);
1005 return Qt::ItemFlags(
v.toInt());
1405#if QT_CONFIG(draganddrop)
1416void QStandardItem::setDragEnabled(
bool dragEnabled)
1446void QStandardItem::setDropEnabled(
bool dropEnabled)
1506 return d->model ?
d->model->indexFromItem(
this) :
QModelIndex();
1548 return d->rowCount();
1576 return d->columnCount();
1753 d->model->d_func()->rowsAboutToBeRemoved(
this,
row,
row +
count - 1);
1754 int i =
d->childIndex(
row, 0);
1755 int n =
count *
d->columnCount();
1756 for (
int j =
i;
j <
n+
i; ++
j) {
1759 oldItem->d_func()->setModel(
nullptr);
1762 d->children.remove(
qMax(
i, 0),
n);
1765 d->model->d_func()->rowsRemoved(
this,
row,
count);
1781 for (
int row =
d->rowCount() - 1;
row >= 0; --
row) {
1786 oldItem->d_func()->setModel(
nullptr);
1793 d->model->d_func()->columnsRemoved(
this,
column,
count);
1840 return d->children.at(
index);
1861 if (
item &&
d->model) {
1863 const int savedRows = item_d->
rows;
1864 const int savedCols = item_d->
columns;
1866 if (savedRows > 0) {
1867 d->model->d_func()->rowsAboutToBeRemoved(
item, 0, savedRows - 1);
1870 d->model->d_func()->rowsRemoved(
item, 0, savedRows);
1872 if (savedCols > 0) {
1873 d->model->d_func()->columnsAboutToBeRemoved(
item, 0, savedCols - 1);
1877 d->model->d_func()->columnsRemoved(
item, 0, savedCols);
1879 item_d->
rows = savedRows;
1882 changedIdx =
d->model->indexFromItem(
item);
1885 d->children.replace(
index,
nullptr);
1887 d->model->dataChanged(changedIdx, changedIdx);
1906 d->model->d_func()->rowsAboutToBeRemoved(
this,
row,
row);
1910 int col_count =
d->columnCount();
1915 ch->d_func()->setParentAndModel(
nullptr,
nullptr);
1918 d->children.remove(
index, col_count);
1922 d->model->d_func()->rowsRemoved(
this,
row, 1);
1940 d->model->d_func()->columnsAboutToBeRemoved(
this,
column,
column);
1948 ch->d_func()->setParentAndModel(
nullptr,
nullptr);
1949 d->children.remove(
index);
1954 d->model->d_func()->columnsRemoved(
this,
column, 1);
2029#ifndef QT_NO_DATASTREAM
2188 d->root->d_func()->setModel(
this);
2200 d->root->insertColumns(0, columns);
2201 d->columnHeaderItems.insert(0, columns,
nullptr);
2202 d->root->insertRows(0, rows);
2203 d->rowHeaderItems.insert(0, rows,
nullptr);
2204 d->root->d_func()->setModel(
this);
2223 delete d->itemPrototype;
2244 return d->roleNames;
2259 d->root->d_func()->setModel(
this);
2261 d->columnHeaderItems.clear();
2263 d->rowHeaderItems.clear();
2289 if ((
index.row() < 0) || (
index.column() < 0) || (
index.model() !=
this))
2296 if (
item ==
nullptr) {
2297 item =
d->createItem();
2317 if (
item &&
item->d_func()->parent) {
2336 d->root->setRowCount(rows);
2351 d->root->setColumnCount(columns);
2405 return d->root.data();
2427 if (
item == oldItem)
2431 if (
item->model() ==
nullptr) {
2432 item->d_func()->setModel(
this);
2434 qWarning(
"QStandardItem::setHorizontalHeaderItem: Ignoring duplicate insertion of item %p",
2441 oldItem->d_func()->setModel(
nullptr);
2461 return d->columnHeaderItems.at(
column);
2483 if (
item == oldItem)
2487 if (
item->model() ==
nullptr) {
2488 item->d_func()->setModel(
this);
2490 qWarning(
"QStandardItem::setVerticalHeaderItem: Ignoring duplicate insertion of item %p",
2497 oldItem->d_func()->setModel(
nullptr);
2500 d->rowHeaderItems.replace(
row,
item);
2517 return d->rowHeaderItems.at(
row);
2533 for (
int i = 0;
i < labels.size(); ++
i) {
2536 item =
d->createItem();
2539 item->setText(labels.at(
i));
2556 for (
int i = 0;
i < labels.size(); ++
i) {
2559 item =
d->createItem();
2562 item->setText(labels.at(
i));
2584 if (
d->itemPrototype !=
item) {
2585 delete d->itemPrototype;
2586 d->itemPrototype =
item;
2602 return d->itemPrototype;
2617 const int numIndexes = indexes.
size();
2619 for (
int i = 0;
i < numIndexes; ++
i)
2724 return d->root->takeRow(
row);
2740 return d->root->takeColumn(
column);
2759 headerItem->d_func()->setParentAndModel(
nullptr,
nullptr);
2760 d->columnHeaderItems.replace(
column,
nullptr);
2781 headerItem->d_func()->setParentAndModel(
nullptr,
nullptr);
2782 d->rowHeaderItems.replace(
row,
nullptr);
2811 return &
d->sortRole;
2821 return item ?
item->columnCount() : 0;
2852 if (!
d->indexValid(
index))
2853 return d->root->flags();
2871 return item ?
item->hasChildren() :
false;
2887 headerItem =
d->columnHeaderItems.at(section);
2889 headerItem =
d->rowHeaderItems.at(section);
2890 return headerItem ? headerItem->
data(role)
2911 if ((parentItem ==
nullptr)
2928 if (
item ==
nullptr)
2940 if (
item ==
nullptr)
2954 return item->d_func()->itemData();
2963 if (!
d->indexValid(
child))
3002 return item ?
item->rowCount() : 0;
3010 if (!
index.isValid())
3013 if (
item ==
nullptr)
3047 headerItem =
d->columnHeaderItems.at(section);
3048 if (headerItem ==
nullptr) {
3049 headerItem =
d->createItem();
3050 headerItem->d_func()->setModel(
this);
3051 d->columnHeaderItems.replace(section, headerItem);
3054 headerItem =
d->rowHeaderItems.at(section);
3055 if (headerItem ==
nullptr) {
3056 headerItem =
d->createItem();
3057 headerItem->d_func()->setModel(
this);
3058 d->rowHeaderItems.replace(section, headerItem);
3074 if (
item ==
nullptr)
3076 item->d_func()->setItemData(roles);
3116 for (
int i = 0;
i < indexes.
size(); ++
i) {
3121 qWarning(
"QStandardItemModel::mimeData: No item associated with invalid index");
3135 for (
int i = 0;
i < childList.
size(); ++
i) {
3170 int colCount, childCount;
3172 stream >> colCount >> childCount;
3173 item->setColumnCount(colCount);
3175 int childPos = childCount;
3177 while(childPos > 0) {
3181 item->setChild( childPos / colCount, childPos % colCount,
child);
3222 while (!
stream.atEnd()) {
3239 int dragRowCount = 0;
3244 for (
int i = 0;
i < rows.
size(); ++
i)
3245 rowsToInsert[rows.
at(
i)] = 1;
3246 for (
int i = 0;
i < rowsToInsert.
size(); ++
i) {
3247 if (rowsToInsert.
at(
i) == 1){
3248 rowsToInsert[
i] = dragRowCount;
3252 for (
int i = 0;
i < rows.
size(); ++
i)
3253 rows[
i] =
top + rowsToInsert.
at(rows.
at(
i));
3255 QBitArray isWrittenTo(dragRowCount * dragColumnCount);
3259 if (colCount < dragColumnCount +
column) {
3275 int relativeRow = rows.
at(
j) -
top;
3276 int relativeColumn = columns.
at(
j) -
left;
3277 int destinationRow = relativeRow +
row;
3278 int destinationColumn = relativeColumn +
column;
3279 int flat = (relativeRow * dragColumnCount) + relativeColumn;
3281 if (destinationColumn >= colCount || isWrittenTo.
testBit(flat)) {
3282 destinationColumn =
qBound(
column, destinationColumn, colCount - 1);
3283 destinationRow =
row + dragRowCount;
3285 flat = (dragRowCount * dragColumnCount) + relativeColumn;
3286 isWrittenTo.
resize(++dragRowCount * dragColumnCount);
3288 if (!isWrittenTo.
testBit(flat)) {
3289 newIndexes[
j] =
index(destinationRow, destinationColumn, parentItem->
index());
3290 isWrittenTo.
setBit(flat);
3294 for(
int k = 0; k < newIndexes.
size(); k++) {
3295 if (newIndexes.
at(k).isValid()) {
3307#include "moc_qstandarditemmodel.cpp"
static const QHash< int, QByteArray > & defaultRoleNames()
static bool isVariantLessThan(const QVariant &left, const QVariant &right, Qt::CaseSensitivity cs=Qt::CaseSensitive, bool isLocaleAware=false)
void endResetModel()
Completes a model reset operation.
virtual Q_INVOKABLE 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 ...
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before rows are inserted into the model.
virtual Q_INVOKABLE 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.
void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before columns are inserted into the model.
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to)
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.
void layoutAboutToBeChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This signal is emitted whenever the data in an existing item changes.
virtual QMimeData * mimeData(const QModelIndexList &indexes) const
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
bool checkIndex(const QModelIndex &index, CheckIndexOptions options=CheckIndexOption::NoOption) const
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
void beginResetModel()
Begins a model reset operation.
void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been inserted into the model.
virtual QStringList mimeTypes() const
Returns the list of allowed MIME types.
QModelIndex createIndex(int row, int column, const void *data=nullptr) const
Creates a model index for the given row and column with the internal pointer ptr.
void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been inserted into the model.
virtual void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const
bool testBit(qsizetype i) const
Returns true if the bit at index position i is 1; otherwise returns false.
void resize(qsizetype size)
Resizes the bit array to size bits.
void setBit(qsizetype i)
Sets the bit at index position i to 1.
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
\inmodule QtCore\reentrant
QList< QGraphicsItem * > children
void setData(int key, const QVariant &value)
Sets this item's custom data for the key key to value.
QScopedPointer< QGraphicsItemPrivate > d_ptr
QVariant data(int key) const
Returns this item's custom data for the key key as a QVariant.
GraphicsItemFlags flags() const
Returns this item's flags.
The QIcon class provides scalable icons in different modes and states.
qsizetype size() const noexcept
bool isEmpty() const noexcept
iterator insert(qsizetype i, parameter_type t)
void push_back(parameter_type t)
const_reference at(qsizetype i) const noexcept
void remove(qsizetype i, qsizetype n=1)
void prepend(rvalue_ref t)
void reserve(qsizetype size)
void replace(qsizetype i, parameter_type t)
void resize(qsizetype size)
void append(parameter_type t)
key_value_iterator keyValueEnd()
key_iterator keyBegin() const
key_value_iterator keyValueBegin()
key_iterator keyEnd() const
constexpr int row() const noexcept
Returns the row this model index refers to.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr int column() const noexcept
Returns the column this model index refers to.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
T * data() const noexcept
Returns the value of the pointer referenced by this object.
bool remove(const T &value)
void reserve(qsizetype size)
bool contains(const T &value) const
T pop()
Removes the top item from the stack and returns it.
void push(const T &t)
Adds element t to the top of the stack.
QStandardItemModelGreaterThan()
bool operator()(const QPair< QStandardItem *, int > &l, const QPair< QStandardItem *, int > &r) const
bool operator()(const QPair< QStandardItem *, int > &l, const QPair< QStandardItem *, int > &r) const
QStandardItemModelLessThan()
QList< QStandardItem * > rowHeaderItems
void rowsAboutToBeRemoved(QStandardItem *parent, int start, int end)
QStandardItem * createItem() const
void columnsAboutToBeRemoved(QStandardItem *parent, int start, int end)
void columnsRemoved(QStandardItem *parent, int column, int count)
~QStandardItemModelPrivate()
QStandardItem * itemFromIndex(const QModelIndex &index) const
void columnsInserted(QStandardItem *parent, int column, int count)
void columnsAboutToBeInserted(QStandardItem *parent, int start, int end)
QStandardItemModelPrivate()
void itemChanged(QStandardItem *item, const QList< int > &roles=QList< int >())
void decodeDataRecursive(QDataStream &stream, QStandardItem *item)
QHash< int, QByteArray > roleNames
void rowsAboutToBeInserted(QStandardItem *parent, int start, int end)
void _q_emitItemChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void rowsRemoved(QStandardItem *parent, int row, int count)
QScopedPointer< QStandardItem > root
QList< QStandardItem * > columnHeaderItems
void rowsInserted(QStandardItem *parent, int row, int count)
The QStandardItemModel class provides a generic model for storing custom data.
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
QList< QStandardItem * > takeRow(int row)
~QStandardItemModel()
Destructs the model.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
\reimp
bool clearItemData(const QModelIndex &index) override
\reimp
void setRowCount(int rows)
void clear()
Removes all items (including header items) from the model and sets the number of rows and columns to ...
QList< QStandardItem * > takeColumn(int column)
void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const override
\reimp
void insertRow(int row, const QList< QStandardItem * > &items)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
QStringList mimeTypes() const override
\reimp
QMap< int, QVariant > itemData(const QModelIndex &index) const override
\reimp
QStandardItem * takeVerticalHeaderItem(int row)
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
\reimp
void setHorizontalHeaderLabels(const QStringList &labels)
void itemChanged(QStandardItem *item)
void insertColumn(int column, const QList< QStandardItem * > &items)
QObject * parent() const
Returns a pointer to the parent object.
QMimeData * mimeData(const QModelIndexList &indexes) const override
\reimp
QBindable< int > bindableSortRole()
const QStandardItem * itemPrototype() const
QStandardItem * item(int row, int column=0) const
int sortRole
the item role that is used to query the model's data when sorting items
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
QList< QStandardItem * > findItems(const QString &text, Qt::MatchFlags flags=Qt::MatchExactly, int column=0) const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
\reimp
void appendRow(const QList< QStandardItem * > &items)
bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles) override
\reimp
void setItemRoleNames(const QHash< int, QByteArray > &roleNames)
Sets the item role names to roleNames.
void setItem(int row, int column, QStandardItem *item)
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
\reimp
void setSortRole(int role)
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
\reimp
QStandardItem * takeHorizontalHeaderItem(int column)
QHash< int, QByteArray > roleNames() const override
reimp
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
Qt::ItemFlags flags(const QModelIndex &index) const override
\reimp
QStandardItemModel(QObject *parent=nullptr)
Constructs a new item model with the given parent.
QModelIndex indexFromItem(const QStandardItem *item) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
\reimp
int rowCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
QStandardItem * verticalHeaderItem(int row) const
QStandardItem * takeItem(int row, int column=0)
void setVerticalHeaderItem(int row, QStandardItem *item)
void setColumnCount(int columns)
Qt::DropActions supportedDropActions() const override
\reimp
void appendColumn(const QList< QStandardItem * > &items)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
QStandardItem * invisibleRootItem() const
QStandardItem * itemFromIndex(const QModelIndex &index) const
void setItemPrototype(const QStandardItem *item)
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) override
\reimp
void setHorizontalHeaderItem(int column, QStandardItem *item)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
\reimp
QStandardItem * horizontalHeaderItem(int column) const
void setVerticalHeaderLabels(const QStringList &labels)
void setModel(QStandardItemModel *mod)
bool insertColumns(int column, int count, const QList< QStandardItem * > &items)
QList< QStandardItemData > values
QPair< int, int > position() const
void setItemData(const QMap< int, QVariant > &roles)
int childIndex(int row, int column) const
void setChild(int row, int column, QStandardItem *item, bool emitChanged=false)
QMap< int, QVariant > itemData() const
void childDeleted(QStandardItem *child)
void setParentAndModel(QStandardItem *par, QStandardItemModel *mod)
bool insertRows(int row, int count, const QList< QStandardItem * > &items)
QStandardItemModel * model
void sortChildren(int column, Qt::SortOrder order)
QList< QStandardItem * > children
void changeFlags(bool enable, Qt::ItemFlags f)
The QStandardItem class provides an item for use with the QStandardItemModel class.
QStandardItem * child(int row, int column=0) const
Returns the child item at (row, column) if one has been set; otherwise returns \nullptr.
Qt::ItemFlags flags() const
Returns the item flags for the item.
void setText(const QString &text)
Sets the item's text to the text specified.
void insertColumns(int column, int count)
Inserts count columns of child items at column column.
void insertRows(int row, const QList< QStandardItem * > &items)
Inserts items at row.
void setEnabled(bool enabled)
Sets whether the item is enabled.
QDataStream & operator<<(QDataStream &out, const QStandardItem &item)
virtual void setData(const QVariant &value, int role=Qt::UserRole+1)
Sets the item's data for the given role to the specified value.
bool isCheckable() const
Returns whether the item is user-checkable.
int rowCount() const
Returns the number of child item rows that the item has.
void setUserTristate(bool tristate)
Sets whether the item is tristate and controlled by the user.
void setIcon(const QIcon &icon)
Sets the item's icon to the icon specified.
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.
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.
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...
QIcon icon() const
Returns the item's icon.
void setColumnCount(int columns)
Sets the number of child item columns to columns.
void removeColumns(int column, int count)
Removes count columns at column column.
QStandardItem * parent() const
Returns the item's parent item, or \nullptr if the item has no parent.
void setRowCount(int rows)
Sets the number of child item rows to rows.
virtual void multiData(QModelRoleDataSpan roleDataSpan) const
void setEditable(bool editable)
Sets whether the item is editable.
void insertColumn(int column, const QList< QStandardItem * > &items)
Inserts a column at column containing items.
void removeColumn(int column)
Removes the given column.
virtual bool operator<(const QStandardItem &other) const
Returns true if this item is less than other; otherwise returns false.
void setChild(int row, int column, QStandardItem *item)
Sets the child item at (row, column) to item.
QStandardItem()
Constructs an item.
QList< QStandardItem * > takeRow(int row)
Removes row without deleting the row items, and returns a list of pointers to the removed items.
QString text() const
Returns the item's text.
void setCheckable(bool checkable)
Sets whether the item is user-checkable.
virtual void read(QDataStream &in)
Reads the item from stream in.
QDataStream & operator>>(QDataStream &in, QStandardItem &item)
QStandardItem & operator=(const QStandardItem &other)
Assigns other's data and flags to this item.
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...
int columnCount() const
Returns the number of child item columns that the item has.
QStandardItem * takeChild(int row, int column=0)
Removes the child item at (row, column) without deleting it, and returns a pointer to the item.
void removeRows(int row, int count)
Removes count rows at row row.
QList< QStandardItem * > takeColumn(int column)
Removes column without deleting the column items, and returns a list of pointers to the removed items...
virtual ~QStandardItem()
Destructs the item.
void setFlags(Qt::ItemFlags flags)
Sets the item flags for the item to flags.
void appendColumn(const QList< QStandardItem * > &items)
Appends a column containing items.
virtual void write(QDataStream &out) const
Writes the item to stream out.
void removeRow(int row)
Removes the given row.
void setSelectable(bool selectable)
Sets whether the item is selectable.
void appendRow(const QList< QStandardItem * > &items)
Appends a row containing items.
virtual int type() const
Returns the type of this item.
QModelIndex index() const
Returns the QModelIndex associated with this item.
virtual QStandardItem * clone() const
Returns a copy of this item.
QStandardItemModel * model() const
Returns the QStandardItemModel that this item belongs to.
bool hasChildren() const
Returns true if this item has any children; otherwise returns false.
void setAutoTristate(bool tristate)
Determines that the item is tristate and controlled by QTreeWidget if tristate is true.
void insertRow(int row, const QList< QStandardItem * > &items)
Inserts a row at row containing items.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
std::pair< T1, T2 > QPair
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLfixed GLfixed GLint GLint order
static QT_BEGIN_NAMESPACE QString qStandardItemModelDataListMimeType()
#define QStringLiteral(str)
QTextStream out(stdout)
[7]
std::array< QModelRoleData, 3 > roleData
[13]
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
virtual HRESULT STDMETHODCALLTYPE Compare(__RPC__in_opt ITextRangeProvider *range, __RPC__out BOOL *pRetVal)=0