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

Daniel Burrows dburrows at costa.debian.org
Tue Aug 16 18:53:40 UTC 2005


Author: dburrows
Date: Tue Aug 16 18:53:37 2005
New Revision: 3867

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/solution_screen.cc
Log:
Display unresolved recommendations in the solution tree.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Aug 16 18:53:37 2005
@@ -1,5 +1,11 @@
 2005-08-16  Daniel Burrows  <dburrows at debian.org>
 
+	* src/solution_screen.cc:
+
+	  View unresolved recomendations in the solution tree too.
+	  Untested; I need to come up with a test case where recommends
+	  can't be satisfied.
+
 	* src/solution_fragment.cc, src/solution_fragment.h:
 
 	  Rename dep_targets_fragment to dep_targets; now it just

Modified: branches/aptitude-0.3/aptitude/src/solution_screen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/solution_screen.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/solution_screen.cc	Tue Aug 16 18:53:37 2005
@@ -20,6 +20,7 @@
 #include "solution_screen.h"
 
 #include "aptitude.h"
+#include "solution_fragment.h"
 
 #include <generic/aptitude_resolver_universe.h>
 #include <generic/problemresolver/exceptions.h>
@@ -157,13 +158,7 @@
 
 class solution_item : public vs_treeitem
 {
-  aptitude_universe::version ver;
 public:
-  solution_item(const aptitude_solution::action &act)
-    :ver(act.ver)
-  {
-  }
-
   const wchar_t *tag()
   {
     return L"";
@@ -174,6 +169,64 @@
     return L"";
   }
 
+  virtual bool is_rejected() = 0;
+
+  virtual bool is_mandatory() = 0;
+
+  virtual void reject() = 0;
+
+  virtual void unreject() = 0;
+
+  virtual void mandate() = 0;
+
+  virtual void unmandate() = 0;
+
+  style get_normal_style()
+  {
+    if(is_rejected())
+      return get_style("SolutionActionRejected");
+    else if(is_mandatory())
+      return get_style("SolutionActionAccepted");
+    else
+      return style();
+  }
+
+  bool dispatch_key(const key &k, vs_tree *owner)
+  {
+    if(global_bindings.key_matches(k, "SolutionActionReject"))
+      {
+	if(is_rejected())
+	  unreject();
+	else
+	  reject();
+
+	owner->line_down();
+      }
+    else if(global_bindings.key_matches(k, "SolutionActionAccept"))
+      {
+	if(is_mandatory())
+	  unmandate();
+	else
+	  mandate();
+
+	owner->line_down();
+      }
+    else
+      return vs_treeitem::dispatch_key(k, owner);
+
+    return true;
+  }
+};
+
+class solution_act_item : public solution_item
+{
+  aptitude_universe::version ver;
+public:
+  solution_act_item(const aptitude_solution::action &act)
+    :ver(act.ver)
+  {
+  }
+
   bool is_rejected()
   {
     assert((*apt_cache_file)->resolver_exists());
@@ -248,16 +301,6 @@
       }
   }
 
-  style get_normal_style()
-  {
-    if(is_rejected())
-      return get_style("SolutionActionRejected");
-    else if(is_mandatory())
-      return get_style("SolutionActionAccepted");
-    else
-      return style();
-  }
-
   void paint(vs_tree *win, int y, bool hierarchical, const style &st)
   {
     unsigned int basex = hierarchical ? 2*get_depth() : 0;
@@ -370,31 +413,99 @@
 	++x;
       }
   }
+};
 
