[Pkg-owncloud-commits] [owncloud-client] 24/78: Progress info: Reset between syncs #4856 (PR #4872)
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri Jun 24 16:29:39 UTC 2016
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 c6794cd3382b6dd3d9caba13a6e0f108463dac6a
Author: ckamm <mail at ckamm.de>
Date: Fri May 20 15:07:54 2016 +0200
Progress info: Reset between syncs #4856 (PR #4872)
---
src/gui/folder.cpp | 2 +-
src/gui/owncloudgui.cpp | 2 +-
src/gui/protocolwidget.cpp | 2 +-
src/libsync/progressdispatcher.cpp | 21 +++++++++++++++++++--
src/libsync/progressdispatcher.h | 20 ++++++++++----------
src/libsync/syncengine.cpp | 4 +++-
6 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index 47c2c29..5b8c019 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -915,7 +915,7 @@ void Folder::slotFolderDiscovered(bool, QString folderName)
// 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);
}
diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp
index d329954..63e4e32 100644
--- a/src/gui/owncloudgui.cpp
+++ b/src/gui/owncloudgui.cpp
@@ -685,7 +685,7 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo&
slotRebuildRecentMenus();
}
- if (progress.hasStarted()
+ if (progress.isUpdatingEstimates()
&& progress.completedFiles() >= progress.totalFiles()
&& progress._currentDiscoveredFolder.isEmpty()) {
QTimer::singleShot(2000, this, SLOT(slotDisplayIdle()));
diff --git a/src/gui/protocolwidget.cpp b/src/gui/protocolwidget.cpp
index 34e91cc..c96fa1d 100644
--- a/src/gui/protocolwidget.cpp
+++ b/src/gui/protocolwidget.cpp
@@ -219,7 +219,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo
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()) {
diff --git a/src/libsync/progressdispatcher.cpp b/src/libsync/progressdispatcher.cpp
index 5175071..560c1ff 100644
--- a/src/libsync/progressdispatcher.cpp
+++ b/src/libsync/progressdispatcher.cpp
@@ -127,13 +127,30 @@ void ProgressDispatcher::setProgressInfo(const QString& folder, const ProgressIn
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();
}
diff --git a/src/libsync/progressdispatcher.h b/src/libsync/progressdispatcher.h
index ec555c3..7ea3f3b 100644
--- a/src/libsync/progressdispatcher.h
+++ b/src/libsync/progressdispatcher.h
@@ -37,27 +37,27 @@ class OWNCLOUDSYNC_EXPORT ProgressInfo : public QObject
{
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.
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 66425cb..89c1c9d 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -673,6 +673,8 @@ void SyncEngine::startSync()
_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.");
@@ -909,7 +911,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
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() ) {
--
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