File indexing completed on 2024-05-12 16:44:07

0001 /*
0002     SPDX-FileCopyrightText: 2006-2018 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "selectedtransactions.h"
0008 
0009 // ----------------------------------------------------------------------------
0010 // QT Includes
0011 
0012 // ----------------------------------------------------------------------------
0013 // KDE Includes
0014 
0015 // ----------------------------------------------------------------------------
0016 // Project Includes
0017 
0018 #include "register.h"
0019 
0020 using namespace KMyMoneyRegister;
0021 
0022 SelectedTransactions::SelectedTransactions(const Register* r)
0023 {
0024     r->selectedTransactions(*this);
0025 }
0026 
0027 SelectedTransaction::warnLevel_t SelectedTransactions::warnLevel() const
0028 {
0029     SelectedTransaction::warnLevel_t warnLevel = SelectedTransaction::NoWarning;
0030     SelectedTransactions::const_iterator it_t;
0031     for (it_t = begin(); warnLevel < SelectedTransaction::OneAccountClosed && it_t != end(); ++it_t) {
0032         SelectedTransaction::warnLevel_t thisLevel = (*it_t).warnLevel();
0033         if (thisLevel > warnLevel)
0034             warnLevel = thisLevel;
0035     }
0036     return warnLevel;
0037 }
0038 
0039 bool SelectedTransactions::canModify() const
0040 {
0041     return warnLevel() < 2;
0042 }
0043 
0044 bool SelectedTransactions::canDuplicate() const
0045 {
0046     return warnLevel() < 3;
0047 }