Abstract proxy model: Add missing delegation of supportedDragActions

Change-Id: I4d2519aaa46d3ca075330c6680dd3672249cbefe
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Eike Ziller 2014-09-23 15:44:47 +02:00
parent 276a5f5acf
commit 3ea0020d3b
3 changed files with 30 additions and 0 deletions

View File

@ -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
*/

View File

@ -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:

View File

@ -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"