mirror of https://github.com/qt/qtbase.git
Abstract proxy model: Add missing delegation of supportedDragActions
Change-Id: I4d2519aaa46d3ca075330c6680dd3672249cbefe Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
276a5f5acf
commit
3ea0020d3b
|
@ -425,6 +425,15 @@ QStringList QAbstractProxyModel::mimeTypes() const
|
|||
return d->model->mimeTypes();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
Qt::DropActions QAbstractProxyModel::supportedDragActions() const
|
||||
{
|
||||
Q_D(const QAbstractProxyModel);
|
||||
return d->model->supportedDragActions();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
|
||||
QStringList mimeTypes() const;
|
||||
Qt::DropActions supportedDragActions() const;
|
||||
Qt::DropActions supportedDropActions() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -72,6 +72,7 @@ private slots:
|
|||
void submit();
|
||||
void testRoleNames();
|
||||
void testSwappingRowsProxy();
|
||||
void testDragAndDrop();
|
||||
};
|
||||
|
||||
// Subclass that exposes the protected functions.
|
||||
|
@ -495,6 +496,25 @@ void tst_QAbstractProxyModel::testSwappingRowsProxy()
|
|||
}
|
||||
}
|
||||
|
||||
class StandardItemModelWithCustomDragAndDrop : public QStandardItemModel
|
||||
{
|
||||
public:
|
||||
QStringList mimeTypes() const { return QStringList() << QStringLiteral("foo/mimetype"); }
|
||||
Qt::DropActions supportedDragActions() const { return Qt::CopyAction | Qt::LinkAction; }
|
||||
Qt::DropActions supportedDropActions() const { return Qt::MoveAction; }
|
||||
};
|
||||
|
||||
void tst_QAbstractProxyModel::testDragAndDrop()
|
||||
{
|
||||
StandardItemModelWithCustomDragAndDrop sourceModel;
|
||||
SubQAbstractProxyModel proxy;
|
||||
proxy.setSourceModel(&sourceModel);
|
||||
QCOMPARE(proxy.mimeTypes(), sourceModel.mimeTypes());
|
||||
QCOMPARE(proxy.supportedDragActions(), sourceModel.supportedDragActions());
|
||||
QCOMPARE(proxy.supportedDropActions(), sourceModel.supportedDropActions());
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(tst_QAbstractProxyModel)
|
||||
#include "tst_qabstractproxymodel.moc"
|
||||
|
||||
|
|
Loading…
Reference in New Issue