Bug 85190

Summary: Unknown remaining time should be ??? insteed of 00:00:00
Product: [Applications] kget Reporter: Morten Sjoegren <kdestuff>
Component: generalAssignee: KGet authors <kget>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Mandrake RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Morten Sjoegren 2004-07-14 16:19:23 UTC
Version:            (using KDE KDE 3.2.3)
Installed from:    Mandrake RPMs
OS:                Linux

This is one small change I have in mind for KGet.
When downloading and the filesize is unknown, the columns "%" and "remaining time" should read "???" or "unknown" insteed of "99%" and "00:00:00" since the latter is... well a lie.
Comment 1 Morten Sjoegren 2005-05-20 22:36:54 UTC
Also if a download in kget is estimated to take longer then 24 hours, "remaining time" stops at "23:59:59". 
I think kget should count in days too, like this:
"1 day, 12:01:29"
or allow hours to be higher then 23, like this:
"36:01:29"
Comment 2 Urs Wolfer 2005-07-23 14:52:26 UTC
SVN commit 437888 by uwolfer:

* Remaining time: replace function KIO::calculateRemaining() with KIO::calculateRemainingSeconds() and KIO::convertSeconds(). So the time can be more than "23:59:59" (now for example "2 days 12:12:12").

BUG: 105770
CCBUG: 85190

* Better formatted systray tooltip.

 M  +3 -11     dlgIndividual.cpp  
 M  +1 -1      dlgIndividual.h  
 M  +9 -7      kmainwidget.cpp  
 M  +16 -10    transfer.cpp  
 M  +4 -3      transfer.h  


--- trunk/KDE/kdenetwork/kget/dlgIndividual.cpp #437887:437888
@@ -226,18 +226,10 @@
 }
 
 
-void DlgIndividual::setSpeed(unsigned long bytes_per_second, QTime remaining)
+void DlgIndividual::setSpeed(QString speed)
 {
-    QString msg;
-    if (bytes_per_second == 0 && item->getStatus() < Transfer::ST_RUNNING)
-        msg=i18n("Stalled");
-    else if (bytes_per_second == 0 && item->getStatus() == Transfer::ST_FINISHED)
-        msg=i18n("Finished");
-    else
-        msg=i18n("%1/s ( %2 )").arg(KIO::convertSize(bytes_per_second)).arg(remaining.toString());
-
-    speedLabel->setText(msg);
-    m_pDockIndividual->setTip(msg);
+    speedLabel->setText(speed);
+    m_pDockIndividual->setTip(speed);
 }
 
 
--- trunk/KDE/kdenetwork/kget/dlgIndividual.h #437887:437888
@@ -61,7 +61,7 @@
 
     void setProcessedSize(unsigned long bytes);
 
-    void setSpeed(unsigned long bytes_per_second, QTime remaining);
+    void setSpeed(QString speed);
     void setPercent(unsigned long percent);
 
     void setCopying(const KURL & src, const KURL & dest);
--- trunk/KDE/kdenetwork/kget/kmainwidget.cpp #437887:437888
@@ -83,6 +83,7 @@
 
 
 #include <kio/authinfo.h>
+#include <kio/global.h>
 #include <qiconset.h>
 
 #include "version.h"
@@ -396,7 +397,7 @@
     statusBar()->insertFixedItem(i18n(" Transfers: %1 ").arg(99), ID_TOTAL_TRANSFERS);
     statusBar()->insertFixedItem(i18n(" Files: %1 ").arg(555), ID_TOTAL_FILES);
     statusBar()->insertFixedItem(i18n(" Size: %1 KB ").arg("134.56"), ID_TOTAL_SIZE);
-    statusBar()->insertFixedItem(i18n(" Time: 00:00:00 "), ID_TOTAL_TIME);
+    statusBar()->insertFixedItem(i18n(" Time: %1 ").arg(KIO::convertSeconds(0)) + "            ", ID_TOTAL_TIME); //added some spaces because "2 days 12:12:12" need more place as "12:12:12"
     statusBar()->insertFixedItem(i18n(" %1 KB/s ").arg("123.34"), ID_TOTAL_SPEED);
 
     setAutoSaveSettings( "MainWindow", false /*Settings takes care of size & pos & state */ );
@@ -2049,7 +2050,7 @@
     int totalFiles = 0;
     KIO::filesize_t totalSize = 0;
     int totalSpeed = 0;
-    QTime remTime;
+    unsigned int remTime = 0;
 
     TransferIterator it(myTransferList);
 
@@ -2069,14 +2070,15 @@
     statusBar()->changeItem(i18n(" Transfers: %1 ").arg(myTransferList->childCount()), ID_TOTAL_TRANSFERS);
     statusBar()->changeItem(i18n(" Files: %1 ").arg(totalFiles), ID_TOTAL_FILES);
     statusBar()->changeItem(i18n(" Size: %1 ").arg(KIO::convertSize(totalSize)), ID_TOTAL_SIZE);