-  bool dispatch_key(const key &k, vs_tree *owner)
+class solution_unresolved_item : public solution_item
+{
+  pkgCache::DepIterator d;
+public:
+  solution_unresolved_item(const aptitude_universe::dep &_d)
+    :d(_d.get_dep())
   {
-    if(global_bindings.key_matches(k, "SolutionActionReject"))
+  }
+
+  bool is_rejected()
+  {
+    // STUB
+    return false;
+  }
+
+  bool is_mandatory()
+  {
+    // STUB
+    return false;
+  }
+
+  void reject()
+  {
+    // STUB
+  }
+
+  void unreject()
+  {
+    // STUB
+  }
+
+  void mandate()
+  {
+    // STUB
+  }
+
+  void unmandate()
+  {
+    // STUB
+  }
+
+  void paint(vs_tree *win, int y, bool hierarchical, const style &st)
+  {
+    unsigned int basex = hierarchical ? 2*get_depth() : 0;
+    unsigned int width = win->getmaxx();
+
+    unsigned int x = 0;
+
+    win->move(y, 0);
+
+    if(x < width)
       {
 	if(is_rejected())
-	  unreject();
+	  win->addch('R'); // For "reject"
+	else if(is_mandatory())
+	  win->addch('A'); // For "accept"
 	else
-	  reject();
+	  win->addch(' ');
+	++x;
+      }
 
-	owner->line_down();
+    if(x < width)
+      {
+	win->addch(' ');
+	++x;
       }
-    else if(global_bindings.key_matches(k, "SolutionActionAccept"))
+
+    while(x < width && x < basex)
       {
-	if(is_mandatory())
-	  unmandate();
-	else
-	  mandate();
+	win->addch(' ');
+	++x;
+      }
 
-	owner->line_down();
+    wstring text = swsprintf(transcode(_("%s recommends %s")).c_str(),
+			     d.ParentPkg().Name(),
+			     dep_targets(d).c_str());
+
+    wstring::const_iterator loc = text.begin();
+
+    while(loc != text.end() && x < width)
+      {
+	win->addch(*loc);
+	x += wcwidth(*loc);
+	++loc;
       }
-    else
-      return vs_treeitem::dispatch_key(k, owner);
 
-    return true;
+    while(x < width)
+      {
+	win->addch(' ');
+	++x;
+      }
   }
 };
 
@@ -429,7 +540,7 @@
 
       for(vector<aptitude_solution::action>::const_iterator i = remove_actions.begin();
 	  i != remove_actions.end(); ++i)
-	remove_tree->add_child(new solution_item(*i));
+	remove_tree->add_child(new solution_act_item(*i));
 
       root->add_child(remove_tree);
     }
@@ -440,7 +551,7 @@
 
       for(vector<aptitude_solution::action>::const_iterator i = keep_actions.begin();
 	  i != keep_actions.end(); ++i)
-	keep_tree->add_child(new solution_item(*i));
+	keep_tree->add_child(new solution_act_item(*i));
 
       root->add_child(keep_tree);
     }
@@ -451,7 +562,7 @@
 
       for(vector<aptitude_solution::action>::const_iterator i = install_actions.begin();
 	  i != install_actions.end(); ++i)
-	install_tree->add_child(new solution_item(*i));
+	install_tree->add_child(new solution_act_item(*i));
 
       root->add_child(install_tree);
     }
@@ -462,7 +573,7 @@
 
       for(vector<aptitude_solution::action>::const_iterator i = upgrade_actions.begin();
 	  i != upgrade_actions.end(); ++i)
-	upgrade_tree->add_child(new solution_item(*i));
+	upgrade_tree->add_child(new solution_act_item(*i));
 
       root->add_child(upgrade_tree);
     }
@@ -473,11 +584,25 @@
 
       for(vector<aptitude_solution::action>::const_iterator i = downgrade_actions.begin();
 	  i != downgrade_actions.end(); ++i)
-	downgrade_tree->add_child(new solution_item(*i));
+	downgrade_tree->add_child(new solution_act_item(*i));
 
       root->add_child(downgrade_tree);
     }
 
+  
+  const set<aptitude_universe::dep> &unresolved = sol.get_unresolved_soft_deps();
+
+  if(!unresolved.empty())
+    {
+      vs_subtree_generic *unresolved_tree = new label_tree(transcode(_("Leave the following recommendations unresolved:")));
+
+      for(set<aptitude_universe::dep>::const_iterator i = unresolved.begin();
+	  i != unresolved.end(); ++i)
+	unresolved_tree->add_child(new solution_unresolved_item(*i));
+
+      root->add_child(unresolved_tree);
+    }
+
   return root;
 }
 



More information about the Aptitude-svn-commit mailing list