kaddressbook

undocmds.h
1/*
2 This file is part of KAddressBook.
3 Copyright (C) 1999 Don Sanders <sanders@kde.org>
4 2005 Tobias Koenig <tokoe@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of TQt, and distribute the resulting executable,
22 without including the source code for TQt in the source distribution.
23*/
24
25#ifndef COMMANDS_H
26#define COMMANDS_H
27
28// Commands for undo/redo functionality.
29
30#include <tqstring.h>
31#include <tqstringlist.h>
32
33#include <tdeabc/addressbook.h>
34#include <tdeabc/addressee.h>
35#include <tdeabc/vcardparser.h> // for KABC_VCARD_ENCODING_FIX define
36
37#include <kcommand.h>
38
39#include "kablock.h"
40
41namespace KAB {
42class Core;
43}
44
45class Command : public KCommand
46{
47 public:
48 Command( TDEABC::AddressBook *addressBook ) { mAddressBook = addressBook; }
49
50 protected:
51 TDEABC::AddressBook *addressBook() const { return mAddressBook; }
52 KABLock *lock() const { return KABLock::self( mAddressBook ); }
53 bool resourceExist( TDEABC::Resource *resource );
54 private:
55 TDEABC::AddressBook* mAddressBook;
56};
57
58class DeleteCommand : public Command
59{
60 public:
61 DeleteCommand( TDEABC::AddressBook *addressBook, const TQStringList &uidList );
62
63 virtual TQString name() const;
64 virtual void unexecute();
65 virtual void execute();
66
67 private:
68 TDEABC::Addressee::List mAddresseeList;
69 TQStringList mUIDList;
70};
71
72class PasteCommand : public Command
73{
74 public:
75 PasteCommand( KAB::Core *core,
76 const TDEABC::Addressee::List &addressees );
77
78 virtual TQString name() const;
79 virtual void unexecute();
80 virtual void execute();
81
82 private:
83 TDEABC::Addressee::List mAddresseeList;
84 KAB::Core *mCore;
85};
86
87class CutCommand : public Command
88{
89 public:
90 CutCommand( TDEABC::AddressBook *addressBook, const TQStringList &uidList );
91
92 virtual TQString name() const;
93 virtual void unexecute();
94 virtual void execute();
95
96 private:
97 TDEABC::Addressee::List mAddresseeList;
98 TQStringList mUIDList;
99#if defined(KABC_VCARD_ENCODING_FIX)
100 TQByteArray mClipText;
101#else
102 TQString mClipText;
103#endif
104 TQString mOldText;
105};
106
107class NewCommand : public Command
108{
109 public:
110 NewCommand( TDEABC::AddressBook *addressBook,
111 const TDEABC::Addressee::List &addressees );
112
113 virtual TQString name() const;
114 virtual void unexecute();
115 virtual void execute();
116
117 private:
118 TDEABC::Addressee::List mAddresseeList;
119};
120
121class EditCommand : public Command
122{
123 public:
124 EditCommand( TDEABC::AddressBook *addressBook, const TDEABC::Addressee &oldAddressee,
125 const TDEABC::Addressee &newAddressee );
126
127 virtual TQString name() const;
128 virtual void unexecute();
129 virtual void execute();
130
131 private:
132 TDEABC::Addressee mOldAddressee;
133 TDEABC::Addressee mNewAddressee;
134};
135
136class CopyToCommand : public Command
137{
138 public:
139 CopyToCommand( TDEABC::AddressBook *addressBook, const TQStringList &uidList,
140 TDEABC::Resource *resource );
141
142 virtual TQString name() const;
143 virtual void unexecute();
144 virtual void execute();
145
146 private:
147 TDEABC::Addressee::List mAddresseeList;
148 TQStringList mUIDList;
149 TDEABC::Resource *mResource;
150};
151
152class MoveToCommand : public Command
153{
154 public:
155 MoveToCommand( KAB::Core *core, const TQStringList &uidList,
156 TDEABC::Resource *resource );
157
158 virtual TQString name() const;
159 virtual void unexecute();
160 virtual void execute();
161 void moveContactTo( TDEABC::Resource *resource );
162
163 private:
164 TDEABC::Addressee::List mAddresseeList;
165 TQStringList mUIDList;
166 TDEABC::Resource *mResource;
167 KAB::Core *mCore;
168};
169#endif