-AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount &newAcc) {
- CoreAccount acc = newAcc;
-
- if(acc.uuid().isNull())
- acc.setUuid(QUuid::createUuid());
-
- if(!acc.accountId().isValid()) {
- // find free Id
- AccountId newId = 0;
- const QList<AccountId> &ids = accountIds();
- for(int i = 1; ; i++) {
- if(!_removedAccounts.contains(i) && !ids.contains(i)) {
- newId = i;
- break;
- }
- }
- acc.setAccountId(newId);
- insertAccount(acc);
- } else {
- int idx = findAccountIdx(acc.accountId());
- if(idx >= 0) {
- if(acc.accountName() == accounts().at(idx).accountName()) {
- _accounts[idx] = acc;
- emit dataChanged(index(idx, 0), index(idx, 0));
- } else {
- takeAccount(acc.accountId());
+AccountId CoreAccountModel::createOrUpdateAccount(const CoreAccount& newAcc)
+{
+ CoreAccount acc = newAcc;
+
+ if (acc.uuid().isNull())
+ acc.setUuid(QUuid::createUuid());
+
+ if (!acc.accountId().isValid()) {
+ // find free Id
+ AccountId newId = 0;
+ const QList<AccountId>& ids = accountIds();
+ for (int i = 1;; i++) {
+ if (!_removedAccounts.contains(i) && !ids.contains(i)) {
+ newId = i;
+ break;
+ }
+ }
+ acc.setAccountId(newId);