Bug 14567 - estimated download time has a maximum of 23h:59m:59s
Summary: estimated download time has a maximum of 23h:59m:59s
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 1.9.8
Platform: unspecified Linux
: NOR minor
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
: 103943 (view as bug list)
Depends on:
Blocks:
 
Reported: 2000-11-04 10:33 UTC by Unknown
Modified: 2005-10-26 20:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Rohdewald 2000-11-04 10:23:34 UTC
(*** This bug was imported into bugs.kde.org ***)

Package: konqueror
Version: 1.9.8 (KDE 2.0 >= 20001022)
Severity: normal
Compiler: gcc version 2.95.2 19991024 (release)
OS: Linux 2.2.16 i686 (compiled sources)

has a maximum of 24 hours. This should be increased. lftp estimates 1d3h for my
current download.
Comment 1 Stephan Kulow 2004-05-17 20:10:56 UTC
Replaced wr@poboxes.com with null@kde.org due to bounces by reporter
Comment 2 Michael Jahn 2004-07-03 12:52:04 UTC
Still valid for KDE 3.2.3.
Comment 3 Michael Jahn 2004-09-10 23:24:23 UTC
IMHO this is a bug, not a wishlist item.
Comment 4 Rainer Endres 2004-10-05 11:57:20 UTC
Still valid in current HEAD (post 3.3)
Comment 5 Rainer Endres 2005-01-27 21:47:44 UTC
Still valid in 3.4beta1
Comment 6 Martin Koller 2005-01-30 22:56:31 UTC
CVS commit by mkoller: 

BUG: 14567
New functions to calculate/format remaining time (which can also be larger than 1 day)


  M +2 -2      defaultprogress.cpp   1.68
  M +24 -0     global.cpp   1.140
  M +25 -1     global.h   1.75


--- kdelibs/kio/kio/defaultprogress.cpp  #1.67:1.68
@@ -322,6 +322,6 @@ void DefaultProgress::slotSpeed( KIO::Jo
     speedLabel->setText( i18n( "Stalled") );
   } else {
-    QTime remaining = KIO::calculateRemaining( m_iTotalSize, m_iProcessedSize, bytes_per_second );
-    speedLabel->setText( i18n( "%1/s ( %2 remaining )").arg( KIO::convertSize( bytes_per_second )).arg( remaining.toString() ) );
+    speedLabel->setText( i18n( "%1/s ( %2 remaining )").arg( KIO::convertSize( bytes_per_second ))
+        .arg( KIO::convertSeconds( KIO::calculateRemainingSeconds( m_iTotalSize, m_iProcessedSize, bytes_per_second ))) );
   }
 }

--- kdelibs/kio/kio/global.cpp  #1.139:1.140
@@ -88,4 +88,28 @@ KIO_EXPORT QString KIO::number( KIO::fil
 }
 
