[Aptitude-svn-commit] r4195 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows at costa.debian.org
Thu Sep 22 23:52:42 UTC 2005


Author: dburrows
Date: Thu Sep 22 23:52:39 2005
New Revision: 4195

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/menu_tree.cc
   branches/aptitude-0.3/aptitude/src/menu_tree.h
Log:
Implement the resolver stuff in menu_tree.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Thu Sep 22 23:52:39 2005
@@ -1,5 +1,12 @@
 2005-09-22  Daniel Burrows  <dburrows at debian.org>
 
+	* src/menu_tree.cc, src/menu_tree.h:
+
+	  Implement the resolver commands.  This exposed some real
+	  kludginess in the menu_tree that should be fixed in the future
+	  (I imagine it acting as simply a proxy for the selection when
+	  the selection is a menu_redirect).
+
 	* src/solution_item.cc, src/solution_item.h:
 
 	  Split the key response actions into public methods.

Modified: branches/aptitude-0.3/aptitude/src/menu_tree.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/menu_tree.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/menu_tree.cc	Thu Sep 22 23:52:39 2005
@@ -24,6 +24,7 @@
 #include "pkg_item.h"
 #include "pkg_tree.h" // For pkg_tree::bindings(?!?!)
 #include "pkg_ver_item.h"
+#include "solution_item.h"
 #include "ui.h"
 #include "view_changelog.h"
 
@@ -74,7 +75,7 @@
   delete last_search_matcher;
 }
 
-pkg_tree_node *menu_tree::selection()
+pkg_tree_node *menu_tree::pkg_node_selection()
 {
   vs_treeiterator i=get_selected();
 
@@ -84,9 +85,19 @@
     return dynamic_cast<pkg_tree_node *>(&*i);
 }
 
+solution_item *menu_tree::solution_selection()
+{
+  vs_treeiterator i = get_selected();
+
+  if(i == get_end())
+    return NULL;
+  else
+    return dynamic_cast<solution_item *>(&*i);
+}
+
 bool menu_tree::pkg_or_ver_selected()
 {
-  pkg_tree_node *curr=selection();
+  pkg_tree_node *curr = pkg_node_selection();
 
   if(curr && (dynamic_cast<pkg_item*>(curr) ||
 	      dynamic_cast<pkg_ver_item*>(curr)))
@@ -97,7 +108,7 @@
 
 bool menu_tree::package_enabled()
 {
-  return get_visible() && selection()!=NULL;
+  return get_visible() && pkg_node_selection()!=NULL;
 }
 
 bool menu_tree::package_action(void (pkg_tree_node::* action)(undo_group *))
@@ -105,7 +116,7 @@
   if(!get_visible())
     return false;
 
-  pkg_tree_node *curr=selection();
+  pkg_tree_node *curr = pkg_node_selection();
 
   if(curr)
     {
@@ -174,7 +185,7 @@
   if(!get_visible())
     return false;
 
-  pkg_tree_node *curr=selection();
+  pkg_tree_node *curr = pkg_node_selection();
 
   if(!curr)
     return false;
@@ -235,7 +246,7 @@
   if(!get_visible())
     return false;
 
-  pkg_tree_node *curr=selection();  
+  pkg_tree_node *curr = pkg_node_selection();  
 
   if(!curr)
     return false;
@@ -270,7 +281,7 @@
   if(!get_visible())
     return false;
 
-  pkg_tree_node *curr=selection();  
+  pkg_tree_node *curr = pkg_node_selection();  
 
   if(!curr)
     return false;
@@ -298,32 +309,67 @@
 
 bool menu_tree::resolver_toggle_rejected()
 {
-  return false;
+  if(!get_visible())
+    return false;
+
+  solution_item *item = solution_selection();
+  if(item == NULL)
+    return false;
+
+  item->toggle_rejected();
+  return true;
 }
 
 bool menu_tree::resolver_toggle_rejected_enabled()
 {
-  return false;
+  return get_visible() && solution_selection() != NULL;
 }
 
 bool menu_tree::resolver_toggle_approved()
 {
-  return false;
+  if(!get_visible())
+    return false;
+
+  solution_item *item = solution_selection();
+  if(item == NULL)
+    return false;
+
+  item->toggle_mandated();
+  return true;
 }
 
+/// \todo eliminate casts as described in the .h
 bool menu_tree::resolver_toggle_approved_enabled()
 {
-  return false;
+  return get_visible() && solution_selection() != NULL;
 }
 
 bool menu_tree::resolver_view_target()
 {
-  return false;
+  vs_treeiterator i = get_selected();
+
+  if(i == get_end())
+    return false;
+
+  solution_act_item *item = dynamic_cast<solution_act_item *>(&*i);
+
+  if(item == NULL)
+    return false;
+
+  item->show_target_info();
+  return true;
 }
 
 bool menu_tree::resolver_view_target_enabled()
 {
-  return false;
+  vs_treeiterator i = get_selected();
+
+  if(i == get_end())
+    return false;
+
+  solution_act_item *item = dynamic_cast<solution_act_item *>(&*i);
+
+  return item != NULL;
 }
 
 

Modified: branches/aptitude-0.3/aptitude/src/menu_tree.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/menu_tree.h	(original)
+++ branches/aptitude-0.3/aptitude/src/menu_tree.h	Thu Sep 22 23:52:39 2005
@@ -30,6 +30,7 @@
 
 class pkg_matcher;
 class pkg_tree_node;
+class solution_item;
 class undo_group;
 
 /** A vs_tree that can be generically used as a menu redirector.  All
@@ -37,11 +38,21 @@
  *  currently selected tree item is used to implement them.  In
  *  addition, the tree will pop up a search dialog in response to
  *  either the Search menu command or the corresponding keybinding.
+ *
+ *  \todo eliminate some of the dynamic_casting by making
+ *  pkg_tree_node and solution_item subclasses of menu_redirect; then
+ *  you can just cast the active item to a menu_redirect and proxy for
+ *  it.
  */
 class menu_tree:public vs_tree, public menu_redirect
 {
   /** Return the selected node, if any, or \b NULL if no node is selected. */
-  pkg_tree_node *selection();
+  pkg_tree_node *pkg_node_selection();
+
+  /** Return the selected solution item, if any, or \b NULL if no
+   *  solution is selected.
+   */
+  solution_item *solution_selection();
 
   /** A precompiled matcher representing the last search that was performed. */
   pkg_matcher *last_search_matcher;



More information about the Aptitude-svn-commit mailing list