本文整理汇总了C++中MyMoneyFile::foreignCurrency方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneyFile::foreignCurrency方法的具体用法?C++ MyMoneyFile::foreignCurrency怎么用?C++ MyMoneyFile::foreignCurrency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneyFile
的用法示例。
在下文中一共展示了MyMoneyFile::foreignCurrency方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
}