void MyMoneyInstitutionTest::testAccountIDList () { MyMoneyInstitution institution; QStringList list; QString id; // list must be empty list = institution.accountList(); CPPUNIT_ASSERT(list.count() == 0); // add one account institution.addAccountId("A000002"); list = institution.accountList(); CPPUNIT_ASSERT(list.count() == 1); CPPUNIT_ASSERT(list.contains("A000002") == 1); // adding same account shouldn't make a difference institution.addAccountId("A000002"); list = institution.accountList(); CPPUNIT_ASSERT(list.count() == 1); CPPUNIT_ASSERT(list.contains("A000002") == 1); // now add another account institution.addAccountId("A000001"); list = institution.accountList(); CPPUNIT_ASSERT(list.count() == 2); CPPUNIT_ASSERT(list.contains("A000002") == 1); CPPUNIT_ASSERT(list.contains("A000001") == 1); id = institution.removeAccountId("A000001"); CPPUNIT_ASSERT(id == "A000001"); list = institution.accountList(); CPPUNIT_ASSERT(list.count() == 1); CPPUNIT_ASSERT(list.contains("A000002") == 1); }
void MyMoneyInstitutionTest::testMyMoneyFileConstructor() { MyMoneyInstitution *t = new MyMoneyInstitution("GUID", *n); CPPUNIT_ASSERT(t->id() == "GUID"); CPPUNIT_ASSERT(t->street() == "street"); CPPUNIT_ASSERT(t->town() == "town"); CPPUNIT_ASSERT(t->postcode() == "postcode"); CPPUNIT_ASSERT(t->telephone() == "telephone"); CPPUNIT_ASSERT(t->manager() == "manager"); CPPUNIT_ASSERT(t->name() == "name"); CPPUNIT_ASSERT(t->sortcode() == "sortcode"); delete t; }
void KNewAccountDlg::slotNewClicked() { MyMoneyInstitution institution; KNewBankDlg dlg(institution, this); if (dlg.exec()) { MyMoneyFileTransaction ft; try { MyMoneyFile *file = MyMoneyFile::instance(); institution = dlg.institution(); file->addInstitution(institution); ft.commit(); slotLoadInstitutions(institution.name()); } catch (MyMoneyException *e) { delete e; KMessageBox::information(this, i18n("Cannot add institution")); } } }
void MyMoneyInstitutionTest::testReadXML() { MyMoneyInstitution i; QString ref_ok = QString( "<!DOCTYPE TEST>\n" "<INSTITUTION-CONTAINER>\n" " <INSTITUTION sortcode=\"sortcode\" id=\"I00001\" manager=\"manager\" name=\"name\" >\n" " <ADDRESS street=\"street\" zip=\"postcode\" city=\"town\" telephone=\"telephone\" />\n" " <ACCOUNTIDS>\n" " <ACCOUNTID id=\"A000001\" />\n" " <ACCOUNTID id=\"A000003\" />\n" " </ACCOUNTIDS>\n" " <KEYVALUEPAIRS>\n" " <PAIR key=\"key\" value=\"value\" />\n" " </KEYVALUEPAIRS>\n" " </INSTITUTION>\n" "</INSTITUTION-CONTAINER>\n"); QString ref_false = QString( "<!DOCTYPE TEST>\n" "<INSTITUTION-CONTAINER>\n" " <KINSTITUTION sortcode=\"sortcode\" id=\"I00001\" manager=\"manager\" name=\"name\" >\n" " <ADDRESS street=\"street\" zip=\"postcode\" city=\"town\" telephone=\"telephone\" />\n" " <ACCOUNTIDS>\n" " <ACCOUNTID id=\"A000001\" />\n" " <ACCOUNTID id=\"A000003\" />\n" " </ACCOUNTIDS>\n" " </KINSTITUTION>\n" "</INSTITUTION-CONTAINER>\n"); QDomDocument doc; QDomElement node; doc.setContent(ref_false); node = doc.documentElement().firstChild().toElement(); try { i = MyMoneyInstitution(node); CPPUNIT_FAIL("Missing expected exception"); } catch(MyMoneyException *e) { delete e; } i.addAccountId("TEST"); doc.setContent(ref_ok); node = doc.documentElement().firstChild().toElement(); try { QStringList alist; alist << "A000001" << "A000003"; i = MyMoneyInstitution(node); CPPUNIT_ASSERT(i.sortcode() == "sortcode"); CPPUNIT_ASSERT(i.id() == "I00001"); CPPUNIT_ASSERT(i.manager() == "manager"); CPPUNIT_ASSERT(i.name() == "name"); CPPUNIT_ASSERT(i.street() == "street"); CPPUNIT_ASSERT(i.postcode() == "postcode"); CPPUNIT_ASSERT(i.city() == "town"); CPPUNIT_ASSERT(i.telephone() == "telephone"); CPPUNIT_ASSERT(i.accountList() == alist); CPPUNIT_ASSERT(i.value(QString("key")) == "value"); } catch(MyMoneyException *e) { delete e; CPPUNIT_FAIL("Unexpected exception"); } }
void MyMoneyStorageDump::writeStream(QDataStream& _s, IMyMoneySerialize* _storage) { QTextStream s(_s.device()); IMyMoneyStorage* storage = dynamic_cast<IMyMoneyStorage *>(_storage); MyMoneyPayee user = storage->user(); s << "File-Info\n"; s << "---------\n"; s << "user name = " << user.name() << "\n"; s << "user street = " << user.address() << "\n"; s << "user city = " << user.city() << "\n"; s << "user city = " << user.state() << "\n"; s << "user zip = " << user.postcode() << "\n"; s << "user telephone = " << user.telephone() << "\n"; s << "user e-mail = " << user.email() << "\n"; s << "creation date = " << storage->creationDate().toString(Qt::ISODate) << "\n"; s << "last modification date = " << storage->lastModificationDate().toString(Qt::ISODate) << "\n"; s << "base currency = " << storage->value("kmm-baseCurrency") << "\n"; s << "\n"; s << "Internal-Info\n"; s << "-------------\n"; QList<MyMoneyAccount> list_a; storage->accountList(list_a); s << "accounts = " << list_a.count() << ", next id = " << _storage->accountId() << "\n"; MyMoneyTransactionFilter filter; filter.setReportAllSplits(false); QList<MyMoneyTransaction> list_t; storage->transactionList(list_t, filter); QList<MyMoneyTransaction>::ConstIterator it_t; s << "transactions = " << list_t.count() << ", next id = " << _storage->transactionId() << "\n"; QMap<int, int> xferCount; for (it_t = list_t.constBegin(); it_t != list_t.constEnd(); ++it_t) { QList<MyMoneySplit>::ConstIterator it_s; int accountCount = 0; for (it_s = (*it_t).splits().constBegin(); it_s != (*it_t).splits().constEnd(); ++it_s) { MyMoneyAccount acc = storage->account((*it_s).accountId()); if (acc.accountGroup() != MyMoneyAccount::Expense && acc.accountGroup() != MyMoneyAccount::Income) accountCount++; } if (accountCount > 1) xferCount[accountCount] = xferCount[accountCount] + 1; } QMap<int, int>::ConstIterator it_cnt; for (it_cnt = xferCount.constBegin(); it_cnt != xferCount.constEnd(); ++it_cnt) { s << " " << *it_cnt << " of them references " << it_cnt.key() << " accounts\n"; } s << "payees = " << _storage->payeeList().count() << ", next id = " << _storage->payeeId() << "\n"; s << "tags = " << _storage->tagList().count() << ", next id = " << _storage->tagId() << "\n"; s << "institutions = " << _storage->institutionList().count() << ", next id = " << _storage->institutionId() << "\n"; s << "schedules = " << _storage->scheduleList().count() << ", next id = " << _storage->scheduleId() << "\n"; s << "\n"; s << "Institutions\n"; s << "------------\n"; QList<MyMoneyInstitution> list_i = storage->institutionList(); QList<MyMoneyInstitution>::ConstIterator it_i; for (it_i = list_i.constBegin(); it_i != list_i.constEnd(); ++it_i) { s << " ID = " << (*it_i).id() << "\n"; s << " Name = " << (*it_i).name() << "\n"; s << "\n"; } s << "\n"; s << "Payees" << "\n"; s << "------" << "\n"; QList<MyMoneyPayee> list_p = storage->payeeList(); QList<MyMoneyPayee>::ConstIterator it_p; for (it_p = list_p.constBegin(); it_p != list_p.constEnd(); ++it_p) { s << " ID = " << (*it_p).id() << "\n"; s << " Name = " << (*it_p).name() << "\n"; s << " Address = " << (*it_p).address() << "\n"; s << " City = " << (*it_p).city() << "\n"; s << " State = " << (*it_p).state() << "\n"; s << " Zip = " << (*it_p).postcode() << "\n"; s << " E-Mail = " << (*it_p).email() << "\n"; s << " Telephone = " << (*it_p).telephone() << "\n"; s << " Reference = " << (*it_p).reference() << "\n"; s << "\n"; } s << "\n"; s << "Tags" << "\n"; s << "------" << "\n"; QList<MyMoneyTag> list_ta = storage->tagList(); QList<MyMoneyTag>::ConstIterator it_ta; for (it_ta = list_ta.constBegin(); it_ta != list_ta.constEnd(); ++it_ta) { s << " ID = " << (*it_ta).id() << "\n"; s << " Name = " << (*it_ta).name() << "\n"; s << " Closed = " << (*it_ta).isClosed() << "\n"; s << " TagColor = " << (*it_ta).tagColor().name() << "\n"; s << " Notes = " << (*it_ta).notes() << "\n"; s << "\n"; } s << "\n"; s << "Accounts" << "\n"; s << "--------" << "\n"; list_a.push_front(storage->equity()); list_a.push_front(storage->expense()); list_a.push_front(storage->income()); list_a.push_front(storage->liability()); list_a.push_front(storage->asset()); QList<MyMoneyAccount>::ConstIterator it_a; for (it_a = list_a.constBegin(); it_a != list_a.constEnd(); ++it_a) { s << " ID = " << (*it_a).id() << "\n"; s << " Name = " << (*it_a).name() << "\n"; s << " Number = " << (*it_a).number() << "\n"; s << " Description = " << (*it_a).description() << "\n"; s << " Type = " << (*it_a).accountType() << "\n"; if ((*it_a).currencyId().isEmpty()) { s << " Currency = unknown\n"; } else { if ((*it_a).isInvest()) { s << " Equity = " << storage->security((*it_a).currencyId()).name() << "\n"; } else { s << " Currency = " << storage->currency((*it_a).currencyId()).name() << "\n"; } } s << " Parent = " << (*it_a).parentAccountId(); if (!(*it_a).parentAccountId().isEmpty()) { MyMoneyAccount parent = storage->account((*it_a).parentAccountId()); s << " (" << parent.name() << ")"; } else { s << "n/a"; } s << "\n"; s << " Institution = " << (*it_a).institutionId(); if (!(*it_a).institutionId().isEmpty()) { MyMoneyInstitution inst = storage->institution((*it_a).institutionId()); s << " (" << inst.name() << ")"; } else { s << "n/a"; } s << "\n"; s << " Opening date = " << (*it_a).openingDate().toString(Qt::ISODate) << "\n"; s << " Last modified = " << (*it_a).lastModified().toString(Qt::ISODate) << "\n"; s << " Last reconciled = " << (*it_a).lastReconciliationDate().toString(Qt::ISODate) << "\n"; s << " Balance = " << (*it_a).balance().formatMoney("", 2) << "\n"; dumpKVP(" KVP: ", s, *it_a); dumpKVP(" OnlineBankingSettings: ", s, (*it_a).onlineBankingSettings()); QStringList list_s = (*it_a).accountList(); QStringList::ConstIterator it_s; if (list_s.count() > 0) { s << " Children =" << "\n"; } for (it_s = list_s.constBegin(); it_s != list_s.constEnd(); ++it_s) { MyMoneyAccount child = storage->account(*it_s); s << " " << *it_s << " (" << child.name() << ")\n"; } s << "\n"; } s << "\n"; #if 0 s << "Currencies" << "\n"; s << "----------" << "\n"; QList<MyMoneyCurrency> list_c = storage->currencyList(); QList<MyMoneyCurrency>::ConstIterator it_c; for (it_c = list_c.begin(); it_c != list_c.end(); ++it_c) { s << " Name = " << (*it_c).name() << "\n"; s << " ID = " << (*it_c).id() << "\n"; s << " Symbol = " << (*it_c).tradingSymbol() << "\n"; s << " Parts/Unit = " << (*it_c).partsPerUnit() << "\n"; s << " smallest cash fraction = " << (*it_c).smallestCashFraction() << "\n"; s << " smallest account fraction = " << (*it_c).smallestAccountFraction() << "\n"; dumpPriceHistory(s, (*it_c).priceHistory()); s << "\n"; } s << "\n"; #endif s << "Securities" << "\n"; s << "----------" << "\n"; QList<MyMoneySecurity> list_e = storage->securityList(); QList<MyMoneySecurity>::ConstIterator it_e; for (it_e = list_e.constBegin(); it_e != list_e.constEnd(); ++it_e) { s << " Name = " << (*it_e).name() << "\n"; s << " ID = " << (*it_e).id() << "\n"; s << " Market = " << (*it_e).tradingMarket() << "\n"; s << " Symbol = " << (*it_e).tradingSymbol() << "\n"; s << " Currency = " << (*it_e).tradingCurrency() << " ("; if ((*it_e).tradingCurrency().isEmpty()) { s << "unknown"; } else { MyMoneySecurity tradingCurrency = storage->currency((*it_e).tradingCurrency()); if (!tradingCurrency.isCurrency()) { s << "invalid currency: "; } s << tradingCurrency.name(); } s << ")\n"; s << " Type = " << MyMoneySecurity::securityTypeToString((*it_e).securityType()) << "\n"; s << " smallest account fraction = " << (*it_e).smallestAccountFraction() << "\n"; s << " KVP: " << "\n"; QMap<QString, QString>kvp = (*it_e).pairs(); QMap<QString, QString>::Iterator it; for (it = kvp.begin(); it != kvp.end(); ++it) { s << " '" << it.key() << "' = '" << it.value() << "'\n"; } s << "\n"; } s << "\n"; s << "Prices" << "\n"; s << "--------" << "\n"; MyMoneyPriceList list_pr = _storage->priceList(); MyMoneyPriceList::ConstIterator it_pr; for (it_pr = list_pr.constBegin(); it_pr != list_pr.constEnd(); ++it_pr) { s << " From = " << it_pr.key().first << "\n"; s << " To = " << it_pr.key().second << "\n"; MyMoneyPriceEntries::ConstIterator it_pre; for (it_pre = (*it_pr).constBegin(); it_pre != (*it_pr).constEnd(); ++it_pre) { s << " Date = " << (*it_pre).date().toString() << "\n"; s << " Price = " << (*it_pre).rate(QString()).formatMoney("", 8) << "\n"; s << " Source = " << (*it_pre).source() << "\n"; s << " From = " << (*it_pre).from() << "\n"; s << " To = " << (*it_pre).to() << "\n"; } s << "\n"; } s << "\n"; s << "Transactions" << "\n"; s << "------------" << "\n"; for (it_t = list_t.constBegin(); it_t != list_t.constEnd(); ++it_t) { dumpTransaction(s, storage, *it_t); } s << "\n"; s << "Schedules" << "\n"; s << "---------" << "\n"; QList<MyMoneySchedule> list_s = storage->scheduleList(); QList<MyMoneySchedule>::ConstIterator it_s; for (it_s = list_s.constBegin(); it_s != list_s.constEnd(); ++it_s) { s << " ID = " << (*it_s).id() << "\n"; s << " Name = " << (*it_s).name() << "\n"; s << " Startdate = " << (*it_s).startDate().toString(Qt::ISODate) << "\n"; if ((*it_s).willEnd()) s << " Enddate = " << (*it_s).endDate().toString(Qt::ISODate) << "\n"; else s << " Enddate = not specified\n"; s << " Occurence = " << (*it_s).occurrenceToString() << "\n"; // krazy:exclude=spelling s << " OccurenceMultiplier = " << (*it_s).occurrenceMultiplier() << "\n"; s << " Type = " << MyMoneySchedule::scheduleTypeToString((*it_s).type()) << "\n"; s << " Paymenttype = " << MyMoneySchedule::paymentMethodToString((*it_s).paymentType()) << "\n"; s << " Fixed = " << (*it_s).isFixed() << "\n"; s << " AutoEnter = " << (*it_s).autoEnter() << "\n"; if ((*it_s).lastPayment().isValid()) s << " Last payment = " << (*it_s).lastPayment().toString(Qt::ISODate) << "\n"; else s << " Last payment = not defined" << "\n"; if ((*it_s).isFinished()) s << " Next payment = payment finished" << "\n"; else { s << " Next payment = " << (*it_s).nextDueDate().toString(Qt::ISODate) << "\n"; if ((*it_s).isOverdue()) s << " = overdue!" << "\n"; } QList<QDate> list_d; QList<QDate>::ConstIterator it_d; list_d = (*it_s).recordedPayments(); if (list_d.count() > 0) { s << " Recorded payments" << "\n"; for (it_d = list_d.constBegin(); it_d != list_d.constEnd(); ++it_d) { s << " " << (*it_d).toString(Qt::ISODate) << "\n"; } } s << " TRANSACTION\n"; dumpTransaction(s, storage, (*it_s).transaction()); } s << "\n"; s << "Reports" << "\n"; s << "-------" << "\n"; QList<MyMoneyReport> list_r = storage->reportList(); QList<MyMoneyReport>::ConstIterator it_r; for (it_r = list_r.constBegin(); it_r != list_r.constEnd(); ++it_r) { s << " ID = " << (*it_r).id() << "\n"; s << " Name = " << (*it_r).name() << "\n"; } s << "Budgets" << "\n"; s << "-------" << "\n"; QList<MyMoneyBudget> list_b = storage->budgetList(); QList<MyMoneyBudget>::ConstIterator it_b; for (it_b = list_b.constBegin(); it_b != list_b.constEnd(); ++it_b) { s << " ID = " << (*it_b).id() << "\n"; s << " Name = " << (*it_b).name() << "\n"; } }
void MyMoneyStorageXML::writeInstitution(QDomElement& institution, const MyMoneyInstitution& i) { i.writeXML(*m_doc, institution); }
KEndingBalanceDlg::KEndingBalanceDlg(const MyMoneyAccount& account, QWidget *parent) : KEndingBalanceDlgDecl(parent), d(new Private(Page_InterestChargeCheckings + 1)) { setModal(true); QString value; MyMoneyMoney endBalance, startBalance; d->m_account = account; MyMoneySecurity currency = MyMoneyFile::instance()->security(account.currencyId()); //FIXME: port m_statementInfoPageCheckings->m_enterInformationLabel->setText(QString("<qt>") + i18n("Please enter the following fields with the information as you find them on your statement. Make sure to enter all values in <b>%1</b>.", currency.name()) + QString("</qt>")); // If the previous reconciliation was postponed, // we show a different first page value = account.value("lastReconciledBalance"); if (value.isEmpty()) { // if the last statement has been entered long enough ago (more than one month), // then take the last statement date and add one month and use that as statement // date. QDate lastStatementDate = account.lastReconciliationDate(); if (lastStatementDate.addMonths(1) < QDate::currentDate()) { setField("statementDate", lastStatementDate.addMonths(1)); } slotUpdateBalances(); d->m_pages.clearBit(Page_PreviousPostpone); } else { d->m_pages.clearBit(Page_CheckingStart); d->m_pages.clearBit(Page_InterestChargeCheckings); //removePage(m_interestChargeCheckings); // make sure, we show the correct start page setStartId(Page_PreviousPostpone); MyMoneyMoney factor(1, 1); if (d->m_account.accountGroup() == MyMoneyAccount::Liability) factor = -factor; startBalance = MyMoneyMoney(value) * factor; value = account.value("statementBalance"); endBalance = MyMoneyMoney(value) * factor; //FIXME: port m_statementInfoPageCheckings->m_previousBalance->setValue(startBalance); m_statementInfoPageCheckings->m_endingBalance->setValue(endBalance); } // We don't need to add the default into the list (see ::help() why) // m_helpAnchor[m_startPageCheckings] = QString(""); d->m_helpAnchor[m_interestChargeCheckings] = QString("details.reconcile.wizard.interest"); d->m_helpAnchor[m_statementInfoPageCheckings] = QString("details.reconcile.wizard.statement"); value = account.value("statementDate"); if (!value.isEmpty()) setField("statementDate", QDate::fromString(value, Qt::ISODate)); //FIXME: port m_statementInfoPageCheckings->m_lastStatementDate->setText(QString()); if (account.lastReconciliationDate().isValid()) { m_statementInfoPageCheckings->m_lastStatementDate->setText(i18n("Last reconciled statement: %1", QLocale().toString(account.lastReconciliationDate()))); } // connect the signals with the slots connect(MyMoneyFile::instance(), SIGNAL(dataChanged()), this, SLOT(slotReloadEditWidgets())); connect(m_statementInfoPageCheckings->m_statementDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotUpdateBalances())); connect(m_interestChargeCheckings->m_interestCategoryEdit, SIGNAL(createItem(QString,QString&)), this, SLOT(slotCreateInterestCategory(QString,QString&))); connect(m_interestChargeCheckings->m_chargesCategoryEdit, SIGNAL(createItem(QString,QString&)), this, SLOT(slotCreateChargesCategory(QString,QString&))); connect(m_interestChargeCheckings->m_payeeEdit, SIGNAL(createItem(QString,QString&)), this, SIGNAL(createPayee(QString,QString&))); KMyMoneyMVCCombo::setSubstringSearchForChildren(m_interestChargeCheckings, !KMyMoneySettings::stringMatchFromStart()); slotReloadEditWidgets(); // preset payee if possible try { // if we find a payee with the same name as the institution, // than this is what we use as payee. if (!d->m_account.institutionId().isEmpty()) { MyMoneyInstitution inst = MyMoneyFile::instance()->institution(d->m_account.institutionId()); MyMoneyPayee payee = MyMoneyFile::instance()->payeeByName(inst.name()); setField("payeeEdit", payee.id()); } } catch (const MyMoneyException &) { } KMyMoneyUtils::updateWizardButtons(this); // setup different text and icon on finish button setButtonText(QWizard::FinishButton, KStandardGuiItem::cont().text()); button(QWizard::FinishButton)->setIcon(KStandardGuiItem::cont().icon()); }
void KInstitutionsView::loadAccounts(void) { QMap<QString, bool> isOpen; ::timetrace("start load institutions view"); // remember the id of the current selected item KMyMoneyAccountTreeBaseItem *item = m_accountTree->selectedItem(); QString selectedItemId = (item) ? item->id() : QString(); // keep a map of all 'expanded' accounts QListViewItemIterator it_lvi(m_accountTree); while(it_lvi.current()) { item = dynamic_cast<KMyMoneyAccountTreeItem*>(it_lvi.current()); if(item && item->isOpen()) { isOpen[item->id()] = true; } ++it_lvi; } // remember the upper left corner of the viewport QPoint startPoint = m_accountTree->viewportToContents(QPoint(0, 0)); // turn off updates to avoid flickering during reload m_accountTree->setUpdatesEnabled(false); // clear the current contents and recreate it m_accountTree->clear(); m_accountMap.clear(); m_securityMap.clear(); m_transactionCountMap.clear(); MyMoneyFile* file = MyMoneyFile::instance(); QValueList<MyMoneyAccount> alist; file->accountList(alist); QValueList<MyMoneyAccount>::const_iterator it_a; for(it_a = alist.begin(); it_a != alist.end(); ++it_a) { m_accountMap[(*it_a).id()] = *it_a; } // we need to make sure we show stock accounts // under the right institution (the one of the parent account) QMap<QString, MyMoneyAccount>::iterator it_am; for(it_am = m_accountMap.begin(); it_am != m_accountMap.end(); ++it_am) { if((*it_am).isInvest()) { (*it_am).setInstitutionId(m_accountMap[(*it_am).parentAccountId()].institutionId()); } } QValueList<MyMoneySecurity> slist = file->currencyList(); slist += file->securityList(); QValueList<MyMoneySecurity>::const_iterator it_s; for(it_s = slist.begin(); it_s != slist.end(); ++it_s) { m_securityMap[(*it_s).id()] = *it_s; } m_transactionCountMap = file->transactionCountMap(); m_accountTree->setBaseCurrency(file->baseCurrency()); // create the items try { const MyMoneySecurity& security = file->baseCurrency(); m_accountTree->setBaseCurrency(security); MyMoneyInstitution none; none.setName(i18n("Accounts with no institution assigned")); KMyMoneyAccountTreeItem* noInstitutionItem = new KMyMoneyAccountTreeItem(m_accountTree, none); noInstitutionItem->setPixmap(0,none.pixmap()); loadSubAccounts(noInstitutionItem, QString()); // hide it, if unused noInstitutionItem->setVisible(noInstitutionItem->childCount() != 0); bool showClosedAccounts = kmymoney2->toggleAction("view_show_all_accounts")->isChecked() || !KMyMoneyGlobalSettings::hideClosedAccounts(); QValueList<MyMoneyInstitution> list = file->institutionList(); QValueList<MyMoneyInstitution>::const_iterator it_i; for(it_i = list.begin(); it_i != list.end(); ++it_i) { KMyMoneyAccountTreeItem* item = new KMyMoneyAccountTreeItem(m_accountTree, *it_i); item->setPixmap(0, none.pixmap()); loadSubAccounts(item, (*it_i).id()); if(!showClosedAccounts) item->setVisible(item->childCount() != 0); } } catch(MyMoneyException *e) { kdDebug(2) << "Problem in institutions view: " << e->what(); delete e; } // scan through the list of accounts and re-expand those that were // expanded and re-select the one that was probably selected before it_lvi = QListViewItemIterator(m_accountTree); while(it_lvi.current()) { item = dynamic_cast<KMyMoneyAccountTreeItem*>(it_lvi.current()); if(item) { if(item->id() == selectedItemId) m_accountTree->setSelected(item, true); if(isOpen.find(item->id()) != isOpen.end()) item->setOpen(true); } ++it_lvi; } // reposition viewport m_accountTree->setContentsPos(startPoint.x(), startPoint.y()); // turn updates back on m_accountTree->setUpdatesEnabled(true); m_accountTree->repaintContents(); ::timetrace("done load institutions view"); }