[Pkg-owncloud-commits] [owncloud-client] 06/332: Changed the time estimate string to be more textual, also added lower limit to the estimate to prevents starting estimation jittering
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 219098c182ed1361cb6a89e970af0786bc126325
Author: Eran <etherpulse at gmail.com>
Date: Mon May 12 00:26:17 2014 +0300
Changed the time estimate string to be more textual, also added lower limit to the estimate to prevents starting estimation jittering
---
src/mirall/accountsettings.cpp | 10 +++++-----
src/mirall/owncloudgui.cpp | 13 +++----------
src/mirall/progressdispatcher.h | 6 ++++--
src/mirall/utility.cpp | 21 +++++++++++----------
src/mirall/utility.h | 2 +-
5 files changed, 24 insertions(+), 28 deletions(-)
diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp
index db0f27c..faf1c2a 100644
--- a/src/mirall/accountsettings.cpp
+++ b/src/mirall/accountsettings.cpp
@@ -616,10 +616,10 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
QString s1 = Utility::octetsToString( curItemProgress );
QString s2 = Utility::octetsToString( curItem._size );
//: Example text: "uploading foobar.png (1MB of 2MB)"
- fileProgressString = tr("%1 %2 (%3 of %4) , Time left : %5 at a rate of %6/s")
+ fileProgressString = tr("%1 %2 (%3 of %4) time left %5 , at a rate of %6")
.arg(kindString, itemFileName, s1, s2,
- Utility::timeConversion(progress.getFileEstimate(curItem).getEtaEstimate()),
- Utility::octetsToString(progress.getFileEstimate(curItem).getEstimatedBandwidth()) );
+ Utility::timeToDescriptiveString(progress.getFileEstimate(curItem).getEtaEstimate()),
+ Utility::octetsToString(progress.getFileEstimate(curItem).getEstimatedBandwidth()) );
} else {
//: Example text: "uploading foobar.png"
fileProgressString = tr("%1 %2").arg(kindString, itemFileName);
@@ -631,10 +631,10 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
quint64 currentFile = progress._completedFileCount + progress._currentItems.count();
QString s1 = Utility::octetsToString( completedSize );
QString s2 = Utility::octetsToString( progress._totalSize );
- QString overallSyncString = tr("%1 of %2, file %3 of %4\n%5")
+ QString overallSyncString = tr("%1 of %2, file %3 of %4\nTime left %5")
.arg(s1, s2)
.arg(currentFile).arg(progress._totalFileCount)
- .arg( Utility::timeConversion(progress.totalEstimate().getEtaEstimate()) );
+ .arg( Utility::timeToDescriptiveString(progress.totalEstimate().getEtaEstimate()) );
item->setData( overallSyncString, FolderStatusDelegate::SyncProgressOverallString );
diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp
index 28a17fa..8e83c81 100644
--- a/src/mirall/owncloudgui.cpp
+++ b/src/mirall/owncloudgui.cpp
@@ -286,7 +286,6 @@ void ownCloudGui::setupContextMenu()
_contextMenu->addAction(_actionQuota);
_contextMenu->addSeparator();
_contextMenu->addAction(_actionStatus);
- _contextMenu->addAction(_actionEstimate);
_contextMenu->addMenu(_recentActionsMenu);
_contextMenu->addSeparator();
}
@@ -353,8 +352,6 @@ 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 );
@@ -411,12 +408,9 @@ 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)")
- .arg(currentFile).arg(progress._totalFileCount).arg(s1, s2));
-
- _actionEstimate->setVisible(progress.completedSize() > 0);
- _actionEstimate->setText( tr("ETA : %5 , %6/s").arg( Utility::timeConversion(progress.totalEstimate().getEtaEstimate()),
- Utility::octetsToString(progress.totalEstimate().getEstimatedBandwidth())) );
+ _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()) ) );
_actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
@@ -459,7 +453,6 @@ 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/progressdispatcher.h b/src/mirall/progressdispatcher.h
index f410cd2..30132bd 100644
--- a/src/mirall/progressdispatcher.h
+++ b/src/mirall/progressdispatcher.h
@@ -48,6 +48,7 @@ namespace Progress
EtaEstimate() : _startedTime(QDateTime::currentMSecsSinceEpoch()), _agvEtaMSecs(0),_effectivProgressPerSec(0) {}
static const int AVG_DIVIDER=10;
+ static const int INITAL_WAIT_TIME=5;
quint64 _startedTime ;
quint64 _agvEtaMSecs;
@@ -67,8 +68,9 @@ namespace Progress
* @param quint64 total the total amout that should be completed.
*/
void updateTime(quint64 completed, quint64 total) {
- if(total != 0 && completed != 0) {
- quint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() - this->_startedTime ;
+ quint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() - this->_startedTime ;
+ //don't start until you have some good data to process, prevents jittring estiamtes at the start of the syncing process
+ if(total != 0 && completed != 0 && elapsedTime > INITAL_WAIT_TIME ) {
// (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);
diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp
index 8be0f4d..9a9dd03 100644
--- a/src/mirall/utility.cpp
+++ b/src/mirall/utility.cpp
@@ -452,16 +452,17 @@ qint64 Utility::qDateTimeToTime_t(const QDateTime& t)
return t.toMSecsSinceEpoch() / 1000;
}
-QString Utility::timeConversion(quint64 msecs)
-{
- msecs = msecs / 1000;
- int hours = msecs/(3600);
- int minutes = (msecs-(hours*3600))/(60);
- int seconds = (msecs-(minutes*60)-(hours*3600));
-
- return (hours > 0 ? QString("%1h ").arg(hours): QString())
- .append(minutes > 0 ? QString("%1m ").arg(minutes, 2, 10, QChar('0')) : QString())
- .append(QString("%1s").arg(seconds, 2, 10, QChar('0')) );
+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);
}
diff --git a/src/mirall/utility.h b/src/mirall/utility.h
index 8b4caaf..18164c5 100644
--- a/src/mirall/utility.h
+++ b/src/mirall/utility.h
@@ -66,7 +66,7 @@ namespace Utility
* @param quint64 msecs the milliseconds to convert to string
* @return an HMS representation of the milliseconds value.
*/
- QString timeConversion(quint64 msecs);
+ QString timeToDescriptiveString(quint64 msecs);
// convinience OS detection methods
bool isWindows();
--
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