[Pkg-owncloud-commits] [owncloud-client] 04/332: Seperated the systray estimation text to a seperate action, fixed an integer rounding bug

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:31 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 a892b79dba5583e281138edd0fcd8e98982ac647
Author: Eran <etherpulse at gmail.com>
Date:   Tue Apr 29 02:31:27 2014 +0300

    Seperated the systray estimation text to a seperate action, fixed an integer rounding bug
---
 src/mirall/owncloudgui.cpp      | 14 ++++++++++----
 src/mirall/owncloudgui.h        |  1 +
 src/mirall/progressdispatcher.h |  5 +++--
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp
index 5bf3605..61e597e 100644
--- a/src/mirall/owncloudgui.cpp
+++ b/src/mirall/owncloudgui.cpp
@@ -286,6 +286,7 @@ void ownCloudGui::setupContextMenu()
         _contextMenu->addAction(_actionQuota);
         _contextMenu->addSeparator();
         _contextMenu->addAction(_actionStatus);
+        _contextMenu->addAction(_actionEstimate);
         _contextMenu->addMenu(_recentActionsMenu);
         _contextMenu->addSeparator();
     }
@@ -352,6 +353,8 @@ void ownCloudGui::setupActions()
     _actionQuota->setEnabled( false );
     _actionStatus = new QAction(tr("Unknown status"), this);
     _actionStatus->setEnabled( false );
+    _actionEstimate = new QAction(tr("Calculating ETA ..."), this);
+    _actionEstimate->setEnabled( false );
     _actionSettings = new QAction(tr("Settings..."), this);
     _actionRecent = new QAction(tr("Details..."), this);
     _actionRecent->setEnabled( true );
@@ -408,11 +411,13 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info
     QString s1 = Utility::octetsToString( completedSize );
     QString s2 = Utility::octetsToString( progress._totalSize );
 
-    _actionStatus->setText( tr("Syncing %1 of %2 (%3 of %4) \nETA : %5 , %6/s")
-        .arg(currentFile).arg(progress._totalFileCount).arg(s1, s2)
-        .arg( Utility::timeConversion(progress.totalEstimate().getEtaEstimate()),
+    _actionStatus->setText( tr("Syncing %1 of %2 (%3 of %4)")
+        .arg(currentFile).arg(progress._totalFileCount).arg(s1, s2));
+    
+    _actionEstimate->setVisible(true);
+    _actionEstimate->setText( tr("ETA : %5 , %6/s").arg( Utility::timeConversion(progress.totalEstimate().getEtaEstimate()),
               Utility::octetsToString(progress.totalEstimate().getEstimatedBandwidth())) );
-
+ 
     _actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
 
     if (!progress._lastCompletedItem.isEmpty()) {
@@ -453,6 +458,7 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info
 void ownCloudGui::slotDisplayIdle()
 {
     _actionStatus->setText(tr("Up to date"));
+    _actionEstimate->setVisible(false);
 }
 
 void ownCloudGui::slotShowGuiMessage(const QString &title, const QString &message)
diff --git a/src/mirall/owncloudgui.h b/src/mirall/owncloudgui.h
index 06fea15..2b238e9 100644
--- a/src/mirall/owncloudgui.h
+++ b/src/mirall/owncloudgui.h
@@ -92,6 +92,7 @@ private:
     QAction *_actionSettings;
     QAction *_actionQuota;
     QAction *_actionStatus;
+    QAction *_actionEstimate;
     QAction *_actionRecent;
     QAction *_actionHelp;
     QAction *_actionQuit;
diff --git a/src/mirall/progressdispatcher.h b/src/mirall/progressdispatcher.h
index 0eead9b..f410cd2 100644
--- a/src/mirall/progressdispatcher.h
+++ b/src/mirall/progressdispatcher.h
@@ -69,11 +69,12 @@ namespace Progress
             void updateTime(quint64 completed, quint64 total) {
                 if(total != 0 && completed != 0) {
                     quint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() -  this->_startedTime ;
-                    // (elapsedTime-1) to avoid float "rounding" issue (ie. 0.99999999999999999999....)
-                    _agvEtaMSecs = _agvEtaMSecs - (_agvEtaMSecs / AVG_DIVIDER) + ( ((total / completed) * elapsedTime) - (elapsedTime-1) );
+                    // (elapsedTime-1) is an hack to avoid float "rounding" issue (ie. 0.99999999999999999999....)
+                    _agvEtaMSecs = _agvEtaMSecs + (((static_cast<float>(total) / completed) * elapsedTime) - (elapsedTime-1)) - this->getEtaEstimate();
                     _effectivProgressPerSec = ( total - completed ) / (1+this->getEtaEstimate()/1000);
                 }
             }
+            
             /**
              * Get the eta estimate in milliseconds 
              * @return quint64 the estimate amount of milliseconds to end the process.

-- 
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