Patch #3030 2010-07-21 11:36

codeman

Allow dragging multiple files into virtual folders.
Download
3030-Allow_dragging.patch (18.7 KB)
Category
Application::Refinement
Status
Accepted
Close date
2011-10-27 11:43
Assigned to
mortenmacfly
Index: src/include/cbproject.h
===================================================================
--- src/include/cbproject.h    (revision 6472)
+++ src/include/cbproject.h    (working copy)
@@ -558,12 +558,12 @@
           */
         bool CanDragNode(wxTreeCtrl* tree, wxTreeItemId node);
 
-        /** Notify that a specific tree node has been dragged.
+        /** Notify that an array of tree nodes has been dragged.
           *
           * @note Called by ProjectManager.
           * @return True if succeeded, false if not.
           */
-        bool NodeDragged(wxTreeCtrl* tree, wxTreeItemId from, wxTreeItemId to);
+        bool NodeDragged(wxTreeCtrl* tree, wxArrayTreeItemIds& fromArray, wxTreeItemId to);
 
         /** Notify that a virtual folder has been added.
           * @return True if it is allowed, false if not. */
Index: src/include/projectmanager.h
===================================================================
--- src/include/projectmanager.h    (revision 6472)
+++ src/include/projectmanager.h    (working copy)
@@ -370,6 +370,17 @@
           * @return A pointer to a wxTreeCtrl window.
           */
         wxTreeCtrl* GetTree(){ return m_pTree; }
+        /** Get the selection of the project manager's tree (GUI).
+          * This must be used instead of tree->GetSelection() because the tree
+          * has the wxTR_MULTIPLE style.
+          * This usually returns the first item in the selection list, but
+          * if there is a right-click popup menu then the user may have
+          * selected several items and right-clicked on one, so return the
+          * right-click item instead.
+          * of the first
+          * @return A wxTreeItemId of the selected tree item.
+          */
+        wxTreeItemId GetTreeSelection();
         /** Retrieve a pointer to the project manager's panel (GUI). This panel
           * is the parent of the project manager's tree obtained through GetTree().
           * @return A pointer to a wxPanel window.
@@ -507,7 +518,8 @@
         bool m_IsClosingProject;
         bool m_IsClosingWorkspace;
         wxString m_InitialDir;
-        wxTreeItemId m_DraggingItem;
+        wxArrayTreeItemIds m_DraggingSelection;
+        wxTreeItemId m_RightClickItem;
         bool m_isCheckingForExternallyModifiedProjects;
         bool m_CanSendWorkspaceChanged;
 
Index: src/plugins/astyle/astyleplugin.cpp
===================================================================
--- src/plugins/astyle/astyleplugin.cpp    (revision 6472)
+++ src/plugins/astyle/astyleplugin.cpp    (working copy)
@@ -131,12 +131,13 @@
 
 void AStylePlugin::OnFormatProject( wxCommandEvent& /*event*/ )
 {
-    wxTreeCtrl *tree = Manager::Get()->GetProjectManager()->GetTree();
+    ProjectManager* manager = Manager::Get()->GetProjectManager();
+    wxTreeCtrl *tree = manager->GetTree();
 
     if ( !tree )
         return;
 
-    wxTreeItemId treeItem =  tree->GetSelection();
+    wxTreeItemId treeItem =  manager->GetTreeSelection();
 
     if ( !treeItem.IsOk() )
         return;
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp    (revision 6472)
+++ src/plugins/compilergcc/compilergcc.cpp    (working copy)
@@ -982,8 +982,9 @@
 
 FileTreeData* CompilerGCC::DoSwitchProjectTemporarily()
 {
-    wxTreeCtrl* tree = Manager::Get()->GetProjectManager()->GetTree();
-    wxTreeItemId sel = tree->GetSelection();
+    ProjectManager* manager = Manager::Get()->GetProjectManager();
+    wxTreeCtrl* tree = manager->GetTree();
+    wxTreeItemId sel = manager->GetTreeSelection();
     FileTreeData* ftd = sel.IsOk() ? (FileTreeData*)tree->GetItemData(sel) : 0;
     if (!ftd)
         return 0L;
@@ -3200,8 +3201,9 @@
 
 void CompilerGCC::OnProjectCompilerOptions(wxCommandEvent& /*event*/)
 {
-    wxTreeCtrl* tree = Manager::Get()->GetProjectManager()->GetTree();
-    wxTreeItemId sel = tree->GetSelection();
+    ProjectManager* manager = Manager::Get()->GetProjectManager();
+    wxTreeCtrl* tree = manager->GetTree();
+    wxTreeItemId sel = manager->GetTreeSelection();
     FileTreeData* ftd = sel.IsOk() ? (FileTreeData*)tree->GetItemData(sel) : 0;
     if (ftd)
     {
Index: src/sdk/cbproject.cpp
===================================================================
--- src/sdk/cbproject.cpp    (revision 6472)
+++ src/sdk/cbproject.cpp    (working copy)
@@ -1170,60 +1170,88 @@
     return ftd->GetKind() == FileTreeData::ftdkFile || ftd->GetKind() == FileTreeData::ftdkVirtualFolder;
 }
 
-bool cbProject::NodeDragged(wxTreeCtrl* tree, wxTreeItemId from, wxTreeItemId to)
+bool cbProject::NodeDragged(wxTreeCtrl* tree, wxArrayTreeItemIds& fromArray, wxTreeItemId to)
 {
     // what items did we drag?
-    if (!from.IsOk() || !to.IsOk())
+    if (!to.IsOk())
         return false;
 
-    // if no data associated with it, disallow
-    FileTreeData* ftd1 = (FileTreeData*)tree->GetItemData(from);
-
download for full patch...
mortenmacfly 2010-07-29 20:11

I believe this introduces a major big now:

When a project is activated (in a workspace with more than one project) and I right-click on another (!) project to go to the build options of that other project I always get the build options of the activated project. This is a wrong behaviour.

mortenmacfly 2010-08-01 09:44

Any news on this? Because the bug I mentioned in the other comment I made is blocking this patch.

codeman 2010-08-01 16:14

Fixed this.

There usages of tree->GetSelection() still being used in compilergcc.cpp and astyleplugin.cpp.

I think Ive replaced them all with the correct manager->GetTreeSelection().

mortenmacfly 2010-08-11 14:30

Another issue: With this patch applied I cannot move projects within a workspace using CTRL+SHIFT + {Cursor UP/DOWN}. It works for one step and then nothing happens anymore.

codeman 2010-08-17 20:52

Ok Ive fixed that one too.

To make it simpler/more reliable, ive changed the system of getting the selected item. Ive explained it in projectmanager.h

codeman 2010-09-09 23:15

Is the patch ok now to go into the repository?

mortenmacfly 2011-10-27 11:43

Finally...