summaryrefslogtreecommitdiffstats
path: root/src/gui/itemmodels/qstandarditemmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/itemmodels/qstandarditemmodel.cpp')
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp285
1 files changed, 161 insertions, 124 deletions
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index ebb4d641eb..8b3e381431 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qstandarditemmodel.h"
@@ -44,10 +8,10 @@
#include <QtCore/qmap.h>
#include <QtCore/qpair.h>
#include <QtCore/qvariant.h>
-#include <QtCore/qvector.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qbitarray.h>
#include <QtCore/qmimedata.h>
+#include <QtCore/qiodevice.h>
#include <private/qduplicatetracker_p.h>
#include <private/qstandarditemmodel_p.h>
#include <qdebug.h>
@@ -55,6 +19,11 @@
QT_BEGIN_NAMESPACE
+// Used internally to store the flags
+namespace {
+constexpr auto DataFlagsRole = Qt::ItemDataRole(Qt::UserRole - 1);
+}
+
static inline QString qStandardItemModelDataListMimeType()
{
return QStringLiteral("application/x-qstandarditemmodeldatalist");
@@ -190,7 +159,7 @@ void QStandardItemPrivate::childDeleted(QStandardItem *child)
int index = childIndex(child);
Q_ASSERT(index != -1);
const auto modelIndex = child->index();
- children.replace(index, 0);
+ children.replace(index, nullptr);
emit model->dataChanged(modelIndex, modelIndex);
}
@@ -274,11 +243,11 @@ void QStandardItemPrivate::setItemData(const QMap<int, QVariant> &roles)
std::sort(values.begin(), values.end(), byRole);
/*
- Create a vector of QStandardItemData that will contain the original values
+ Create a list of QStandardItemData that will contain the original values
if the matching role is not contained in roles, the new value if it is and
if the new value is an invalid QVariant, it will be removed.
*/
- QVector<QStandardItemData> newValues;
+ QList<QStandardItemData> newValues;
newValues.reserve(values.size());
roleMapStandardItemDataUnion(roles.keyValueBegin(),
roles.keyValueEnd(),
@@ -288,7 +257,7 @@ void QStandardItemPrivate::setItemData(const QMap<int, QVariant> &roles)
if (newValues != values) {
values.swap(newValues);
if (model) {
- QVector<int> roleKeys;
+ QList<int> roleKeys;
roleKeys.reserve(roles.size() + 1);
bool hasEditRole = false;
bool hasDisplayRole = false;
@@ -311,14 +280,12 @@ void QStandardItemPrivate::setItemData(const QMap<int, QVariant> &roles)
/*!
\internal
*/
-const QMap<int, QVariant> QStandardItemPrivate::itemData() const
+QMap<int, QVariant> QStandardItemPrivate::itemData() const
{
QMap<int, QVariant> result;
- QVector<QStandardItemData>::const_iterator it;
- for (it = values.cbegin(); it != values.cend(); ++it){
- // Qt::UserRole - 1 is used internally to store the flags
- if (it->role != Qt::UserRole - 1)
- result.insert(it->role, it->value);
+ for (const auto &data : values) {
+ if (data.role != DataFlagsRole)
+ result.insert(data.role, data.value);
}
return result;
}
@@ -332,8 +299,8 @@ void QStandardItemPrivate::sortChildren(int column, Qt::SortOrder order)
if (column >= columnCount())
return;
- QVector<QPair<QStandardItem*, int> > sortable;
- QVector<int> unsortable;
+ QList<QPair<QStandardItem*, int> > sortable;
+ QList<int> unsortable;
sortable.reserve(rowCount());
unsortable.reserve(rowCount());
@@ -355,11 +322,11 @@ void QStandardItemPrivate::sortChildren(int column, Qt::SortOrder order)
}
QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo;
- QVector<QStandardItem*> sorted_children(children.count());
+ QList<QStandardItem*> sorted_children(children.size());
for (int i = 0; i < rowCount(); ++i) {
- int r = (i < sortable.count()
+ int r = (i < sortable.size()
? sortable.at(i).second
- : unsortable.at(i - sortable.count()));
+ : unsortable.at(i - sortable.size()));
for (int c = 0; c < columnCount(); ++c) {
QStandardItem *itm = q->child(r, c);
sorted_children[childIndex(i, c)] = itm;
@@ -380,7 +347,7 @@ void QStandardItemPrivate::sortChildren(int column, Qt::SortOrder order)
model->changePersistentIndexList(changedPersistentIndexesFrom, changedPersistentIndexesTo);
}
- QVector<QStandardItem*>::iterator it;
+ QList<QStandardItem*>::iterator it;
for (it = children.begin(); it != children.end(); ++it) {
if (*it)
(*it)->d_func()->sortChildren(column, order);
@@ -406,8 +373,8 @@ void QStandardItemPrivate::setModel(QStandardItemModel *mod)
itm->d_func()->model->d_func()->invalidatePersistentIndex(itm->d_func()->model->indexFromItem(itm));
}
itm->d_func()->model = mod;
- const QVector<QStandardItem*> &childList = itm->d_func()->children;
- for (int i = 0; i < childList.count(); ++i) {
+ const QList<QStandardItem*> &childList = itm->d_func()->children;
+ for (int i = 0; i < childList.size(); ++i) {
QStandardItem *chi = childList.at(i);
if (chi)
stack.push(chi);
@@ -420,9 +387,7 @@ void QStandardItemPrivate::setModel(QStandardItemModel *mod)
\internal
*/
QStandardItemModelPrivate::QStandardItemModelPrivate()
- : root(new QStandardItem),
- itemPrototype(nullptr),
- sortRole(Qt::DisplayRole)
+ : root(new QStandardItem), itemPrototype(nullptr)
{
root->setFlags(Qt::ItemIsDropEnabled);
}
@@ -470,7 +435,7 @@ bool QStandardItemPrivate::insertRows(int row, const QList<QStandardItem*> &item
Q_Q(QStandardItem);
if ((row < 0) || (row > rowCount()) || items.isEmpty())
return false;
- int count = items.count();
+ int count = items.size();
if (model)
model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1);
if (rowCount() == 0) {
@@ -482,9 +447,9 @@ bool QStandardItemPrivate::insertRows(int row, const QList<QStandardItem*> &item
rows += count;
int index = childIndex(row, 0);
if (index != -1)
- children.insert(index, columnCount() * count, 0);
+ children.insert(index, columnCount() * count, nullptr);
}
- for (int i = 0; i < items.count(); ++i) {
+ for (int i = 0; i < items.size(); ++i) {
QStandardItem *item = items.at(i);
item->d_func()->model = model;
item->d_func()->parent = q;
@@ -512,11 +477,11 @@ bool QStandardItemPrivate::insertRows(int row, int count, const QList<QStandardI
rows += count;
int index = childIndex(row, 0);
if (index != -1)
- children.insert(index, columnCount() * count, 0);
+ children.insert(index, columnCount() * count, nullptr);
}
if (!items.isEmpty()) {
int index = childIndex(row, 0);
- int limit = qMin(items.count(), columnCount() * count);
+ int limit = qMin(items.size(), columnCount() * count);
for (int i = 0; i < limit; ++i) {
QStandardItem *item = items.at(i);
if (item) {
@@ -556,12 +521,12 @@ bool QStandardItemPrivate::insertColumns(int column, int count, const QList<QSta
columns += count;
int index = childIndex(0, column);
for (int row = 0; row < rowCount(); ++row) {
- children.insert(index, count, 0);
+ children.insert(index, count, nullptr);
index += columnCount();
}
}
if (!items.isEmpty()) {
- int limit = qMin(items.count(), rowCount() * count);
+ int limit = qMin(items.size(), rowCount() * count);
for (int i = 0; i < limit; ++i) {
QStandardItem *item = items.at(i);
if (item) {
@@ -589,7 +554,7 @@ bool QStandardItemPrivate::insertColumns(int column, int count, const QList<QSta
/*!
\internal
*/
-void QStandardItemModelPrivate::itemChanged(QStandardItem *item, const QVector<int> &roles)
+void QStandardItemModelPrivate::itemChanged(QStandardItem *item, const QList<int> &roles)
{
Q_Q(QStandardItemModel);
Q_ASSERT(item);
@@ -662,7 +627,7 @@ void QStandardItemModelPrivate::rowsInserted(QStandardItem *parent,
{
Q_Q(QStandardItemModel);
if (parent == root.data())
- rowHeaderItems.insert(row, count, 0);
+ rowHeaderItems.insert(row, count, nullptr);
q->endInsertRows();
}
@@ -674,7 +639,7 @@ void QStandardItemModelPrivate::columnsInserted(QStandardItem *parent,
{
Q_Q(QStandardItemModel);
if (parent == root.data())
- columnHeaderItems.insert(column, count, 0);
+ columnHeaderItems.insert(column, count, nullptr);
q->endInsertColumns();
}
@@ -878,7 +843,7 @@ QStandardItem &QStandardItem::operator=(const QStandardItem &other)
QStandardItem::~QStandardItem()
{
Q_D(QStandardItem);
- for (QStandardItem *child : qAsConst(d->children)) {
+ for (QStandardItem *child : std::as_const(d->children)) {
if (child)
child->d_func()->setModel(nullptr);
delete child;
@@ -907,9 +872,15 @@ QStandardItem *QStandardItem::parent() const
Sets the item's data for the given \a role to the specified \a value.
If you subclass QStandardItem and reimplement this function, your
- reimplementation should call emitDataChanged() if you do not call
- the base implementation of setData(). This will ensure that e.g.
- views using the model are notified of the changes.
+ reimplementation should:
+ \list
+ \li call emitDataChanged() if you do not call the base implementation of
+ setData(). This will ensure that e.g. views using the model are notified
+ of the changes
+ \li call the base implementation for roles you don't handle, otherwise
+ setting flags, e.g. by calling setFlags(), setCheckable(), setEditable()
+ etc., will not work.
+ \endlist
\note The default implementation treats Qt::EditRole and Qt::DisplayRole
as referring to the same data.
@@ -920,17 +891,18 @@ void QStandardItem::setData(const QVariant &value, int role)
{
Q_D(QStandardItem);
role = (role == Qt::EditRole) ? Qt::DisplayRole : role;
- const QVector<int> roles((role == Qt::DisplayRole) ?
- QVector<int>({Qt::DisplayRole, Qt::EditRole}) :
- QVector<int>({role}));
- QVector<QStandardItemData>::iterator it;
- for (it = d->values.begin(); it != d->values.end(); ++it) {
+ const QList<int> roles((role == Qt::DisplayRole) ?
+ QList<int>({Qt::DisplayRole, Qt::EditRole}) :
+ QList<int>({role}));
+ for (auto it = d->values.begin(); it != d->values.end(); ++it) {
if ((*it).role == role) {
if (value.isValid()) {
if ((*it).value.userType() == value.userType() && (*it).value == value)
return;
(*it).value = value;
} else {
+ // Don't need to assign proper it after erase() since we
+ // return unconditionally in this code path.
d->values.erase(it);
}
if (d->model)
@@ -955,29 +927,49 @@ void QStandardItem::clearData()
return;
d->values.clear();
if (d->model)
- d->model->d_func()->itemChanged(this, QVector<int>{});
+ d->model->d_func()->itemChanged(this, QList<int>{});
}
/*!
Returns the item's data for the given \a role, or an invalid
QVariant if there is no data for the role.
+ If you reimplement this function, your reimplementation should call
+ the base implementation for roles you don't handle, otherwise getting
+ flags, e.g. by calling flags(), isCheckable(), isEditable() etc.,
+ will not work.
+
\note The default implementation treats Qt::EditRole and Qt::DisplayRole
as referring to the same data.
*/
QVariant QStandardItem::data(int role) const
{
Q_D(const QStandardItem);
- role = (role == Qt::EditRole) ? Qt::DisplayRole : role;
- QVector<QStandardItemData>::const_iterator it;
- for (it = d->values.begin(); it != d->values.end(); ++it) {
- if ((*it).role == role)
- return (*it).value;
+ const int r = (role == Qt::EditRole) ? Qt::DisplayRole : role;
+ for (const auto &value : d->values) {
+ if (value.role == r)
+ return value.value;
}
return QVariant();
}
/*!
+ \since 6.0
+
+ Fills the \a roleDataSpan span with the data from this item.
+
+ The default implementation simply calls data() for each role
+ in the span.
+
+ \sa data()
+*/
+void QStandardItem::multiData(QModelRoleDataSpan roleDataSpan) const
+{
+ for (auto &roleData : roleDataSpan)
+ roleData.setData(data(roleData.role()));
+}
+
+/*!
\since 4.4
Causes the model associated with this item to emit a
@@ -1006,7 +998,7 @@ void QStandardItem::emitDataChanged()
*/
void QStandardItem::setFlags(Qt::ItemFlags flags)
{
- setData((int)flags, Qt::UserRole - 1);
+ setData((int)flags, DataFlagsRole);
}
/*!
@@ -1021,7 +1013,7 @@ void QStandardItem::setFlags(Qt::ItemFlags flags)
*/
Qt::ItemFlags QStandardItem::flags() const
{
- QVariant v = data(Qt::UserRole - 1);
+ QVariant v = data(DataFlagsRole);
if (!v.isValid())
return (Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable
|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled);
@@ -1610,8 +1602,8 @@ void QStandardItem::insertRow(int row, const QList<QStandardItem*> &items)
Q_D(QStandardItem);
if (row < 0)
return;
- if (columnCount() < items.count())
- setColumnCount(items.count());
+ if (columnCount() < items.size())
+ setColumnCount(items.size());
d->insertRows(row, 1, items);
}
@@ -1639,8 +1631,8 @@ void QStandardItem::insertColumn(int column, const QList<QStandardItem*> &items)
Q_D(QStandardItem);
if (column < 0)
return;
- if (rowCount() < items.count())
- setRowCount(items.count());
+ if (rowCount() < items.size())
+ setRowCount(items.size());
d->insertColumns(column, 1, items);
}
@@ -1879,10 +1871,37 @@ QStandardItem *QStandardItem::takeChild(int row, int column)
QStandardItem *item = nullptr;
int index = d->childIndex(row, column);
if (index != -1) {
+ QModelIndex changedIdx;
item = d->children.at(index);
- if (item)
- item->d_func()->setParentAndModel(nullptr, nullptr);
- d->children.replace(index, 0);
+ if (item) {
+ QStandardItemPrivate *const item_d = item->d_func();
+ if (d->model) {
+ QStandardItemModelPrivate *const model_d = d->model->d_func();
+ const int savedRows = item_d->rows;
+ const int savedCols = item_d->columns;
+ const QVector<QStandardItem*> savedChildren = item_d->children;
+ if (savedRows > 0) {
+ model_d->rowsAboutToBeRemoved(item, 0, savedRows - 1);
+ item_d->rows = 0;
+ item_d->children = QVector<QStandardItem*>(); //slightly faster than clear
+ model_d->rowsRemoved(item, 0, savedRows);
+ }
+ if (savedCols > 0) {
+ model_d->columnsAboutToBeRemoved(item, 0, savedCols - 1);
+ item_d->columns = 0;
+ item_d->children = QVector<QStandardItem*>(); //slightly faster than clear
+ model_d->columnsRemoved(item, 0, savedCols);
+ }
+ item_d->rows = savedRows;
+ item_d->columns = savedCols;
+ item_d->children = savedChildren;
+ changedIdx = d->model->indexFromItem(item);
+ }
+ item_d->setParentAndModel(nullptr, nullptr);
+ }
+ d->children.replace(index, nullptr);
+ if (changedIdx.isValid())
+ d->model->dataChanged(changedIdx, changedIdx);
}
return item;
}
@@ -2196,9 +2215,9 @@ QStandardItemModel::QStandardItemModel(int rows, int columns, QObject *parent)
Q_D(QStandardItemModel);
d->init();
d->root->insertColumns(0, columns);
- d->columnHeaderItems.insert(0, columns, 0);
+ d->columnHeaderItems.insert(0, columns, nullptr);
d->root->insertRows(0, rows);
- d->rowHeaderItems.insert(0, rows, 0);
+ d->rowHeaderItems.insert(0, rows, nullptr);
d->root->d_func()->setModel(this);
}
@@ -2526,9 +2545,9 @@ QStandardItem *QStandardItemModel::verticalHeaderItem(int row) const
void QStandardItemModel::setHorizontalHeaderLabels(const QStringList &labels)
{
Q_D(QStandardItemModel);
- if (columnCount() < labels.count())
- setColumnCount(labels.count());
- for (int i = 0; i < labels.count(); ++i) {
+ if (columnCount() < labels.size())
+ setColumnCount(labels.size());
+ for (int i = 0; i < labels.size(); ++i) {
QStandardItem *item = horizontalHeaderItem(i);
if (!item) {
item = d->createItem();
@@ -2549,9 +2568,9 @@ void QStandardItemModel::setHorizontalHeaderLabels(const QStringList &labels)
void QStandardItemModel::setVerticalHeaderLabels(const QStringList &labels)
{
Q_D(QStandardItemModel);
- if (rowCount() < labels.count())
- setRowCount(labels.count());
- for (int i = 0; i < labels.count(); ++i) {
+ if (rowCount() < labels.size())
+ setRowCount(labels.size());
+ for (int i = 0; i < labels.size(); ++i) {
QStandardItem *item = verticalHeaderItem(i);
if (!item) {
item = d->createItem();
@@ -2755,7 +2774,7 @@ QStandardItem *QStandardItemModel::takeHorizontalHeaderItem(int column)
QStandardItem *headerItem = d->columnHeaderItems.at(column);
if (headerItem) {
headerItem->d_func()->setParentAndModel(nullptr, nullptr);
- d->columnHeaderItems.replace(column, 0);
+ d->columnHeaderItems.replace(column, nullptr);
}
return headerItem;
}
@@ -2777,7 +2796,7 @@ QStandardItem *QStandardItemModel::takeVerticalHeaderItem(int row)
QStandardItem *headerItem = d->rowHeaderItems.at(row);
if (headerItem) {
headerItem->d_func()->setParentAndModel(nullptr, nullptr);
- d->rowHeaderItems.replace(row, 0);
+ d->rowHeaderItems.replace(row, nullptr);
}
return headerItem;
}
@@ -2803,6 +2822,12 @@ void QStandardItemModel::setSortRole(int role)
d->sortRole = role;
}
+QBindable<int> QStandardItemModel::bindableSortRole()
+{
+ Q_D(QStandardItemModel);
+ return &d->sortRole;
+}
+
/*!
\reimp
*/
@@ -2826,6 +2851,18 @@ QVariant QStandardItemModel::data(const QModelIndex &index, int role) const
/*!
\reimp
*/
+void QStandardItemModel::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const
+{
+ // Cannot offer a better implementation; users may be overriding
+ // data(), and thus multiData() may fall out of sync for them.
+ // The base class' implementation will simply call data() in a loop,
+ // so it's fine.
+ QAbstractItemModel::multiData(index, roleDataSpan);
+}
+
+/*!
+ \reimp
+*/
Qt::ItemFlags QStandardItemModel::flags(const QModelIndex &index) const
{
Q_D(const QStandardItemModel);
@@ -3079,21 +3116,21 @@ QStringList QStandardItemModel::mimeTypes() const
*/
QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
{
- QMimeData *data = QAbstractItemModel::mimeData(indexes);
- if(!data)
+ std::unique_ptr<QMimeData> data(QAbstractItemModel::mimeData(indexes));
+ if (!data)
return nullptr;
const QString format = qStandardItemModelDataListMimeType();
if (!mimeTypes().contains(format))
- return data;
+ return data.release();
QByteArray encoded;
QDataStream stream(&encoded, QIODevice::WriteOnly);
QSet<QStandardItem*> itemsSet;
QStack<QStandardItem*> stack;
- itemsSet.reserve(indexes.count());
- stack.reserve(indexes.count());
- for (int i = 0; i < indexes.count(); ++i) {
+ itemsSet.reserve(indexes.size());
+ stack.reserve(indexes.size());
+ for (int i = 0; i < indexes.size(); ++i) {
if (QStandardItem *item = itemFromIndex(indexes.at(i))) {
itemsSet << item;
stack.push(item);
@@ -3103,7 +3140,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
}
}
- //remove duplicates childrens
+ //remove duplicates children
{
QDuplicateTracker<QStandardItem *> seen;
while (!stack.isEmpty()) {
@@ -3111,8 +3148,8 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
if (seen.hasSeen(itm))
continue;
- const QVector<QStandardItem*> &childList = itm->d_func()->children;
- for (int i = 0; i < childList.count(); ++i) {
+ const QList<QStandardItem*> &childList = itm->d_func()->children;
+ for (int i = 0; i < childList.size(); ++i) {
QStandardItem *chi = childList.at(i);
if (chi) {
itemsSet.remove(chi);
@@ -3122,8 +3159,8 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
}
}
- stack.reserve(itemsSet.count());
- for (QStandardItem *item : qAsConst(itemsSet))
+ stack.reserve(itemsSet.size());
+ for (QStandardItem *item : std::as_const(itemsSet))
stack.push(item);
//stream everything recursively
@@ -3132,12 +3169,12 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
if (itemsSet.contains(item)) //if the item is selection 'top-level', stream its position
stream << item->row() << item->column();
- stream << *item << item->columnCount() << item->d_ptr->children.count();
+ stream << *item << item->columnCount() << int(item->d_ptr->children.size());
stack += item->d_ptr->children;
}
data->setData(format, encoded);
- return data;
+ return data.release();
}
@@ -3196,8 +3233,8 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
int left = INT_MAX;
int bottom = 0;
int right = 0;
- QVector<int> rows, columns;
- QVector<QStandardItem *> items;
+ QList<int> rows, columns;
+ QList<QStandardItem *> items;
while (!stream.atEnd()) {
int r, c;
@@ -3220,16 +3257,16 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
int dragColumnCount = right - left + 1;
// Compute the number of continuous rows upon insertion and modify the rows to match
- QVector<int> rowsToInsert(bottom + 1);
- for (int i = 0; i < rows.count(); ++i)
+ QList<int> rowsToInsert(bottom + 1);
+ for (int i = 0; i < rows.size(); ++i)
rowsToInsert[rows.at(i)] = 1;
- for (int i = 0; i < rowsToInsert.count(); ++i) {
+ for (int i = 0; i < rowsToInsert.size(); ++i) {
if (rowsToInsert.at(i) == 1){
rowsToInsert[i] = dragRowCount;
++dragRowCount;
}
}
- for (int i = 0; i < rows.count(); ++i)
+ for (int i = 0; i < rows.size(); ++i)
rows[i] = top + rowsToInsert.at(rows.at(i));
QBitArray isWrittenTo(dragRowCount * dragColumnCount);
@@ -3249,7 +3286,7 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
if (!parentItem)
parentItem = invisibleRootItem();
- QVector<QPersistentModelIndex> newIndexes(items.size());
+ QList<QPersistentModelIndex> newIndexes(items.size());
// set the data in the table
for (int j = 0; j < items.size(); ++j) {
int relativeRow = rows.at(j) - top;