diff options
Diffstat (limited to 'src/commands')
27 files changed, 1666 insertions, 0 deletions
diff --git a/src/commands/Makefile.am b/src/commands/Makefile.am new file mode 100644 index 0000000..95147c2 --- /dev/null +++ b/src/commands/Makefile.am @@ -0,0 +1,29 @@ +AM_CPPFLAGS = $(all_includes) + +noinst_LIBRARIES = libcommands.a +libcommands_a_SOURCES = \ + addentries.cpp modifyentries.cpp removeentries.cpp \ + addloans.cpp modifyloans.cpp removeloans.cpp \ + fieldcommand.cpp filtercommand.cpp reorderfields.cpp \ + group.cpp collectioncommand.cpp renamecollection.cpp \ + updateentries.cpp + +libcommands_a_METASOURCES = AUTO +KDE_OPTIONS = noautodist +EXTRA_DIST = \ + addentries.h addentries.cpp \ + modifyentries.h modifyentries.cpp \ + removeentries.h removeentries.cpp \ + addloans.h addloans.cpp \ + modifyloans.h modifyloans.cpp \ + removeloans.h removeloans.cpp \ + fieldcommand.h fieldcommand.cpp \ + filtercommand.h filtercommand.cpp \ + reorderfields.h reorderfields.cpp \ + group.h group.cpp \ + collectioncommand.h collectioncommand.cpp \ + renamecollection.h renamecollection.cpp \ + updateentries.h updateentries.cpp + + +CLEANFILES = *~ diff --git a/src/commands/addentries.cpp b/src/commands/addentries.cpp new file mode 100644 index 0000000..6cd7636 --- /dev/null +++ b/src/commands/addentries.cpp @@ -0,0 +1,64 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "addentries.h" +#include "../collection.h" +#include "../controller.h" +#include "../datavectors.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Command::AddEntries; + +AddEntries::AddEntries(Data::CollPtr coll_, const Data::EntryVec& entries_) + : KCommand() + , m_coll(coll_) + , m_entries(entries_) +{ +} + +void AddEntries::execute() { + if(!m_coll || m_entries.isEmpty()) { + return; + } + + m_coll->addEntries(m_entries); + // now check for default values + Data::FieldVec fields = m_coll->fields(); + for(Data::FieldVec::Iterator field = fields.begin(); field != fields.end(); ++field) { + const QString defaultValue = field->defaultValue(); + if(!defaultValue.isEmpty()) { + for(Data::EntryVec::Iterator entry = m_entries.begin(); entry != m_entries.end(); ++entry) { + if(entry->field(field).isEmpty()) { + entry->setField(field->name(), defaultValue); + } + } + } + } + Controller::self()->addedEntries(m_entries); +} + +void AddEntries::unexecute() { + if(!m_coll || m_entries.isEmpty()) { + return; + } + + m_coll->removeEntries(m_entries); + Controller::self()->removedEntries(m_entries); +} + +QString AddEntries::name() const { + return m_entries.count() > 1 ? i18n("Add Entries") + : i18n("Add (Entry Title)", "Add %1").arg(m_entries.begin()->title()); +} diff --git a/src/commands/addentries.h b/src/commands/addentries.h new file mode 100644 index 0000000..54d8e29 --- /dev/null +++ b/src/commands/addentries.h @@ -0,0 +1,44 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_ADDENTRIES_H +#define TELLICO_ADDENTRIES_H + +#include "../datavectors.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class AddEntries : public KCommand { + +public: + AddEntries(Data::CollPtr coll, const Data::EntryVec& entries); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Data::CollPtr m_coll; + Data::EntryVec m_entries; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/addloans.cpp b/src/commands/addloans.cpp new file mode 100644 index 0000000..dab67d7 --- /dev/null +++ b/src/commands/addloans.cpp @@ -0,0 +1,110 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "addloans.h" +#include "../document.h" +#include "../entry.h" +#include "../collection.h" +#include "../controller.h" +#include "../calendarhandler.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Command::AddLoans; + +AddLoans::AddLoans(Data::BorrowerPtr borrower_, Data::LoanVec loans_, bool addToCalendar_) + : KCommand() + , m_borrower(borrower_) + , m_loans(loans_) + , m_addedLoanField(false) + , m_addToCalendar(addToCalendar_) +{ +} + +void AddLoans::execute() { + if(!m_borrower || m_loans.isEmpty()) { + return; + } + + // if the borrower is empty, assume it's getting added, otherwise it's being modified + bool wasEmpty = m_borrower->isEmpty(); + + // if there's no loaned field, we'll add one + bool loanExisted = m_loans.begin()->entry()->collection()->hasField(QString::fromLatin1("loaned")); + m_addedLoanField = false; // assume we didn't add the field yet + + // add the loans to the borrower + for(Data::LoanVec::Iterator loan = m_loans.begin(); loan != m_loans.end(); ++loan) { + m_borrower->addLoan(loan); + Data::Document::self()->checkOutEntry(loan->entry()); + Data::EntryVec vec; + vec.append(loan->entry()); + Controller::self()->modifiedEntries(vec); + } + if(!loanExisted) { + Data::CollPtr c = m_loans.begin()->entry()->collection(); + Data::FieldPtr f = c->fieldByName(QString::fromLatin1("loaned")); + if(f) { + // notify everything that a new field was added + Controller::self()->addedField(c, f); + m_addedLoanField = true; + } + } + if(m_addToCalendar) { + CalendarHandler::addLoans(m_loans); + } + if(wasEmpty) { + m_loans.begin()->entry()->collection()->addBorrower(m_borrower); + Controller::self()->addedBorrower(m_borrower); + } else { + // don't have to do anything to the document, it just holds a pointer + myDebug() << "AddLoansCommand::execute() - modifying an existing borrower! " << endl; + Controller::self()->modifiedBorrower(m_borrower); + } +} + +void AddLoans::unexecute() { + if(!m_borrower) { + return; + } + + // remove the loans from the borrower + for(Data::LoanVec::Iterator loan = m_loans.begin(); loan != m_loans.end(); ++loan) { + m_borrower->removeLoan(loan); + Data::Document::self()->checkInEntry(loan->entry()); + Data::EntryVec vec; + vec.append(loan->entry()); + Controller::self()->modifiedEntries(vec); + } + if(m_addedLoanField) { + Data::CollPtr c = m_loans.begin()->entry()->collection(); + Data::FieldPtr f = c->fieldByName(QString::fromLatin1("loaned")); + if(f) { + c->removeField(f); + Controller::self()->removedField(c, f); + } + } + if(m_addToCalendar) { + CalendarHandler::removeLoans(m_loans); + } + // the borrower object is kept in the document, it's just empty + // it won't get saved in the document file + // here, just notify everybody that it changed + Controller::self()->modifiedBorrower(m_borrower); +} + +QString AddLoans::name() const { + return m_loans.count() > 1 ? i18n("Check-out Items") + : i18n("Check-out (Entry Title)", "Check-out %1").arg(m_loans.begin()->entry()->title()); +} diff --git a/src/commands/addloans.h b/src/commands/addloans.h new file mode 100644 index 0000000..b80cbc3 --- /dev/null +++ b/src/commands/addloans.h @@ -0,0 +1,47 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_ADDLOANS_H +#define TELLICO_ADDLOANS_H + +#include "../borrower.h" +#include "../datavectors.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class AddLoans : public KCommand { + +public: + AddLoans(Data::BorrowerPtr borrower, Data::LoanVec loans, bool addToCalendar); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Data::BorrowerPtr m_borrower; + Data::LoanVec m_loans; + bool m_addedLoanField : 1; + bool m_addToCalendar : 1; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/collectioncommand.cpp b/src/commands/collectioncommand.cpp new file mode 100644 index 0000000..8955ea0 --- /dev/null +++ b/src/commands/collectioncommand.cpp @@ -0,0 +1,126 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "collectioncommand.h" +#include "../collection.h" +#include "../document.h" +#include "../controller.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Command::CollectionCommand; + +CollectionCommand::CollectionCommand(Mode mode_, Data::CollPtr origColl_, Data::CollPtr newColl_) + : KCommand() + , m_mode(mode_) + , m_origColl(origColl_) + , m_newColl(newColl_) + , m_cleanup(DoNothing) +{ +#ifndef NDEBUG +// just some sanity checking + if(m_origColl == 0 || m_newColl == 0) { + myDebug() << "CollectionCommand() - null collection pointer" << endl; + } +#endif +} + +CollectionCommand::~CollectionCommand() { + switch(m_cleanup) { + case ClearOriginal: + m_origColl->clear(); + break; + case ClearNew: + m_newColl->clear(); + break; + default: + break; + } +} + +void CollectionCommand::execute() { + if(!m_origColl || !m_newColl) { + return; + } + + switch(m_mode) { + case Append: + copyFields(); + Data::Document::self()->appendCollection(m_newColl); + Controller::self()->slotCollectionModified(m_origColl); + break; + + case Merge: + copyFields(); + m_mergePair = Data::Document::self()->mergeCollection(m_newColl); + Controller::self()->slotCollectionModified(m_origColl); + break; + + case Replace: + // replaceCollection() makes the URL = "Unknown" + m_origURL = Data::Document::self()->URL(); + Data::Document::self()->replaceCollection(m_newColl); + Controller::self()->slotCollectionDeleted(m_origColl); + Controller::self()->slotCollectionAdded(m_newColl); + m_cleanup = ClearOriginal; + break; + } +} + +void CollectionCommand::unexecute() { + if(!m_origColl || !m_newColl) { + return; + } + + switch(m_mode) { + case Append: + Data::Document::self()->unAppendCollection(m_newColl, m_origFields); + Controller::self()->slotCollectionModified(m_origColl); + break; + + case Merge: + Data::Document::self()->unMergeCollection(m_newColl, m_origFields, m_mergePair); + Controller::self()->slotCollectionModified(m_origColl); + break; + + case Replace: + Data::Document::self()->replaceCollection(m_origColl); + Data::Document::self()->setURL(m_origURL); + Controller::self()->slotCollectionDeleted(m_newColl); + Controller::self()->slotCollectionAdded(m_origColl); + m_cleanup = ClearNew; + break; + } +} + +QString CollectionCommand::name() const { + switch(m_mode) { + case Append: + return i18n("Append Collection"); + case Merge: + return i18n("Merge Collection"); + case Replace: + return i18n("Replace Collection"); + } + // hush warnings + return QString::null; +} + +void CollectionCommand::copyFields() { + m_origFields.clear(); + Data::FieldVec fieldsToCopy = m_origColl->fields(); + for(Data::FieldVec::Iterator field = fieldsToCopy.begin(); field != fieldsToCopy.end(); ++field) { + m_origFields.append(new Data::Field(*field)); + } +} diff --git a/src/commands/collectioncommand.h b/src/commands/collectioncommand.h new file mode 100644 index 0000000..ad0b2f4 --- /dev/null +++ b/src/commands/collectioncommand.h @@ -0,0 +1,63 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_COLLECTIONCOMMAND_H +#define TELLICO_COLLECTIONCOMMAND_H + +#include "../datavectors.h" + +#include <kcommand.h> +#include <kurl.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class CollectionCommand : public KCommand { +public: + enum Mode { + Append, + Merge, + Replace + }; + + CollectionCommand(Mode mode, Data::CollPtr currentColl, Data::CollPtr newColl); + ~CollectionCommand(); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + void copyFields(); + + Mode m_mode; + Data::CollPtr m_origColl; + Data::CollPtr m_newColl; + + KURL m_origURL; + Data::FieldVec m_origFields; + Data::MergePair m_mergePair; + // for the Replace case, the collection that got replaced needs to be cleared + enum CleanupMode { + DoNothing, ClearOriginal, ClearNew + }; + CleanupMode m_cleanup; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/fieldcommand.cpp b/src/commands/fieldcommand.cpp new file mode 100644 index 0000000..6902e15 --- /dev/null +++ b/src/commands/fieldcommand.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "fieldcommand.h" +#include "../collection.h" +#include "../controller.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Command::FieldCommand; + +FieldCommand::FieldCommand(Mode mode_, Data::CollPtr coll_, + Data::FieldPtr activeField_, Data::FieldPtr oldField_/*=0*/) + : KCommand() + , m_mode(mode_) + , m_coll(coll_) + , m_activeField(activeField_) + , m_oldField(oldField_) +{ + if(!m_coll) { + myDebug() << "FieldCommand() - null collection pointer" << endl; + } else if(!m_activeField) { + myDebug() << "FieldCommand() - null active field pointer" << endl; + } +#ifndef NDEBUG +// just some sanity checking + if(m_mode == FieldAdd && m_oldField != 0) { + myDebug() << "FieldCommand() - adding field, but pointers are wrong" << endl; + } else if(m_mode == FieldModify && m_oldField == 0) { + myDebug() << "FieldCommand() - modifying field, but pointers are wrong" << endl; + } else if(m_mode == FieldRemove && m_oldField != 0) { + myDebug() << "FieldCommand() - removing field, but pointers are wrong" << endl; + } +#endif +} + +void FieldCommand::execute() { + if(!m_coll || !m_activeField) { + return; + } + + switch(m_mode) { + case FieldAdd: + // if there's currently a field in the collection with the same name, it will get overwritten + // so save a pointer to it here, the collection should not delete it + m_oldField = m_coll->fieldByName(m_activeField->name()); + m_coll->addField(m_activeField); + Controller::self()->addedField(m_coll, m_activeField); + break; + + case FieldModify: + m_coll->modifyField(m_activeField); + Controller::self()->modifiedField(m_coll, m_oldField, m_activeField); + break; + + case FieldRemove: + m_coll->removeField(m_activeField); + Controller::self()->removedField(m_coll, m_activeField); + break; + } +} + +void FieldCommand::unexecute() { + if(!m_coll || !m_activeField) { + return; + } + + switch(m_mode) { + case FieldAdd: + m_coll->removeField(m_activeField); + Controller::self()->removedField(m_coll, m_activeField); + if(m_oldField) { + m_coll->addField(m_oldField); + Controller::self()->addedField(m_coll, m_oldField); + } + break; + + case FieldModify: + m_coll->modifyField(m_oldField); + Controller::self()->modifiedField(m_coll, m_activeField, m_oldField); + break; + + case FieldRemove: + m_coll->addField(m_activeField); + Controller::self()->addedField(m_coll, m_activeField); + break; + } +} + +QString FieldCommand::name() const { + switch(m_mode) { + case FieldAdd: + return i18n("Add %1 Field").arg(m_activeField->title()); + case FieldModify: + return i18n("Modify %1 Field").arg(m_activeField->title()); + case FieldRemove: + return i18n("Delete %1 Field").arg(m_activeField->title()); + } + // hush warnings + return QString::null; +} diff --git a/src/commands/fieldcommand.h b/src/commands/fieldcommand.h new file mode 100644 index 0000000..0e5706f --- /dev/null +++ b/src/commands/fieldcommand.h @@ -0,0 +1,52 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_FIELDCOMMAND_H +#define TELLICO_FIELDCOMMAND_H + +#include "../datavectors.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class FieldCommand : public KCommand { + +public: + enum Mode { + FieldAdd, + FieldModify, + FieldRemove + }; + + FieldCommand(Mode mode, Data::CollPtr coll, Data::FieldPtr activeField, Data::FieldPtr oldField=0); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Mode m_mode; + Data::CollPtr m_coll; + Data::FieldPtr m_activeField; + Data::FieldPtr m_oldField; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/filtercommand.cpp b/src/commands/filtercommand.cpp new file mode 100644 index 0000000..ba205e5 --- /dev/null +++ b/src/commands/filtercommand.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "filtercommand.h" +#include "../document.h" +#include "../collection.h" +#include "../controller.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Command::FilterCommand; + +FilterCommand::FilterCommand(Mode mode_, FilterPtr activeFilter_, FilterPtr oldFilter_/*=0*/) + : KCommand() + , m_mode(mode_) + , m_activeFilter(activeFilter_) + , m_oldFilter(oldFilter_) +{ + if(!m_activeFilter) { + myDebug() << "FilterCommand() - null active filter pointer" << endl; + } +#ifndef NDEBUG +// just some sanity checking + if(m_mode == FilterAdd && m_oldFilter != 0) { + myDebug() << "FilterCommand() - adding field, but pointers are wrong" << endl; + } else if(m_mode == FilterModify && m_oldFilter == 0) { + myDebug() << "FilterCommand() - modifying field, but pointers are wrong" << endl; + } else if(m_mode == FilterRemove && m_oldFilter != 0) { + myDebug() << "FilterCommand() - removing field, but pointers are wrong" << endl; + } +#endif +} + +void FilterCommand::execute() { + if(!m_activeFilter) { + return; + } + + switch(m_mode) { + case FilterAdd: + Data::Document::self()->collection()->addFilter(m_activeFilter); + Controller::self()->addedFilter(m_activeFilter); + break; + + case FilterModify: + Data::Document::self()->collection()->removeFilter(m_oldFilter); + Controller::self()->removedFilter(m_oldFilter); + Data::Document::self()->collection()->addFilter(m_activeFilter); + Controller::self()->addedFilter(m_activeFilter); + break; + + case FilterRemove: + Data::Document::self()->collection()->removeFilter(m_activeFilter); + Controller::self()->removedFilter(m_activeFilter); + break; + } +} + +void FilterCommand::unexecute() { + if(!m_activeFilter) { + return; + } + + switch(m_mode) { + case FilterAdd: + Data::Document::self()->collection()->removeFilter(m_activeFilter); + Controller::self()->removedFilter(m_activeFilter); + break; + + case FilterModify: + Data::Document::self()->collection()->removeFilter(m_activeFilter); + Controller::self()->removedFilter(m_activeFilter); + Data::Document::self()->collection()->addFilter(m_oldFilter); + Controller::self()->addedFilter(m_oldFilter); + break; + + case FilterRemove: + Data::Document::self()->collection()->addFilter(m_activeFilter); + Controller::self()->addedFilter(m_activeFilter); + break; + } +} + +QString FilterCommand::name() const { + switch(m_mode) { + case FilterAdd: + return i18n("Add Filter"); + case FilterModify: + return i18n("Modify Filter"); + case FilterRemove: + return i18n("Delete Filter"); + } + // hush warnings + return QString::null; +} diff --git a/src/commands/filtercommand.h b/src/commands/filtercommand.h new file mode 100644 index 0000000..93aa629 --- /dev/null +++ b/src/commands/filtercommand.h @@ -0,0 +1,51 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_FILTERCOMMAND_H +#define TELLICO_FILTERCOMMAND_H + +#include "../datavectors.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class FilterCommand : public KCommand { + +public: + enum Mode { + FilterAdd, + FilterModify, + FilterRemove + }; + + FilterCommand(Mode mode, FilterPtr activeFilter, FilterPtr oldFilter=0); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Mode m_mode; + FilterPtr m_activeFilter; + FilterPtr m_oldFilter; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/group.cpp b/src/commands/group.cpp new file mode 100644 index 0000000..fd9cd76 --- /dev/null +++ b/src/commands/group.cpp @@ -0,0 +1,23 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "group.h" + +using Tellico::Command::Group; + +QString Group::name() const { + if(m_commands.count() == 1) { + return m_commands.getFirst()->name(); + } + return KMacroCommand::name(); +} diff --git a/src/commands/group.h b/src/commands/group.h new file mode 100644 index 0000000..dc87bf9 --- /dev/null +++ b/src/commands/group.h @@ -0,0 +1,38 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_COMMAND_GROUP_H +#define TELLICO_COMMAND_GROUP_H + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class Group : public KMacroCommand { + +public: + Group(const QString& name) : KMacroCommand(name) {} + + virtual QString name() const; + + bool isEmpty() const { return m_commands.count() == 0; } +}; + + } // end namespace +} + +#endif diff --git a/src/commands/modifyentries.cpp b/src/commands/modifyentries.cpp new file mode 100644 index 0000000..895348e --- /dev/null +++ b/src/commands/modifyentries.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "modifyentries.h" +#include "../collection.h" +#include "../controller.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Command::ModifyEntries; + +ModifyEntries::ModifyEntries(Data::CollPtr coll_, const Data::EntryVec& oldEntries_, const Data::EntryVec& newEntries_) + : KCommand() + , m_coll(coll_) + , m_oldEntries(oldEntries_) + , m_entries(newEntries_) + , m_needToSwap(false) +{ +#ifndef NDEBUG + if(m_oldEntries.count() != m_entries.count()) { + kdWarning() << "ModifyEntriesCommand() - unequal number of entries" << endl; + } +#endif +} + +void ModifyEntries::execute() { + if(!m_coll || m_entries.isEmpty()) { + return; + } + if(m_needToSwap) { + swapValues(); + m_needToSwap = false; + } + // loans expose a field named "loaned", and the user might modify that without + // checking in the loan, so verify that. Heavy-handed, yes... + const QString loaned = QString::fromLatin1("loaned"); + bool hasLoanField = m_coll->hasField(loaned); + for(Data::EntryVecIt entry = m_entries.begin(); hasLoanField && entry != m_entries.end(); ++entry) { + if(entry->field(loaned).isEmpty()) { + Data::EntryVec notLoaned; + notLoaned.append(entry); + Controller::self()->slotCheckIn(notLoaned); + } + } + m_coll->updateDicts(m_entries); + Controller::self()->modifiedEntries(m_entries); +} + +void ModifyEntries::unexecute() { + if(!m_coll || m_entries.isEmpty()) { + return; + } + swapValues(); + m_needToSwap = true; + m_coll->updateDicts(m_entries); + Controller::self()->modifiedEntries(m_entries); + //TODO: need to tell edit dialog that it's not modified +} + +QString ModifyEntries::name() const { + return m_entries.count() > 1 ? i18n("Modify Entries") + : i18n("Modify (Entry Title)", "Modify %1").arg(m_entries.begin()->title()); +} + +void ModifyEntries::swapValues() { + // since things like the detailedlistview and the entryiconview hold pointers to the entries + // can't just call Controller::modifiedEntry() on the old pointers + for(size_t i = 0; i < m_entries.count(); ++i) { + // need to swap entry values, not just pointers + // the id gets reset when copying, so need to keep it + long id = m_entries.at(i)->id(); + Data::Entry tmp(*m_entries.at(i)); // tmp id becomes -1 + *m_entries.at(i) = *m_oldEntries.at(i); // id becomes -1 + m_entries.at(i)->setId(id); // id becomes what was originally + *m_oldEntries.at(i) = tmp; // id becomes -1 + } +} diff --git a/src/commands/modifyentries.h b/src/commands/modifyentries.h new file mode 100644 index 0000000..4dfbda1 --- /dev/null +++ b/src/commands/modifyentries.h @@ -0,0 +1,48 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_MODIFYENTRIES_H +#define TELLICO_MODIFYENTRIES_H + +#include "../datavectors.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class ModifyEntries : public KCommand { + +public: + ModifyEntries(Data::CollPtr coll, const Data::EntryVec& oldEntries, const Data::EntryVec& newEntries); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + void swapValues(); + + Data::CollPtr m_coll; + Data::EntryVec m_oldEntries; + Data::EntryVec m_entries; + bool m_needToSwap : 1; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/modifyloans.cpp b/src/commands/modifyloans.cpp new file mode 100644 index 0000000..f8976e4 --- /dev/null +++ b/src/commands/modifyloans.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "modifyloans.h" +#include "../document.h" +#include "../entry.h" +#include "../controller.h" +#include "../calendarhandler.h" + +#include <klocale.h> + +using Tellico::Command::ModifyLoans; + +ModifyLoans::ModifyLoans(Data::LoanPtr oldLoan_, Data::LoanPtr newLoan_, bool addToCalendar_) + : KCommand() + , m_oldLoan(oldLoan_) + , m_newLoan(newLoan_) + , m_addToCalendar(addToCalendar_) +{ +} + +void ModifyLoans::execute() { + if(!m_oldLoan || !m_newLoan) { + return; + } + + Data::BorrowerPtr b = m_oldLoan->borrower(); + b->removeLoan(m_oldLoan); + b->addLoan(m_newLoan); + Controller::self()->modifiedBorrower(b); + + if(m_addToCalendar && !m_oldLoan->inCalendar()) { + Data::LoanVec loans; + loans.append(m_newLoan); + CalendarHandler::addLoans(loans); + } else if(!m_addToCalendar && m_oldLoan->inCalendar()) { + Data::LoanVec loans; + loans.append(m_newLoan); // CalendarHandler checks via uid + CalendarHandler::removeLoans(loans); + } +} + +void ModifyLoans::unexecute() { + if(!m_oldLoan || !m_newLoan) { + return; + } + + Data::BorrowerPtr b = m_oldLoan->borrower(); + b->removeLoan(m_newLoan); + b->addLoan(m_oldLoan); + Controller::self()->modifiedBorrower(b); + + if(m_addToCalendar && !m_oldLoan->inCalendar()) { + Data::LoanVec loans; + loans.append(m_newLoan); + CalendarHandler::removeLoans(loans); + } else if(!m_addToCalendar && m_oldLoan->inCalendar()) { + Data::LoanVec loans; + loans.append(m_oldLoan); + CalendarHandler::addLoans(loans); + } +} + +QString ModifyLoans::name() const { + return i18n("Modify Loan"); +} diff --git a/src/commands/modifyloans.h b/src/commands/modifyloans.h new file mode 100644 index 0000000..6f531ce --- /dev/null +++ b/src/commands/modifyloans.h @@ -0,0 +1,45 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_MODIFYLOANS_H +#define TELLICO_MODIFYLOANS_H + +#include "../borrower.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class ModifyLoans : public KCommand { + +public: + ModifyLoans(Data::LoanPtr oldLoan, Data::LoanPtr newLoan, bool addToCalendar); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Data::LoanPtr m_oldLoan; + Data::LoanPtr m_newLoan; + bool m_addToCalendar : 1; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/removeentries.cpp b/src/commands/removeentries.cpp new file mode 100644 index 0000000..8d77fb6 --- /dev/null +++ b/src/commands/removeentries.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "removeentries.h" +#include "../collection.h" +#include "../controller.h" + +#include <klocale.h> + +using Tellico::Command::RemoveEntries; + +RemoveEntries::RemoveEntries(Data::CollPtr coll_, const Data::EntryVec& entries_) + : KCommand() + , m_coll(coll_) + , m_entries(entries_) +{ +} + +void RemoveEntries::execute() { + if(!m_coll || m_entries.isEmpty()) { + return; + } + + m_coll->removeEntries(m_entries); + Controller::self()->removedEntries(m_entries); +} + +void RemoveEntries::unexecute() { + if(!m_coll || m_entries.isEmpty()) { + return; + } + + m_coll->addEntries(m_entries); + Controller::self()->addedEntries(m_entries); +} + +QString RemoveEntries::name() const { + return m_entries.count() > 1 ? i18n("Delete Entries") + : i18n("Delete (Entry Title)", "Delete %1").arg(m_entries.begin()->title()); +} diff --git a/src/commands/removeentries.h b/src/commands/removeentries.h new file mode 100644 index 0000000..71c5ed4 --- /dev/null +++ b/src/commands/removeentries.h @@ -0,0 +1,44 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_REMOVEENTRIES_H +#define TELLICO_REMOVEENTRIES_H + +#include "../datavectors.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class RemoveEntries : public KCommand { + +public: + RemoveEntries(Data::CollPtr coll, const Data::EntryVec& entries); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Data::CollPtr m_coll; + Data::EntryVec m_entries; +}; + + } // end namespace +} + +#endif 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 : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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()); +} diff --git a/src/commands/removeloans.h b/src/commands/removeloans.h new file mode 100644 index 0000000..5b578b7 --- /dev/null +++ b/src/commands/removeloans.h @@ -0,0 +1,43 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_REMOVELOANS_H +#define TELLICO_REMOVELOANS_H + +#include "../borrower.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class RemoveLoans : public KCommand { + +public: + RemoveLoans(Data::LoanVec loans); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Data::LoanVec m_loans; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/renamecollection.cpp b/src/commands/renamecollection.cpp new file mode 100644 index 0000000..b2fcc39 --- /dev/null +++ b/src/commands/renamecollection.cpp @@ -0,0 +1,46 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "renamecollection.h" +#include "../document.h" +#include "../collection.h" + +#include <klocale.h> + +using Tellico::Command::RenameCollection; + +RenameCollection::RenameCollection(Data::CollPtr coll_, const QString& newTitle_) + : KCommand() + , m_coll(coll_) + , m_newTitle(newTitle_) +{ +} + +void RenameCollection::execute() { + if(!m_coll) { + return; + } + m_oldTitle = m_coll->title(); + Data::Document::self()->renameCollection(m_newTitle); +} + +void RenameCollection::unexecute() { + if(!m_coll) { + return; + } + Data::Document::self()->renameCollection(m_oldTitle); +} + +QString RenameCollection::name() const { + return i18n("Rename Collection"); +} diff --git a/src/commands/renamecollection.h b/src/commands/renamecollection.h new file mode 100644 index 0000000..bdbb64c --- /dev/null +++ b/src/commands/renamecollection.h @@ -0,0 +1,43 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_RENAMECOLLECTION_H +#define TELLICO_RENAMECOLLECTION_H + +#include "../datavectors.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** +@author Robby Stephenson +*/ +class RenameCollection : public KCommand { +public: + RenameCollection(Data::CollPtr coll, const QString& newTitle); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Data::CollPtr m_coll; + QString m_oldTitle; + QString m_newTitle; +}; + + } // end namespace +} // end namespace +#endif diff --git a/src/commands/reorderfields.cpp b/src/commands/reorderfields.cpp new file mode 100644 index 0000000..0c9f7fe --- /dev/null +++ b/src/commands/reorderfields.cpp @@ -0,0 +1,55 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "reorderfields.h" +#include "../collection.h" +#include "../controller.h" +#include "../tellico_debug.h" + +#include <klocale.h> + +using Tellico::Command::ReorderFields; + +ReorderFields::ReorderFields(Data::CollPtr coll_, const Data::FieldVec& oldFields_, + const Data::FieldVec& newFields_) + : KCommand() + , m_coll(coll_) + , m_oldFields(oldFields_) + , m_newFields(newFields_) +{ + if(!m_coll) { + myDebug() << "ReorderFieldsCommand() - null collection pointer" << endl; + } else if(m_oldFields.count() != m_newFields.count()) { + myDebug() << "ReorderFieldsCommand() - unequal number of fields" << endl; + } +} + +void ReorderFields::execute() { + if(!m_coll) { + return; + } + m_coll->reorderFields(m_newFields); + Controller::self()->reorderedFields(m_coll); +} + +void ReorderFields::unexecute() { + if(!m_coll) { + return; + } + m_coll->reorderFields(m_oldFields); + Controller::self()->reorderedFields(m_coll); +} + +QString ReorderFields::name() const { + return i18n("Reorder Fields"); +} diff --git a/src/commands/reorderfields.h b/src/commands/reorderfields.h new file mode 100644 index 0000000..6a59050 --- /dev/null +++ b/src/commands/reorderfields.h @@ -0,0 +1,45 @@ +/*************************************************************************** + copyright : (C) 2005-2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_REORDERFIELDS_H +#define TELLICO_REORDERFIELDS_H + +#include "../datavectors.h" + +#include <kcommand.h> + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class ReorderFields : public KCommand { + +public: + ReorderFields(Data::CollPtr coll, const Data::FieldVec& oldFields, const Data::FieldVec& newFields); + + virtual void execute(); + virtual void unexecute(); + virtual QString name() const; + +private: + Data::CollPtr m_coll; + Data::FieldVec m_oldFields; + Data::FieldVec m_newFields; +}; + + } // end namespace +} + +#endif diff --git a/src/commands/updateentries.cpp b/src/commands/updateentries.cpp new file mode 100644 index 0000000..cb2f850 --- /dev/null +++ b/src/commands/updateentries.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** + copyright : (C) 2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "updateentries.h" +#include "fieldcommand.h" +#include "modifyentries.h" +#include "../collection.h" +#include "../tellico_kernel.h" +#include "../document.h" + +#include <klocale.h> + +using Tellico::Command::UpdateEntries; + +namespace Tellico { + namespace Command { + +class MergeEntries : public KCommand { +public: + MergeEntries(Data::EntryPtr currEntry_, Data::EntryPtr newEntry_, bool overWrite_) : KCommand() + , m_oldEntry(new Data::Entry(*currEntry_)) { + // we merge the entries here instead of in execute() because this + // command is never called without also calling ModifyEntries() + // which takes care of copying the entry values + Data::Collection::mergeEntry(currEntry_, newEntry_, overWrite_); + } + + virtual void execute() {} // does nothing + virtual void unexecute() {} // does nothing + virtual QString name() const { return QString(); } + Data::EntryPtr oldEntry() const { return m_oldEntry; } + +private: + Data::EntryPtr m_oldEntry; +}; + } +} + +UpdateEntries::UpdateEntries(Data::CollPtr coll_, Data::EntryPtr oldEntry_, Data::EntryPtr newEntry_, bool overWrite_) + : Group(i18n("Modify (Entry Title)", "Modify %1").arg(newEntry_->title())) + , m_coll(coll_) + , m_oldEntry(oldEntry_) + , m_newEntry(newEntry_) + , m_overWrite(overWrite_) +{ +} + +void UpdateEntries::execute() { + if(isEmpty()) { + // add commands + // do this here instead of the constructor because several UpdateEntries may be in one command + // and I don't want to add new fields multiple times + + QPair<Data::FieldVec, Data::FieldVec> p = Kernel::self()->mergeFields(m_coll, + m_newEntry->collection()->fields(), + m_newEntry); + Data::FieldVec modifiedFields = p.first; + Data::FieldVec addedFields = p.second; + + for(Data::FieldVec::Iterator field = modifiedFields.begin(); field != modifiedFields.end(); ++field) { + if(m_coll->hasField(field->name())) { + addCommand(new FieldCommand(FieldCommand::FieldModify, m_coll, + field, m_coll->fieldByName(field->name()))); + } + } + + for(Data::FieldVec::Iterator field = addedFields.begin(); field != addedFields.end(); ++field) { + addCommand(new FieldCommand(FieldCommand::FieldAdd, m_coll, field)); + } + + // MergeEntries copies values from m_newEntry into m_oldEntry + // m_oldEntry is in the current collection + // m_newEntry isn't... + MergeEntries* cmd = new MergeEntries(m_oldEntry, m_newEntry, m_overWrite); + addCommand(cmd); + // cmd->oldEntry() returns a copy of m_oldEntry before values were merged + // m_oldEntry has new values + // in the ModifyEntries command, the second entry should be owned by the current + // collection and contain the updated values + // the first one is not owned by current collection + addCommand(new ModifyEntries(m_coll, cmd->oldEntry(), m_oldEntry)); + } + Group::execute(); +} diff --git a/src/commands/updateentries.h b/src/commands/updateentries.h new file mode 100644 index 0000000..feb80e7 --- /dev/null +++ b/src/commands/updateentries.h @@ -0,0 +1,43 @@ +/*************************************************************************** + copyright : (C) 2006 by Robby Stephenson + email : robby@periapsis.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +#ifndef TELLICO_UPDATEENTRIES_H +#define TELLICO_UPDATEENTRIES_H + +#include "group.h" +#include "../datavectors.h" + +namespace Tellico { + namespace Command { + +/** + * @author Robby Stephenson + */ +class UpdateEntries : public Group { + +public: + UpdateEntries(Data::CollPtr coll, Data::EntryPtr oldEntry, Data::EntryPtr newEntry, bool overWrite); + + virtual void execute(); + +private: + Data::CollPtr m_coll; + Data::EntryPtr m_oldEntry; + Data::EntryPtr m_newEntry; + bool m_overWrite : 1; +}; + + } // end namespace +} + +#endif |