[Pkg-owncloud-commits] [owncloud-client] 07/332: changed the systray to display total size and estimated time when the syncronization actually has size changed the descriptive time logic to be more generic

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:32 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 71ea2b582ce36833e95ee47ec177eb6da7d6179e
Author: Eran <etherpulse at gmail.com>
Date:   Mon May 12 17:36:27 2014 +0300

    changed the  systray  to  display total size  and  estimated time  when the  syncronization actually has size changed the  descriptive  time logic to be more generic
---
 src/mirall/owncloudgui.cpp | 23 +++++++++++++++--------
 src/mirall/utility.cpp     | 36 +++++++++++++++++++++++++++---------
 2 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp
index 8e83c81..8d25615 100644
--- a/src/mirall/owncloudgui.cpp
+++ b/src/mirall/owncloudgui.cpp
@@ -403,14 +403,21 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info
 {
     Q_UNUSED(folder);
 
-    quint64 completedSize = progress.completedSize();
-    quint64 currentFile =  progress._completedFileCount + progress._currentItems.count();
-    QString s1 = Utility::octetsToString( completedSize );
-    QString s2 = Utility::octetsToString( progress._totalSize );
-
-    _actionStatus->setText( tr("Syncing %1 of %2 (%3 of %4) %5 left")
-        .arg(currentFile).arg(progress._totalFileCount).arg(s1, s2)
-        .arg( Utility::timeToDescriptiveString(progress.totalEstimate().getEtaEstimate()) ) );
+     QString totalSizeStr = Utility::octetsToString( progress._totalSize );
+        if(progress._totalSize == 0 ) {
+            quint64 completedSize = progress.completedSize();
+            quint64 currentFile =  progress._completedFileCount + progress._currentItems.count();
+            QString completedSizeStr = Utility::octetsToString( completedSize );
+            _actionStatus->setText( tr("Syncing %1 of %2  ( %3 of %4 )")
+                .arg( currentFile ).arg( progress._totalFileCount )
+                .arg( completedSizeStr, totalSizeStr ) );
+        } else {
+            _actionStatus->setText( tr("Syncing %1 ( %2 left )")
+                .arg( totalSizeStr )
+                .arg( Utility::timeToDescriptiveString(progress.totalEstimate().getEtaEstimate()) ) );
+        }
+
+
 
 
     _actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp
index 9a9dd03..4f2f00f 100644
--- a/src/mirall/utility.cpp
+++ b/src/mirall/utility.cpp
@@ -454,15 +454,33 @@ qint64 Utility::qDateTimeToTime_t(const QDateTime& t)
 
 QString Utility::timeToDescriptiveString(quint64 msecs)
 {
-    msecs = msecs / 1000;
-    int hours = msecs/(3600);
-    int minutes = (msecs-(hours*3600))/(60);
-    int seconds = (msecs-(minutes*60)-(hours*3600));
-
-    QString units = (hours > 0 ?  " hours" : (minutes > 0 ? " minutes" : " seconds") );
-
-    return (hours > 0 ? QString("%1:").arg(hours): QString())
-           .append(minutes > 0 ? QString("%1").arg(minutes, 2, 10, QChar(hours > 0 ? '0' : ' ')) : QString("%1").arg(seconds, 2, 10, QChar('0')) ).append(units);
+    QList<QPair<QString,quint32> > timeMapping = QList<QPair<QString,quint32> >();    
+    //timeMapping.append(QPair<QString,quint32>("years",86400*365));
+    //timeMapping.append(QPair<QString,quint32>("months",86400*30));
+    //timeMapping.append(QPair<QString,quint32>("days",86400));
+    timeMapping.append(QPair<QString,quint32>("hours",3600));
+    timeMapping.append(QPair<QString,quint32>("minutes",60));
+    timeMapping.append(QPair<QString,quint32>("seconds",1));
+    
+    quint64 secs = msecs / 1000;
+    QString units = "seconds";
+    qint64 minor =-1, major = -1;
+    
+   QList<QPair<QString,quint32> >::Iterator itr = timeMapping.begin();
+    for(; itr != timeMapping.end(); itr++) {
+        major = secs / itr->second;
+        secs -= (major * itr->second);
+        if(major > 0 ) {
+            units = itr->first;
+            break;
+        }
+        
+    }
+    if(itr < timeMapping.end() ) {
+        minor = secs / (++itr)->second;
+    }
+    
+    return (QString("%1").arg(major)).append(minor > -1 ?  QString(":%1").arg(minor, 2, 10, QChar('0')) : "" ).append(" ").append(units);
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list