X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fcoreaccountmodel.cpp;h=a7a2f017333c0d132584c58bab910bda7e663436;hp=1734c78894e91b2f46b597a6418999e14b915333;hb=d45d1044c030312878cb648fd1325ce70b079c44;hpb=0f87a72d470196f5781053927d9b91e52cc363f2 diff --git a/src/client/coreaccountmodel.cpp b/src/client/coreaccountmodel.cpp index 1734c788..a7a2f017 100644 --- a/src/client/coreaccountmodel.cpp +++ b/src/client/coreaccountmodel.cpp @@ -39,10 +39,13 @@ CoreAccountModel::CoreAccountModel(const CoreAccountModel *other, QObject *paren void CoreAccountModel::update(const CoreAccountModel *other) { clear(); - beginInsertRows(QModelIndex(), 0, other->_accounts.count() -1); + if (other->_accounts.count() > 0) { + beginInsertRows(QModelIndex(), 0, other->_accounts.count() -1); + _accounts = other->_accounts; + endInsertRows(); + } _internalAccount = other->internalAccount(); - _accounts = other->_accounts; - endInsertRows(); + _removedAccounts = other->_removedAccounts; } void CoreAccountModel::load() { @@ -65,7 +68,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 +147,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 +206,7 @@ CoreAccount CoreAccountModel::takeAccount(AccountId accId) { void CoreAccountModel::removeAccount(AccountId accId) { takeAccount(accId); + _removedAccounts.insert(accId); } QModelIndex CoreAccountModel::accountIndex(AccountId accId) const {