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

Not including secondary background transfers in statistics + Bug fix: Pending background transfers were not considered for progress bar on task bar button.

Source commit: 32fbe70426519049c7c6fd68dacce9144c72516e
Martin Prikryl 8 лет назад
Родитель
Сommit
ed9482ab69
3 измененных файлов с 58 добавлено и 23 удалено
  1. 39 10
      source/core/Queue.cpp
  2. 9 2
      source/core/Queue.h
  3. 10 11
      source/forms/CustomScpExplorer.cpp

+ 39 - 10
source/core/Queue.cpp

@@ -1885,6 +1885,8 @@ __fastcall TTerminalQueueStatus::~TTerminalQueueStatus()
 void __fastcall TTerminalQueueStatus::ResetStats()
 {
   FActiveCount = -1;
+  FActivePrimaryCount = -1;
+  FActiveAndPendingPrimaryCount = -1;
 }
 //---------------------------------------------------------------------------
 void __fastcall TTerminalQueueStatus::SetDoneCount(int Value)
@@ -1893,21 +1895,36 @@ void __fastcall TTerminalQueueStatus::SetDoneCount(int Value)
   ResetStats();
 }
 //---------------------------------------------------------------------------
-int __fastcall TTerminalQueueStatus::GetActiveCount()
+void __fastcall TTerminalQueueStatus::NeedStats()
 {
   if (FActiveCount < 0)
   {
     FActiveCount = 0;
-
-    int Index = FDoneCount;
-    while ((Index < FList->Count) &&
-      (GetItem(Index)->Status != TQueueItem::qsPending))
+    FActivePrimaryCount = 0;
+    FActiveAndPendingPrimaryCount = 0;
+    for (int Index = DoneCount; Index < Count; Index++)
     {
-      FActiveCount++;
-      Index++;
+      bool Primary = GetItem(Index)->Info->Primary;
+
+      if (GetItem(Index)->Status != TQueueItem::qsPending)
+      {
+        FActiveCount++;
+        if (Primary)
+        {
+          FActivePrimaryCount++;
+        }
+      }
+      if (Primary)
+      {
+        FActiveAndPendingPrimaryCount++;
+      }
     }
   }
-
+}
+//---------------------------------------------------------------------------
+int __fastcall TTerminalQueueStatus::GetActiveCount()
+{
+  NeedStats();
   return FActiveCount;
 }
 //---------------------------------------------------------------------------
@@ -1916,9 +1933,21 @@ int __fastcall TTerminalQueueStatus::GetDoneAndActiveCount()
   return DoneCount + ActiveCount;
 }
 //---------------------------------------------------------------------------
-int __fastcall TTerminalQueueStatus::GetActiveAndPendingCount()
+int __fastcall TTerminalQueueStatus::GetActivePrimaryCount()
+{
+  NeedStats();
+  return FActivePrimaryCount;
+}
+//---------------------------------------------------------------------------
+bool __fastcall TTerminalQueueStatus::IsOnlyOneActiveAndNoPending()
+{
+  return (ActivePrimaryCount == 1) && (ActiveAndPendingPrimaryCount == 1);
+}
+//---------------------------------------------------------------------------
+int __fastcall TTerminalQueueStatus::GetActiveAndPendingPrimaryCount()
 {
-  return Count - DoneCount;
+  NeedStats();
+  return FActiveAndPendingPrimaryCount;
 }
 //---------------------------------------------------------------------------
 void __fastcall TTerminalQueueStatus::Add(TQueueItemProxy * ItemProxy)

+ 9 - 2
source/core/Queue.h

@@ -267,25 +267,32 @@ public:
   __property int DoneCount = { read = FDoneCount };
   __property int ActiveCount = { read = GetActiveCount };
   __property int DoneAndActiveCount = { read = GetDoneAndActiveCount };
-  __property int ActiveAndPendingCount = { read = GetActiveAndPendingCount };
+  __property int ActivePrimaryCount = { read = GetActivePrimaryCount };
+  __property int ActiveAndPendingPrimaryCount = { read = GetActiveAndPendingPrimaryCount };
   __property TQueueItemProxy * Items[int Index] = { read = GetItem };
 
+  bool __fastcall IsOnlyOneActiveAndNoPending();
+
 protected:
   __fastcall TTerminalQueueStatus();
 
   void __fastcall Add(TQueueItemProxy * ItemProxy);
   void __fastcall Delete(TQueueItemProxy * ItemProxy);
   void __fastcall ResetStats();
