Review Request: Add moveFilesAndFolders to iprojectfilemanager fix ibuildsystemmanager's TargetFile usage
Olivier Jean de Gaalon
olivier.jg at gmail.com
Tue Apr 26 04:01:13 UTC 2011
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/101234/#review2892
-----------------------------------------------------------
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;
-------------------------------------------------------------------------------------------
- Olivier Jean de
On April 26, 2011, 3:48 a.m., Olivier Jean de Gaalon wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/101234/
> -----------------------------------------------------------
>
> (Updated April 26, 2011, 3:48 a.m.)
>
>
> Review request for KDevelop.
>
>
> Summary
> -------
>
> 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.
>
>
> Diffs
> -----
>
> plugins/projectmanagerview/projectmanagerviewplugin.h 5f3e06f
> plugins/projectmanagerview/projectmanagerviewplugin.cpp b3cb948
> project/abstractfilemanagerplugin.h 3404744
> project/abstractfilemanagerplugin.cpp 6d23a15
> project/interfaces/ibuildsystemmanager.h eba6984
> project/interfaces/iprojectfilemanager.h aad8beb
> project/projectmodel.h d1cb3cc
> project/projectmodel.cpp 981bd3f
> shell/kross/xmltokross/dummybsm.h 5b8b0c6
>
> Diff: http://git.reviewboard.kde.org/r/101234/diff
>
>
> Testing
> -------
>
> See kdevelop patch.
>
>
> Thanks,
>
> Olivier Jean de
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20110426/a7bd6a9d/attachment.html>
More information about the KDevelop-devel
mailing list