mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Issue-#142 : Added support for current file completion estimation.
Changed the account settings estimation to display both current file and overwhole estimation. Decresed the progress font size to fit the added information
This commit is contained in:
parent
46ffd1c29a
commit
eadcdab8e7
@ -618,8 +618,8 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
|
||||
//: Example text: "uploading foobar.png (1MB of 2MB)"
|
||||
fileProgressString = tr("%1 %2 (%3 of %4) , Time left : %5 at a rate of %6/s")
|
||||
.arg(kindString, itemFileName, s1, s2)
|
||||
.arg( Utility::timeConversion(progress.etaEstimate()))
|
||||
.arg(Utility::octetsToString(progress.getEstimatedBandwidth()) );
|
||||
.arg( Utility::timeConversion(progress.currentFileEstimate().getEtaEstimate()) )
|
||||
.arg( Utility::octetsToString(progress.currentFileEstimate().getEstimatedBandwidth()) );
|
||||
} else {
|
||||
//: Example text: "uploading foobar.png"
|
||||
fileProgressString = tr("%1 %2").arg(kindString, itemFileName);
|
||||
@ -631,8 +631,11 @@ 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").arg(s1, s2)
|
||||
.arg(currentFile).arg(progress._totalFileCount);
|
||||
QString overallSyncString = tr("%1 of %2, file %3 of %4\n%5")
|
||||
.arg(s1, s2)
|
||||
.arg(currentFile).arg(progress._totalFileCount)
|
||||
.arg( Utility::timeConversion(progress.totalEstimate().getEtaEstimate()) );
|
||||
//.arg( Utility::octetsToString(progress.totalEstimate().getEstimatedBandwidth()) );
|
||||
item->setData( overallSyncString, FolderStatusDelegate::SyncProgressOverallString );
|
||||
|
||||
int overallPercent = 0;
|
||||
|
||||
@ -110,7 +110,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
QFont errorFont = subFont;
|
||||
QFont progressFont = subFont;
|
||||
|
||||
progressFont.setPointSize( subFont.pointSize()-1);
|
||||
progressFont.setPointSize( subFont.pointSize()-2);
|
||||
//font.setPixelSize(font.weight()+);
|
||||
aliasFont.setBold(true);
|
||||
aliasFont.setPointSize( subFont.pointSize()+2 );
|
||||
|
||||
@ -410,8 +410,8 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info
|
||||
|
||||
_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.etaEstimate()) )
|
||||
.arg(Utility::octetsToString(progress.getEstimatedBandwidth())) );
|
||||
.arg( Utility::timeConversion(progress.totalEstimate().getEtaEstimate()) )
|
||||
.arg( Utility::octetsToString(progress.totalEstimate().getEstimatedBandwidth())) );
|
||||
|
||||
_actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
|
||||
|
||||
|
||||
@ -36,20 +36,28 @@ namespace Progress
|
||||
|
||||
|
||||
struct Info {
|
||||
Info() : _totalFileCount(0), _totalSize(0), _completedFileCount(0), _completedSize(0), _etaEstimate() {}
|
||||
Info() : _totalFileCount(0), _totalSize(0), _completedFileCount(0), _completedSize(0), _totalEtaEstimate(),_currentEtaEstimate() {}
|
||||
|
||||
quint64 _totalFileCount;
|
||||
quint64 _totalSize;
|
||||
quint64 _completedFileCount;
|
||||
quint64 _completedSize;
|
||||
struct EtaEstimate {
|
||||
EtaEstimate() : _startedTime(QDateTime::currentMSecsSinceEpoch()), _agvEtaMSecs(0),_effectiveBandwidth(0) {}
|
||||
EtaEstimate() : _startedTime(QDateTime::currentMSecsSinceEpoch()), _agvEtaMSecs(0),_effectivProgressPerSec(0) {}
|
||||
|
||||
static const int AVG_DIVIDER=10;
|
||||
|
||||
quint64 _startedTime ;
|
||||
quint64 _agvEtaMSecs;
|
||||
quint64 _effectiveBandwidth;
|
||||
quint64 _effectivProgressPerSec;
|
||||
|
||||
/**
|
||||
* reset the estiamte.
|
||||
*/
|
||||
void reset() {
|
||||
_startedTime = QDateTime::currentMSecsSinceEpoch();
|
||||
_effectivProgressPerSec = _agvEtaMSecs = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* update the estimated eta time with more current data.
|
||||
@ -60,15 +68,28 @@ namespace Progress
|
||||
if(total != 0) {
|
||||
quint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() - this->_startedTime ;
|
||||
// (elapsedTime-1) to avoid float "rounding" issue (ie. 0.99999999999999999999....)
|
||||
_agvEtaMSecs = _agvEtaMSecs - (_agvEtaMSecs / AVG_DIVIDER) + (elapsedTime * ((float) total / completed ) - (elapsedTime-1) );
|
||||
_agvEtaMSecs = _agvEtaMSecs - (_agvEtaMSecs / AVG_DIVIDER) + (elapsedTime * ((float) total / completed ) - (elapsedTime-1) );
|
||||
_effectivProgressPerSec = ( total - completed ) / (1+this->getEtaEstimate()/1000);
|
||||
}
|
||||
}
|
||||
|
||||
quint64 getEtaEstimate() const {
|
||||
/**
|
||||
* Get the eta estimate in milliseconds
|
||||
* @return quint64 the estimate amount of milliseconds to end the process.
|
||||
*/
|
||||
quint64 getEtaEstimate() const {
|
||||
return _agvEtaMSecs / AVG_DIVIDER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the estimated average bandwidth usage.
|
||||
* @return quint64 the estimated bandwidth usage in bytes.
|
||||
*/
|
||||
quint64 getEstimatedBandwidth() const {
|
||||
return _effectivProgressPerSec;
|
||||
}
|
||||
};
|
||||
EtaEstimate _etaEstimate;
|
||||
EtaEstimate _totalEtaEstimate;
|
||||
EtaEstimate _currentEtaEstimate;
|
||||
|
||||
struct ProgressItem {
|
||||
ProgressItem() : _completedSize(0) {}
|
||||
@ -85,13 +106,16 @@ namespace Progress
|
||||
}
|
||||
_completedFileCount++;
|
||||
_lastCompletedItem = item;
|
||||
_currentEtaEstimate.reset();
|
||||
}
|
||||
void setProgressItem(const SyncFileItem &item, quint64 size) {
|
||||
_currentItems[item._file]._item = item;
|
||||
_currentItems[item._file]._completedSize = size;
|
||||
_lastCompletedItem = SyncFileItem();
|
||||
_etaEstimate.updateTime(this->completedSize(),this->_totalSize);
|
||||
}
|
||||
|
||||
_totalEtaEstimate.updateTime(this->completedSize(),this->_totalSize);
|
||||
_currentEtaEstimate.updateTime(size,item._size);
|
||||
}
|
||||
|
||||
quint64 completedSize() const {
|
||||
quint64 r = _completedSize;
|
||||
@ -102,20 +126,21 @@ namespace Progress
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the eta estimate in milliseconds
|
||||
* @return quint64 the estimate amount of milliseconds to end the process.
|
||||
* Get the total completion estimate structure
|
||||
* @return EtaEstimate a structure containing the total completion information.
|
||||
*/
|
||||
quint64 etaEstimate() const {
|
||||
return _etaEstimate.getEtaEstimate();
|
||||
EtaEstimate totalEstimate() const {
|
||||
return _totalEtaEstimate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the estimated average bandwidth usage.
|
||||
* @return quint64 the estimated bandwidth usage in bytes.
|
||||
* Get the current file completion estimate structure
|
||||
* @return EtaEstimate a structure containing the current file completion information.
|
||||
*/
|
||||
quint64 getEstimatedBandwidth() const {
|
||||
return ( this->_totalSize - this->completedSize() ) / (1+_etaEstimate.getEtaEstimate()/1000) ;
|
||||
}
|
||||
EtaEstimate currentFileEstimate() const {
|
||||
return _currentEtaEstimate;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
QString asActionString( const SyncFileItem& item );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user