kaddressbook

undocmds.h

00001 /*
00002     This file is part of KAddressBook.
00003     Copyright (C) 1999 Don Sanders <sanders@kde.org>
00004                   2005 Tobias Koenig <tokoe@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of TQt, and distribute the resulting executable,
00022     without including the source code for TQt in the source distribution.
00023 */
00024 
00025 #ifndef COMMANDS_H
00026 #define COMMANDS_H
00027 
00028 // Commands for undo/redo functionality.
00029 
00030 #include <tqstring.h>
00031 #include <tqstringlist.h>
00032 
00033 #include <kabc/addressbook.h>
00034 #include <kabc/addressee.h>
00035 #include <kabc/vcardparser.h> // for KABC_VCARD_ENCODING_FIX define
00036 
00037 #include <kcommand.h>
00038 
00039 #include "kablock.h"
00040 
00041 namespace KAB {
00042 class Core;
00043 }
00044 
00045 class Command : public KCommand
00046 {
00047   public:
00048     Command( KABC::AddressBook *addressBook ) { mAddressBook = addressBook; }
00049 
00050   protected:
00051     KABC::AddressBook *addressBook() const { return mAddressBook; }
00052     KABLock *lock() const { return KABLock::self( mAddressBook ); }
00053   bool resourceExist( KABC::Resource *resource );
00054   private:
00055     KABC::AddressBook* mAddressBook;
00056 };
00057 
00058 class DeleteCommand : public Command
00059 {
00060   public:
00061     DeleteCommand( KABC::AddressBook *addressBook, const TQStringList &uidList );
00062 
00063     virtual TQString name() const;
00064     virtual void unexecute();
00065     virtual void execute();
00066 
00067   private:
00068     KABC::Addressee::List mAddresseeList;
00069     TQStringList mUIDList;
00070 };
00071 
00072 class PasteCommand : public Command
00073 {
00074   public:
00075     PasteCommand( KAB::Core *core,
00076                   const KABC::Addressee::List &addressees );
00077 
00078     virtual TQString name() const;
00079     virtual void unexecute();
00080     virtual void execute();
00081 
00082   private:
00083     KABC::Addressee::List mAddresseeList;
00084     KAB::Core *mCore;
00085 };
00086 
00087 class CutCommand : public Command
00088 {
00089   public:
00090     CutCommand( KABC::AddressBook *addressBook, const TQStringList &uidList );
00091 
00092     virtual TQString name() const;
00093     virtual void unexecute();
00094     virtual void execute();
00095 
00096   private:
00097     KABC::Addressee::List mAddresseeList;
00098     TQStringList mUIDList;
00099 #if defined(KABC_VCARD_ENCODING_FIX)
00100     TQByteArray mClipText;
00101 #else
00102     TQString mClipText;
00103 #endif
00104     TQString mOldText;
00105 };
00106 
00107 class NewCommand : public Command
00108 {
00109   public:
00110     NewCommand( KABC::AddressBook *addressBook,
00111                 const KABC::Addressee::List &addressees );
00112 
00113     virtual TQString name() const;
00114     virtual void unexecute();
00115     virtual void execute();
00116 
00117   private:
00118     KABC::Addressee::List mAddresseeList;
00119 };
00120 
00121 class EditCommand : public Command
00122 {
00123   public:
00124     EditCommand( KABC::AddressBook *addressBook, const KABC::Addressee &oldAddressee,
00125                  const KABC::Addressee &newAddressee );
00126 
00127     virtual TQString name() const;
00128     virtual void unexecute();
00129     virtual void execute();
00130 
00131   private:
00132     KABC::Addressee mOldAddressee;
00133     KABC::Addressee mNewAddressee;
00134 };
00135 
00136 class CopyToCommand : public Command
00137 {
00138     public:
00139         CopyToCommand( KABC::AddressBook *addressBook, const TQStringList &uidList,
00140                                KABC::Resource *resource );
00141 
00142         virtual TQString name() const;
00143         virtual void unexecute();
00144         virtual void execute();
00145 
00146     private:
00147         KABC::Addressee::List mAddresseeList;
00148         TQStringList mUIDList;
00149         KABC::Resource *mResource;
00150 };
00151 
00152 class MoveToCommand : public Command
00153 {
00154     public:
00155         MoveToCommand( KAB::Core *core, const TQStringList &uidList,
00156                                KABC::Resource *resource );
00157 
00158         virtual TQString name() const;
00159         virtual void unexecute();
00160         virtual void execute();
00161         void moveContactTo( KABC::Resource *resource );
00162 
00163     private:
00164         KABC::Addressee::List mAddresseeList;
00165         TQStringList mUIDList;
00166         KABC::Resource *mResource;
00167         KAB::Core *mCore;
00168 };
00169 #endif