diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
commit | e38d2351b83fa65c66ccde443777647ef5cb6cff (patch) | |
tree | 1897fc20e9f73a81c520a5b9f76f8ed042124883 /src/commands/removeloans.cpp | |
download | tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.tar.gz tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.zip |
Added KDE3 version of Tellico
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1097620 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/commands/removeloans.cpp')
-rw-r--r-- | src/commands/removeloans.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/commands/removeloans.cpp b/src/commands/removeloans.cpp new file mode 100644 index 0000000..5ceadc9 --- /dev/null +++ b/src/commands/removeloans.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of version 2 of the GNU General Public License as * + * published by the Free Software Foundation; * + * * + ***************************************************************************/ + +#include "removeloans.h" +#include "../document.h" +#include "../entry.h" +#include "../controller.h" +#include "../calendarhandler.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Command::RemoveLoans; + +RemoveLoans::RemoveLoans(Data::LoanVec loans_) + : KCommand() + , m_loans(loans_) +{ +} + +void RemoveLoans::execute() { + if(m_loans.isEmpty()) { + return; + } + + // not all of the loans might be in the calendar + Data::LoanVec calLoans; + // remove the loans from the borrowers + for(Data::LoanVec::Iterator loan = m_loans.begin(); loan != m_loans.end(); ++loan) { + if(loan->inCalendar()) { + calLoans.append(loan); + } + loan->borrower()->removeLoan(loan); + Data::Document::self()->checkInEntry(loan->entry()); + Data::EntryVec vec; + vec.append(loan->entry()); + Controller::self()->modifiedEntries(vec); + Controller::self()->modifiedBorrower(loan->borrower()); + } + if(!calLoans.isEmpty()) { + CalendarHandler::removeLoans(calLoans); + } +} + +void RemoveLoans::unexecute() { + if(m_loans.isEmpty()) { + return; + } + + // not all of the loans might be in the calendar + Data::LoanVec calLoans; + for(Data::LoanVec::Iterator loan = m_loans.begin(); loan != m_loans.end(); ++loan) { + if(loan->inCalendar()) { + calLoans.append(loan); + } + loan->borrower()->addLoan(loan); + Data::Document::self()->checkOutEntry(loan->entry()); + Data::EntryVec vec; + vec.append(loan->entry()); + Controller::self()->modifiedEntries(vec); + Controller::self()->modifiedBorrower(loan->borrower()); + } + if(!calLoans.isEmpty()) { + CalendarHandler::addLoans(calLoans); + } +} + +QString RemoveLoans::name() const { + return m_loans.count() > 1 ? i18n("Check-in Entries") + : i18n("Check-in (Entry Title)", "Check-in %1").arg(m_loans.begin()->entry()->title()); +} |