From 20abd88e711a2dfcbe07925f8902faa45e5110e2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 6 Jan 2012 08:02:19 +0100 Subject: Make the supportedDragActions a virtual accessor. Change-Id: I4001fcabc67e5b46465b3c9111c33247c52e5788 Reviewed-by: David Faure Reviewed-by: Lars Knoll Reviewed-by: David Faure --- .../qabstractitemmodel/tst_qabstractitemmodel.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp') diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index fd7b0d76ba..5d7eb1d759 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -113,6 +113,7 @@ private slots: void testChildrenLayoutsChanged(); void testRoleNames(); + void testDragActions(); private: DynamicTreeModel *m_model; @@ -1978,11 +1979,11 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() } } -class OverrideRoleNames : public QStringListModel +class OverrideRoleNamesAndDragActions : public QStringListModel { Q_OBJECT public: - OverrideRoleNames(QObject *parent = 0) + OverrideRoleNamesAndDragActions(QObject *parent = 0) : QStringListModel(parent) { @@ -1994,15 +1995,28 @@ public: roles.insert(Qt::UserRole + 2, "custom"); return roles; } + + Qt::DropActions supportedDragActions() const + { + return QStringListModel::supportedDragActions() | Qt::MoveAction; + } }; void tst_QAbstractItemModel::testRoleNames() { - QAbstractItemModel *model = new OverrideRoleNames(this); + QAbstractItemModel *model = new OverrideRoleNamesAndDragActions(this); QHash roles = model->roleNames(); QVERIFY(roles.contains(Qt::UserRole + 2)); QVERIFY(roles.value(Qt::UserRole + 2) == "custom"); } +void tst_QAbstractItemModel::testDragActions() +{ + QAbstractItemModel *model = new OverrideRoleNamesAndDragActions(this); + const Qt::DropActions actions = model->supportedDragActions(); + QVERIFY(actions & Qt::CopyAction); // Present by default + QVERIFY(actions & Qt::MoveAction); +} + QTEST_MAIN(tst_QAbstractItemModel) #include "tst_qabstractitemmodel.moc" -- cgit v1.2.3