+  void __fastcall NeedStats();
 
 private:
   TList * FList;
   int FDoneCount;
   int FActiveCount;
+  int FActivePrimaryCount;
+  int FActiveAndPendingPrimaryCount;
 
   int __fastcall GetCount();
   int __fastcall GetActiveCount();
   int __fastcall GetDoneAndActiveCount();
-  int __fastcall GetActiveAndPendingCount();
+  int __fastcall GetActivePrimaryCount();
+  int __fastcall GetActiveAndPendingPrimaryCount();
   void __fastcall SetDoneCount(int Value);
   TQueueItemProxy * __fastcall GetItem(int Index);
 };

+ 10 - 11
source/forms/CustomScpExplorer.cpp

@@ -683,8 +683,7 @@ UnicodeString __fastcall TCustomScpExplorerForm::GetQueueProgressTitle()
   UnicodeString Result;
   if (FQueueStatus != NULL)
   {
-    int ActiveAndPendingCount = FQueueStatus->ActiveAndPendingCount;
-    if ((ActiveAndPendingCount == 1) && (FQueueStatus->ActiveCount == 1))
+    if (FQueueStatus->IsOnlyOneActiveAndNoPending())
     {
       TFileOperationProgressType * ProgressData =
         FQueueStatus->Items[FQueueStatus->DoneCount]->ProgressData;
@@ -693,9 +692,9 @@ UnicodeString __fastcall TCustomScpExplorerForm::GetQueueProgressTitle()
         Result = TProgressForm::ProgressStr(ProgressData);
       }
     }
-    else if (ActiveAndPendingCount > 1)
+    else if (FQueueStatus->ActiveAndPendingPrimaryCount > 1)
     {
-      Result = FMTLOAD(PROGRESS_IN_QUEUE, (ActiveAndPendingCount));
+      Result = FMTLOAD(PROGRESS_IN_QUEUE, (FQueueStatus->ActiveAndPendingPrimaryCount));
     }
   }
   return Result;
@@ -839,9 +838,9 @@ void __fastcall TCustomScpExplorerForm::SetQueueProgress()
 
   if ((FTaskbarList != NULL) && (FProgressForm == NULL))
   {
-    if ((FQueueStatus != NULL) && (FQueueStatus->ActiveCount > 0))
+    if ((FQueueStatus != NULL) && (FQueueStatus->ActiveAndPendingPrimaryCount > 0))
     {
-      if (FQueueStatus->ActiveCount == 1)
+      if (FQueueStatus->IsOnlyOneActiveAndNoPending())
       {
         TFileOperationProgressType * ProgressData = NULL;
         if (FQueueStatus->Items[FQueueStatus->DoneCount] != NULL)
@@ -878,10 +877,10 @@ void __fastcall TCustomScpExplorerForm::UpdateQueueLabel()
   UnicodeString Caption = LoadStr(QUEUE_CAPTION);
   if (FQueueStatus != NULL)
   {
-    int ActiveAndPendingCount = FQueueStatus->ActiveAndPendingCount;
-    if (ActiveAndPendingCount > 0)
+    int ActiveAndPendingPrimaryCount = FQueueStatus->ActiveAndPendingPrimaryCount;
+    if (ActiveAndPendingPrimaryCount > 0)
     {
-      Caption = FORMAT("%s (%d)", (Caption, ActiveAndPendingCount));
+      Caption = FORMAT("%s (%d)", (Caption, ActiveAndPendingPrimaryCount));
     }
   }
   QueueLabel->Caption = Caption;
@@ -4374,11 +4373,11 @@ void __fastcall TCustomScpExplorerForm::ApplicationRestore(TObject * /*Sender*/)
   // When restoring maximized window from minimization,
   // rarely some controls do not align properly.
   // Two instances seen (both for Commander):
-  // - When restoring, window is temporarily narrower (not maximizer),
+  // - When restoring, window is temporarily narrower (not maximized),
   //   causing toolbars on TopDock to wrap and dock to expand horizontally.
   //   Once maximized already, top dock shinks back, but the session PageControl,
   //   do not align up, leaving space between TopDock and PageControl.
-  // - Similar issue seem with LocalDirView not aligning down to status bar.
+  // - Similar issue seen with LocalDirView not aligning down to status bar.
   for (int Index = 0; Index < ControlCount; Index++)
   {
     RealignControl(Controls[Index]);