Commit 2be7fad9 authored by Eike Ziller's avatar Eike Ziller
Browse files

ProjectTree: Support dragging files onto editor splits



Change-Id: I26e4de2818d89c012526116851d67155d3eeaa7e
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 0edefc4c
......@@ -38,8 +38,9 @@
#include <QDebug>
#include <QFileInfo>
#include <QFont>
#include <QMimeData>
#include <QUrl>
namespace ProjectExplorer {
......@@ -334,6 +335,8 @@ Qt::ItemFlags FlatModel::flags(const QModelIndex &index) const
// either folder or file node
if (node->supportedActions(node).contains(ProjectExplorer::Rename))
f = f | Qt::ItemIsEditable;
if (qobject_cast<FileNode *>(node))
f = f | Qt::ItemIsDragEnabled;
}
}
return f;
......@@ -486,6 +489,24 @@ void FlatModel::reset()
endResetModel();
}
QStringList FlatModel::mimeTypes() const
{
return QStringList() << QStringLiteral("text/uri-list");
}
QMimeData *FlatModel::mimeData(const QModelIndexList &indexes) const
{
QList<QUrl> urls;
foreach (const QModelIndex &index, indexes) {
Node *node = nodeForIndex(index);
if (qobject_cast<FileNode *>(node))
urls.append(QUrl::fromLocalFile(node->path()));
}
auto data = new QMimeData;
data->setUrls(urls);
return data;
}
QModelIndex FlatModel::indexForNode(const Node *node_)
{
// We assume that we are only called for nodes that are represented
......
......@@ -65,6 +65,9 @@ public:
void reset();
QStringList mimeTypes() const;
QMimeData *mimeData(const QModelIndexList &indexes) const;
void setStartupProject(ProjectNode *projectNode);
ProjectExplorer::Node *nodeForIndex(const QModelIndex &index) const;
......
......@@ -87,6 +87,8 @@ public:
{
setEditTriggers(QAbstractItemView::EditKeyPressed);
setContextMenuPolicy(Qt::CustomContextMenu);
setDragEnabled(true);
setDragDropMode(QAbstractItemView::DragOnly);
m_context = new IContext(this);
m_context->setContext(Context(ProjectExplorer::Constants::C_PROJECT_TREE));
m_context->setWidget(this);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment