forked from qt-creator/qt-creator
Editors: Support dragging from outline views
Fill the line and column information in the location returned by QmlOutlineModel::sourceLocation for that. The drag & drop code also needed a way to override the executed drop action for file drops, because the QML outline supports move-drags, which would lead to the items being removed from the outline when dragged onto a split... Change-Id: I2478abc7d5aa2f3aa676cdd609ecb69a50adce8c Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <cplusplus/Scope.h>
|
||||
#include <cplusplus/Literals.h>
|
||||
#include <cplusplus/Symbols.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
@@ -242,3 +243,35 @@ void OverviewModel::rebuild(Document::Ptr doc)
|
||||
_cppDocument = doc;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
Qt::ItemFlags OverviewModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
|
||||
}
|
||||
|
||||
Qt::DropActions OverviewModel::supportedDragActions() const
|
||||
{
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
QStringList OverviewModel::mimeTypes() const
|
||||
{
|
||||
return Utils::FileDropSupport::mimeTypesForFilePaths();
|
||||
}
|
||||
|
||||
QMimeData *OverviewModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
auto mimeData = new Utils::FileDropMimeData;
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
const QVariant fileName = data(index, FileNameRole);
|
||||
if (!fileName.canConvert<QString>())
|
||||
continue;
|
||||
const QVariant lineNumber = data(index, LineNumberRole);
|
||||
if (!fileName.canConvert<unsigned>())
|
||||
continue;
|
||||
mimeData->addFile(fileName.toString(), lineNumber.value<unsigned>());
|
||||
}
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user