Author Topic: project manager tree item double click  (Read 7976 times)

Offline blueshake

  • Regular
  • ***
  • Posts: 459
project manager tree item double click
« on: August 27, 2009, 08:06:46 am »
apply this patch,when you double click the item on manager tree,
if item is folder ,the item will expand or collapse.
Code
Index: projectmanager.cpp
===================================================================
--- projectmanager.cpp (revision 5744)
+++ projectmanager.cpp (working copy)
@@ -1761,6 +1761,12 @@
             #endif
         }
     }
+    else if (ftd && ftd->GetKind() == FileTreeData::ftdkVirtualGroup)
+    {
+        #ifdef __WXMSW__
+        m_pTree->IsExpanded(id) ? m_pTree->Collapse(id) : m_pTree->Expand(id);
+        #endif
+    }
     else
         DoOpenSelectedFile();
 }
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: project manager tree item double click
« Reply #1 on: August 27, 2009, 09:12:05 am »
This is what I expect for long time.
I will apply and test it!
Thanks!!!

Edit

It works OK!
« Last Edit: August 27, 2009, 09:35:50 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: project manager tree item double click
« Reply #2 on: August 27, 2009, 11:49:48 am »
I find a bug.
It seems only the second level of the tree can be open and collapse by double click.

See the screen shot blew:



[attachment deleted by admin]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: project manager tree item double click
« Reply #3 on: August 27, 2009, 12:00:02 pm »
@ollydbg
thank you for your feedback.
here is the new patch.
Code
Index: projectmanager.cpp
===================================================================
--- projectmanager.cpp (revision 5744)
+++ projectmanager.cpp (working copy)
@@ -1761,6 +1761,12 @@
             #endif
         }
     }
+    else if (ftd && (ftd->GetKind() == FileTreeData::ftdkVirtualGroup || ftd->GetKind() == FileTreeData::ftdkFolder))
+    {
+        #ifdef __WXMSW__
+        m_pTree->IsExpanded(id) ? m_pTree->Collapse(id) : m_pTree->Expand(id);
+        #endif
+    }
     else
         DoOpenSelectedFile();
 }
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: project manager tree item double click
« Reply #4 on: August 27, 2009, 12:12:07 pm »
Ok, I think you should add another option.

It seems the "first tree level" which named "Code::blocks" in my previous image still can't work.

So, it should like:

Code
else if (ftd && (ftd->GetKind() == FileTreeData::ftdkVirtualGroup || ftd->GetKind() == FileTreeData::ftdkFolder)  || ftd->GetKind() == XXXXXXX)

 :D
« Last Edit: August 27, 2009, 12:13:40 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: project manager tree item double click
« Reply #5 on: August 27, 2009, 12:23:07 pm »
the first level is project and had been implemented by prior codes.
it can work when the current project is not that you double click.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: project manager tree item double click
« Reply #6 on: August 27, 2009, 12:31:08 pm »
The first level is "workplace", then "project".
Till now, these two levels can't work. see my screen shot.


[attachment deleted by admin]
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: project manager tree item double click
« Reply #7 on: August 27, 2009, 01:31:13 pm »
ok , by this patch, everytingn work now.
Code
Index: projectmanager.cpp
===================================================================
--- projectmanager.cpp (revision 5744)
+++ projectmanager.cpp (working copy)
@@ -1754,13 +1754,25 @@
         if (ftd->GetProject() != m_pActiveProject)
         {
             SetProject(ftd->GetProject(), false);
-            // prevent item expand state toggle when project is activated
-            #ifdef __WXMSW__
-            // toggle it one time so that it is toggled back by wx
-            m_pTree->IsExpanded(id) ? m_pTree->Collapse(id) : m_pTree->Expand(id);
-            #endif
         }
+        // prevent item expand state toggle when project is activated
+        #ifdef __WXMSW__
+        // toggle it one time so that it is toggled back by wx
+        m_pTree->IsExpanded(id) ? m_pTree->Collapse(id) : m_pTree->Expand(id);
+        #endif
     }
+    else if (ftd && (ftd->GetKind() == FileTreeData::ftdkVirtualGroup || ftd->GetKind() == FileTreeData::ftdkFolder))
+    {
+        #ifdef __WXMSW__
+        m_pTree->IsExpanded(id) ? m_pTree->Collapse(id) : m_pTree->Expand(id);
+        #endif
+    }
+    else if (!ftd && m_pWorkspace)
+    {
+        #ifdef __WXMSW__
+        m_pTree->IsExpanded(m_TreeRoot) ? m_pTree->Collapse(m_TreeRoot) : m_pTree->Expand(m_TreeRoot);
+        #endif
+    }
     else
         DoOpenSelectedFile();
 }
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: project manager tree item double click
« Reply #8 on: August 27, 2009, 02:48:11 pm »
@blueshake

Thanks, it works now, till now I haven't found any bug!
What a great improvement! :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: project manager tree item double click
« Reply #9 on: August 27, 2009, 03:39:15 pm »
Why do you have those windows guards?
I'll give it a try (on linux) when I get home later today.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: project manager tree item double click
« Reply #10 on: August 27, 2009, 03:43:45 pm »
Why do you have those windows guards?
I'll give it a try (on linux) when I get home later today.

Both blueshake and I use only Windows OS I think. :D
If it works on Linux. these guards should be deleted.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: project manager tree item double click
« Reply #11 on: August 27, 2009, 09:38:47 pm »
It works.... with some modifications....

Code
Index: src/sdk/projectmanager.cpp
===================================================================
--- src/sdk/projectmanager.cpp  (revision 5742)
+++ src/sdk/projectmanager.cpp  (working copy)
@@ -1754,12 +1754,18 @@
         if (ftd->GetProject() != m_pActiveProject)
         {
             SetProject(ftd->GetProject(), false);
-            // prevent item expand state toggle when project is activated
-            #ifdef __WXMSW__
-            // toggle it one time so that it is toggled back by wx
-            m_pTree->IsExpanded(id) ? m_pTree->Collapse(id) : m_pTree->Expand(id);
-            #endif
         }
+        // prevent item expand state toggle when project is activated
+        // toggle it one time so that it is toggled back by wx
+        m_pTree->IsExpanded(id) ? m_pTree->Collapse(id) : m_pTree->Expand(id);
+    }
+    else if (ftd && (ftd->GetKind() == FileTreeData::ftdkVirtualGroup || ftd->GetKind() == FileTreeData::ftdkFolder))
+    {
+        m_pTree->IsExpanded(id) ? m_pTree->Collapse(id) : m_pTree->Expand(id);
+    }
+    else if (!ftd && m_pWorkspace)
+    {
+        m_pTree->IsExpanded(m_TreeRoot) ? m_pTree->Collapse(m_TreeRoot) : m_pTree->Expand(m_TreeRoot);
     }
     else
         DoOpenSelectedFile();

Best regards

p.s. blueshake, please call svn diff from the root of the project, so the patches are easier to apply
p.s.s. guards should be place only if the wx docs say that the used API is platform specific... in the above code non-win32 users won't be able to test your work
« Last Edit: August 27, 2009, 09:42:13 pm by oBFusCATed »
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]