// and hand the result over to the progress dispatcher.
void Folder::slotTransmissionProgress(const ProgressInfo &pi)
{
- if( !pi.hasStarted() ) {
+ if( !pi.isUpdatingEstimates() ) {
// this is the beginning of a sync, set the warning level to 0
_syncResult.setWarnCount(0);
}
slotRebuildRecentMenus();
}
- if (progress.hasStarted()
+ if (progress.isUpdatingEstimates()
&& progress.completedFiles() >= progress.totalFiles()
&& progress._currentDiscoveredFolder.isEmpty()) {
QTimer::singleShot(2000, this, SLOT(slotDisplayIdle()));
void ProtocolWidget::slotProgressInfo( const QString& folder, const ProgressInfo& progress )
{
- if( !progress.hasStarted() ) {
+ if( !progress.isUpdatingEstimates() ) {
// The sync is restarting, clean the old items
cleanItems(folder);
} else if (progress.completedFiles() >= progress.totalFiles()) {
emit progressInfo( folder, progress );
}
-void ProgressInfo::start()
+ProgressInfo::ProgressInfo()
{
connect(&_updateEstimatesTimer, SIGNAL(timeout()), SLOT(updateEstimates()));
+ reset();
+}
+
+void ProgressInfo::reset()
+{
+ _currentItems.clear();
+ _currentDiscoveredFolder.clear();
+ _sizeProgress = Progress();
+ _fileProgress = Progress();
+ _totalSizeOfCompletedJobs = 0;
+ _maxBytesPerSecond = 100000.0;
+ _maxFilesPerSecond = 2.0;
+ _updateEstimatesTimer.stop();
+}
+
+void ProgressInfo::startEstimateUpdates()
+{
_updateEstimatesTimer.start(1000);
}
-bool ProgressInfo::hasStarted() const
+bool ProgressInfo::isUpdatingEstimates() const
{
return _updateEstimatesTimer.isActive();
}
{
Q_OBJECT
public:
- ProgressInfo()
- : _totalSizeOfCompletedJobs(0)
- , _maxFilesPerSecond(2.0)
- , _maxBytesPerSecond(100000.0)
- {}
+ ProgressInfo();
+
+ /** Resets for a new sync run.
+ */
+ void reset();
/**
* Called when propagation starts.
*
- * hasStarted() will return true afterwards.
+ * isUpdatingEstimates() will return true afterwards.
*/
- void start();
+ void startEstimateUpdates();
/**
- * Returns true when propagation has started (start() was called).
+ * Returns true when startEstimateUpdates() was called.
*
* This is used when the SyncEngine wants to indicate a new sync
* is about to start via the transmissionProgress() signal. The
- * first ProgressInfo will have hasStarted() == false.
+ * first ProgressInfo will have isUpdatingEstimates() == false.
*/
- bool hasStarted() const;
+ bool isUpdatingEstimates() const;
/**
* Increase the file and size totals by the amount indicated in item.
_syncRunning = true;
_anotherSyncNeeded = false;
+ _progressInfo->reset();
+
if (!QDir(_localPath).exists()) {
// No _tr, it should only occur in non-mirall
emit csyncError("Unable to find local sync folder.");
emit aboutToPropagate(_syncedItems);
// it's important to do this before ProgressInfo::start(), to announce start of new sync
emit transmissionProgress(*_progressInfo);
- _progressInfo->start();
+ _progressInfo->startEstimateUpdates();
// post update phase script: allow to tweak stuff by a custom script in debug mode.
if( !qgetenv("OWNCLOUD_POST_UPDATE_SCRIPT").isEmpty() ) {