-void CoreAccountModel::update(const CoreAccountModel *other) {
- clear();
- if (other->_accounts.count() > 0) {
- beginInsertRows(QModelIndex(), 0, other->_accounts.count() -1);
- _accounts = other->_accounts;
- endInsertRows();
- }
- _internalAccount = other->internalAccount();
- _removedAccounts = other->_removedAccounts;
-}
-
-void CoreAccountModel::load() {
- clear();
- CoreAccountSettings s;
- foreach(AccountId accId, s.knownAccounts()) {
- QVariantMap map = s.retrieveAccountData(accId);
- CoreAccount acc;
- acc.fromVariantMap(map); // TODO Hook into kwallet/password saving stuff
- insertAccount(acc);
- }
- if(Quassel::runMode() == Quassel::Monolithic && !internalAccount().isValid()) {
- // Make sure we have an internal account in monolithic mode
- CoreAccount intAcc;
- intAcc.setInternal(true);
- intAcc.setAccountName(tr("Internal Core"));
- _internalAccount = createOrUpdateAccount(intAcc);
- }
-}
-
-void CoreAccountModel::save() {
- CoreAccountSettings s;
- 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);
- }
-}
-
-void CoreAccountModel::clear() {
- if(rowCount()) {
- beginRemoveRows(QModelIndex(), 0, rowCount()-1);
+void CoreAccountModel::save()
+{
+ CoreAccountSettings s;
+ 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);
+ }
+}
+
+void CoreAccountModel::clear()
+{
+ beginResetModel();