+KIO_EXPORT unsigned long long int KIO::calculateRemainingSeconds( KIO::filesize_t totalSize,
+                                                                  KIO::filesize_t processedSize, KIO::filesize_t speed )
+{
+  if ( (speed != 0) && (totalSize != 0) )
+    return ( totalSize - processedSize ) / speed;
+  else
+    return 0;
+}
+
+KIO_EXPORT QString KIO::convertSeconds( unsigned long long int seconds )
+{
+  unsigned int days  = seconds / 86400;
+  unsigned int hours = (seconds - (days * 86400)) / 3600;
+  unsigned int mins  = (seconds - (days * 86400) - (hours * 3600)) / 60;
+  seconds            = (seconds - (days * 86400) - (hours * 3600) - (mins * 60));
+
+  const QTime time(hours, mins, seconds);
+  const QString timeStr( KGlobal::locale()->formatTime(time, true /*with seconds*/, true /*duration*/) );
+  if ( days > 0 )
+    return i18n("1 day %1", "%n days %1", days).arg(timeStr);
+  else
+    return timeStr;
+}
+
 KIO_EXPORT QTime KIO::calculateRemaining( KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed )
 {

--- kdelibs/kio/kio/global.h  #1.74:1.75
@@ -65,5 +65,29 @@ namespace KIO
 
   /**
+   * Calculates remaining time in seconds from total size, processed size and speed.
+   *
+   * @param  totalSize      total size in bytes
+   * @param  processedSize  processed size in bytes
+   * @param  speed          speed in bytes per second
+   * @return calculated remaining time in seconds
+   *
+   * @since 3.4
+   */
+  KIO_EXPORT unsigned long long int calculateRemainingSeconds( KIO::filesize_t totalSize,
+                                                               KIO::filesize_t processedSize, KIO::filesize_t speed );
+
+  /**
+   * Convert @p seconds to a string representing number of days, hours, minutes and seconds
+   *
+   * @param  number of seconds to convert
+   * @return string representation in a locale depending format
+   *
+   * @since 3.4
+   */
+  KIO_EXPORT QString convertSeconds( unsigned long long int seconds );
+
+  /**
    * Calculates remaining time from total size, processed size and speed.
+   * Warning: As QTime is limited to 23:59:59, use calculateRemainingSeconds() instead
    *
    * @param  totalSize      total size in bytes
@@ -72,5 +96,5 @@ namespace KIO
    * @return calculated remaining time
    */
-  KIO_EXPORT QTime calculateRemaining( KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed );
+  KIO_EXPORT QTime calculateRemaining( KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed ) KDE_DEPRECATED;
 
   /**


Comment 7 Pascal Létourneau 2005-07-08 19:08:20 UTC
*** Bug 103943 has been marked as a duplicate of this bug. ***
Comment 8 David Faure 2005-10-26 20:59:28 UTC
SVN commit 474570 by dfaure:

Actually use the new methods so that the remaining time doesn't max at 23:59:59.
CCBUG: 14567


 M  +6 -6      uiserver.cpp  
 M  +2 -2      uiserver.h  


--- branches/KDE/3.5/kdelibs/kio/misc/uiserver.cpp #474569:474570
@@ -281,7 +281,7 @@
 
 void ProgressItem::setSpeed( unsigned long bytes_per_second ) {
   m_iSpeed = bytes_per_second;
-  m_remainingTime = KIO::calculateRemaining( m_iTotalSize, m_iProcessedSize, m_iSpeed );
+  m_remainingSeconds = KIO::calculateRemainingSeconds( m_iTotalSize, m_iProcessedSize, m_iSpeed );
 
   QString tmps, tmps2;
   if ( m_iSpeed == 0 ) {
@@ -289,7 +289,7 @@
     tmps2 = tmps;
   } else {
     tmps = i18n( "%1/s").arg( KIO::convertSize( m_iSpeed ));
-    tmps2 = m_remainingTime.toString();
+    tmps2 = KIO::convertSeconds( m_remainingSeconds );
   }
   setText( ListProgress::TB_SPEED, tmps );
   setText( ListProgress::TB_REMAINING_TIME, tmps2 );
@@ -1073,7 +1073,7 @@
   int iTotalFiles = 0;
   KIO::filesize_t iTotalSize = 0;
   int iTotalSpeed = 0;
-  QTime totalRemTime;
+  unsigned int totalRemTime = 0; // in seconds
 
   ProgressItem *item;
 
@@ -1088,8 +1088,8 @@
     iTotalFiles += ( item->totalFiles() - item->processedFiles() );
     iTotalSpeed += item->speed();
 
-    if ( item->remainingTime() > totalRemTime ) {
-      totalRemTime = item->remainingTime();
+    if ( item->remainingSeconds() > totalRemTime ) {
+      totalRemTime = item->remainingSeconds();
     }
   }
 
@@ -1097,7 +1097,7 @@
   statusBar()->changeItem( i18n( " Files: %1 ").arg( iTotalFiles ), ID_TOTAL_FILES);
   statusBar()->changeItem( i18n( "Remaining Size", " Rem. Size: %1 ").arg( KIO::convertSize( iTotalSize ) ),
                            ID_TOTAL_SIZE);
-  statusBar()->changeItem( i18n( "Remaining Time", " Rem. Time: %1 ").arg( totalRemTime.toString() ),
+  statusBar()->changeItem( i18n( "Remaining Time", " Rem. Time: %1 ").arg( KIO::convertSeconds( totalRemTime ) ),
                            ID_TOTAL_TIME);
   statusBar()->changeItem( i18n( " %1/s ").arg( KIO::convertSize( iTotalSpeed ) ),
                            ID_TOTAL_SPEED);
--- branches/KDE/3.5/kdelibs/kio/misc/uiserver.h #474569:474570
@@ -150,7 +150,7 @@
   KIO::filesize_t processedSize() { return m_iProcessedSize; }
   unsigned long processedFiles() { return m_iProcessedFiles; }
   unsigned long speed() { return m_iSpeed; }
-  QTime remainingTime() { return m_remainingTime; }
+  unsigned int remainingSeconds() { return m_remainingSeconds; }
 
   const QString& fullLengthAddress() const {return m_fullLengthAddress;}
   void setText(ListProgress::ListProgressFields field, const QString& text);
@@ -187,7 +187,7 @@
   KIO::filesize_t m_iProcessedSize;
   unsigned long m_iProcessedFiles;
   unsigned long m_iSpeed;
-  QTime m_remainingTime;
+  int m_remainingSeconds;
   QTimer m_showTimer;
   QString m_fullLengthAddress;
 };