[Pkg-owncloud-commits] [owncloud-client] 94/470: Improve folder pausing API
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu May 12 16:24:49 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 40c109597e57c3425337b71bb43a906b59b0a4b9
Author: Christian Kamm <mail at ckamm.de>
Date: Wed Mar 2 11:06:03 2016 +0100
Improve folder pausing API
Previously one could accidentally call Folder::setSyncPaused() and miss
some expected side effects. Before, the correct call was to FolderMan::
slotSetFolderPaused(). Now the setter on Folder has the expected effect.
---
src/gui/accountsettings.cpp | 3 +--
src/gui/folder.cpp | 13 ++++++-------
src/gui/folder.h | 3 +--
src/gui/folderman.cpp | 9 +++++----
src/gui/folderman.h | 2 +-
5 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index fa4018f..9cf0fe3 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -437,8 +437,7 @@ void AccountSettings::slotEnableCurrentFolder()
if ( f->isBusy() && terminate ) {
f->slotTerminateSync();
}
- f->setSyncPaused(!currentlyPaused); // toggle the pause setting
- folderMan->slotSetFolderPaused( f, !currentlyPaused );
+ f->setSyncPaused(!currentlyPaused);
// keep state for the icon setting.
if( currentlyPaused ) _wasDisabledBefore = true;
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index ce9ab60..da6eedf 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -265,20 +265,19 @@ bool Folder::canSync() const
void Folder::setSyncPaused( bool paused )
{
- if (paused != _definition.paused) {
- _definition.paused = paused;
- saveToSettings();
+ if (paused == _definition.paused) {
+ return;
}
+ _definition.paused = paused;
+ saveToSettings();
+
if( !paused ) {
- // qDebug() << "Syncing enabled on folder " << name();
setSyncState(SyncResult::NotYetStarted);
} else {
- // do not stop or start the watcher here, that is done internally by
- // folder class. Even if the watcher fires, the folder does not
- // schedule itself because it checks the var. _enabled before.
setSyncState(SyncResult::Paused);
}
+ emit syncPausedChanged(this, paused);
emit syncStateChange();
}
diff --git a/src/gui/folder.h b/src/gui/folder.h
index 510fd0f..2310deb 100644
--- a/src/gui/folder.h
+++ b/src/gui/folder.h
@@ -133,8 +133,6 @@ public:
/**
* switch sync on or off
- * If the sync is switched off, the startSync method is not going to
- * be called.
*/
void setSyncPaused( bool );
@@ -214,6 +212,7 @@ signals:
void scheduleToSync(Folder*);
void progressInfo(const ProgressInfo& progress);
void newBigFolderDiscovered(const QString &); // A new folder bigger than the threshold was discovered
+ void syncPausedChanged(Folder*, bool paused);
public slots:
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp
index a0ea57f..50659bf 100644
--- a/src/gui/folderman.cpp
+++ b/src/gui/folderman.cpp
@@ -106,6 +106,8 @@ void FolderMan::unloadFolder( Folder *f )
this, SLOT(slotFolderSyncFinished(SyncResult)));
disconnect(f, SIGNAL(syncStateChange()),
this, SLOT(slotForwardFolderSyncStateChange()));
+ disconnect(f, SIGNAL(syncPausedChanged(Folder*,bool)),
+ this, SLOT(slotFolderSyncPaused(Folder*,bool)));
}
int FolderMan::unloadAndDeleteAllFolders()
@@ -411,21 +413,19 @@ Folder* FolderMan::setupFolderFromOldConfigFile(const QString &file, AccountStat
return folder;
}
-void FolderMan::slotSetFolderPaused( Folder *f, bool paused )
+void FolderMan::slotFolderSyncPaused( Folder *f, bool paused )
{
if( !f ) {
- qWarning() << "!! slotSetFolderPaused called with empty folder";
+ qWarning() << "!! slotFolderSyncPaused called with empty folder";
return;
}
- f->setSyncPaused(paused);
if (!paused) {
_disabledFolders.remove(f);
slotScheduleSync(f);
} else {
_disabledFolders.insert(f);
}
- emit folderSyncStateChange(f);
}
// this really terminates the current sync process
@@ -796,6 +796,7 @@ Folder* FolderMan::addFolderInternal(const FolderDefinition& folderDefinition)
connect(folder, SIGNAL(syncStarted()), SLOT(slotFolderSyncStarted()));
connect(folder, SIGNAL(syncFinished(SyncResult)), SLOT(slotFolderSyncFinished(SyncResult)));
connect(folder, SIGNAL(syncStateChange()), SLOT(slotForwardFolderSyncStateChange()));
+ connect(folder, SIGNAL(syncPausedChanged(Folder*,bool)), SLOT(slotFolderSyncPaused(Folder*,bool)));
registerFolderMonitor(folder);
return folder;
diff --git a/src/gui/folderman.h b/src/gui/folderman.h
index b120ea5..7eca291 100644
--- a/src/gui/folderman.h
+++ b/src/gui/folderman.h
@@ -143,7 +143,7 @@ signals:
public slots:
void slotRemoveFolder( Folder* );
- void slotSetFolderPaused(Folder *, bool paused);
+ void slotFolderSyncPaused(Folder *, bool paused);
void slotFolderSyncStarted();
void slotFolderSyncFinished( const SyncResult& );
--
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