本文整理汇总了C++中MyMoneyFile::baseCurrency方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneyFile::baseCurrency方法的具体用法?C++ MyMoneyFile::baseCurrency怎么用?C++ MyMoneyFile::baseCurrency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneyFile
的用法示例。
在下文中一共展示了MyMoneyFile::baseCurrency方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadSubAccounts
void KInstitutionsView::loadSubAccounts(KMyMoneyAccountTreeItem* parent)
{
bool showClosedAccounts = kmymoney2->toggleAction("view_show_all_accounts")->isChecked()
|| !KMyMoneyGlobalSettings::hideClosedAccounts();
const MyMoneyAccount& account = dynamic_cast<const MyMoneyAccount&>(parent->itemObject());
QValueList<QString>::const_iterator it_a;
MyMoneyFile* file = MyMoneyFile::instance();
for(it_a = account.accountList().begin(); it_a != account.accountList().end(); ++it_a) {
MyMoneyAccount acc = m_accountMap[(*it_a)];
if(!acc.isInvest())
continue;
if(acc.isClosed() && !showClosedAccounts)
continue;
const MyMoneySecurity& security = m_securityMap[acc.currencyId()];
QValueList<MyMoneyPrice> prices;
prices += file->price(acc.currencyId(), security.tradingCurrency());
if(security.tradingCurrency() != file->baseCurrency().id()) {
MyMoneySecurity sec = m_securityMap[security.tradingCurrency()];
prices += file->price(sec.id(), file->baseCurrency().id());
}
KMyMoneyAccountTreeItem* item = new KMyMoneyAccountTreeItem(parent, acc, prices, security);
if(acc.id() == m_reconciliationAccount.id())
item->setReconciliation(true);
}
}
示例2: addPricePair
void KEquityPriceUpdateDlg::addPricePair(const MyMoneySecurityPair& pair, bool dontCheckExistance)
{
MyMoneyFile* file = MyMoneyFile::instance();
QString symbol = QString("%1 > %2").arg(pair.first, pair.second);
QString id = QString("%1 %2").arg(pair.first, pair.second);
// Check that the pair does not already exist
if (lvEquityList->findItems(id, Qt::MatchExactly, ID_COL).empty()) {
const MyMoneyPrice &pr = file->price(pair.first, pair.second);
if (pr.source() != "KMyMoney") {
bool keep = true;
if ((pair.first == file->baseCurrency().id())
|| (pair.second == file->baseCurrency().id())) {
const QString& foreignCurrency = file->foreignCurrency(pair.first, pair.second);
// check that the foreign currency is still in use
QList<MyMoneyAccount>::const_iterator it_a;
QList<MyMoneyAccount> list;
file->accountList(list);
for (it_a = list.constBegin(); !dontCheckExistance && it_a != list.constEnd(); ++it_a) {
// if it's an account denominated in the foreign currency
// keep it
if (((*it_a).currencyId() == foreignCurrency)
&& !(*it_a).isClosed())
break;
// if it's an investment traded in the foreign currency
// keep it
if ((*it_a).isInvest() && !(*it_a).isClosed()) {
MyMoneySecurity sec = file->security((*it_a).currencyId());
if (sec.tradingCurrency() == foreignCurrency)
break;
}
}
// if it is in use, it_a is not equal to list.end()
if (it_a == list.constEnd() && !dontCheckExistance)
keep = false;
}
if (keep) {
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(SYMBOL_COL, symbol);
item->setText(NAME_COL, i18n("%1 units in %2", pair.first, pair.second));
if (pr.isValid()) {
item->setText(PRICE_COL, pr.rate(pair.second).formatMoney(file->currency(pair.second).tradingSymbol(), KMyMoneyGlobalSettings::pricePrecision()));
item->setText(DATE_COL, pr.date().toString(Qt::ISODate));
}
item->setText(ID_COL, id);
item->setText(SOURCE_COL, "Yahoo Currency"); // This string value should not be localized
lvEquityList->invisibleRootItem()->addChild(item);
}
}
}
}
示例3: baseCurrencyPrice
MyMoneyMoney ReportAccount::baseCurrencyPrice(const QDate& date, bool exactDate) const
{
// Note that whether or not the user chooses to convert to base currency, all the values
// for a given account/category are converted to the currency for THAT account/category
// The "Convert to base currency" tells the report to convert from the account/category
// currency to the file's base currency.
//
// An example where this matters is if Category 'C' and account 'U' are in USD, but
// Account 'J' is in JPY. Say there are two transactions, one is US$100 from U to C,
// the other is JPY10,000 from J to C. Given a JPY price of USD$0.01, this means
// C will show a balance of $200 NO MATTER WHAT the user chooses for 'convert to base
// currency. This confused me for a while, which is why I wrote this comment.
// --acejones
DEBUG_ENTER(Q_FUNC_INFO);
MyMoneyMoney result(1, 1);
MyMoneyFile* file = MyMoneyFile::instance();
if (isForeignCurrency()) {
result = foreignCurrencyPrice(file->baseCurrency().id(), date, exactDate);
}
return result;
}
示例4: addInvestment
void KEquityPriceUpdateDlg::addInvestment(const MyMoneySecurity& inv)
{
MyMoneyFile* file = MyMoneyFile::instance();
QString symbol = inv.tradingSymbol();
QString id = inv.id();
// Check that the pair does not already exist
if (lvEquityList->findItems(id, Qt::MatchExactly, ID_COL).empty()) {
// check that the security is still in use
QList<MyMoneyAccount>::const_iterator it_a;
QList<MyMoneyAccount> list;
file->accountList(list);
for (it_a = list.constBegin(); it_a != list.constEnd(); ++it_a) {
if ((*it_a).isInvest()
&& ((*it_a).currencyId() == inv.id())
&& !(*it_a).isClosed())
break;
}
// if it is in use, it_a is not equal to list.end()
if (it_a != list.constEnd()) {
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(SYMBOL_COL, symbol);
item->setText(NAME_COL, inv.name());
MyMoneySecurity currency = file->currency(inv.tradingCurrency());
const MyMoneyPrice &pr = file->price(id.toUtf8(), inv.tradingCurrency());
if (pr.isValid()) {
item->setText(PRICE_COL, pr.rate(currency.id()).formatMoney(currency.tradingSymbol(), KMyMoneyGlobalSettings::pricePrecision()));
item->setText(DATE_COL, pr.date().toString(Qt::ISODate));
}
item->setText(ID_COL, id);
if (inv.value("kmm-online-quote-system") == "Finance::Quote")
item->setText(SOURCE_COL, QString("Finance::Quote %1").arg(inv.value("kmm-online-source")));
else
item->setText(SOURCE_COL, inv.value("kmm-online-source"));
lvEquityList->invisibleRootItem()->addChild(item);
// If this investment is denominated in a foreign currency, ensure that
// the appropriate price pair is also on the list
if (currency.id() != file->baseCurrency().id()) {
addPricePair(MyMoneySecurityPair(currency.id(), file->baseCurrency().id()));
}
}
}
}
示例5: makePrice
void makePrice(const QString& _currencyid, const QDate& _date, const MyMoneyMoney& _price )
{
MyMoneyFileTransaction ft;
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneySecurity curr = file->currency(_currencyid);
MyMoneyPrice price(_currencyid, file->baseCurrency().id(), _date, _price, "test");
file->addPrice(price);
ft.commit();
}
示例6: makeEquityPrice
void makeEquityPrice(const QString& _id, const QDate& _date, const MyMoneyMoney& _price )
{
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneyFileTransaction ft;
QString basecurrencyid = file->baseCurrency().id();
MyMoneyPrice price = file->price( _id, basecurrencyid, _date, true );
if ( !price.isValid() )
{
MyMoneyPrice newprice( _id, basecurrencyid, _date, _price, "test" );
file->addPrice(newprice);
}
ft.commit();
}
示例7: nameToId
QString CsvUtil::nameToId(const QString& name, MyMoneyAccount& parent)
{
// Adapted from KMyMoneyApp::createAccount(MyMoneyAccount& newAccount, MyMoneyAccount& parentAccount, MyMoneyAccount& brokerageAccount, MyMoneyMoney openingBal)
// Needed to find/create category:sub-categories
MyMoneyFile* file = MyMoneyFile::instance();
QString id = file->categoryToAccount(name, MyMoneyAccount::UnknownAccountType);
// if it does not exist, we have to create it
if (id.isEmpty()) {
MyMoneyAccount newAccount;
MyMoneyAccount parentAccount = parent;
newAccount.setName(name) ;
int pos;
// check for ':' in the name and use it as separator for a hierarchy
while ((pos = newAccount.name().indexOf(MyMoneyFile::AccountSeperator)) != -1) {
QString part = newAccount.name().left(pos);
QString remainder = newAccount.name().mid(pos + 1);
const MyMoneyAccount& existingAccount = file->subAccountByName(parentAccount, part);
if (existingAccount.id().isEmpty()) {
newAccount.setName(part);
newAccount.setAccountType(parentAccount.accountType());
file->addAccount(newAccount, parentAccount);
parentAccount = newAccount;
} else {
parentAccount = existingAccount;
}
newAccount.setParentAccountId(QString()); // make sure, there's no parent
newAccount.clearId(); // and no id set for adding
newAccount.removeAccountIds(); // and no sub-account ids
newAccount.setName(remainder);
}//end while
newAccount.setAccountType(parentAccount.accountType());
// make sure we have a currency. If none is assigned, we assume base currency
if (newAccount.currencyId().isEmpty())
newAccount.setCurrencyId(file->baseCurrency().id());
file->addAccount(newAccount, parentAccount);
id = newAccount.id();
}
return id;
}
示例8: if
QList<MyMoneyPrice> KForecastView::getAccountPrices(const MyMoneyAccount& acc)
{
MyMoneyFile* file = MyMoneyFile::instance();
QList<MyMoneyPrice> prices;
MyMoneySecurity security = file->baseCurrency();
try {
if (acc.isInvest()) {
security = file->security(acc.currencyId());
if (security.tradingCurrency() != file->baseCurrency().id()) {
MyMoneySecurity sec = file->security(security.tradingCurrency());
prices += file->price(sec.id(), file->baseCurrency().id());
}
} else if (acc.currencyId() != file->baseCurrency().id()) {
if (acc.currencyId() != file->baseCurrency().id()) {
security = file->security(acc.currencyId());
prices += file->price(acc.currencyId(), file->baseCurrency().id());
}
}
} catch (const MyMoneyException &e) {
qDebug() << Q_FUNC_INFO << " caught exception while adding " << acc.name() << "[" << acc.id() << "]: " << e.what();
}
return prices;
}
示例9: init
void InvTransactionHelper::init( const QDate& _date, const QString& _action, MyMoneyMoney _shares, MyMoneyMoney _price, const QString& _stockaccountid, const QString& _transferid, const QString& _categoryid )
{
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneyAccount stockaccount = file->account(_stockaccountid);
MyMoneyMoney value = _shares * _price;
setPostDate(_date);
setCommodity("USD");
MyMoneySplit s1;
s1.setValue(value);
s1.setAccountId(_stockaccountid);
if ( _action == MyMoneySplit::ActionReinvestDividend )
{
s1.setShares(_shares);
s1.setAction(MyMoneySplit::ActionReinvestDividend);
MyMoneySplit s2;
s2.setAccountId(_categoryid);
s2.setShares(-value);
s2.setValue(-value);
addSplit(s2);
}
else if ( _action == MyMoneySplit::ActionDividend || _action == MyMoneySplit::ActionYield )
{
s1.setAccountId(_categoryid);
s1.setShares(-value);
s1.setValue(-value);
// Split 2 will be the zero-amount investment split that serves to
// mark this transaction as a cash dividend and note which stock account
// it belongs to.
MyMoneySplit s2;
s2.setValue(0);
s2.setShares(0);
s2.setAction(_action);
s2.setAccountId(_stockaccountid);
addSplit(s2);
MyMoneySplit s3;
s3.setAccountId(_transferid);
s3.setShares(value);
s3.setValue(value);
addSplit(s3);
}
else if ( _action == MyMoneySplit::ActionBuyShares )
{
s1.setShares(_shares);
s1.setAction(MyMoneySplit::ActionBuyShares);
MyMoneySplit s3;
s3.setAccountId(_transferid);
s3.setShares(-value);
s3.setValue(-value);
addSplit(s3);
}
addSplit(s1);
//kdDebug(2) << "created transaction, now adding..." << endl;
MyMoneyFileTransaction ft;
file->addTransaction(*this);
//kdDebug(2) << "updating price..." << endl;
// update the price, while we're here
QString stockid = stockaccount.currencyId();
QString basecurrencyid = file->baseCurrency().id();
MyMoneyPrice price = file->price( stockid, basecurrencyid, _date, true );
if ( !price.isValid() )
{
MyMoneyPrice newprice( stockid, basecurrencyid, _date, _price, "test" );
file->addPrice(newprice);
}
ft.commit();
//kdDebug(2) << "successfully added " << id() << endl;
}
示例10: loadAdvancedView
void KForecastView::loadAdvancedView()
{
MyMoneyFile* file = MyMoneyFile::instance();
QList<MyMoneyAccount> accList;
MyMoneySecurity baseCurrency = file->baseCurrency();
MyMoneyForecast forecast = KMyMoneyGlobalSettings::forecast();
int daysToBeginDay;
//get the settings from current page
forecast.setForecastDays(m_forecastDays->value());
forecast.setAccountsCycle(m_accountsCycle->value());
forecast.setBeginForecastDay(m_beginDay->value());
forecast.setForecastCycles(m_forecastCycles->value());
forecast.setHistoryMethod(m_historyMethod->checkedId());
forecast.doForecast();
//Get all accounts of the right type to calculate forecast
m_nameIdx.clear();
accList = forecast.accountList();
QList<MyMoneyAccount>::const_iterator accList_t = accList.constBegin();
for (; accList_t != accList.constEnd(); ++accList_t) {
MyMoneyAccount acc = *accList_t;
if (m_nameIdx[acc.id()] != acc.id()) { //Check if the account is there
m_nameIdx[acc.id()] = acc.id();
}
}
//clear the list, including columns
m_advancedList->clear();
m_advancedList->setColumnCount(0);
m_advancedList->setIconSize(QSize(22, 22));
QStringList headerLabels;
//add first column of both lists
headerLabels << i18n("Account");
//if beginning of forecast is today, set the begin day to next cycle to avoid repeating the first cycle
if (QDate::currentDate() < forecast.beginForecastDate()) {
daysToBeginDay = QDate::currentDate().daysTo(forecast.beginForecastDate());
} else {
daysToBeginDay = forecast.accountsCycle();
}
//add columns
for (int i = 1; ((i * forecast.accountsCycle()) + daysToBeginDay) <= forecast.forecastDays(); ++i) {
headerLabels << i18n("Min Bal %1", i);
headerLabels << i18n("Min Date %1", i);
}
for (int i = 1; ((i * forecast.accountsCycle()) + daysToBeginDay) <= forecast.forecastDays(); ++i) {
headerLabels << i18n("Max Bal %1", i);
headerLabels << i18n("Max Date %1", i);
}
headerLabels << i18nc("Average balance", "Average");
m_advancedList->setHeaderLabels(headerLabels);
QTreeWidgetItem *advancedItem = 0;
QMap<QString, QString>::ConstIterator it_nc;
for (it_nc = m_nameIdx.constBegin(); it_nc != m_nameIdx.constEnd(); ++it_nc) {
const MyMoneyAccount& acc = file->account(*it_nc);
QString amount;
MyMoneyMoney amountMM;
MyMoneySecurity currency;
//change currency to deep currency if account is an investment
if (acc.isInvest()) {
MyMoneySecurity underSecurity = file->security(acc.currencyId());
currency = file->security(underSecurity.tradingCurrency());
} else {
currency = file->security(acc.currencyId());
}
advancedItem = new QTreeWidgetItem(m_advancedList, advancedItem, false);
advancedItem->setText(0, acc.name());
advancedItem->setIcon(0, acc.accountPixmap());
int it_c = 1; // iterator for the columns of the listview
//get minimum balance list
QList<QDate> minBalanceList = forecast.accountMinimumBalanceDateList(acc);
QList<QDate>::Iterator t_min;
for (t_min = minBalanceList.begin(); t_min != minBalanceList.end() ; ++t_min) {
QDate minDate = *t_min;
amountMM = forecast.forecastBalance(acc, minDate);
amount = MyMoneyUtils::formatMoney(amountMM, acc, currency);
advancedItem->setText(it_c, amount);
advancedItem->setTextAlignment(it_c, Qt::AlignRight | Qt::AlignVCenter);
if (amountMM.isNegative()) {
advancedItem->setForeground(it_c, KMyMoneyGlobalSettings::listNegativeValueColor());
}
it_c++;
QString dateString = QLocale().toString(minDate, QLocale::ShortFormat);
advancedItem->setText(it_c, dateString);
advancedItem->setTextAlignment(it_c, Qt::AlignRight | Qt::AlignVCenter);
if (amountMM.isNegative()) {
advancedItem->setForeground(it_c, KMyMoneyGlobalSettings::listNegativeValueColor());
}
//.........这里部分代码省略.........
示例11: createAccount
void CsvUtil::createAccount(MyMoneyAccount& newAccount, MyMoneyAccount& parentAccount, MyMoneyAccount& brokerageAccount, MyMoneyMoney openingBal)
{
MyMoneyFile* file = MyMoneyFile::instance();
// make sure we have a currency. If none is assigned, we assume base currency
if (newAccount.currencyId().isEmpty())
newAccount.setCurrencyId(file->baseCurrency().id());
MyMoneyFileTransaction ft;
try {
int pos;
// check for ':' in the name and use it as separator for a hierarchy
while ((pos = newAccount.name().indexOf(MyMoneyFile::AccountSeperator)) != -1) {
QString part = newAccount.name().left(pos);
QString remainder = newAccount.name().mid(pos + 1);
const MyMoneyAccount& existingAccount = file->subAccountByName(parentAccount, part);
if (existingAccount.id().isEmpty()) {
newAccount.setName(part);
file->addAccount(newAccount, parentAccount);
parentAccount = newAccount;
} else {
parentAccount = existingAccount;
}
newAccount.setParentAccountId(QString()); // make sure, there's no parent
newAccount.clearId(); // and no id set for adding
newAccount.removeAccountIds(); // and no sub-account ids
newAccount.setName(remainder);
}
const MyMoneySecurity& sec = file->security(newAccount.currencyId());
// Check the opening balance
if (openingBal.isPositive() && newAccount.accountGroup() == MyMoneyAccount::Liability) {
QString message = i18n("This account is a liability and if the "
"opening balance represents money owed, then it should be negative. "
"Negate the amount?\n\n"
"Please click Yes to change the opening balance to %1,\n"
"Please click No to leave the amount as %2,\n"
"Please click Cancel to abort the account creation."
, MyMoneyUtils::formatMoney(-openingBal, newAccount, sec)
, MyMoneyUtils::formatMoney(openingBal, newAccount, sec));
int ans = KMessageBox::questionYesNoCancel(0, message);
if (ans == KMessageBox::Yes) {
openingBal = -openingBal;
} else if (ans == KMessageBox::Cancel)
return;
}
file->addAccount(newAccount, parentAccount);
if (newAccount.accountType() == MyMoneyAccount::Investment
&& !brokerageAccount.name().isEmpty()) {
file->addAccount(brokerageAccount, parentAccount);
// set a link from the investment account to the brokerage account
file->modifyAccount(newAccount);
file->createOpeningBalanceTransaction(brokerageAccount, openingBal);
} else
file->createOpeningBalanceTransaction(newAccount, openingBal);
ft.commit();
} catch (const MyMoneyException &e) {
KMessageBox::information(0, i18n("Unable to add account: %1", e.what()));
}
}
示例12: showTransactions
void KTagsView::showTransactions()
{
MyMoneyMoney balance;
MyMoneyFile *file = MyMoneyFile::instance();
MyMoneySecurity base = file->baseCurrency();
// setup sort order
m_register->setSortOrder(KMyMoneyGlobalSettings::sortSearchView());
// clear the register
m_register->clear();
if (m_tag.id().isEmpty() || !m_tabWidget->isEnabled()) {
m_balanceLabel->setText(i18n("Balance: %1", balance.formatMoney(file->baseCurrency().smallestAccountFraction())));
return;
}
// setup the list and the pointer vector
MyMoneyTransactionFilter filter;
filter.addTag(m_tag.id());
filter.setDateFilter(KMyMoneyGlobalSettings::startDate().date(), QDate());
// retrieve the list from the engine
file->transactionList(m_transactionList, filter);
// create the elements for the register
QList<QPair<MyMoneyTransaction, MyMoneySplit> >::const_iterator it;
QMap<QString, int> uniqueMap;
MyMoneyMoney deposit, payment;
int splitCount = 0;
bool balanceAccurate = true;
for (it = m_transactionList.constBegin(); it != m_transactionList.constEnd(); ++it) {
const MyMoneySplit& split = (*it).second;
MyMoneyAccount acc = file->account(split.accountId());
++splitCount;
uniqueMap[(*it).first.id()]++;
KMyMoneyRegister::Register::transactionFactory(m_register, (*it).first, (*it).second, uniqueMap[(*it).first.id()]);
// take care of foreign currencies
MyMoneyMoney val = split.shares().abs();
if (acc.currencyId() != base.id()) {
const MyMoneyPrice &price = file->price(acc.currencyId(), base.id());
// in case the price is valid, we use it. Otherwise, we keep
// a flag that tells us that the balance is somewhat inaccurate
if (price.isValid()) {
val *= price.rate(base.id());
} else {
balanceAccurate = false;
}
}
if (split.shares().isNegative()) {
payment += val;
} else {
deposit += val;
}
}
balance = deposit - payment;
// add the group markers
m_register->addGroupMarkers();
// sort the transactions according to the sort setting
m_register->sortItems();
// remove trailing and adjacent markers
m_register->removeUnwantedGroupMarkers();
m_register->updateRegister(true);
// we might end up here with updates disabled on the register so
// make sure that we enable updates here
m_register->setUpdatesEnabled(true);
m_balanceLabel->setText(i18n("Balance: %1%2",
balanceAccurate ? "" : "~",
balance.formatMoney(file->baseCurrency().smallestAccountFraction())));
}
示例13: loadAccounts
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);
//.........这里部分代码省略.........