[Pkg-owncloud-commits] [owncloud-client] 84/498: Multi-Account: add possibility to delete an account

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:38 UTC 2015


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 1edd46b995239fef5963a819c0696091c0102aa8
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Tue May 12 15:16:32 2015 +0200

    Multi-Account: add possibility to delete an account
---
 src/gui/accountmanager.cpp  | 10 ++++++++++
 src/gui/accountmanager.h    |  7 +++++++
 src/gui/accountsettings.cpp | 19 +++++++++++++++++++
 src/gui/accountsettings.h   |  1 +
 src/gui/accountsettings.ui  |  2 +-
 5 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp
index b17de5d..819ecea 100644
--- a/src/gui/accountmanager.cpp
+++ b/src/gui/accountmanager.cpp
@@ -207,6 +207,16 @@ AccountState *AccountManager::addAccount(const AccountPtr& newAccount)
     return newAccountState.data();
 }
 
+void AccountManager::deleteAccount(AccountState* account)
+{
+    auto it = std::find(_accounts.begin(), _accounts.end(), account);
+    if (it == _accounts.end()) { return; }
+    auto copy = *it; // keep a reference to the shared pointer so it does not delete it just yet
+    _accounts.erase(it);
+    accountRemoved(account);
+}
+
+
 void AccountManager::shutdown()
 {
     auto accountsCopy = _accounts;
diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h
index 6cf4434..f8a3ce9 100644
--- a/src/gui/accountmanager.h
+++ b/src/gui/accountmanager.h
@@ -50,9 +50,16 @@ public:
 
     /**
      * Return a list of all accounts.
+     * (this is a list of QSharedPointer for internal reason, one should normaly not keep a copy of them)
      */
     QList<AccountStatePtr> accounts() { return _accounts; }
 
+    /**
+     * Delete the AccountState
+     */
+    void deleteAccount(AccountState *account);
+
+
 private:
     void save(const AccountPtr& account, QSettings& settings);
     AccountPtr load(QSettings& settings);
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index 322d411..1a5245e 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -25,6 +25,7 @@
 #include "account.h"
 #include "accountstate.h"
 #include "quotainfo.h"
+#include "accountmanager.h"
 #include "creds/abstractcredentials.h"
 
 #include <math.h>
@@ -126,6 +127,8 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
             this, SLOT(slotUpdateQuota(qint64,qint64)));
     slotUpdateQuota(quotaInfo->lastQuotaTotalBytes(), quotaInfo->lastQuotaUsedBytes());
 
+    connect(ui->deleteButton, SIGNAL(clicked()) , this, SLOT(slotDeleteAccount()));
+
     connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, ProgressInfo)),
              this, SLOT(slotSetProgress(QString, ProgressInfo)) );
 
@@ -643,4 +646,20 @@ void AccountSettings::refreshSelectiveSyncStatus()
     }
 }
 
+void AccountSettings::slotDeleteAccount()
+{
+    int ret = QMessageBox::question( this, tr("Confirm Account Delete"),
+                                     tr("<p>Do you really want to delete the account <i>%1</i>?</p>"
+                                     "<p><b>Note:</b> This will not remove the files from your client.</p>")
+                                        .arg(_accountState->account()->displayName()),
+                                     QMessageBox::Yes|QMessageBox::No );
+
+    if( ret == QMessageBox::No ) {
+        return;
+    }
+
+    AccountManager::instance()->deleteAccount(_accountState);
+}
+
+
 } // namespace OCC
diff --git a/src/gui/accountsettings.h b/src/gui/accountsettings.h
index 86bd74c..fbbf23d 100644
--- a/src/gui/accountsettings.h
+++ b/src/gui/accountsettings.h
@@ -77,6 +77,7 @@ protected slots:
     void slotFolderWizardAccepted();
     void slotFolderWizardRejected();
     void slotHideProgress();
+    void slotDeleteAccount();
     void refreshSelectiveSyncStatus();
 
 private:
diff --git a/src/gui/accountsettings.ui b/src/gui/accountsettings.ui
index e2adf85..c2c3f63 100644
--- a/src/gui/accountsettings.ui
+++ b/src/gui/accountsettings.ui
@@ -44,7 +44,7 @@
        </widget>
       </item>
       <item>
-       <widget class="QPushButton" name="pushButton">
+       <widget class="QPushButton" name="deleteButton">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
           <horstretch>0</horstretch>

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