<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/101234/">http://git.reviewboard.kde.org/r/101234/</a>
</td>
</tr>
</table>
<br />
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I guess I'll just put this here...
Drag and drop support for the ProjectTreeView. Not production code. Testing purposes only.
----------------------------------------------------------------------------------------
diff --git a/plugins/projectmanagerview/projecttreeview.cpp b/plugins/projectmanagerview/projecttreeview.cpp
index 920eb5a..4013f0b 100644
--- a/plugins/projectmanagerview/projecttreeview.cpp
+++ b/plugins/projectmanagerview/projecttreeview.cpp
@@ -50,6 +50,10 @@
#include <language/util/navigationtooltip.h>
#include <project/projectutils.h>
+#include <project/interfaces/iprojectfilemanager.h>
+#include <interfaces/iselectioncontroller.h>
+#include <project/interfaces/ibuildsystemmanager.h>
+
using namespace KDevelop;
ProjectTreeView::ProjectTreeView( QWidget *parent )
@@ -64,10 +68,62 @@ ProjectTreeView::ProjectTreeView( QWidget *parent )
setIndentation(10);
+ setDragEnabled(true);
+ setDragDropMode( QAbstractItemView::InternalMove );
+ setDropIndicatorShown(true);
+
connect( this, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( popupContextMenu( QPoint ) ) );
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( slotActivated( QModelIndex ) ) );
}
+QList<ProjectFileItem*> fileItemsWithin(const QList<ProjectBaseItem*> items)
+{
+ QList<ProjectFileItem*> fileItems;
+ foreach(ProjectBaseItem* item, items)
+ {
+ if (ProjectFileItem *file = item->file())
+ fileItems.append(file);
+ else if (item->folder())
+ fileItems.append(fileItemsWithin(item->children()));
+ }
+ return fileItems;
+}
+
+QList<ProjectBaseItem*> topLevelItemsWithin(QList<ProjectBaseItem*> items)
+{
+ qSort(items.begin(), items.end(), ProjectBaseItem::urlLessThan);
+ KUrl lastFolder;
+ for (int i = items.size() - 1; i >= 0; --i)
+ {
+ if (lastFolder.isParentOf(items[i]->url()))
+ items.removeAt(i);
+ else if (items[i]->folder())
+ lastFolder = items[i]->url();
+ }
+ return items;
+}
+
+void ProjectTreeView::dropEvent(QDropEvent* event)
+{
+ QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel*>(model());
+ ProjectBaseItem* item = projectModel()->itemFromIndex(proxy->mapToSource(indexAt(event->pos())));
+ ProjectItemContext* selectionCtxt = static_cast<ProjectItemContext*>(KDevelop::ICore::self()->selectionController()->currentSelection());
+ if (selectionCtxt && item)
+ {
+ if (ProjectFolderItem *folder = item->folder())
+ {
+ QList<ProjectBaseItem*> usefulItems = topLevelItemsWithin(selectionCtxt->items());
+ item->project()->projectFileManager()->moveFilesAndFolders(usefulItems, folder);
+ }
+ else if (item->target() && item->project()->buildSystemManager())
+ {
+ QList<ProjectFileItem*> usefulItems = fileItemsWithin(selectionCtxt->items());
+ item->project()->buildSystemManager()->addFilesToTarget(usefulItems, item->target());
+ }
+ }
+ event->accept();
+}
+
ProjectTreeView::~ProjectTreeView()
{
}
diff --git a/plugins/projectmanagerview/projecttreeview.h b/plugins/projectmanagerview/projecttreeview.h
index 99bfc7f..2654369 100644
--- a/plugins/projectmanagerview/projecttreeview.h
+++ b/plugins/projectmanagerview/projecttreeview.h
@@ -69,6 +69,7 @@ class ProjectTreeView: public QTreeView
protected:
virtual void keyPressEvent(QKeyEvent *event);
+ virtual void dropEvent(QDropEvent* event);
private:
KDevelop::IProject* m_ctxProject;
-------------------------------------------------------------------------------------------</pre>
<br />
<p>- Olivier Jean de</p>
<br />
<p>On April 26th, 2011, 3:48 a.m., Olivier Jean de Gaalon wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for KDevelop.</div>
<div>By Olivier Jean de Gaalon.</div>
<p style="color: grey;"><i>Updated April 26, 2011, 3:48 a.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Add moveFilesAndFolders function to iprojectfilemanager
Add context-menu support for removing files from targets
Add drag and drop support to model items
Fix ibuildsystem manager to get rid of the TargetFile QPair
See also kdevelop patch.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">See kdevelop patch.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>plugins/projectmanagerview/projectmanagerviewplugin.h <span style="color: grey">(5f3e06f)</span></li>
<li>plugins/projectmanagerview/projectmanagerviewplugin.cpp <span style="color: grey">(b3cb948)</span></li>
<li>project/abstractfilemanagerplugin.h <span style="color: grey">(3404744)</span></li>
<li>project/abstractfilemanagerplugin.cpp <span style="color: grey">(6d23a15)</span></li>
<li>project/interfaces/ibuildsystemmanager.h <span style="color: grey">(eba6984)</span></li>
<li>project/interfaces/iprojectfilemanager.h <span style="color: grey">(aad8beb)</span></li>
<li>project/projectmodel.h <span style="color: grey">(d1cb3cc)</span></li>
<li>project/projectmodel.cpp <span style="color: grey">(981bd3f)</span></li>
<li>shell/kross/xmltokross/dummybsm.h <span style="color: grey">(5b8b0c6)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/101234/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>