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>
38 inline bool operator()(
const QPair<QStandardItem*, int> &l,
39 const QPair<QStandardItem*, int> &
r)
const
41 return *(l.first) < *(
r.first);
51 inline bool operator()(
const QPair<QStandardItem*, int> &l,
52 const QPair<QStandardItem*, int> &
r)
const
54 return *(
r.first) < *(l.first);
64 int idx = par->d_func()->childIndex(q_func());
66 return QPair<int, int>(-1, -1);
67 return QPair<int, int>(idx / par->columnCount(), idx % par->columnCount());
70 return QPair<int, int>(-1, -1);
81 qWarning(
"QStandardItem::setChild: Can't make an item a child of itself %p",
88 q->setRowCount(
row + 1);
97 if (
model && emitChanged) {
102 if (
item->d_func()->parent ==
nullptr) {
105 qWarning(
"QStandardItem::setChild: Ignoring duplicate insertion of item %p",
112 if (!
item && oldItem)
113 oldItem->d_func()->setModel(
nullptr);
120 oldItem->d_func()->setModel(
nullptr);
126 if (
model && emitChanged)
129 if (emitChanged &&
model) {
146 Qt::ItemFlags
flags =
q->flags();
161 const auto modelIndex =
child->index();
168 struct ByNormalizedRole
170 static int normalizedRole(
int role)
175 bool operator()(
const QStandardItemData& standardItemData,
const std::pair<const int &, const QVariant&>& roleMapIt)
const
177 return standardItemData.role < normalizedRole(roleMapIt.first);
179 bool operator()(
const std::pair<const int&, const QVariant &>& roleMapIt,
const QStandardItemData& standardItemData)
const
181 return normalizedRole(roleMapIt.first) < standardItemData.role;
191 template<
class Input,
class OutputIt>
192 OutputIt roleMapStandardItemDataTransform(Input first1, Input last1, OutputIt d_first)
194 while (first1 != last1) {
195 if ((*first1).second.isValid())
208 template<
class Input1,
class Input2,
210 OutputIt roleMapStandardItemDataUnion(Input1 first1, Input1 last1,
211 Input2 first2, Input2 last2,
212 OutputIt d_first,
Compare comp)
214 for (; first1 != last1; ++d_first) {
215 if (first2 == last2) {
216 return roleMapStandardItemDataTransform(first1, last1, d_first);
218 if (comp(*first2, *first1)) {
219 *d_first = *first2++;
221 if ((*first1).second.isValid())
223 if (!comp(*first1, *first2))
228 return std::copy(first2, last2, d_first);
240 return item1.role < item2.role;
250 QList<QStandardItemData> newValues;
251 newValues.reserve(
values.size());
252 roleMapStandardItemDataUnion(roles.keyValueBegin(),
255 std::back_inserter(newValues), ByNormalizedRole());
257 if (newValues !=
values) {
261 roleKeys.reserve(roles.size() + 1);
262 bool hasEditRole =
false;
263 bool hasDisplayRole =
false;
264 for (
auto it = roles.keyBegin();
it != roles.keyEnd(); ++
it) {
265 roleKeys.push_back(*
it);
269 hasDisplayRole =
true;
271 if (hasEditRole && !hasDisplayRole)
273 else if (!hasEditRole && hasDisplayRole)
285 QMap<int, QVariant>
result;
287 if (
data.role != DataFlagsRole)
302 QList<QPair<QStandardItem*, int> > sortable;
303 QList<int> unsortable;
311 sortable.append(QPair<QStandardItem*,int>(itm,
row));
313 unsortable.append(
row);
318 std::stable_sort(sortable.begin(), sortable.end(), lt);
321 std::stable_sort(sortable.begin(), sortable.end(), gt);
324 QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo;
327 int r = (
i < sortable.size()
328 ? sortable.at(
i).second
329 : unsortable.at(
i - sortable.size()));
335 if (
model->d_func()->persistent.indexes.contains(from)) {
337 changedPersistentIndexesFrom.append(from);
338 changedPersistentIndexesTo.append(to);
368 QStack<QStandardItem*> stack;
370 while (!stack.isEmpty()) {
372 if (itm->d_func()->
model) {
375 itm->d_func()->
model = mod;
376 const QList<QStandardItem*> &childList = itm->d_func()->children;
377 for (
int i = 0;
i < childList.size(); ++
i) {
443 q->setColumnCount(1);
455 item->d_func()->parent =
q;
488 if (
item->d_func()->parent ==
nullptr) {
491 qWarning(
"QStandardItem::insertRows: Ignoring duplicate insertion of item %p",
533 if (
item->d_func()->parent ==
nullptr) {
536 qWarning(
"QStandardItem::insertColumns: Ignoring duplicate insertion of item %p",
561 if (
item->d_func()->parent ==
nullptr) {
643 q->endInsertColumns();
657 oldItem->d_func()->setModel(
nullptr);
676 oldItem->d_func()->setModel(
nullptr);
681 q->endRemoveColumns();
835 d->values =
other.d_func()->values;
848 child->d_func()->setModel(
nullptr);
852 if (
d->parent &&
d->model)
853 d->parent->d_func()->childDeleted(
this);
866 if (!
d->model || (
d->model->d_func()->root.data() !=
d->parent))
898 if ((*it).role == role) {
899 if (
value.isValid()) {
900 if ((*it).value.userType() ==
value.userType() && (*it).value ==
value)
909 d->model->d_func()->itemChanged(
this, roles);
915 d->model->d_func()->itemChanged(
this, roles);
926 if (
d->values.isEmpty())
930 d->model->d_func()->itemChanged(
this, QList<int>{});
949 for (
const auto &
value :
d->values) {
988 d->model->d_func()->itemChanged(
this);
1020 return Qt::ItemFlags(
v.toInt());
1420#if QT_CONFIG(draganddrop)
1431void QStandardItem::setDragEnabled(
bool dragEnabled)
1461void QStandardItem::setDropEnabled(
bool dropEnabled)
1489 QPair<int, int>
pos =
d->position();
1502 QPair<int, int>
pos =
d->position();
1521 return d->model ?
d->model->indexFromItem(
this) :
QModelIndex();
1563 return d->rowCount();
1591 return d->columnCount();
1651 d->insertRows(
row,
count, QList<QStandardItem*>());
1666 d->insertColumns(
column,
count, QList<QStandardItem*>());
1768 d->model->d_func()->rowsAboutToBeRemoved(
this,
row,
row +
count - 1);
1769 int i =
d->childIndex(
row, 0);
1770 int n =
count *
d->columnCount();
1771 for (
int j =
i;
j <
n+
i; ++
j) {
1774 oldItem->d_func()->setModel(
nullptr);
1777 d->children.remove(
qMax(
i, 0),
n);
1796 for (
int row =
d->rowCount() - 1;
row >= 0; --
row) {
1801 oldItem->d_func()->setModel(
nullptr);
1855 return d->children.at(
index);
1880 const int savedRows = item_d->rows;
1881 const int savedCols = item_d->columns;
1882 const QVector<QStandardItem*> savedChildren = item_d->
children;
1883 if (savedRows > 0) {
1884 model_d->rowsAboutToBeRemoved(
item, 0, savedRows - 1);
1886 item_d->children = QVector<QStandardItem*>();
1887 model_d->rowsRemoved(
item, 0, savedRows);
1889 if (savedCols > 0) {
1890 model_d->columnsAboutToBeRemoved(
item, 0, savedCols - 1);
1891 item_d->columns = 0;
1892 item_d->children = QVector<QStandardItem*>();
1893 model_d->columnsRemoved(
item, 0, savedCols);
1895 item_d->rows = savedRows;
1896 item_d->columns = savedCols;
1897 item_d->children = savedChildren;
1898 changedIdx =
d->model->indexFromItem(
item);
1900 item_d->setParentAndModel(
nullptr,
nullptr);
1902 d->children.replace(
index,
nullptr);
1903 if (changedIdx.isValid())
1904 d->model->dataChanged(changedIdx, changedIdx);
1919 QList<QStandardItem*>
items;
1923 d->model->d_func()->rowsAboutToBeRemoved(
this,
row,
row);
1927 int col_count =
d->columnCount();
1932 ch->d_func()->setParentAndModel(
nullptr,
nullptr);
1935 d->children.remove(
index, col_count);
1939 d->model->d_func()->rowsRemoved(
this,
row, 1);
1953 QList<QStandardItem*>
items;
1957 d->model->d_func()->columnsAboutToBeRemoved(
this,
column,
column);
1965 ch->d_func()->setParentAndModel(
nullptr,
nullptr);
1966 d->children.remove(
index);
1971 d->model->d_func()->columnsRemoved(
this,
column, 1);
2009 QList<QPersistentModelIndex> parents;
2046#ifndef QT_NO_DATASTREAM
2205 d->root->d_func()->setModel(
this);
2217 d->root->insertColumns(0, columns);
2218 d->columnHeaderItems.insert(0, columns,
nullptr);
2219 d->root->insertRows(0, rows);
2220 d->rowHeaderItems.insert(0, rows,
nullptr);
2221 d->root->d_func()->setModel(
this);
2240 delete d->itemPrototype;
2261 return d->roleNames;
2276 d->root->d_func()->setModel(
this);
2278 d->columnHeaderItems.clear();
2280 d->rowHeaderItems.clear();
2306 if ((
index.row() < 0) || (
index.column() < 0) || (
index.model() !=
this))
2313 if (
item ==
nullptr) {
2314 item =
d->createItem();
2334 if (
item &&
item->d_func()->parent) {
2335 QPair<int, int>
pos =
item->d_func()->position();
2353 d->root->setRowCount(rows);
2368 d->root->setColumnCount(columns);
2422 return d->root.data();
2444 if (
item == oldItem)
2448 if (
item->model() ==
nullptr) {
2449 item->d_func()->setModel(
this);
2451 qWarning(
"QStandardItem::setHorizontalHeaderItem: Ignoring duplicate insertion of item %p",
2458 oldItem->d_func()->setModel(
nullptr);
2478 return d->columnHeaderItems.at(
column);
2500 if (
item == oldItem)
2504 if (
item->model() ==
nullptr) {
2505 item->d_func()->setModel(
this);
2507 qWarning(
"QStandardItem::setVerticalHeaderItem: Ignoring duplicate insertion of item %p",
2514 oldItem->d_func()->setModel(
nullptr);
2517 d->rowHeaderItems.replace(
row,
item);
2534 return d->rowHeaderItems.at(
row);
2550 for (
int i = 0;
i < labels.size(); ++
i) {
2553 item =
d->createItem();
2556 item->setText(labels.at(
i));
2573 for (
int i = 0;
i < labels.size(); ++
i) {
2576 item =
d->createItem();
2579 item->setText(labels.at(
i));
2601 if (
d->itemPrototype !=
item) {
2602 delete d->itemPrototype;
2603 d->itemPrototype =
item;
2619 return d->itemPrototype;
2633 QList<QStandardItem*>
items;
2634 const int numIndexes = indexes.
size();
2636 for (
int i = 0;
i < numIndexes; ++
i)
2741 return d->root->takeRow(
row);
2757 return d->root->takeColumn(
column);
2776 headerItem->d_func()->setParentAndModel(
nullptr,
nullptr);
2777 d->columnHeaderItems.replace(
column,
nullptr);
2798 headerItem->d_func()->setParentAndModel(
nullptr,
nullptr);
2799 d->rowHeaderItems.replace(
row,
nullptr);
2828 return &
d->sortRole;
2838 return item ?
item->columnCount() : 0;
2869 if (!
d->indexValid(
index))
2870 return d->root->flags();
2888 return item ?
item->hasChildren() :
false;
2904 headerItem =
d->columnHeaderItems.at(section);
2906 headerItem =
d->rowHeaderItems.at(section);
2907 return headerItem ? headerItem->
data(role)
2928 if ((parentItem ==
nullptr)
2945 if (
item ==
nullptr)
2947 return item->d_func()->insertColumns(
column,
count, QList<QStandardItem*>());
2957 if (
item ==
nullptr)
2959 return item->d_func()->insertRows(
row,
count, QList<QStandardItem*>());
2970 return QMap<int, QVariant>();
2971 return item->d_func()->itemData();
2980 if (!
d->indexValid(
child))
3019 return item ?
item->rowCount() : 0;
3027 if (!
index.isValid())
3030 if (
item ==
nullptr)
3064 headerItem =
d->columnHeaderItems.at(section);
3065 if (headerItem ==
nullptr) {
3066 headerItem =
d->createItem();
3067 headerItem->d_func()->setModel(
this);
3068 d->columnHeaderItems.replace(section, headerItem);
3071 headerItem =
d->rowHeaderItems.at(section);
3072 if (headerItem ==
nullptr) {
3073 headerItem =
d->createItem();
3074 headerItem->d_func()->setModel(
this);
3075 d->rowHeaderItems.replace(section, headerItem);
3091 if (
item ==
nullptr)
3093 item->d_func()->setItemData(roles);
3125 return data.release();
3129 QSet<QStandardItem*> itemsSet;
3130 QStack<QStandardItem*> stack;
3131 itemsSet.reserve(indexes.
size());
3132 stack.reserve(indexes.
size());
3133 for (
int i = 0;
i < indexes.
size(); ++
i) {
3138 qWarning(
"QStandardItemModel::mimeData: No item associated with invalid index");
3145 QDuplicateTracker<QStandardItem *> seen;
3146 while (!stack.isEmpty()) {
3148 if (seen.hasSeen(itm))
3151 const QList<QStandardItem*> &childList = itm->d_func()->children;
3152 for (
int i = 0;
i < childList.size(); ++
i) {
3155 itemsSet.remove(chi);
3162 stack.reserve(itemsSet.size());
3167 while (!stack.isEmpty()) {
3169 if (itemsSet.contains(
item))
3177 return data.release();
3187 int colCount, childCount;
3189 stream >> colCount >> childCount;
3190 item->setColumnCount(colCount);
3192 int childPos = childCount;
3194 while(childPos > 0) {
3198 item->setChild( childPos / colCount, childPos % colCount,
child);
3236 QList<int> rows, columns;
3237 QList<QStandardItem *>
items;
3239 while (!
stream.atEnd()) {
3256 int dragRowCount = 0;
3260 QList<int> rowsToInsert(
bottom + 1);
3261 for (
int i = 0;
i < rows.size(); ++
i)
3262 rowsToInsert[rows.at(
i)] = 1;
3263 for (
int i = 0;
i < rowsToInsert.size(); ++
i) {
3264 if (rowsToInsert.at(
i) == 1){
3265 rowsToInsert[
i] = dragRowCount;
3269 for (
int i = 0;
i < rows.size(); ++
i)
3270 rows[
i] =
top + rowsToInsert.at(rows.at(
i));
3272 QBitArray isWrittenTo(dragRowCount * dragColumnCount);
3276 if (colCount < dragColumnCount +
column) {
3289 QList<QPersistentModelIndex> newIndexes(
items.
size());
3292 int relativeRow = rows.at(
j) -
top;
3293 int relativeColumn = columns.at(
j) -
left;
3294 int destinationRow = relativeRow +
row;
3295 int destinationColumn = relativeColumn +
column;
3296 int flat = (relativeRow * dragColumnCount) + relativeColumn;
3298 if (destinationColumn >= colCount || isWrittenTo.testBit(flat)) {
3299 destinationColumn =
qBound(
column, destinationColumn, colCount - 1);
3300 destinationRow =
row + dragRowCount;
3302 flat = (dragRowCount * dragColumnCount) + relativeColumn;
3303 isWrittenTo.resize(++dragRowCount * dragColumnCount);
3305 if (!isWrittenTo.testBit(flat)) {
3306 newIndexes[
j] =
index(destinationRow, destinationColumn, parentItem->
index());
3307 isWrittenTo.setBit(flat);
3311 for(
int k = 0; k < newIndexes.size(); k++) {
3312 if (newIndexes.at(k).isValid()) {
3313 parentItem->
setChild(newIndexes.at(k).row(), newIndexes.at(k).column(),
items.
at(k));
3324#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 columnsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been removed from the model.
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
void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been removed from the model.
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)
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)
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.
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.
QList< T > values() const
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)
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.
constexpr auto DataFlagsRole
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
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
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 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