[Pkg-owncloud-commits] [owncloud-client] 73/115: Status Icons: Rename the syncEnable method to isPaused.

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Aug 29 22:04:03 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 01b0ee49dece7d32e21db667b69ccba7635b8df2
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Tue Aug 19 13:58:20 2014 +0200

    Status Icons: Rename the syncEnable method to isPaused.
    
    Previously, in folder and folderman there have been the syncEnabled
    properties, but they confused the semantics: While in FolderMan the
    syncEnabled flag represents the network connection and stuff, in
    Folder it represented if the user paused or resumed the folder.
    
    This resulted in mixed use of both, which lead to wrong icon states.
    This patch renames the folder methods and properties to isPaused to
    make more clear about what it is.
---
 src/mirall/accountsettings.cpp | 100 +++++++++++++++---------------
 src/mirall/folder.cpp          |  10 +--
 src/mirall/folder.h            |   6 +-
 src/mirall/folderman.cpp       | 137 ++++++++++++++++++++++-------------------
 src/mirall/folderman.h         |   6 +-
 src/mirall/folderstatusmodel.h |   2 +-
 src/mirall/owncloudgui.cpp     |   2 +-
 7 files changed, 138 insertions(+), 125 deletions(-)

diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp
index 7298c2c..93479cb 100644
--- a/src/mirall/accountsettings.cpp
+++ b/src/mirall/accountsettings.cpp
@@ -159,8 +159,8 @@ void AccountSettings::slotFolderActivated( const QModelIndex& indx )
   ui->_buttonEnable->setEnabled( isValid );
 
   if ( isValid ) {
-    bool folderEnabled = _model->data( indx, FolderStatusDelegate::FolderSyncEnabled).toBool();
-    if ( folderEnabled ) {
+    bool folderPaused = _model->data( indx, FolderStatusDelegate::FolderSyncPaused).toBool();
+    if ( !folderPaused) {
       ui->_buttonEnable->setText( tr( "Pause" ) );
     } else {
       ui->_buttonEnable->setText( tr( "Resume" ) );
@@ -256,8 +256,7 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f )
     item->setData( f->nativePath(),        FolderStatusDelegate::FolderPathRole );
     item->setData( f->remotePath(),        FolderStatusDelegate::FolderSecondPathRole );
     item->setData( f->alias(),             FolderStatusDelegate::FolderAliasRole );
-    item->setData( f->syncEnabled(),       FolderStatusDelegate::FolderSyncEnabled );
-
+    item->setData( f->syncPaused(),        FolderStatusDelegate::FolderSyncPaused );
     SyncResult res = f->syncResult();
     SyncResult::Status status = res.status();
 
@@ -266,7 +265,10 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f )
     Theme *theme = Theme::instance();
     item->setData( theme->statusHeaderText( status ),  Qt::ToolTipRole );
     if (_account->state() == Account::Connected) {
-        if( f->syncEnabled() ) {
+        if( f->syncPaused() ) {
+            item->setData( theme->folderDisabledIcon( ), FolderStatusDelegate::FolderStatusIconRole ); // size 48 before
+            _wasDisabledBefore = false;
+        } else {
             if( status == SyncResult::SyncPrepare ) {
                 if( _wasDisabledBefore ) {
                     // if the folder was disabled before, set the sync icon
@@ -284,9 +286,6 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f )
                     item->setData( theme->syncStateIcon( status ), FolderStatusDelegate::FolderStatusIconRole );
                 }
             }
-        } else {
-            item->setData( theme->folderDisabledIcon( ), FolderStatusDelegate::FolderStatusIconRole ); // size 48 before
-            _wasDisabledBefore = false;
         }
     } else {
         item->setData( theme->folderOfflineIcon(), FolderStatusDelegate::FolderStatusIconRole);
@@ -431,57 +430,60 @@ void AccountSettings::slotEnableCurrentFolder()
 
     if( selected.isValid() ) {
         QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
-        bool folderEnabled = _model->data( selected, FolderStatusDelegate::FolderSyncEnabled).toBool();
-        qDebug() << "Toggle enabled/disabled Folder alias " << alias << " - current state: " << folderEnabled;
-        if( !alias.isEmpty() ) {
-            FolderMan *folderMan = FolderMan::instance();
 
-            qDebug() << "Application: enable folder with alias " << alias;
-            bool terminate = false;
+        if( alias.isEmpty() ) {
+            qDebug() << "Empty alias to enable.";
+            return;
+        }
 
-            // this sets the folder status to disabled but does not interrupt it.
-            Folder *f = folderMan->folder( alias );
-            if (!f) {
-                return;
-            }
+        FolderMan *folderMan = FolderMan::instance();
+
+        qDebug() << "Application: enable folder with alias " << alias;
+        bool terminate = false;
+        bool currentlyPaused = false;
 
-            if( folderEnabled ) {
-                // check if a sync is still running and if so, ask if we should terminate.
-                if( f->isBusy() ) { // its still running
+        // this sets the folder status to disabled but does not interrupt it.
+        Folder *f = folderMan->folder( alias );
+        if (!f) {
+            return;
+        }
+        currentlyPaused = f->syncPaused();
+        if( ! currentlyPaused ) {
+            // check if a sync is still running and if so, ask if we should terminate.
+            if( f->isBusy() ) { // its still running
 #if defined(Q_OS_MAC)
-                    QWidget *parent = this;
-                    Qt::WindowFlags flags = Qt::Sheet;
+                QWidget *parent = this;
+                Qt::WindowFlags flags = Qt::Sheet;
 #else
-                    QWidget *parent = 0;
-                    Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint; // default flags
+                QWidget *parent = 0;
+                Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint; // default flags
 #endif
-                    QMessageBox msgbox(QMessageBox::Question, tr("Sync Running"),
-                                       tr("The syncing operation is running.<br/>Do you want to terminate it?"),
-                                       QMessageBox::Yes | QMessageBox::No, parent, flags);
-                    msgbox.setDefaultButton(QMessageBox::Yes);
-                    int reply = msgbox.exec();
-                    if ( reply == QMessageBox::Yes )
-                        terminate = true;
-                    else
-                        return; // do nothing
-                }
-            }
-
-            // message box can return at any time while the thread keeps running,
-            // so better check again after the user has responded.
-            if ( f->isBusy() && terminate ) {
-                f->slotTerminateSync();
+                QMessageBox msgbox(QMessageBox::Question, tr("Sync Running"),
+                                   tr("The syncing operation is running.<br/>Do you want to terminate it?"),
+                                   QMessageBox::Yes | QMessageBox::No, parent, flags);
+                msgbox.setDefaultButton(QMessageBox::Yes);
+                int reply = msgbox.exec();
+                if ( reply == QMessageBox::Yes )
+                    terminate = true;
+                else
+                    return; // do nothing
             }
+        }
 
-            folderMan->slotEnableFolder( alias, !folderEnabled );
+        // message box can return at any time while the thread keeps running,
+        // so better check again after the user has responded.
+        if ( f->isBusy() && terminate ) {
+            f->slotTerminateSync();
+        }
+        f->setSyncPaused(!currentlyPaused); // toggle the pause setting
+        folderMan->slotSetFolderPaused( alias, !currentlyPaused );
 
-            // keep state for the icon setting.
-            if( !folderEnabled ) _wasDisabledBefore = true;
+        // keep state for the icon setting.
+        if( currentlyPaused ) _wasDisabledBefore = true;
 
-            slotUpdateFolderState (f);
-            // set the button text accordingly.
-            slotFolderActivated( selected );
-        }
+        slotUpdateFolderState (f);
+        // set the button text accordingly.
+        slotFolderActivated( selected );
     }
 }
 
diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp
index 6844e49..6660d0a 100644
--- a/src/mirall/folder.cpp
+++ b/src/mirall/folder.cpp
@@ -54,7 +54,7 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP
       , _path(path)
       , _remotePath(secondPath)
       , _alias(alias)
-      , _enabled(true)
+      , _paused(false)
       , _csyncError(false)
       , _csyncUnavail(false)
       , _wipeDb(false)
@@ -215,14 +215,14 @@ QString Folder::nativePath() const
     return QDir::toNativeSeparators(_path);
 }
 
-bool Folder::syncEnabled() const
+bool Folder::syncPaused() const
 {
-  return _enabled;
+  return _paused;
 }
 
-void Folder::setSyncEnabled( bool doit )
+void Folder::setSyncPaused( bool doit )
 {
-  _enabled = doit;
+  _paused = doit;
 
   if( doit ) {
       // qDebug() << "Syncing enabled on folder " << name();
diff --git a/src/mirall/folder.h b/src/mirall/folder.h
index 0e5656c..dcea1a2 100644
--- a/src/mirall/folder.h
+++ b/src/mirall/folder.h
@@ -85,9 +85,9 @@ public:
      * If the sync is switched off, the startSync method is not going to
      * be called.
      */
-     void setSyncEnabled( bool );
+     void setSyncPaused( bool );
 
-     bool syncEnabled() const;
+     bool syncPaused() const;
 
      void prepareToSync();
 
@@ -185,7 +185,7 @@ private:
     QString   _remotePath;
     QString   _alias;
     QString   _configFile;
-    bool       _enabled;
+    bool       _paused;
     SyncResult _syncResult;
     QScopedPointer<SyncEngine> _engine;
     QStringList  _errors;
diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp
index 7ec10a3..11da864 100644
--- a/src/mirall/folderman.cpp
+++ b/src/mirall/folderman.cpp
@@ -330,7 +330,7 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) {
     qDebug() << "Adding folder to Folder Map " << folder;
     _folderMap[alias] = folder;
     if (paused) {
-        folder->setSyncEnabled(!paused);
+        folder->setSyncPaused(paused);
         _disabledFolders.insert(folder);
     }
 
@@ -361,7 +361,7 @@ void FolderMan::slotEnableFolder( const QString& alias, bool enable )
         // FIXME: Use MirallConfigFile
         QSettings settings(_folderConfigPath + QLatin1Char('/') + f->configFile(), QSettings::IniFormat);
         settings.beginGroup(escapeAlias(f->alias()));
-        if (enable) {
+        if (!paused) {
             settings.remove("paused");
             _disabledFolders.remove(f);
         } else {
@@ -410,7 +410,7 @@ SyncResult FolderMan::syncResult( const QString& alias )
 void FolderMan::slotScheduleAllFolders()
 {
     foreach( Folder *f, _folderMap.values() ) {
-        if (f && f->syncEnabled()) {
+        if (f && ! f->syncPaused()) {
             slotScheduleSync( f->alias() );
         }
     }
@@ -433,7 +433,7 @@ void FolderMan::slotScheduleSync( const QString& alias )
     if( ! _scheduleQueue.contains(alias ) && _folderMap.contains(alias) ) {
         Folder *f = _folderMap[alias];
         if( f ) {
-            if( f->syncEnabled() ) {
+            if( !f->syncPaused() ) {
                 f->prepareToSync();
             } else {
                 qDebug() << "Folder is not enabled, not scheduled!";
@@ -487,7 +487,7 @@ void FolderMan::slotScheduleFolderSync()
         const QString alias = _scheduleQueue.dequeue();
         if( _folderMap.contains( alias ) ) {
             Folder *f = _folderMap[alias];
-            if( f && f->syncEnabled() ) {
+            if( f && !f->syncPaused() ) {
                 _currentSyncFolder = alias;
 
                 f->startSync( QStringList() );
@@ -585,7 +585,7 @@ void FolderMan::removeFolder( const QString& alias )
         f->wipe();
 
         // can be removed if we are able to delete the folder object.
-        f->setSyncEnabled(false);
+        f->setSyncPaused(true);
 
         // remove the folder configuration
         QFile file( _folderConfigPath + QLatin1Char('/') + f->configFile() );
@@ -680,39 +680,44 @@ SyncResult FolderMan::accountStatus(const QList<Folder*> &folders)
     if( cnt == 1 ) {
         Folder *folder = folders.at(0);
         if( folder ) {
-            SyncResult::Status syncStatus = folder->syncResult().status();
-
-            switch( syncStatus ) {
-            case SyncResult::Undefined:
-                overallResult.setStatus(SyncResult::Error);
-                break;
-            case SyncResult::NotYetStarted:
-                overallResult.setStatus( SyncResult::NotYetStarted );
-                break;
-            case SyncResult::SyncPrepare:
-                overallResult.setStatus( SyncResult::SyncPrepare );
-                break;
-            case SyncResult::SyncRunning:
-                overallResult.setStatus( SyncResult::SyncRunning );
-                break;
-            case SyncResult::Problem: // don't show the problem icon in tray.
-            case SyncResult::Success:
-                if( overallResult.status() == SyncResult::Undefined )
-                    overallResult.setStatus( SyncResult::Success );
-                break;
-            case SyncResult::Error:
-                overallResult.setStatus( SyncResult::Error );
-                break;
-            case SyncResult::SetupError:
-                if ( overallResult.status() != SyncResult::Error )
-                    overallResult.setStatus( SyncResult::SetupError );
-                break;
-            case SyncResult::SyncAbortRequested:
-                overallResult.setStatus( SyncResult::SyncAbortRequested);
-                break;
-            case SyncResult::Paused:
-                overallResult.setStatus( SyncResult::Paused);
-                break;
+            if( folder->syncPaused() ) {
+                overallResult.setStatus(SyncResult::Paused);
+            } else {
+                SyncResult::Status syncStatus = folder->syncResult().status();
+
+
+                switch( syncStatus ) {
+                case SyncResult::Undefined:
+                    overallResult.setStatus(SyncResult::Error);
+                    break;
+                case SyncResult::NotYetStarted:
+                    overallResult.setStatus( SyncResult::NotYetStarted );
+                    break;
+                case SyncResult::SyncPrepare:
+                    overallResult.setStatus( SyncResult::SyncPrepare );
+                    break;
+                case SyncResult::SyncRunning:
+                    overallResult.setStatus( SyncResult::SyncRunning );
+                    break;
+                case SyncResult::Problem: // don't show the problem icon in tray.
+                case SyncResult::Success:
+                    if( overallResult.status() == SyncResult::Undefined )
+                        overallResult.setStatus( SyncResult::Success );
+                    break;
+                case SyncResult::Error:
+                    overallResult.setStatus( SyncResult::Error );
+                    break;
+                case SyncResult::SetupError:
+                    if ( overallResult.status() != SyncResult::Error )
+                        overallResult.setStatus( SyncResult::SetupError );
+                    break;
+                case SyncResult::SyncAbortRequested:
+                    overallResult.setStatus( SyncResult::SyncAbortRequested);
+                    break;
+                case SyncResult::Paused:
+                    overallResult.setStatus( SyncResult::Paused);
+                    break;
+                }
             }
         }
     } else {
@@ -723,30 +728,34 @@ SyncResult FolderMan::accountStatus(const QList<Folder*> &folders)
         int various = 0;
 
         foreach ( Folder *folder, folders ) {
-            SyncResult folderResult = folder->syncResult();
-            SyncResult::Status syncStatus = folderResult.status();
-
-            switch( syncStatus ) {
-            case SyncResult::Undefined:
-            case SyncResult::NotYetStarted:
-            case SyncResult::SyncPrepare:
-                various++;
-                break;
-            case SyncResult::SyncRunning:
-                runSeen++;
-                break;
-            case SyncResult::Problem: // don't show the problem icon in tray.
-            case SyncResult::Success:
-                goodSeen++;
-                break;
-            case SyncResult::Error:
-            case SyncResult::SetupError:
-                errorsSeen++;
-                break;
-            case SyncResult::SyncAbortRequested:
-            case SyncResult::Paused:
+            if( folder->syncPaused() ) {
                 abortSeen++;
-                // no default case on purpose, check compiler warnings
+            } else {
+                SyncResult folderResult = folder->syncResult();
+                SyncResult::Status syncStatus = folderResult.status();
+
+                switch( syncStatus ) {
+                case SyncResult::Undefined:
+                case SyncResult::NotYetStarted:
+                case SyncResult::SyncPrepare:
+                    various++;
+                    break;
+                case SyncResult::SyncRunning:
+                    runSeen++;
+                    break;
+                case SyncResult::Problem: // don't show the problem icon in tray.
+                case SyncResult::Success:
+                    goodSeen++;
+                    break;
+                case SyncResult::Error:
+                case SyncResult::SetupError:
+                    errorsSeen++;
+                    break;
+                case SyncResult::SyncAbortRequested:
+                case SyncResult::Paused:
+                    abortSeen++;
+                    // no default case on purpose, check compiler warnings
+                }
             }
         }
         bool set = false;
@@ -772,7 +781,7 @@ SyncResult FolderMan::accountStatus(const QList<Folder*> &folders)
     return overallResult;
 }
 
-QString FolderMan::statusToString( SyncResult syncStatus, bool enabled ) const
+QString FolderMan::statusToString( SyncResult syncStatus, bool paused ) const
 {
     QString folderMessage;
     switch( syncStatus.status() ) {
@@ -807,7 +816,7 @@ QString FolderMan::statusToString( SyncResult syncStatus, bool enabled ) const
         break;
     // no default case on purpose, check compiler warnings
     }
-    if( !enabled ) {
+    if( paused ) {
         // sync is disabled.
         folderMessage = tr( "%1 (Sync is paused)" ).arg(folderMessage);
     }
diff --git a/src/mirall/folderman.h b/src/mirall/folderman.h
index c3a8d00..1b4c551 100644
--- a/src/mirall/folderman.h
+++ b/src/mirall/folderman.h
@@ -77,7 +77,7 @@ public:
     /** Creates a new and empty local directory. */
     bool startFromScratch( const QString& );
 
-    QString statusToString( SyncResult, bool enabled ) const;
+    QString statusToString(SyncResult, bool paused ) const;
 
     static SyncResult accountStatus( const QList<Folder*> &folders );
 
@@ -88,6 +88,8 @@ signals:
     /**
       * signal to indicate a folder named by alias has changed its sync state.
       * Get the state via the Folder Map or the syncResult and syncState methods.
+      *
+      * Attention: The alias string may be zero. Do a general update of the state than.
       */
     void folderSyncStateChange( const QString & );
 
@@ -95,7 +97,7 @@ signals:
 
 public slots:
     void slotRemoveFolder( const QString& );
-    void slotEnableFolder( const QString&, bool );
+    void slotSetFolderPaused(const QString&, bool paused);
 
     void slotFolderSyncStarted();
     void slotFolderSyncFinished( const SyncResult& );
diff --git a/src/mirall/folderstatusmodel.h b/src/mirall/folderstatusmodel.h
index 74acaa0..77120b3 100644
--- a/src/mirall/folderstatusmodel.h
+++ b/src/mirall/folderstatusmodel.h
@@ -42,7 +42,7 @@ class FolderStatusDelegate : public QStyledItemDelegate
                     FolderRemotePath,
                     FolderStatus,
                     FolderErrorMsg,
-                    FolderSyncEnabled,
+                    FolderSyncPaused,
                     FolderStatusIconRole,
 
                     SyncProgressOverallPercent,
diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp
index baa84bb..9bb2743 100644
--- a/src/mirall/owncloudgui.cpp
+++ b/src/mirall/owncloudgui.cpp
@@ -249,7 +249,7 @@ void ownCloudGui::slotComputeOverallSyncStatus()
             QStringList allStatusStrings;
             foreach(Folder* folder, map.values()) {
                 qDebug() << "Folder in overallStatus Message: " << folder << " with name " << folder->alias();
-                QString folderMessage = folderMan->statusToString(folder->syncResult().status(), folder->syncEnabled());
+                QString folderMessage = folderMan->statusToString(folder->syncResult().status(), folder->syncPaused());
                 allStatusStrings += tr("Folder %1: %2").arg(folder->alias(), folderMessage);
             }
 

-- 
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