本文整理汇总了C++中MyMoneyFile::expense方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMoneyFile::expense方法的具体用法?C++ MyMoneyFile::expense怎么用?C++ MyMoneyFile::expense使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMoneyFile
的用法示例。
在下文中一共展示了MyMoneyFile::expense方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
const MyMoneyAccount& KNewAccountDlg::parentAccount(void)
{
if (!m_bSelectedParentAccount)
{
MyMoneyFile *file = MyMoneyFile::instance();
switch (m_account.accountGroup())
{
case MyMoneyAccount::Asset:
m_parentAccount = file->asset();
break;
case MyMoneyAccount::Liability:
m_parentAccount = file->liability();
break;
case MyMoneyAccount::Income:
m_parentAccount = file->income();
break;
case MyMoneyAccount::Expense:
m_parentAccount = file->expense();
break;
case MyMoneyAccount::Equity:
m_parentAccount = file->equity();
break;
default:
qDebug("Seems we have an account that hasn't been mapped to the top five");
if(m_categoryEditor)
m_parentAccount = file->income();
else
m_parentAccount = file->asset();
}
}
return m_parentAccount;
}
示例2: addIncomeExpenseRows
void KForecastView::addIncomeExpenseRows(const MyMoneyForecast& forecast)
{
MyMoneyFile* file = MyMoneyFile::instance();
m_incomeItem = new QTreeWidgetItem(m_totalItem);
m_incomeItem->setText(0, file->income().name());
m_incomeItem->setIcon(0, file->income().accountPixmap());
m_incomeItem->setData(0, ForecastRole, QVariant::fromValue(forecast));
m_incomeItem->setData(0, AccountRole, QVariant::fromValue(file->income()));
m_incomeItem->setExpanded(true);
m_expenseItem = new QTreeWidgetItem(m_totalItem);
m_expenseItem->setText(0, file->expense().name());
m_expenseItem->setIcon(0, file->expense().accountPixmap());
m_expenseItem->setData(0, ForecastRole, QVariant::fromValue(forecast));
m_expenseItem->setData(0, AccountRole, QVariant::fromValue(file->expense()));
m_expenseItem->setExpanded(true);
}
示例3: it
void KAccountTemplateSelector::Private::loadHierarchy(void)
{
m_templateHierarchy.clear();
QListViewItemIterator it(m_parent->m_groupList, QListViewItemIterator::Selected);
QListViewItem* it_v;
while((it_v = it.current()) != 0) {
m_templates[it_v->text(2)].hierarchy(m_templateHierarchy);
++it;
}
// I need to think about this some more. The code works and shows
// the current account hierarchy. It might be usefull, to show
// existing accounts dimmed and the new ones in bold or so.
#if 0
// add the hierarchy from the MyMoneyFile object
QValueList<MyMoneyAccount> aList;
QValueList<MyMoneyAccount>::const_iterator it_a;
MyMoneyFile* file = MyMoneyFile::instance();
file->accountList(aList);
if(aList.count() > 0) {
m_templateHierarchy[file->accountToCategory(file->asset().id(), true)] = 0;
m_templateHierarchy[file->accountToCategory(file->liability().id(), true)] = 0;
m_templateHierarchy[file->accountToCategory(file->income().id(), true)] = 0;
m_templateHierarchy[file->accountToCategory(file->expense().id(), true)] = 0;
m_templateHierarchy[file->accountToCategory(file->equity().id(), true)] = 0;
}
for(it_a = aList.begin(); it_a != aList.end(); ++it_a) {
m_templateHierarchy[file->accountToCategory((*it_a).id(), true)] = 0;
}
#endif
m_parent->m_accountList->clear();
QMap<QString, QListViewItem*>::iterator it_m;
QRegExp exp("(.*):(.*)");
for(it_m = m_templateHierarchy.begin(); it_m != m_templateHierarchy.end(); ++it_m) {
if(exp.search(it_m.key()) == -1) {
(*it_m) = new KListViewItem(m_parent->m_accountList, it_m.key());
} else {
(*it_m) = hierarchyItem(exp.cap(1), exp.cap(2));
}
(*it_m)->setOpen(true);
}
m_parent->m_description->clear();
if(m_parent->m_groupList->currentItem()) {
m_parent->m_description->setText(m_templates[m_parent->m_groupList->currentItem()->text(2)].longDescription());
}
}
示例4: loadBudgetView
void KForecastView::loadBudgetView()
{
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneyForecast forecast = KMyMoneyGlobalSettings::forecast();
//get the settings from current page and calculate this year based on last year
QDate historyEndDate = QDate(QDate::currentDate().year() - 1, 12, 31);
QDate historyStartDate = historyEndDate.addDays(-m_accountsCycle->value() * m_forecastCycles->value());
QDate forecastStartDate = QDate(QDate::currentDate().year(), 1, 1);
QDate forecastEndDate = QDate::currentDate().addDays(m_forecastDays->value());
forecast.setHistoryMethod(m_historyMethod->checkedId());
MyMoneyBudget budget;
forecast.createBudget(budget, historyStartDate, historyEndDate, forecastStartDate, forecastEndDate, false);
m_budgetList->clear();
m_budgetList->setIconSize(QSize(22, 22));
m_budgetList->setSortingEnabled(true);
m_budgetList->sortByColumn(0, Qt::AscendingOrder);
//add columns
QStringList headerLabels;
headerLabels << i18n("Account");
{
QDate forecastStartDate = forecast.forecastStartDate();
QDate forecastEndDate = forecast.forecastEndDate();
//add cycle interval columns
QDate f_date = forecastStartDate;
for (; f_date <= forecastEndDate; f_date = f_date.addMonths(1)) {
headerLabels << QDate::longMonthName(f_date.month());
}
}
//add total column
headerLabels << i18nc("Total balance", "Total");
//set the columns
m_budgetList->setHeaderLabels(headerLabels);
//add default rows
addTotalRow(m_budgetList, forecast);
addIncomeExpenseRows(forecast);
//load income and expense budget accounts
loadAccounts(forecast, file->income(), m_incomeItem, eBudget);
loadAccounts(forecast, file->expense(), m_expenseItem, eBudget);
adjustHeadersAndResizeToContents(m_budgetList);
}
示例5: importTemplate
bool MyMoneyTemplate::importTemplate(void(*callback)(int, int, const QString&))
{
m_progressCallback = callback;
bool rc = !m_accounts.isNull();
MyMoneyFile* file = MyMoneyFile::instance();
signalProgress(0, m_doc.elementsByTagName("account").count(), i18n("Loading template %1", m_source.url()));
m_accountsRead = 0;
while (rc == true && !m_accounts.isNull() && m_accounts.isElement()) {
QDomElement childElement = m_accounts.toElement();
if (childElement.tagName() == "account"
&& childElement.attribute("name").isEmpty()) {
++m_accountsRead;
MyMoneyAccount parent;
switch (childElement.attribute("type").toUInt()) {
case MyMoneyAccount::Asset:
parent = file->asset();
break;
case MyMoneyAccount::Liability:
parent = file->liability();
break;
case MyMoneyAccount::Income:
parent = file->income();
break;
case MyMoneyAccount::Expense:
parent = file->expense();
break;
case MyMoneyAccount::Equity:
parent = file->equity();
break;
default:
KMessageBox::error(KMyMoneyUtils::mainWindow(), i18n("<p>Invalid top-level account type <b>%1</b> in template file <b>%2</b></p>", childElement.attribute("type"), m_source.prettyUrl()));
rc = false;
}
if (rc == true) {
rc = createAccounts(parent, childElement.firstChild());
}
} else {
rc = false;
}
m_accounts = m_accounts.nextSibling();
}
signalProgress(-1, -1);
return rc;
}
示例6: writeCategoryEntries
void MyMoneyQifWriter::writeCategoryEntries(QTextStream &s)
{
MyMoneyFile* file = MyMoneyFile::instance();
MyMoneyAccount income;
MyMoneyAccount expense;
income = file->income();
expense = file->expense();
s << "!Type:Cat" << endl;
QStringList list = income.accountList() + expense.accountList();
emit signalProgress(0, list.count());
QStringList::Iterator it;
int count = 0;
for(it = list.begin(); it != list.end(); ++it) {
writeCategoryEntry(s, *it, "");
emit signalProgress(++count, 0);
}
}
示例7: slotAccountTypeChanged
void KNewAccountDlg::slotAccountTypeChanged(const QString& typeStr)
{
MyMoneyAccount::accountTypeE type;
MyMoneyAccount::accountTypeE oldType;
MyMoneyFile* file = MyMoneyFile::instance();
type = KMyMoneyUtils::stringToAccountType(typeStr);
try {
oldType = m_account.accountType();
if(oldType != type) {
QString parentId;
switch(MyMoneyAccount::accountGroup(type)) {
case MyMoneyAccount::Asset:
parentId = file->asset().id();
break;
case MyMoneyAccount::Liability:
parentId = file->liability().id();
break;
case MyMoneyAccount::Expense:
parentId = file->expense().id();
break;
case MyMoneyAccount::Income:
parentId = file->income().id();
break;
default:
qWarning("Unknown account group in KNewAccountDlg::slotAccountTypeChanged()");
break;
}
initParentWidget(parentId, QString());
m_account.setAccountType(type);
}
} catch(MyMoneyException *e) {
delete e;
qWarning("Unexpected exception in KNewAccountDlg::slotAccountTypeChanged()");
}
}
示例8: checkCategory
const QString CsvUtil::checkCategory(const QString& name, const MyMoneyMoney& value, const MyMoneyMoney& value2)
{
// Borrowed from MyMoneyQifReader::checkCategory()
QString accountId;
MyMoneyFile *file = MyMoneyFile::instance();
MyMoneyAccount account;
bool found = true;
if (!name.isEmpty()) {
// The category might be constructed with an arbitraty depth (number of
// colon delimited fields). We try to find a parent account within this
// hierarchy by searching the following sequence:
//
// aaaa:bbbb:cccc:ddddd
//
// 1. search aaaa:bbbb:cccc:dddd, create nothing
// 2. search aaaa:bbbb:cccc , create dddd
// 3. search aaaa:bbbb , create cccc:dddd
// 4. search aaaa , create bbbb:cccc:dddd
// 5. don't search , create aaaa:bbbb:cccc:dddd
account.setName(name);
QString accName; // part to be created (right side in above list)
QString parent(name); // a possible parent part (left side in above list)
do {
accountId = file->categoryToAccount(parent);
if (accountId.isEmpty()) {
found = false;
// prepare next step
if (!accName.isEmpty())
accName.prepend(':');
accName.prepend(parent.section(':', -1));
account.setName(accName);
parent = parent.section(':', 0, -2);
} else if (!accName.isEmpty()) {
account.setParentAccountId(accountId);
}
} while (!parent.isEmpty() && accountId.isEmpty());
// if we did not find the category, we create it
if (!found) {
MyMoneyAccount parent;
if (account.parentAccountId().isEmpty()) {
if (!value.isNegative() && value2.isNegative())
parent = file->income();
else
parent = file->expense();
} else {
parent = file->account(account.parentAccountId());
}
account.setAccountType((!value.isNegative() && value2.isNegative()) ? MyMoneyAccount::Income : MyMoneyAccount::Expense);
MyMoneyAccount brokerage;
// clear out the parent id, because createAccount() does not like that
account.setParentAccountId(QString());
createAccount(account, parent, brokerage, MyMoneyMoney());
accountId = account.id();
}
}
return accountId;
}
示例9: initParentWidget
void KNewAccountDlg::initParentWidget(QString parentId, const QString& accountId)
{
MyMoneyFile *file = MyMoneyFile::instance();
MyMoneyAccount liabilityAccount = file->liability();
MyMoneyAccount assetAccount = file->asset();
MyMoneyAccount expenseAccount = file->expense();
MyMoneyAccount incomeAccount = file->income();
MyMoneyAccount equityAccount = file->equity();
m_parentItem = 0;
m_accountItem = 0;
// Determine the parent account
try
{
m_parentAccount = file->account(parentId);
}
catch (MyMoneyException *e)
{
m_bSelectedParentAccount = false;
m_parentAccount = MyMoneyAccount();
if(m_account.accountType() != MyMoneyAccount::UnknownAccountType) {
parentAccount();
parentId = m_parentAccount.id();
}
delete e;
}
m_bSelectedParentAccount = true;
// extract the account type from the combo box
MyMoneyAccount::accountTypeE type;
MyMoneyAccount::accountTypeE groupType;
type = KMyMoneyUtils::stringToAccountType(typeCombo->currentText());
groupType = MyMoneyAccount::accountGroup(type);
m_qlistviewParentAccounts->clear();
// Now scan all 4 account roots to load the list and mark the parent
try
{
if (!m_categoryEditor)
{
if(groupType == MyMoneyAccount::Asset || type == MyMoneyAccount::Loan) {
// Asset
KMyMoneyAccountTreeBaseItem *assetTopLevelAccount = new KMyMoneyAccountTreeItem(m_qlistviewParentAccounts, assetAccount);
if(m_parentAccount.id().isEmpty()) {
m_parentAccount = assetAccount;
parentId = m_parentAccount.id();
}
if (parentId == assetAccount.id())
m_parentItem = assetTopLevelAccount;
assetTopLevelAccount->setOpen(true);
for ( QStringList::ConstIterator it = assetAccount.accountList().begin();
it != assetAccount.accountList().end();
++it )
{
MyMoneyAccount acc = file->account(*it);
if(acc.isClosed())
continue;
KMyMoneyAccountTreeBaseItem *accountItem = new KMyMoneyAccountTreeItem(assetTopLevelAccount, acc);
if(parentId == acc.id()) {
m_parentItem = accountItem;
} else if(accountId == acc.id()) {
if(m_isEditing)
accountItem->setSelectable(false);
m_accountItem = accountItem;
}
QStringList subAccounts = acc.accountList();
if (subAccounts.count() >= 1)
{
showSubAccounts(subAccounts, accountItem, parentId, acc.id());
}
}
}
if(groupType == MyMoneyAccount::Liability) {
// Liability
KMyMoneyAccountTreeBaseItem *liabilityTopLevelAccount = new KMyMoneyAccountTreeItem(m_qlistviewParentAccounts, liabilityAccount);
if(m_parentAccount.id().isEmpty()) {
m_parentAccount = liabilityAccount;
parentId = m_parentAccount.id();
}
if (parentId == liabilityAccount.id())
m_parentItem = liabilityTopLevelAccount;
liabilityTopLevelAccount->setOpen(true);
for ( QStringList::ConstIterator it = liabilityAccount.accountList().begin();
it != liabilityAccount.accountList().end();
++it )
//.........这里部分代码省略.........