From dadc34655c3ab961b0b0b94a10eaaba710f0b5e8 Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 4 Jul 2011 22:38:03 +0000 Subject: Added kmymoney git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239792 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmymoney2/widgets/selectedtransaction.cpp | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 kmymoney2/widgets/selectedtransaction.cpp (limited to 'kmymoney2/widgets/selectedtransaction.cpp') diff --git a/kmymoney2/widgets/selectedtransaction.cpp b/kmymoney2/widgets/selectedtransaction.cpp new file mode 100644 index 0000000..055dc3d --- /dev/null +++ b/kmymoney2/widgets/selectedtransaction.cpp @@ -0,0 +1,69 @@ +/*************************************************************************** + selectedtransaction.cpp - description + ------------------- + begin : Fri Jun 2008 + copyright : (C) 2000-2008 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. * + * * + ***************************************************************************/ + +#include "selectedtransaction.h" + +#include "register.h" +#include +#include + +namespace KMyMoneyRegister { + +int SelectedTransaction::warnLevel() const +{ + int warnLevel = 0; + QValueList::const_iterator it_s; + for(it_s = transaction().splits().begin(); warnLevel < 2 && it_s != transaction().splits().end(); ++it_s) { + const MyMoneyAccount& acc = MyMoneyFile::instance()->account((*it_s).accountId()); + if(acc.isClosed()) + warnLevel = 3; + else if((*it_s).reconcileFlag() == MyMoneySplit::Frozen) + warnLevel = 2; + else if((*it_s).reconcileFlag() == MyMoneySplit::Reconciled && warnLevel < 1) + warnLevel = 1; + } + return warnLevel; +} + +SelectedTransactions::SelectedTransactions(const Register* r) +{ + r->selectedTransactions(*this); +} + +int SelectedTransactions::warnLevel() const +{ + int warnLevel = 0; + SelectedTransactions::const_iterator it_t; + for(it_t = begin(); warnLevel < 3 && it_t != end(); ++it_t) { + int thisLevel = (*it_t).warnLevel(); + if (thisLevel > warnLevel) + warnLevel = thisLevel; + } + return warnLevel; +} + +bool SelectedTransactions::canModify() const +{ + return warnLevel() < 2; +} + +bool SelectedTransactions::canDuplicate() const +{ + return warnLevel() < 3; +} + +} // namespace -- cgit v1.2.1