diff options
author | Andy Shaw <qt-info@nokia.com> | 2009-09-22 12:38:09 (GMT) |
---|---|---|
committer | Andy Shaw <qt-info@nokia.com> | 2009-09-22 12:38:09 (GMT) |
commit | e410d2711ae2aba15b9da7b07a4f8e40a50ab9c5 (patch) | |
tree | d5e52504c64fd55543857d9993d32027078ddc5c /src | |
parent | 1053d8564ca33e18a813e0f0fa1ec1f381e4a937 (diff) | |
download | Qt-e410d2711ae2aba15b9da7b07a4f8e40a50ab9c5.zip Qt-e410d2711ae2aba15b9da7b07a4f8e40a50ab9c5.tar.gz Qt-e410d2711ae2aba15b9da7b07a4f8e40a50ab9c5.tar.bz2 |
Ensure that QStandardItem::clone() is used when a prototype is set
This fixes a regression introduced in Qt 4.5.0, when dragging an item
within a QTreeView it would not call clone() when it was dropped even if
a prototype was set on the QStandardItemModel.
Reviewed-by: Marius Bugge Monsen
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemviews/qstandarditemmodel.cpp | 9 | ||||
-rw-r--r-- | src/gui/itemviews/qstandarditemmodel_p.h | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/gui/itemviews/qstandarditemmodel.cpp index bc25edd..8c9a2fd 100644 --- a/src/gui/itemviews/qstandarditemmodel.cpp +++ b/src/gui/itemviews/qstandarditemmodel.cpp @@ -2965,7 +2965,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const Used by QStandardItemModel::dropMimeData stream out an item and his children */ -static void decodeDataRecursive(QDataStream &stream, QStandardItem *item) +void QStandardItemModelPrivate::decodeDataRecursive(QDataStream &stream, QStandardItem *item) { int colCount, childCount; stream >> *item; @@ -2976,7 +2976,7 @@ static void decodeDataRecursive(QDataStream &stream, QStandardItem *item) while(childPos > 0) { childPos--; - QStandardItem *child = new QStandardItem; + QStandardItem *child = createItem(); decodeDataRecursive(stream, child); item->setChild( childPos / colCount, childPos % colCount, child); } @@ -2989,6 +2989,7 @@ static void decodeDataRecursive(QDataStream &stream, QStandardItem *item) bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { + Q_D(QStandardItemModel); // check if the action is supported if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction)) return false; @@ -3020,9 +3021,9 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti while (!stream.atEnd()) { int r, c; - QStandardItem *item = new QStandardItem; + QStandardItem *item = d->createItem(); stream >> r >> c; - decodeDataRecursive(stream, item); + d->decodeDataRecursive(stream, item); rows.append(r); columns.append(c); diff --git a/src/gui/itemviews/qstandarditemmodel_p.h b/src/gui/itemviews/qstandarditemmodel_p.h index 3d842f3..430fcb6 100644 --- a/src/gui/itemviews/qstandarditemmodel_p.h +++ b/src/gui/itemviews/qstandarditemmodel_p.h @@ -175,6 +175,8 @@ public: void _q_emitItemChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void decodeDataRecursive(QDataStream &stream, QStandardItem *item); + QVector<QStandardItem*> columnHeaderItems; QVector<QStandardItem*> rowHeaderItems; QStandardItem *root; |