ordering combiSolutions
authorStefan Schubert <schubi@suse.de>
Mon, 14 Jan 2008 13:31:23 +0000 (13:31 +0000)
committerStefan Schubert <schubi@suse.de>
Mon, 14 Jan 2008 13:31:23 +0000 (13:31 +0000)
zypp/ResolverProblem.cc
zypp/ResolverProblem.h
zypp/sat/SATResolver.cc
zypp/solver/detail/ProblemSolutionCombi.cc
zypp/solver/detail/ProblemSolutionCombi.h

index af733aa..41969de 100644 (file)
@@ -101,9 +101,14 @@ ResolverProblem::solutions() const
  **/
 
 void
-ResolverProblem::addSolution( ProblemSolution_Ptr solution )
+ResolverProblem::addSolution( ProblemSolution_Ptr solution,
+                             bool inFront )
 {
-    _solutions.push_back (solution);
+    if (inFront) {
+       _solutions.push_front (solution);
+    } else {
+       _solutions.push_back (solution);
+    }
 }
 
 void
index 6780b96..4cd6b0d 100644 (file)
@@ -97,7 +97,7 @@ namespace zypp
         * Add a solution to this problem. This class takes over ownership of
         * the problem and will delete it when neccessary.
         **/
-       void addSolution( ProblemSolution_Ptr solution );
+       void addSolution( ProblemSolution_Ptr solution, bool inFront = false );
 
     };
     ///////////////////////////////////////////////////////////////////////
index b0c36cf..c1a20a9 100644 (file)
@@ -796,7 +796,8 @@ SATResolver::problems ()
                        }
                    }
                }
-               resolverProblem->addSolution (problemSolution);
+               resolverProblem->addSolution (problemSolution,
+                                             problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first.
                MIL << "------------------------------------" << endl;
            }
            // save problem
index 3facc6e..dd75863 100644 (file)
@@ -48,6 +48,7 @@ IMPL_PTR_TYPE(ProblemSolutionCombi);
 
 ProblemSolutionCombi::ProblemSolutionCombi( ResolverProblem_Ptr parent)
     : ProblemSolution (parent, "", "")
+      , actNumber(0)
 {
     _description = "";
     _details = "";
@@ -56,6 +57,7 @@ ProblemSolutionCombi::ProblemSolutionCombi( ResolverProblem_Ptr parent)
 void ProblemSolutionCombi::addSingleAction( PoolItem_Ref item, const TransactionKind action)
 {
     addAction (new TransactionSolutionAction(item, action));
+    actNumber++;
 }
 
 void ProblemSolutionCombi::addDescription( const std::string description)
index ba71bed..3958778 100644 (file)
@@ -44,6 +44,8 @@ namespace zypp
         **/
        class ProblemSolutionCombi : public ProblemSolution
        {
+        protected:
+           int actNumber; // number of actions
        public:
 
            /**
@@ -54,10 +56,17 @@ namespace zypp
             * Add a single action
             */
            void addSingleAction( PoolItem_Ref item, const TransactionKind action);
+
+           /**
+            * returns the number of actions
+            */
+           int actionCount() { return actNumber;}
+           
            /**
             * Set description text
             */
-           void addDescription( const std::string description);            
+           void addDescription( const std::string description);
+
        };
 
       ///////////////////////////////////////////////////////////////////