]> git.saurik.com Git - apt.git/commitdiff
fix SubProgress to accept a Percent parameter to update the Current
authorDavid Kalnischkies <kalnischkies@gmail.com>
Tue, 10 May 2011 10:18:08 +0000 (12:18 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Tue, 10 May 2011 10:18:08 +0000 (12:18 +0200)
with the text as otherwise the update will be ignored

apt-pkg/contrib/progress.cc
apt-pkg/contrib/progress.h
apt-pkg/edsp.cc

index 45e81edcb3ca3ab7b7f877f799cf7fb1aa9b9633..84ee4c124cf3c1c0c9c733f5a58e1aeca4e5f499 100644 (file)
@@ -65,27 +65,18 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
 // OpProgress::SubProgress - Set the sub progress state                        /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void OpProgress::SubProgress(unsigned long SubTotal,const string &Op)
+void OpProgress::SubProgress(unsigned long SubTotal,const string &Op,
+                            float const Percent)
 {
    this->SubTotal = SubTotal;
-   SubOp = Op;
-   if (Total == 0)
-      Percent = 0;
+   if (Op.empty() == false)
+      SubOp = Op;
+   if (Total == 0 || Percent == 0)
+      this->Percent = 0;
+   else if (Percent != -1)
+      this->Percent = this->Current += (Size*Percent)/SubTotal;
    else
-      Percent = Current*100.0/Total;
-   Update();
-}
-                                                                       /*}}}*/
-// OpProgress::SubProgress - Set the sub progress state                        /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-void OpProgress::SubProgress(unsigned long SubTotal)
-{
-   this->SubTotal = SubTotal;
-   if (Total == 0)
-      Percent = 0;
-   else
-      Percent = Current*100.0/Total;
+      this->Percent = Current*100.0/Total;
    Update();
 }
                                                                        /*}}}*/
index 7dd004f7e6fa2a3e305fae960968ea4877573600..3a914d17f6aca935059a30a56834875b85d745ea 100644 (file)
@@ -55,8 +55,7 @@ class OpProgress
    public:
    
    void Progress(unsigned long Current);
-   void SubProgress(unsigned long SubTotal);
-   void SubProgress(unsigned long SubTotal,const string &Op);
+   void SubProgress(unsigned long SubTotal, const string &Op = "", float const Percent = -1);
    void OverallProgress(unsigned long Current,unsigned long Total,
                        unsigned long Size,const string &Op);
    virtual void Done() {};
index 489dd293336a3c4a47b17b6a787bfb69e4644e4a..0e229e1c099118d6169854eaf69d22129fd5343f 100644 (file)
@@ -267,12 +267,10 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
                        type = "Remove";
                else if (section.Exists("Progress") == true) {
                        if (Progress != NULL) {
-                               string const msg = section.FindS("Message");
+                               string msg = section.FindS("Message");
                                if (msg.empty() == true)
-                                       Progress->SubProgress(100, _("Prepare for receiving solution"));
-                               else
-                                       Progress->SubProgress(100, msg);
-                               Progress->Progress(section.FindI("Percentage", 0));
+                                       msg = _("Prepare for receiving solution");
+                               Progress->SubProgress(100, msg, section.FindI("Percentage", 0));
                        }
                        continue;
                } else if (section.Exists("Error") == true) {