-    statusBar()->changeItem(i18n(" Time: %1 ").arg(remTime.toString()), ID_TOTAL_TIME);
+    statusBar()->changeItem(i18n(" Time: %1 ").arg(KIO::convertSeconds(remTime)), ID_TOTAL_TIME);
     statusBar()->changeItem(i18n(" %1/s ").arg(KIO::convertSize(totalSpeed)), ID_TOTAL_SPEED);
 
     if (kdock) {
-        tmpstr = i18n(" Transfers: %1 ").arg(myTransferList->childCount()) +
-                 i18n(" Files: %1 ").arg(totalFiles)+
-                 i18n(" Size: %1 ").arg(KIO::convertSize(totalSize))+
-                 i18n(" Time: %1 %2/s").arg(remTime.toString()).arg(KIO::convertSize(totalSpeed));
+        tmpstr = i18n("<b>Transfers:</b> %1 ").arg(myTransferList->childCount()) +
+                 i18n("<br /><b>Files:</b> %1 ").arg(totalFiles) +
+                 i18n("<br /><b>Size:</b> %1 ").arg(KIO::convertSize(totalSize)) +
+                 i18n("<br /><b>Time:</b> %1 ").arg(KIO::convertSeconds(remTime)) +
+                 i18n("<br /><b>Speed:</b> %1/s").arg(KIO::convertSize(totalSpeed));
         kdock->updateToolTip( tmpstr );
     }
 #ifdef _DEBUG
--- trunk/KDE/kdenetwork/kget/transfer.cpp #437887:437888
@@ -101,7 +101,7 @@
 Transfer::init(const uint _id)
 {
     sDebugIn << endl;
-
+    remainingTimeSec = 0;
     totalSize = 0;
     processedSize = 0;
     percent = 0;
@@ -258,7 +258,8 @@
     // sDebugIn <<endl;
     speed = _speed;
 
-    remainingTime = KIO::calculateRemaining(totalSize, processedSize, speed);
+    remainingTimeSec = KIO::calculateRemainingSeconds(totalSize, processedSize, speed);
+    remainingTime = KIO::convertSeconds(remainingTimeSec);
     //sDebugOut <<endl;
 }
 
@@ -594,27 +595,32 @@
     if (speed == 0 && status == ST_RUNNING) {
         setText(view->lv_speed, i18n("Stalled"));
         setText(view->lv_remaining, i18n("Stalled"));
+        if(dlgIndividual)
+            dlgIndividual->setSpeed(i18n("Stalled"));
     } else if (speed == 0 && status == ST_FINISHED) {
 
         setText(view->lv_progress, i18n("OK as in 'finished'","OK"));
-        setText(view->lv_speed, i18n("0 MB/s"));
-        setText(view->lv_remaining, i18n("00:00:00"));
+        setText(view->lv_speed, i18n("Finished"));
+        setText(view->lv_remaining, i18n("Finished"));
+        if(dlgIndividual)
+            dlgIndividual->setSpeed(i18n("Finished"));
 
     } else if (speed == 0 && status == ST_STOPPED) {
 
 
-        setText(view->lv_speed, i18n("0 MB/s"));
-        setText(view->lv_remaining, i18n("00:00:00"));
+        setText(view->lv_speed, i18n("Stopped"));
+        setText(view->lv_remaining, i18n("Stopped"));
+        if(dlgIndividual)
+            dlgIndividual->setSpeed(i18n("Stopped"));
 
     } else {
         QString tmps = i18n("%1/s").arg(KIO::convertSize(speed));
         setText(view->lv_speed, tmps);
-        setText(view->lv_remaining, remainingTime.toString());
+        setText(view->lv_remaining, remainingTime);
+        if(dlgIndividual)
+            dlgIndividual->setSpeed(tmps + " ( " + remainingTime  + " ) ");
     }
 
-	if(dlgIndividual)
-    	dlgIndividual->setSpeed(speed, remainingTime);
-
     //sDebugOut<<endl;
 }
 
--- trunk/KDE/kdenetwork/kget/transfer.h #437887:437888
@@ -82,9 +82,9 @@
     {
         return startTime;
     }
-    QTime getRemainingTime()const
+    unsigned int getRemainingTime()const
     {
-        return remainingTime;
+        return remainingTimeSec;
     }
 
     KIO::filesize_t getTotalSize()const
@@ -216,7 +216,8 @@
     int percent;
 
     int speed;
-    QTime remainingTime;
+    unsigned int remainingTimeSec;
+    QString remainingTime;
 
     TransferStatus status;
     TransferMode mode;
Comment 3 Lukas Appelhans 2010-02-02 15:25:37 UTC
It says nothing now if it's not calculateable iirc...

Lukas