Просмотр исходного кода

fix SubProgress to accept a Percent parameter to update the Current
with the text as otherwise the update will be ignored

David Kalnischkies лет назад: 15
Родитель
Сommit
c6660a4ba9
3 измененных файлов с 13 добавлено и 25 удалено
  1. 9 18
      apt-pkg/contrib/progress.cc
  2. 1 2
      apt-pkg/contrib/progress.h
  3. 3 5
      apt-pkg/edsp.cc

+ 9 - 18
apt-pkg/contrib/progress.cc

@@ -65,27 +65,18 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total,
 // OpProgress::SubProgress - Set the sub progress state			/*{{{*/
 // 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;
    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
    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();
    Update();
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 1 - 2
apt-pkg/contrib/progress.h

@@ -55,8 +55,7 @@ class OpProgress
    public:
    public:
    
    
    void Progress(unsigned long Current);
    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,
    void OverallProgress(unsigned long Current,unsigned long Total,
 			unsigned long Size,const string &Op);
 			unsigned long Size,const string &Op);
    virtual void Done() {};
    virtual void Done() {};

+ 3 - 5
apt-pkg/edsp.cc

@@ -267,12 +267,10 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
 			type = "Remove";
 			type = "Remove";
 		else if (section.Exists("Progress") == true) {
 		else if (section.Exists("Progress") == true) {
 			if (Progress != NULL) {
 			if (Progress != NULL) {
-				string const msg = section.FindS("Message");
+				string msg = section.FindS("Message");
 				if (msg.empty() == true)
 				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;
 			continue;
 		} else if (section.Exists("Error") == true) {
 		} else if (section.Exists("Error") == true) {