本文整理汇总了C++中MyMoneySecurity::tradingSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneySecurity::tradingSymbol方法的具体用法?C++ MyMoneySecurity::tradingSymbol怎么用?C++ MyMoneySecurity::tradingSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneySecurity
的用法示例。
在下文中一共展示了MyMoneySecurity::tradingSymbol方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()));
}
}
}
}
示例2:
/**
* 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"));
}
示例3: 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, "---");
}
}
示例4: slotReceivedQuote
void KEquityPriceUpdateDlg::slotReceivedQuote(const QString& _id, const QString& _symbol, const QDate& _date, const double& _price)
{
QList<QTreeWidgetItem*> foundItems = lvEquityList->findItems(_id, Qt::MatchExactly, ID_COL);
QTreeWidgetItem* item = 0;
if (! foundItems.empty())
item = foundItems.at(0);
QTreeWidgetItem* next = 0;
if (item) {
if (_price > 0.0f && _date.isValid()) {
QDate date = _date;
if (date > QDate::currentDate())
date = QDate::currentDate();
double price = _price;
QString id = _id.toUtf8();
MyMoneySecurity sec;
if (_id.contains(" ") == 0) {
MyMoneySecurity security = MyMoneyFile::instance()->security(id);
QString factor = security.value("kmm-online-factor");
if (!factor.isEmpty()) {
price *= MyMoneyMoney(factor).toDouble();
}
try {
sec = MyMoneyFile::instance()->security(id);
sec = MyMoneyFile::instance()->security(sec.tradingCurrency());
} catch (const MyMoneyException &) {
sec = MyMoneySecurity();
}
} else {
QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive);
if (splitrx.indexIn(_id) != -1) {
try {
sec = MyMoneyFile::instance()->security(splitrx.cap(2).toUtf8());
} catch (const MyMoneyException &) {
sec = MyMoneySecurity();
}
}
}
item->setText(PRICE_COL, KGlobal::locale()->formatMoney(price, sec.tradingSymbol(), KMyMoneyGlobalSettings::pricePrecision()));
item->setText(DATE_COL, date.toString(Qt::ISODate));
logStatusMessage(i18n("Price for %1 updated (id %2)", _symbol, _id));
// make sure to make OK button available
btnOK->setEnabled(true);
} else {
logErrorMessage(i18n("Received an invalid price for %1, unable to update.", _symbol));
}
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);
}
}
} else {
logErrorMessage(i18n("Received a price for %1 (id %2), but this symbol is not on the list. Aborting entire update.", _symbol, _id));
}
if (next) {
m_webQuote.launch(next->text(SYMBOL_COL), next->text(ID_COL), next->text(SOURCE_COL));
} else {
finishUpdate();
}
}