(*** 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.
Replaced wr@poboxes.com with null@kde.org due to bounces by reporter
Still valid for KDE 3.2.3.
IMHO this is a bug, not a wishlist item.
Still valid in current HEAD (post 3.3)
Still valid in 3.4beta1
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; /**
*** Bug 103943 has been marked as a duplicate of this bug. ***
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; };