summaryrefslogtreecommitdiffstats
path: root/kmymoney2/widgets/kmymoneyaccounttreebudget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmymoney2/widgets/kmymoneyaccounttreebudget.cpp')
-rw-r--r--kmymoney2/widgets/kmymoneyaccounttreebudget.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/kmymoney2/widgets/kmymoneyaccounttreebudget.cpp b/kmymoney2/widgets/kmymoneyaccounttreebudget.cpp
new file mode 100644
index 0000000..cd1da0b
--- /dev/null
+++ b/kmymoney2/widgets/kmymoneyaccounttreebudget.cpp
@@ -0,0 +1,84 @@
+/***************************************************************************
+ kmymoneyaccounttreebudget.cpp - description
+ -------------------
+ begin : Tue Feb 21 2006
+ copyright : (C) 2005 by Darren Gould
+ email : Darren Gould <darren_gould@gmx.de>
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+// ----------------------------------------------------------------------------
+// Project Includes
+#include <kmymoneyaccounttreebudget.h>
+
+KMyMoneyAccountTreeBudget::KMyMoneyAccountTreeBudget(QWidget* parent, const char* name) :
+ KMyMoneyAccountTreeBase::KMyMoneyAccountTreeBase(parent, name)
+{
+ showType();
+ showValue();
+}
+
+void KMyMoneyAccountTreeBudget::slotSelectObject(const QListViewItem* i)
+{
+ emit selectObject(MyMoneyInstitution());
+ emit selectObject(MyMoneyAccount());
+
+ const KMyMoneyAccountTreeBaseItem* item = dynamic_cast<const KMyMoneyAccountTreeBaseItem*>(i);
+ if(item) {
+ emit openObject(item->itemObject());
+ }
+}
+
+KMyMoneyAccountTreeBudgetItem::KMyMoneyAccountTreeBudgetItem(KListView *parent, const MyMoneyAccount& account, const MyMoneyBudget &budget, const MyMoneySecurity& security, const QString& name) :
+ KMyMoneyAccountTreeBaseItem(parent, account, security, name),
+ m_budget(budget)
+{
+ updateAccount(true);
+}
+
+KMyMoneyAccountTreeBudgetItem::KMyMoneyAccountTreeBudgetItem(KMyMoneyAccountTreeBudgetItem *parent, const MyMoneyAccount& account, const MyMoneyBudget& budget, const QValueList<MyMoneyPrice>& price, const MyMoneySecurity& security) :
+ KMyMoneyAccountTreeBaseItem(parent, account, price, security),
+ m_budget(budget)
+{
+ updateAccount(true);
+}
+
+
+KMyMoneyAccountTreeBudgetItem::~KMyMoneyAccountTreeBudgetItem()
+{
+}
+
+void KMyMoneyAccountTreeBudgetItem::setBudget(const MyMoneyBudget& budget)
+{
+ m_budget = budget;
+ updateAccount();
+}
+
+MyMoneyMoney KMyMoneyAccountTreeBudgetItem::balance() const
+{
+ MyMoneyMoney result = MyMoneyMoney();
+ // find out if the account is budgeted
+ MyMoneyBudget::AccountGroup budgetAccount = m_budget.account( m_account.id() );
+ if ( budgetAccount.id() == m_account.id() ) {
+ result = budgetAccount.balance();
+ switch(budgetAccount.budgetLevel()) {
+ case MyMoneyBudget::AccountGroup::eMonthly:
+ result = result * 12;
+ break;
+
+ default:
+ break;
+ }
+ }
+ return result;
+}
+
+#include "kmymoneyaccounttreebudget.moc"