本文整理汇总了C++中MyMoneyFile::currency方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneyFile::currency方法的具体用法?C++ MyMoneyFile::currency怎么用?C++ MyMoneyFile::currency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneyFile
的用法示例。
在下文中一共展示了MyMoneyFile::currency方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例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: foreignCurrencyPrice
MyMoneyMoney ReportAccount::foreignCurrencyPrice(const QString foreignCurrency, const QDate& date, bool exactDate) const
{
DEBUG_ENTER(Q_FUNC_INFO);
MyMoneyMoney result(1, 1);
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneySecurity security = file->security(foreignCurrency);
//check whether it is a currency or a commodity. In the latter case case, get the trading currency
QString tradingCurrency;
if (security.isCurrency()) {
tradingCurrency = foreignCurrency;
} else {
tradingCurrency = security.tradingCurrency();
}
//It makes no sense to get the price if both currencies are the same
if (currency().id() != tradingCurrency) {
const MyMoneyPrice &price = file->price(currency().id(), tradingCurrency, date, exactDate);
if (price.isValid()) {
result = price.rate(tradingCurrency);
DEBUG_OUTPUT(QString("Converting deep %1 to currency %2, price on %3 is %4")
.arg(file->currency(currency().id()).name())
.arg(file->currency(foreignCurrency).name())
.arg(date.toString())
.arg(result.toDouble()));
} else {
DEBUG_OUTPUT(QString("No price to convert deep %1 to currency %2 on %3")
.arg(file->currency(currency().id()).name())
.arg(file->currency(foreignCurrency).name())
.arg(date.toString()));
}
}
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: KNewAccountDlgDecl
KNewAccountDlg::KNewAccountDlg(const MyMoneyAccount& account, bool isEditing, bool categoryEditor, QWidget *parent, const char *name, const QString& title)
: KNewAccountDlgDecl(parent,name,true),
m_account(account),
m_bSelectedParentAccount(false),
m_categoryEditor(categoryEditor),
m_isEditing(isEditing)
{
QString columnName = ( (categoryEditor) ? i18n("Categories") : i18n("Accounts") );
m_qlistviewParentAccounts->setRootIsDecorated(true);
m_qlistviewParentAccounts->setAllColumnsShowFocus(true);
m_qlistviewParentAccounts->setSectionHeader(columnName);
m_qlistviewParentAccounts->setMultiSelection(false);
m_qlistviewParentAccounts->header()->setResizeEnabled(true);
m_qlistviewParentAccounts->setColumnWidthMode(0, QListView::Maximum);
m_qlistviewParentAccounts->setEnabled(false);
// never show the horizontal scroll bar
m_qlistviewParentAccounts->setHScrollBarMode(QScrollView::AlwaysOff);
m_subAccountLabel->setText(i18n("Is a sub account"));
m_qlistviewParentAccounts->header()->setFont(KMyMoneyGlobalSettings::listHeaderFont());
accountNameEdit->setText(account.name());
descriptionEdit->setText(account.description());
typeCombo->setEnabled(true);
MyMoneyFile *file = MyMoneyFile::instance();
// load the price mode combo
m_priceMode->insertItem(i18n("default price mode", "<default>"), 0);
m_priceMode->insertItem(i18n("Price per share"), 1);
m_priceMode->insertItem(i18n("Total for all shares"), 2);
int priceMode = 0;
if(m_account.accountType() == MyMoneyAccount::Investment) {
m_priceMode->setEnabled(true);
if(!m_account.value("priceMode").isEmpty())
priceMode = m_account.value("priceMode").toInt();
}
m_priceMode->setCurrentItem(priceMode);
bool haveMinBalance = false;
bool haveMaxCredit = false;
if (categoryEditor)
{
// get rid of the tabs that are not used for categories
QWidget* tab = m_tab->page(m_tab->indexOf(m_institutionTab));
if(tab)
m_tab->removePage(tab);
tab = m_tab->page(m_tab->indexOf(m_limitsTab));
if(tab)
m_tab->removePage(tab);
//m_qlistviewParentAccounts->setEnabled(true);
startDateEdit->setEnabled(false);
accountNoEdit->setEnabled(false);
m_institutionBox->hide();
m_qcheckboxNoVat->hide();
typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Income));
typeCombo->insertItem(KMyMoneyUtils::accountTypeToString(MyMoneyAccount::Expense));
// Hardcoded but acceptable
switch (account.accountType())
{
case MyMoneyAccount::Income:
typeCombo->setCurrentItem(0);
break;
case MyMoneyAccount::Expense:
default:
typeCombo->setCurrentItem(1);
break;
}
m_currency->setEnabled(true);
if (m_isEditing)
{
typeCombo->setEnabled(false);
m_currency->setDisabled(MyMoneyFile::instance()->isReferenced(m_account));
}
m_qcheckboxPreferred->hide();
m_qcheckboxTax->setChecked(account.value("Tax") == "Yes");
loadVatAccounts();
}
else
{
// get rid of the tabs that are not used for accounts
QWidget* taxtab = m_tab->page(m_tab->indexOf(m_taxTab));
if (taxtab) {
if(m_account.isAssetLiability()) {
m_vatCategory->setText(i18n( "VAT account"));
m_vatAssignmentFrame->hide();
m_qcheckboxTax->setChecked(account.value("Tax") == "Yes");
} else {
m_tab->removePage(taxtab);
}
}
//.........这里部分代码省略.........