diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-01-24 17:29:20 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-30 16:24:57 +0100 |
commit | be1867b6c4743da937d269f04c2e108a18d3f400 (patch) | |
tree | 5971ed2bee8bdfe0e1ae10c433cb98650be01b95 /src | |
parent | 3fe3d1dfdda9be266ba2400a85fd100c4e3d2cc2 (diff) |
Add the QAbstractItemModel::canDropMimeData method.
Can be used by views to indicate whether a drop is allowed (eg
adequete permissions in a filesystem model).
Change-Id: Iefedb5399e44c8edc5f5df1403c8d5c0da618612
Reviewed-by: Peter Penz <peter.penz19@gmail.com>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 19 | ||||
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.h | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index d9fff33ad0..cb5c62c190 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -1753,6 +1753,23 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const } /*! + Returns whether a model can accept a drop of data. + + This can be used to indicate whether a drop of certain data is allowed, for example + by using a 'forbidden' emblem on a mouse cursor during a drag operation. + + This method returns true by default. + + \sa dropMimeData(), {Using drag and drop with item views} + */ +bool QAbstractItemModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, + int row, int column, + const QModelIndex &parent) const +{ + return true; +} + +/*! Handles the \a data supplied by a drag and drop operation that ended with the given \a action. @@ -1773,7 +1790,7 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const greater than or equal zero, it means that the drop occurred just before the specified \a row and \a column in the specified \a parent. - \sa supportedDropActions(), {Using drag and drop with item views} + \sa supportedDropActions(), canDropMimeData(), {Using drag and drop with item views} */ bool QAbstractItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 06b7e482c3..4ea912c3f4 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -193,6 +193,8 @@ public: virtual QStringList mimeTypes() const; virtual QMimeData *mimeData(const QModelIndexList &indexes) const; + virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, + int row, int column, const QModelIndex &parent) const; virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); virtual Qt::DropActions supportedDropActions() const; |