本文整理汇总了C++中MyMoneySecurity类的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneySecurity类的具体用法?C++ MyMoneySecurity怎么用?C++ MyMoneySecurity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MyMoneySecurity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateBudget
void KMyMoneyAccountTreeForecastItem::updateBudget()
{
MyMoneySecurity currency;
MyMoneyMoney tAmountMM;
MyMoneyFile* file = MyMoneyFile::instance();
int it_c = 1; // iterator for the columns of the listview
QDate forecastDate = m_forecast.forecastStartDate();
if(m_account.isInvest()) {
MyMoneySecurity underSecurity = file->security(m_account.currencyId());
currency = file->security(underSecurity.tradingCurrency());
} else {
currency = file->security(m_account.currencyId());
}
//iterate columns
for(; forecastDate <= m_forecast.forecastEndDate(); forecastDate = forecastDate.addMonths(1), ++it_c) {
MyMoneyMoney amountMM;
amountMM = m_forecast.forecastBalance(m_account,forecastDate);
if(m_account.accountType() == MyMoneyAccount::Expense)
amountMM = -amountMM;
tAmountMM += amountMM;
setAmount(it_c, amountMM);
setValue(it_c, amountMM, forecastDate);
showAmount(it_c, amountMM, currency);
}
//set total column
setAmount(it_c, tAmountMM);
setValue(it_c, tAmountMM, m_forecast.forecastEndDate());
showAmount(it_c, tAmountMM, currency);
}
示例2: updateDetailed
void KMyMoneyAccountTreeForecastItem::updateDetailed()
{
QString amount;
QString vAmount;
MyMoneyMoney vAmountMM;
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneySecurity currency;
if(m_account.isInvest()) {
MyMoneySecurity underSecurity = file->security(m_account.currencyId());
currency = file->security(underSecurity.tradingCurrency());
} else {
currency = file->security(m_account.currencyId());
}
int it_c = 1; // iterator for the columns of the listview
for(QDate forecastDate = QDate::currentDate(); forecastDate <= m_forecast.forecastEndDate(); ++it_c, forecastDate = forecastDate.addDays(1)) {
MyMoneyMoney amountMM = m_forecast.forecastBalance(m_account, forecastDate);
//calculate the balance in base currency for the total row
setAmount(it_c, amountMM);
setValue(it_c, amountMM, forecastDate);
showAmount(it_c, amountMM, currency);
}
//calculate and add variation per cycle
vAmountMM = m_forecast.accountTotalVariation(m_account);
setAmount(it_c, vAmountMM);
setValue(it_c, vAmountMM, m_forecast.forecastEndDate());
showAmount(it_c, vAmountMM, currency);
}
示例3: i18n
void KEquityPriceUpdateDlg::slotQuoteFailed(const QString& _id, const QString& _symbol)
{
QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(_id, Qt::MatchExactly, ID_COL);
QTreeWidgetItem* item = 0;
if (! foundItems.empty())
item = foundItems.at(0);
// Give the user some options
int result;
if (_id.contains(" ")) {
result = KMessageBox::warningContinueCancel(this, i18n("Failed to retrieve an exchange rate for %1 from %2. It will be skipped this time.", _symbol, item->text(SOURCE_COL)), i18n("Price Update Failed"));
} else {
result = KMessageBox::questionYesNoCancel(this, QString("<qt>%1</qt>").arg(i18n("Failed to retrieve a quote for %1 from %2. Press <b>No</b> to remove the online price source from this security permanently, <b>Yes</b> to continue updating this security during future price updates or <b>Cancel</b> to stop the current update operation.", _symbol, item->text(SOURCE_COL))), i18n("Price Update Failed"), KStandardGuiItem::yes(), KStandardGuiItem::no());
}
if (result == KMessageBox::No) {
// Disable price updates for this security
MyMoneyFileTransaction ft;
try {
// Get this security (by ID)
MyMoneySecurity security = MyMoneyFile::instance()->security(_id.toUtf8());
// Set the quote source to blank
security.setValue("kmm-online-source", QString());
security.setValue("kmm-online-quote-system", QString());
// Re-commit the security
MyMoneyFile::instance()->modifySecurity(security);
ft.commit();
} catch (const MyMoneyException &e) {
KMessageBox::error(this, QString("<qt>") + i18n("Cannot update security <b>%1</b>: %2", _symbol, e.what()) + QString("</qt>"), i18n("Price Update Failed"));
}
}
// As long as the user doesn't want to cancel, move on!
if (result != KMessageBox::Cancel) {
QTreeWidgetItem* next = 0;
prgOnlineProgress->setValue(prgOnlineProgress->value() + 1);
item->setSelected(false);
// launch the NEXT one ... in case of m_fUpdateAll == false, we
// need to parse the list to find the next selected one
next = lvEquityList->invisibleRootItem()->child(lvEquityList->invisibleRootItem()->indexOfChild(item) + 1);
if (!m_fUpdateAll) {
while (next && !next->isSelected()) {
prgOnlineProgress->setValue(prgOnlineProgress->value() + 1);
next = lvEquityList->invisibleRootItem()->child(lvEquityList->invisibleRootItem()->indexOfChild(next) + 1);
}
}
if (next) {
m_webQuote.launch(next->text(SYMBOL_COL), next->text(ID_COL), next->text(SOURCE_COL));
} else {
finishUpdate();
}
} else {
finishUpdate();
}
}
示例4: 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);
}
}
示例5: rate
MyMoneyPrice KEquityPriceUpdateDlg::price(const QString& id) const
{
MyMoneyPrice price;
QTreeWidgetItem* item = 0;
QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(id, Qt::MatchExactly, ID_COL);
if (! foundItems.empty())
item = foundItems.at(0);
if (item) {
MyMoneyMoney rate(item->text(PRICE_COL));
if (!rate.isZero()) {
QString id = item->text(ID_COL).toUtf8();
// if the ID has a space, then this is TWO ID's, so it's a currency quote
if (id.contains(" ")) {
QStringList ids = id.split(' ', QString::SkipEmptyParts);
QString fromid = ids[0].toUtf8();
QString toid = ids[1].toUtf8();
price = MyMoneyPrice(fromid, toid, QDate().fromString(item->text(DATE_COL), Qt::ISODate), rate, item->text(SOURCE_COL));
} else
// otherwise, it's a security quote
{
MyMoneySecurity security = MyMoneyFile::instance()->security(id);
price = MyMoneyPrice(id, security.tradingCurrency(), QDate().fromString(item->text(DATE_COL), Qt::ISODate), rate, item->text(SOURCE_COL));
}
}
}
return price;
}
示例6: testSetFunctions
void MyMoneySecurityTest::testInequality () {
testSetFunctions();
m->setValue("Key", "Value");
MyMoneySecurity n;
n = *m;
CPPUNIT_ASSERT(!(n != *m));
n.setName("NewName");
CPPUNIT_ASSERT(n != *m);
n = *m;
n.setTradingSymbol("NewSymbol");
CPPUNIT_ASSERT(n != *m);
n = *m;
n.setTradingMarket("NewMarket");
CPPUNIT_ASSERT(n != *m);
n = *m;
n.setTradingCurrency("NewCurrency");
CPPUNIT_ASSERT(n != *m);
n = *m;
n.setSecurityType(MyMoneySecurity::SECURITY_CURRENCY);
CPPUNIT_ASSERT(n != *m);
n = *m;
n.setSmallestAccountFraction(40);
CPPUNIT_ASSERT(n != *m);
n = *m;
n.setSmallestCashFraction(20);
CPPUNIT_ASSERT(n != *m);
n = *m;
n.setPartsPerUnit(3);
CPPUNIT_ASSERT(n != *m);
n = *m;
n.setValue("Key", "NewValue");
CPPUNIT_ASSERT(n != *m);
}
示例7: loadAccounts
void KForecastView::loadAccounts(MyMoneyForecast& forecast, const MyMoneyAccount& account, QTreeWidgetItem* parentItem, int forecastType)
{
QMap<QString, QString> nameIdx;
QStringList accList;
MyMoneyFile* file = MyMoneyFile::instance();
QTreeWidgetItem *forecastItem = 0;
//Get all accounts of the right type to calculate forecast
accList = account.accountList();
if (accList.size() == 0)
return;
QStringList::ConstIterator accList_t;
for (accList_t = accList.constBegin(); accList_t != accList.constEnd(); ++accList_t) {
MyMoneyAccount subAccount = file->account(*accList_t);
//only add the account if it is a forecast account or the parent of a forecast account
if (includeAccount(forecast, subAccount)) {
nameIdx[subAccount.id()] = subAccount.id();
}
}
QMap<QString, QString>::ConstIterator it_nc;
for (it_nc = nameIdx.constBegin(); it_nc != nameIdx.constEnd(); ++it_nc) {
const MyMoneyAccount subAccount = file->account(*it_nc);
MyMoneySecurity currency;
if (subAccount.isInvest()) {
MyMoneySecurity underSecurity = file->security(subAccount.currencyId());
currency = file->security(underSecurity.tradingCurrency());
} else {
currency = file->security(subAccount.currencyId());
}
forecastItem = new QTreeWidgetItem(parentItem);
forecastItem->setText(0, subAccount.name());
forecastItem->setIcon(0, subAccount.accountPixmap());
forecastItem->setData(0, ForecastRole, QVariant::fromValue(forecast));
forecastItem->setData(0, AccountRole, QVariant::fromValue(subAccount));
forecastItem->setExpanded(true);
switch (forecastType) {
case eSummary:
updateSummary(forecastItem);
break;
case eDetailed:
updateDetailed(forecastItem);
break;
case eBudget:
updateBudget(forecastItem);
break;
default:
break;
}
loadAccounts(forecast, subAccount, forecastItem, forecastType);
}
}
示例8:
/**
* Set the values based on the @param security
*/
void KInvestmentDetailsWizardPage::init2(const MyMoneySecurity& security)
{
MyMoneySecurity tradingCurrency = MyMoneyFile::instance()->currency(security.tradingCurrency());
m_investmentSymbol->setText(security.tradingSymbol());
m_tradingMarket->setCurrentIndex(m_tradingMarket->findText(security.tradingMarket(), Qt::MatchExactly));
m_fraction->setValue(MyMoneyMoney(security.smallestAccountFraction(), 1));
m_tradingCurrencyEdit->setSecurity(tradingCurrency);
m_investmentIdentification->setText(security.value("kmm-security-id"));
}
示例9: DEBUG_ENTER
MyMoneyMoney ReportAccount::deepCurrencyPrice(const QDate& date, bool exactDate) const
{
DEBUG_ENTER(Q_FUNC_INFO);
MyMoneyMoney result(1, 1);
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneySecurity undersecurity = file->security(currencyId());
if (! undersecurity.isCurrency()) {
const MyMoneyPrice &price = file->price(undersecurity.id(), undersecurity.tradingCurrency(), date, exactDate);
if (price.isValid()) {
result = price.rate(undersecurity.tradingCurrency());
DEBUG_OUTPUT(QString("Converting under %1 to deep %2, price on %3 is %4")
.arg(undersecurity.name())
.arg(file->security(undersecurity.tradingCurrency()).name())
.arg(date.toString())
.arg(result.toDouble()));
} else {
DEBUG_OUTPUT(QString("No price to convert under %1 to deep %2 on %3")
.arg(undersecurity.name())
.arg(file->security(undersecurity.tradingCurrency()).name())
.arg(date.toString()));
result = MyMoneyMoney();
}
}
return result;
}
示例10: KListViewItem
KInvestmentListItem::KInvestmentListItem(KListView* parent, const MyMoneyAccount& account)
: KListViewItem(parent)
{
bColumn5Negative = false;
bColumn6Negative = false;
bColumn7Negative = false;
bColumn8Negative = false;
bColumn9Negative = false;
m_account = account;
m_listView = parent;
MyMoneySecurity security;
MyMoneyFile* file = MyMoneyFile::instance();
security = file->security(m_account.currencyId());
m_tradingCurrency = file->security(security.tradingCurrency());
int prec = MyMoneyMoney::denomToPrec(m_tradingCurrency.smallestAccountFraction());
QValueList<MyMoneyTransaction> transactionList;
// FIXME PRICE
// equity_price_history history = equity.priceHistory();
//column 0 (COLUMN_NAME_INDEX) is the name of the stock
setText(COLUMN_NAME_INDEX, m_account.name());
//column 1 (COLUMN_SYMBOL_INDEX) is the ticker symbol
setText(COLUMN_SYMBOL_INDEX, security.tradingSymbol());
//column 2 is the net value (price * quantity owned)
MyMoneyPrice price = file->price(m_account.currencyId(), m_tradingCurrency.id());
if(price.isValid()) {
setText(COLUMN_VALUE_INDEX, (file->balance(m_account.id()) * price.rate(m_tradingCurrency.id())).formatMoney(m_tradingCurrency.tradingSymbol(), prec));
} else {
setText(COLUMN_VALUE_INDEX, "---");
}
//column 3 (COLUMN_QUANTITY_INDEX) is the quantity of shares owned
prec = MyMoneyMoney::denomToPrec(security.smallestAccountFraction());
setText(COLUMN_QUANTITY_INDEX, file->balance(m_account.id()).formatMoney("", prec));
//column 4 is the current price
// Get the price precision from the configuration
prec = KMyMoneyGlobalSettings::pricePrecision();
// prec = MyMoneyMoney::denomToPrec(m_tradingCurrency.smallestAccountFraction());
if(price.isValid()) {
setText(COLUMN_PRICE_INDEX, price.rate(m_tradingCurrency.id()).formatMoney(m_tradingCurrency.tradingSymbol(), prec));
} else {
setText(COLUMN_PRICE_INDEX, "---");
}
}
示例11: currency
/**
* Fetch the trading currency of this account's currency
*
* @return The account's currency trading currency
*/
MyMoneySecurity ReportAccount::currency() const
{
MyMoneyFile* file = MyMoneyFile::instance();
// First, get the deep currency
MyMoneySecurity deepcurrency = file->security(currencyId());
if (! deepcurrency.isCurrency())
deepcurrency = file->security(deepcurrency.tradingCurrency());
// Return the deep currency's ID
return deepcurrency;
}
示例12: QString
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);
}
}
}
}
示例13: updateSummary
void KForecastView::updateSummary(QTreeWidgetItem *item)
{
MyMoneyMoney amountMM;
int it_c = 1; // iterator for the columns of the listview
MyMoneyFile* file = MyMoneyFile::instance();
int daysToBeginDay;
MyMoneyForecast forecast = item->data(0, ForecastRole).value<MyMoneyForecast>();
if (QDate::currentDate() < forecast.beginForecastDate()) {
daysToBeginDay = QDate::currentDate().daysTo(forecast.beginForecastDate());
} else {
daysToBeginDay = forecast.accountsCycle();
}
MyMoneyAccount account = item->data(0, AccountRole).value<MyMoneyAccount>();
MyMoneySecurity currency;
if (account.isInvest()) {
MyMoneySecurity underSecurity = file->security(account.currencyId());
currency = file->security(underSecurity.tradingCurrency());
} else {
currency = file->security(account.currencyId());
}
//add current balance column
QDate summaryDate = QDate::currentDate();
amountMM = forecast.forecastBalance(account, summaryDate);
//calculate the balance in base currency for the total row
setAmount(item, it_c, amountMM);
setValue(item, it_c, amountMM, summaryDate);
showAmount(item, it_c, amountMM, currency);
it_c++;
//iterate through all other columns
for (QDate summaryDate = QDate::currentDate().addDays(daysToBeginDay); summaryDate <= forecast.forecastEndDate(); summaryDate = summaryDate.addDays(forecast.accountsCycle()), ++it_c) {
amountMM = forecast.forecastBalance(account, summaryDate);
//calculate the balance in base currency for the total row
setAmount(item, it_c, amountMM);
setValue(item, it_c, amountMM, summaryDate);
showAmount(item, it_c, amountMM, currency);
}
//calculate and add variation per cycle
setNegative(item, forecast.accountTotalVariation(account).isNegative());
setAmount(item, it_c, forecast.accountTotalVariation(account));
setValue(item, it_c, forecast.accountTotalVariation(account), forecast.forecastEndDate());
showAmount(item, it_c, forecast.accountTotalVariation(account), currency);
}
示例14: addFutureTransactions
void MyMoneyForecast::doFutureScheduledForecast(void)
{
MyMoneyFile* file = MyMoneyFile::instance();
if(isIncludingFutureTransactions())
addFutureTransactions();
if(isIncludingScheduledTransactions())
addScheduledTransactions();
//do not show accounts with no transactions
if(!isIncludingUnusedAccounts())
purgeForecastAccountsList(m_accountList);
//adjust value of investments to deep currency
QMap<QString, QString>::ConstIterator it_n;
for ( it_n = m_nameIdx.begin(); it_n != m_nameIdx.end(); ++it_n ) {
MyMoneyAccount acc = file->account ( *it_n );
if ( acc.isInvest() ) {
//get the id of the security for that account
MyMoneySecurity undersecurity = file->security ( acc.currencyId() );
//only do it if the security is not an actual currency
if ( ! undersecurity.isCurrency() )
{
//set the default value
MyMoneyMoney rate = MyMoneyMoney ( 1, 1 );
MyMoneyPrice price;
for (QDate it_day = QDate::currentDate(); it_day <= forecastEndDate(); ) {
//get the price for the tradingCurrency that day
price = file->price ( undersecurity.id(), undersecurity.tradingCurrency(), it_day );
if ( price.isValid() )
{
rate = price.rate ( undersecurity.tradingCurrency() );
}
//value is the amount of shares multiplied by the rate of the deep currency
m_accountList[acc.id() ][it_day] = m_accountList[acc.id() ][it_day] * rate;
it_day = it_day.addDays(1);
}
}
}
}
}
示例15:
/**
* Set the values based on the @param security
*/
void KOnlineUpdateWizardPage::init2(const MyMoneySecurity& security)
{
int idx;
if (security.value("kmm-online-quote-system") == "Finance::Quote") {
FinanceQuoteProcess p;
m_useFinanceQuote->setChecked(true);
idx = m_onlineSourceCombo->findText(p.niceName(security.value("kmm-online-source")));
} else {
idx = m_onlineSourceCombo->findText(security.value("kmm-online-source"));
}
// in case we did not find the entry, we use the empty one
if (idx == -1)
idx = m_onlineSourceCombo->findText(QString());
m_onlineSourceCombo->setCurrentIndex(idx);
if (!security.value("kmm-online-factor").isEmpty())
m_onlineFactor->setValue(MyMoneyMoney(security.value("kmm-online-factor")));
}