-rw-r--r-- | kabc/addressbook.h | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 3383fc0..3a8e028 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,337 +1,327 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #ifndef KAB_EMBEDDED | ||
37 | |||
38 | #else //KAB_EMBEDDED | ||
39 | #endif //KAB_EMBEDDED | ||
40 | |||
41 | |||
42 | #include "addressee.h" | 36 | #include "addressee.h" |
43 | #include "field.h" | 37 | #include "field.h" |
44 | 38 | ||
45 | namespace KABC { | 39 | namespace KABC { |
46 | 40 | ||
47 | class ErrorHandler; | 41 | class ErrorHandler; |
48 | class Resource; | 42 | class Resource; |
49 | class Ticket; | 43 | class Ticket; |
50 | 44 | ||
51 | /** | 45 | /** |
52 | @short Address Book | 46 | @short Address Book |
53 | 47 | ||
54 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
55 | */ | 49 | */ |
56 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
57 | { | 51 | { |
58 | Q_OBJECT | 52 | Q_OBJECT |
59 | 53 | ||
60 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
61 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
62 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
63 | 57 | ||
64 | public: | 58 | public: |
65 | /** | 59 | /** |
66 | @short Address Book Iterator | 60 | @short Address Book Iterator |
67 | 61 | ||
68 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
69 | */ | 63 | */ |
70 | class Iterator | 64 | class Iterator |
71 | { | 65 | { |
72 | public: | 66 | public: |
73 | Iterator(); | 67 | Iterator(); |
74 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
75 | ~Iterator(); | 69 | ~Iterator(); |
76 | 70 | ||
77 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
78 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
79 | Addressee &operator*(); | 73 | Addressee &operator*(); |
80 | Addressee* operator->(); | 74 | Addressee* operator->(); |
81 | Iterator &operator++(); | 75 | Iterator &operator++(); |
82 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
83 | Iterator &operator--(); | 77 | Iterator &operator--(); |
84 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
85 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
86 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
87 | 81 | ||
88 | struct IteratorData; | 82 | struct IteratorData; |
89 | IteratorData *d; | 83 | IteratorData *d; |
90 | }; | 84 | }; |
91 | 85 | ||
92 | /** | 86 | /** |
93 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
94 | 88 | ||
95 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
96 | */ | 90 | */ |
97 | class ConstIterator | 91 | class ConstIterator |
98 | { | 92 | { |
99 | public: | 93 | public: |
100 | ConstIterator(); | 94 | ConstIterator(); |
101 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
102 | ~ConstIterator(); | 96 | ~ConstIterator(); |
103 | 97 | ||
104 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
105 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
106 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
107 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
108 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
109 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
110 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
111 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
112 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
113 | 107 | ||
114 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
115 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
116 | }; | 110 | }; |
117 | 111 | ||
118 | /** | 112 | /** |
119 | Constructs a address book object. | 113 | Constructs a address book object. |
120 | 114 | ||
121 | @param format File format class. | 115 | @param format File format class. |
122 | */ | 116 | */ |
123 | AddressBook(); | 117 | AddressBook(); |
124 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
125 | virtual ~AddressBook(); | 119 | virtual ~AddressBook(); |
126 | 120 | ||
127 | /** | 121 | /** |
128 | Requests a ticket for saving the addressbook. Calling this function locks | 122 | Requests a ticket for saving the addressbook. Calling this function locks |
129 | the addressbook for all other processes. If the address book is already | 123 | the addressbook for all other processes. If the address book is already |
130 | locked the function returns 0. You need the returned @ref Ticket object | 124 | locked the function returns 0. You need the returned @ref Ticket object |
131 | for calling the @ref save() function. | 125 | for calling the @ref save() function. |
132 | 126 | ||
133 | @see save() | 127 | @see save() |
134 | */ | 128 | */ |
135 | Ticket *requestSaveTicket( Resource *resource=0 ); | 129 | Ticket *requestSaveTicket( Resource *resource=0 ); |
136 | 130 | ||
137 | /** | 131 | /** |
138 | Load address book from file. | 132 | Load address book from file. |
139 | */ | 133 | */ |
140 | bool load(); | 134 | bool load(); |
141 | 135 | ||
142 | /** | 136 | /** |
143 | Save address book. The address book is saved to the file, the Ticket | 137 | Save address book. The address book is saved to the file, the Ticket |
144 | object has been requested for by @ref requestSaveTicket(). | 138 | object has been requested for by @ref requestSaveTicket(). |
145 | 139 | ||
146 | @param ticket a ticket object returned by @ref requestSaveTicket() | 140 | @param ticket a ticket object returned by @ref requestSaveTicket() |
147 | */ | 141 | */ |
148 | bool save( Ticket *ticket ); | 142 | bool save( Ticket *ticket ); |
149 | 143 | ||
150 | /** | 144 | /** |
151 | Returns a iterator for first entry of address book. | 145 | Returns a iterator for first entry of address book. |
152 | */ | 146 | */ |
153 | Iterator begin(); | 147 | Iterator begin(); |
154 | 148 | ||
155 | /** | 149 | /** |
156 | Returns a const iterator for first entry of address book. | 150 | Returns a const iterator for first entry of address book. |
157 | */ | 151 | */ |
158 | ConstIterator begin() const; | 152 | ConstIterator begin() const; |
159 | 153 | ||
160 | /** | 154 | /** |
161 | Returns a iterator for first entry of address book. | 155 | Returns a iterator for first entry of address book. |
162 | */ | 156 | */ |
163 | Iterator end(); | 157 | Iterator end(); |
164 | 158 | ||
165 | /** | 159 | /** |
166 | Returns a const iterator for first entry of address book. | 160 | Returns a const iterator for first entry of address book. |
167 | */ | 161 | */ |
168 | ConstIterator end() const; | 162 | ConstIterator end() const; |
169 | 163 | ||
170 | /** | 164 | /** |
171 | Removes all entries from address book. | 165 | Removes all entries from address book. |
172 | */ | 166 | */ |
173 | void clear(); | 167 | void clear(); |
174 | 168 | ||
175 | /** | 169 | /** |
176 | Insert an Addressee object into address book. If an object with the same | 170 | Insert an Addressee object into address book. If an object with the same |
177 | unique id already exists in the address book it it replaced by the new | 171 | unique id already exists in the address book it it replaced by the new |
178 | one. If not the new object is appended to the address book. | 172 | one. If not the new object is appended to the address book. |
179 | */ | 173 | */ |
180 | void insertAddressee( const Addressee & ); | 174 | void insertAddressee( const Addressee & ); |
181 | 175 | ||
182 | /** | 176 | /** |
183 | Removes entry from the address book. | 177 | Removes entry from the address book. |
184 | */ | 178 | */ |
185 | void removeAddressee( const Addressee & ); | 179 | void removeAddressee( const Addressee & ); |
186 | 180 | ||
187 | /** | 181 | /** |
188 | This is like @ref removeAddressee() just above, with the difference that | 182 | This is like @ref removeAddressee() just above, with the difference that |
189 | the first element is a iterator, returned by @ref begin(). | 183 | the first element is a iterator, returned by @ref begin(). |
190 | */ | 184 | */ |
191 | void removeAddressee( const Iterator & ); | 185 | void removeAddressee( const Iterator & ); |
192 | 186 | ||
193 | /** | 187 | /** |
194 | Find the specified entry in address book. Returns end(), if the entry | 188 | Find the specified entry in address book. Returns end(), if the entry |
195 | couldn't be found. | 189 | couldn't be found. |
196 | */ | 190 | */ |
197 | Iterator find( const Addressee & ); | 191 | Iterator find( const Addressee & ); |
198 | 192 | ||
199 | /** | 193 | /** |
200 | Find the entry specified by an unique id. Returns an empty Addressee | 194 | Find the entry specified by an unique id. Returns an empty Addressee |
201 | object, if the address book does not contain an entry with this id. | 195 | object, if the address book does not contain an entry with this id. |
202 | */ | 196 | */ |
203 | Addressee findByUid( const QString & ); | 197 | Addressee findByUid( const QString & ); |
204 | 198 | ||
205 | 199 | ||
206 | /** | 200 | /** |
207 | Returns a list of all addressees in the address book. This list can | 201 | Returns a list of all addressees in the address book. This list can |
208 | be sorted with @ref KABC::AddresseeList for example. | 202 | be sorted with @ref KABC::AddresseeList for example. |
209 | */ | 203 | */ |
210 | Addressee::List allAddressees(); | 204 | Addressee::List allAddressees(); |
211 | 205 | ||
212 | /** | 206 | /** |
213 | Find all entries with the specified name in the address book. Returns | 207 | Find all entries with the specified name in the address book. Returns |
214 | an empty list, if no entries could be found. | 208 | an empty list, if no entries could be found. |
215 | */ | 209 | */ |
216 | Addressee::List findByName( const QString & ); | 210 | Addressee::List findByName( const QString & ); |
217 | 211 | ||
218 | /** | 212 | /** |
219 | Find all entries with the specified email address in the address book. | 213 | Find all entries with the specified email address in the address book. |
220 | Returns an empty list, if no entries could be found. | 214 | Returns an empty list, if no entries could be found. |
221 | */ | 215 | */ |
222 | Addressee::List findByEmail( const QString & ); | 216 | Addressee::List findByEmail( const QString & ); |
223 | 217 | ||
224 | /** | 218 | /** |
225 | Find all entries wich have the specified category in the address book. | 219 | Find all entries wich have the specified category in the address book. |
226 | Returns an empty list, if no entries could be found. | 220 | Returns an empty list, if no entries could be found. |
227 | */ | 221 | */ |
228 | Addressee::List findByCategory( const QString & ); | 222 | Addressee::List findByCategory( const QString & ); |
229 | 223 | ||
230 | /** | 224 | /** |
231 | Return a string identifying this addressbook. | 225 | Return a string identifying this addressbook. |
232 | */ | 226 | */ |
233 | virtual QString identifier(); | 227 | virtual QString identifier(); |
234 | 228 | ||
235 | /** | 229 | /** |
236 | Used for debug output. | 230 | Used for debug output. |
237 | */ | 231 | */ |
238 | void dump() const; | 232 | void dump() const; |
239 | 233 | ||
240 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 234 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
241 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 235 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
242 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 236 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
243 | 237 | ||
244 | /** | 238 | /** |
245 | Return list of all Fields known to the address book which are associated | 239 | Return list of all Fields known to the address book which are associated |
246 | with the given field category. | 240 | with the given field category. |
247 | */ | 241 | */ |
248 | Field::List fields( int category = Field::All ); | 242 | Field::List fields( int category = Field::All ); |
249 | 243 | ||
250 | /** | 244 | /** |
251 | Add custom field to address book. | 245 | Add custom field to address book. |
252 | 246 | ||
253 | @param label User visible label of the field. | 247 | @param label User visible label of the field. |
254 | @param category Ored list of field categories. | 248 | @param category Ored list of field categories. |
255 | @param key Identifier used as key for reading and writing the field. | 249 | @param key Identifier used as key for reading and writing the field. |
256 | @param app String used as application key for reading and writing | 250 | @param app String used as application key for reading and writing |
257 | the field. | 251 | the field. |
258 | */ | 252 | */ |
259 | bool addCustomField( const QString &label, int category = Field::All, | 253 | bool addCustomField( const QString &label, int category = Field::All, |
260 | const QString &key = QString::null, | 254 | const QString &key = QString::null, |
261 | const QString &app = QString::null ); | 255 | const QString &app = QString::null ); |
262 | 256 | ||
263 | 257 | ||
264 | /** | 258 | /** |
265 | Add address book resource. | 259 | Add address book resource. |
266 | */ | 260 | */ |
267 | bool addResource( Resource * ); | 261 | bool addResource( Resource * ); |
268 | 262 | ||
269 | /** | 263 | /** |
270 | Remove address book resource. | 264 | Remove address book resource. |
271 | */ | 265 | */ |
272 | bool removeResource( Resource * ); | 266 | bool removeResource( Resource * ); |
273 | 267 | ||
274 | /** | 268 | /** |
275 | Return pointer list of all resources. | 269 | Return pointer list of all resources. |
276 | */ | 270 | */ |
277 | QPtrList<Resource> resources(); | 271 | QPtrList<Resource> resources(); |
278 | 272 | ||
279 | /** | 273 | /** |
280 | Set the @p ErrorHandler, that is used by @ref error() to | 274 | Set the @p ErrorHandler, that is used by @ref error() to |
281 | provide gui-independend error messages. | 275 | provide gui-independend error messages. |
282 | */ | 276 | */ |
283 | void setErrorHandler( ErrorHandler * ); | 277 | void setErrorHandler( ErrorHandler * ); |
284 | 278 | ||
285 | /** | 279 | /** |
286 | Shows gui independend error messages. | 280 | Shows gui independend error messages. |
287 | */ | 281 | */ |
288 | void error( const QString& ); | 282 | void error( const QString& ); |
289 | 283 | ||
290 | /** | 284 | /** |
291 | Query all resources to clean up their lock files | 285 | Query all resources to clean up their lock files |
292 | */ | 286 | */ |
293 | void cleanUp(); | 287 | void cleanUp(); |
294 | 288 | ||
295 | signals: | 289 | signals: |
296 | /** | 290 | /** |
297 | Emitted, when the address book has changed on disk. | 291 | Emitted, when the address book has changed on disk. |
298 | */ | 292 | */ |
299 | void addressBookChanged( AddressBook * ); | 293 | void addressBookChanged( AddressBook * ); |
300 | 294 | ||
301 | /** | 295 | /** |
302 | Emitted, when the address book has been locked for writing. | 296 | Emitted, when the address book has been locked for writing. |
303 | */ | 297 | */ |
304 | void addressBookLocked( AddressBook * ); | 298 | void addressBookLocked( AddressBook * ); |
305 | 299 | ||
306 | /** | 300 | /** |
307 | Emitted, when the address book has been unlocked. | 301 | Emitted, when the address book has been unlocked. |
308 | */ | 302 | */ |
309 | void addressBookUnlocked( AddressBook * ); | 303 | void addressBookUnlocked( AddressBook * ); |
310 | 304 | ||
311 | protected: | 305 | protected: |
312 | void deleteRemovedAddressees(); | 306 | void deleteRemovedAddressees(); |
313 | void setStandardResource( Resource * ); | 307 | void setStandardResource( Resource * ); |
314 | Resource *standardResource(); | 308 | Resource *standardResource(); |
315 | KRES::Manager<Resource> *resourceManager(); | 309 | KRES::Manager<Resource> *resourceManager(); |
316 | 310 | ||
317 | private: | 311 | private: |
318 | #ifndef KAB_EMBEDDED | 312 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
319 | QPtrList<Resource> mDummy; // Remove in KDE 4 | ||
320 | #endif //KAB_EMBEDDED | ||
321 | 313 | ||
322 | #ifdef KAB_EMBEDDED | ||
323 | //US optimization | 314 | //US optimization |
324 | void init(const QString &config); | 315 | void init(const QString &config); |
325 | #endif //KAB_EMBEDDED | ||
326 | 316 | ||
327 | 317 | ||
328 | struct AddressBookData; | 318 | struct AddressBookData; |
329 | AddressBookData *d; | 319 | AddressBookData *d; |
330 | }; | 320 | }; |
331 | 321 | ||
332 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 322 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
333 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 323 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
334 | 324 | ||
335 | } | 325 | } |
336 | 326 | ||
337 | #endif | 327 | #endif |