/*************************************************************************** kmymoneyaccounttree.cpp - description ------------------- begin : Sat Jan 1 2005 copyright : (C) 2005 by Thomas Baumgart email : Thomas Baumgart ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ // ---------------------------------------------------------------------------- // QT Includes #include #include #include #include #include #include #include #include #include // ---------------------------------------------------------------------------- // KDE Includes #include #include #include #include #include // ---------------------------------------------------------------------------- // Project Includes #include #include #include #include KMyMoneyAccountTree::KMyMoneyAccountTree(TQWidget* tqparent, const char *name) : KMyMoneyAccountTreeBase(tqparent,name) { showType(); m_taxReportColumn = addColumn(i18n("Column heading for category in tax report", "Tax")); setColumnWidthMode(m_taxReportColumn, TQListView::Manual); setColumnAlignment(m_taxReportColumn, TQt::AlignHCenter); m_vatCategoryColumn = addColumn(i18n("Column heading for VAT category", "VAT")); setColumnWidthMode(m_vatCategoryColumn, TQListView::Manual); setColumnAlignment(m_vatCategoryColumn, TQt::AlignHCenter); showValue(); } KMyMoneyAccountTreeItem::KMyMoneyAccountTreeItem(KListView *tqparent, const MyMoneyAccount& account, const MyMoneySecurity& security , const TQString& name) : KMyMoneyAccountTreeBaseItem(tqparent,account,security,name), m_reconcileFlag(false) { updateAccount(); } KMyMoneyAccountTreeItem::KMyMoneyAccountTreeItem(KMyMoneyAccountTreeBaseItem *tqparent, const MyMoneyAccount& account, const TQValueList& price, const MyMoneySecurity& security) : KMyMoneyAccountTreeBaseItem(tqparent,account,price,security), m_reconcileFlag(false) { updateAccount(); } KMyMoneyAccountTreeItem::KMyMoneyAccountTreeItem(KListView *tqparent, const MyMoneyInstitution& institution) : KMyMoneyAccountTreeBaseItem(tqparent,institution), m_reconcileFlag(false) { } void KMyMoneyAccountTreeItem::fillColumns() { KMyMoneyAccountTree* lv = dynamic_cast(listView()); if (!lv) return; KMyMoneyAccountTreeBaseItem::fillColumns(); TQPixmap checkMark = TQPixmap(KGlobal::iconLoader()->loadIcon("ok", KIcon::Small)); MyMoneyMoney vatRate; if (!isInstitution()) setPixmap(lv->nameColumn(), m_account.accountPixmap(m_reconcileFlag, 22)); switch(m_account.accountType()) { case MyMoneyAccount::Income: case MyMoneyAccount::Expense: case MyMoneyAccount::Asset: case MyMoneyAccount::Liability: if(m_account.value("Tax").lower() == "yes") setPixmap(lv->taxReportColumn(), checkMark); if(!m_account.value("VatAccount").isEmpty()) { setPixmap(lv->vatCategoryColumn(), checkMark); } if(!m_account.value("VatRate").isEmpty()) { vatRate = MyMoneyMoney(m_account.value("VatRate")) * MyMoneyMoney(100,1); setText(lv->vatCategoryColumn(), TQString("%1 %").tqarg(vatRate.formatMoney("", 1))); } break; default: break; } } void KMyMoneyAccountTreeItem::setReconciliation(bool on) { if(m_reconcileFlag == on) return; m_reconcileFlag = on; updateAccount(); } MyMoneyMoney KMyMoneyAccountTreeItem::balance() const { MyMoneyMoney result; // account.balance() is not compatable with stock accounts if ( m_account.isInvest() ) result = MyMoneyFile::instance()->balance(m_account.id()); else result = m_account.balance(); // for income and liability accounts, we reverse the sign switch(m_account.accountGroup()) { case MyMoneyAccount::Income: case MyMoneyAccount::Liability: case MyMoneyAccount::Equity: result = -result; break; default: break; } return result; } #include "kmymoneyaccounttree.moc" // vim:cin:si:ai:et:ts=2:sw=2: