projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean-up and refactor the blowfish encryption stuff
[quassel.git]
/
src
/
client
/
coreaccountmodel.cpp
diff --git
a/src/client/coreaccountmodel.cpp
b/src/client/coreaccountmodel.cpp
index
bcd69dc
..
a7a2f01
100644
(file)
--- 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();
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();
_internalAccount = other->internalAccount();
- _accounts = other->_accounts;
- endInsertRows();
+ _removedAccounts = other->_removedAccounts;
}
void CoreAccountModel::load() {
}
void CoreAccountModel::load() {
@@
-58,17
+61,19
@@
void CoreAccountModel::load() {
// Make sure we have an internal account in monolithic mode
CoreAccount intAcc;
intAcc.setInternal(true);
// Make sure we have an internal account in monolithic mode
CoreAccount intAcc;
intAcc.setInternal(true);
- insertAccount(intAcc);
+ intAcc.setAccountName(tr("Internal Core"));
+ _internalAccount = createOrUpdateAccount(intAcc);
}
}
void CoreAccountModel::save() {
CoreAccountSettings s;
}
}
void CoreAccountModel::save() {
CoreAccountSettings s;
+ foreach(AccountId id, _removedAccounts) {
+ s.removeAccount(id);
+ }
+ _removedAccounts.clear();
foreach(const CoreAccount &acc, accounts()) {
foreach(const CoreAccount &acc, accounts()) {
- if(acc.isInternal())
- continue; // FIXME don't save internal for now - but make sure to handle this correctly once mono can do remotes!
- // we'll have to ensure that autoConnectAccount works with internal as well then
- QVariantMap map = acc.toVariantMap(true); // TODO Hook into kwallet/password saving stuff
+ QVariantMap map = acc.toVariantMap(false); // TODO Hook into kwallet/password saving stuff
s.storeAccountData(acc.accountId(), map);
}
}
s.storeAccountData(acc.accountId(), map);
}
}
@@
-142,7
+147,7
@@
AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount &newAcc) {
AccountId newId = 0;
const QList<AccountId> &ids = accountIds();
for(int i = 1; ; i++) {
AccountId newId = 0;
const QList<AccountId> &ids = accountIds();
for(int i = 1; ; i++) {
- if(!ids.contains(i)) {
+ if(!
_removedAccounts.contains(i) && !
ids.contains(i)) {
newId = i;
break;
}
newId = i;
break;
}
@@
-167,8
+172,6
@@
AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount &newAcc) {
void CoreAccountModel::insertAccount(const CoreAccount &acc) {
if(acc.isInternal()) {
void CoreAccountModel::insertAccount(const CoreAccount &acc) {
if(acc.isInternal()) {
- if(Quassel::runMode() == Quassel::Monolithic)
- return;
if(internalAccount().isValid()) {
qWarning() << "Trying to insert a second internal account in CoreAccountModel, ignoring";
return;
if(internalAccount().isValid()) {
qWarning() << "Trying to insert a second internal account in CoreAccountModel, ignoring";
return;
@@
-203,6
+206,7
@@
CoreAccount CoreAccountModel::takeAccount(AccountId accId) {
void CoreAccountModel::removeAccount(AccountId accId) {
takeAccount(accId);
void CoreAccountModel::removeAccount(AccountId accId) {
takeAccount(accId);
+ _removedAccounts.insert(accId);
}
QModelIndex CoreAccountModel::accountIndex(AccountId accId) const {
}
QModelIndex CoreAccountModel::accountIndex(AccountId accId) const {