From: Manuel Nickschas Date: Wed, 25 Nov 2009 21:37:45 +0000 (+0100) Subject: Handle removal of accounts a bit better X-Git-Tag: 0.6-beta1~155 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=e472996a053e11d21ffef4a30f7d37461239cdab;ds=sidebyside Handle removal of accounts a bit better We don't want to always clear and rewrite them all, in order to not lose additional accountValues. So remember which accounts have been removed from the model, and only delete those. Also, useSsl should be on by default. --- diff --git a/src/client/clientsettings.h b/src/client/clientsettings.h index 0e4b4102..6aacdfe9 100644 --- a/src/client/clientsettings.h +++ b/src/client/clientsettings.h @@ -73,7 +73,6 @@ public: void setJumpKeyMap(const QHash &keyMap); QHash jumpKeyMap(); -protected: void setAccountValue(const QString &key, const QVariant &data); QVariant accountValue(const QString &key, const QVariant &def = QVariant()); diff --git a/src/client/coreaccount.cpp b/src/client/coreaccount.cpp index d0c8a53b..a9444ce3 100644 --- a/src/client/coreaccount.cpp +++ b/src/client/coreaccount.cpp @@ -25,7 +25,7 @@ CoreAccount::CoreAccount(AccountId accountId) { _internal = false; _port = 4242; _storePassword = false; - _useSsl = false; + _useSsl = true; _useProxy = false; _proxyType = QNetworkProxy::Socks5Proxy; _proxyPort = 8080; diff --git a/src/client/coreaccountmodel.cpp b/src/client/coreaccountmodel.cpp index 1734c788..1ab159c8 100644 --- a/src/client/coreaccountmodel.cpp +++ b/src/client/coreaccountmodel.cpp @@ -42,6 +42,7 @@ void CoreAccountModel::update(const CoreAccountModel *other) { beginInsertRows(QModelIndex(), 0, other->_accounts.count() -1); _internalAccount = other->internalAccount(); _accounts = other->_accounts; + _removedAccounts = other->_removedAccounts; endInsertRows(); } @@ -65,7 +66,10 @@ void CoreAccountModel::load() { void CoreAccountModel::save() { CoreAccountSettings s; - s.clearAccounts(); + foreach(AccountId id, _removedAccounts) { + s.removeAccount(id); + } + _removedAccounts.clear(); foreach(const CoreAccount &acc, accounts()) { QVariantMap map = acc.toVariantMap(false); // TODO Hook into kwallet/password saving stuff s.storeAccountData(acc.accountId(), map); @@ -141,7 +145,7 @@ AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount &newAcc) { AccountId newId = 0; const QList &ids = accountIds(); for(int i = 1; ; i++) { - if(!ids.contains(i)) { + if(!_removedAccounts.contains(i) && !ids.contains(i)) { newId = i; break; } @@ -200,6 +204,7 @@ CoreAccount CoreAccountModel::takeAccount(AccountId accId) { void CoreAccountModel::removeAccount(AccountId accId) { takeAccount(accId); + _removedAccounts.insert(accId); } QModelIndex CoreAccountModel::accountIndex(AccountId accId) const { diff --git a/src/client/coreaccountmodel.h b/src/client/coreaccountmodel.h index 0dc22cff..1c314693 100644 --- a/src/client/coreaccountmodel.h +++ b/src/client/coreaccountmodel.h @@ -70,8 +70,8 @@ private: int listIndex(AccountId); QList _accounts; + QSet _removedAccounts; AccountId _internalAccount; - }; // Inlines