-rw-r--r-- | kabc/addressbook.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index f89d7da..e43de31 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,327 +1,328 @@ | |||
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 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | ||
144 | 145 | ||
145 | /** | 146 | /** |
146 | Returns a iterator for first entry of address book. | 147 | Returns a iterator for first entry of address book. |
147 | */ | 148 | */ |
148 | Iterator begin(); | 149 | Iterator begin(); |
149 | 150 | ||
150 | /** | 151 | /** |
151 | Returns a const iterator for first entry of address book. | 152 | Returns a const iterator for first entry of address book. |
152 | */ | 153 | */ |
153 | ConstIterator begin() const; | 154 | ConstIterator begin() const; |
154 | 155 | ||
155 | /** | 156 | /** |
156 | Returns a iterator for first entry of address book. | 157 | Returns a iterator for first entry of address book. |
157 | */ | 158 | */ |
158 | Iterator end(); | 159 | Iterator end(); |
159 | 160 | ||
160 | /** | 161 | /** |
161 | Returns a const iterator for first entry of address book. | 162 | Returns a const iterator for first entry of address book. |
162 | */ | 163 | */ |
163 | ConstIterator end() const; | 164 | ConstIterator end() const; |
164 | 165 | ||
165 | /** | 166 | /** |
166 | Removes all entries from address book. | 167 | Removes all entries from address book. |
167 | */ | 168 | */ |
168 | void clear(); | 169 | void clear(); |
169 | 170 | ||
170 | /** | 171 | /** |
171 | Insert an Addressee object into address book. If an object with the same | 172 | Insert an Addressee object into address book. If an object with the same |
172 | unique id already exists in the address book it it replaced by the new | 173 | unique id already exists in the address book it it replaced by the new |
173 | one. If not the new object is appended to the address book. | 174 | one. If not the new object is appended to the address book. |
174 | */ | 175 | */ |
175 | void insertAddressee( const Addressee & ); | 176 | void insertAddressee( const Addressee & ); |
176 | 177 | ||
177 | /** | 178 | /** |
178 | Removes entry from the address book. | 179 | Removes entry from the address book. |
179 | */ | 180 | */ |
180 | void removeAddressee( const Addressee & ); | 181 | void removeAddressee( const Addressee & ); |
181 | 182 | ||
182 | /** | 183 | /** |
183 | This is like @ref removeAddressee() just above, with the difference that | 184 | This is like @ref removeAddressee() just above, with the difference that |
184 | the first element is a iterator, returned by @ref begin(). | 185 | the first element is a iterator, returned by @ref begin(). |
185 | */ | 186 | */ |
186 | void removeAddressee( const Iterator & ); | 187 | void removeAddressee( const Iterator & ); |
187 | 188 | ||
188 | /** | 189 | /** |
189 | Find the specified entry in address book. Returns end(), if the entry | 190 | Find the specified entry in address book. Returns end(), if the entry |
190 | couldn't be found. | 191 | couldn't be found. |
191 | */ | 192 | */ |
192 | Iterator find( const Addressee & ); | 193 | Iterator find( const Addressee & ); |
193 | 194 | ||
194 | /** | 195 | /** |
195 | Find the entry specified by an unique id. Returns an empty Addressee | 196 | Find the entry specified by an unique id. Returns an empty Addressee |
196 | object, if the address book does not contain an entry with this id. | 197 | object, if the address book does not contain an entry with this id. |
197 | */ | 198 | */ |
198 | Addressee findByUid( const QString & ); | 199 | Addressee findByUid( const QString & ); |
199 | 200 | ||
200 | 201 | ||
201 | /** | 202 | /** |
202 | Returns a list of all addressees in the address book. This list can | 203 | Returns a list of all addressees in the address book. This list can |
203 | be sorted with @ref KABC::AddresseeList for example. | 204 | be sorted with @ref KABC::AddresseeList for example. |
204 | */ | 205 | */ |
205 | Addressee::List allAddressees(); | 206 | Addressee::List allAddressees(); |
206 | 207 | ||
207 | /** | 208 | /** |
208 | Find all entries with the specified name in the address book. Returns | 209 | Find all entries with the specified name in the address book. Returns |
209 | an empty list, if no entries could be found. | 210 | an empty list, if no entries could be found. |
210 | */ | 211 | */ |
211 | Addressee::List findByName( const QString & ); | 212 | Addressee::List findByName( const QString & ); |
212 | 213 | ||
213 | /** | 214 | /** |
214 | Find all entries with the specified email address in the address book. | 215 | Find all entries with the specified email address in the address book. |
215 | Returns an empty list, if no entries could be found. | 216 | Returns an empty list, if no entries could be found. |
216 | */ | 217 | */ |
217 | Addressee::List findByEmail( const QString & ); | 218 | Addressee::List findByEmail( const QString & ); |
218 | 219 | ||
219 | /** | 220 | /** |
220 | Find all entries wich have the specified category in the address book. | 221 | Find all entries wich have the specified category in the address book. |
221 | Returns an empty list, if no entries could be found. | 222 | Returns an empty list, if no entries could be found. |
222 | */ | 223 | */ |
223 | Addressee::List findByCategory( const QString & ); | 224 | Addressee::List findByCategory( const QString & ); |
224 | 225 | ||
225 | /** | 226 | /** |
226 | Return a string identifying this addressbook. | 227 | Return a string identifying this addressbook. |
227 | */ | 228 | */ |
228 | virtual QString identifier(); | 229 | virtual QString identifier(); |
229 | 230 | ||
230 | /** | 231 | /** |
231 | Used for debug output. | 232 | Used for debug output. |
232 | */ | 233 | */ |
233 | void dump() const; | 234 | void dump() const; |
234 | 235 | ||
235 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 236 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
236 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 237 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
237 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 238 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
238 | 239 | ||
239 | /** | 240 | /** |
240 | Return list of all Fields known to the address book which are associated | 241 | Return list of all Fields known to the address book which are associated |
241 | with the given field category. | 242 | with the given field category. |
242 | */ | 243 | */ |
243 | Field::List fields( int category = Field::All ); | 244 | Field::List fields( int category = Field::All ); |
244 | 245 | ||
245 | /** | 246 | /** |
246 | Add custom field to address book. | 247 | Add custom field to address book. |
247 | 248 | ||
248 | @param label User visible label of the field. | 249 | @param label User visible label of the field. |
249 | @param category Ored list of field categories. | 250 | @param category Ored list of field categories. |
250 | @param key Identifier used as key for reading and writing the field. | 251 | @param key Identifier used as key for reading and writing the field. |
251 | @param app String used as application key for reading and writing | 252 | @param app String used as application key for reading and writing |
252 | the field. | 253 | the field. |
253 | */ | 254 | */ |
254 | bool addCustomField( const QString &label, int category = Field::All, | 255 | bool addCustomField( const QString &label, int category = Field::All, |
255 | const QString &key = QString::null, | 256 | const QString &key = QString::null, |
256 | const QString &app = QString::null ); | 257 | const QString &app = QString::null ); |
257 | 258 | ||
258 | 259 | ||
259 | /** | 260 | /** |
260 | Add address book resource. | 261 | Add address book resource. |
261 | */ | 262 | */ |
262 | bool addResource( Resource * ); | 263 | bool addResource( Resource * ); |
263 | 264 | ||
264 | /** | 265 | /** |
265 | Remove address book resource. | 266 | Remove address book resource. |
266 | */ | 267 | */ |
267 | bool removeResource( Resource * ); | 268 | bool removeResource( Resource * ); |
268 | 269 | ||
269 | /** | 270 | /** |
270 | Return pointer list of all resources. | 271 | Return pointer list of all resources. |
271 | */ | 272 | */ |
272 | QPtrList<Resource> resources(); | 273 | QPtrList<Resource> resources(); |
273 | 274 | ||
274 | /** | 275 | /** |
275 | Set the @p ErrorHandler, that is used by @ref error() to | 276 | Set the @p ErrorHandler, that is used by @ref error() to |
276 | provide gui-independend error messages. | 277 | provide gui-independend error messages. |
277 | */ | 278 | */ |
278 | void setErrorHandler( ErrorHandler * ); | 279 | void setErrorHandler( ErrorHandler * ); |
279 | 280 | ||
280 | /** | 281 | /** |
281 | Shows gui independend error messages. | 282 | Shows gui independend error messages. |
282 | */ | 283 | */ |
283 | void error( const QString& ); | 284 | void error( const QString& ); |
284 | 285 | ||
285 | /** | 286 | /** |
286 | Query all resources to clean up their lock files | 287 | Query all resources to clean up their lock files |
287 | */ | 288 | */ |
288 | void cleanUp(); | 289 | void cleanUp(); |
289 | 290 | ||
290 | signals: | 291 | signals: |
291 | /** | 292 | /** |
292 | Emitted, when the address book has changed on disk. | 293 | Emitted, when the address book has changed on disk. |
293 | */ | 294 | */ |
294 | void addressBookChanged( AddressBook * ); | 295 | void addressBookChanged( AddressBook * ); |
295 | 296 | ||
296 | /** | 297 | /** |
297 | Emitted, when the address book has been locked for writing. | 298 | Emitted, when the address book has been locked for writing. |
298 | */ | 299 | */ |
299 | void addressBookLocked( AddressBook * ); | 300 | void addressBookLocked( AddressBook * ); |
300 | 301 | ||
301 | /** | 302 | /** |
302 | Emitted, when the address book has been unlocked. | 303 | Emitted, when the address book has been unlocked. |
303 | */ | 304 | */ |
304 | void addressBookUnlocked( AddressBook * ); | 305 | void addressBookUnlocked( AddressBook * ); |
305 | 306 | ||
306 | protected: | 307 | protected: |
307 | void deleteRemovedAddressees(); | 308 | void deleteRemovedAddressees(); |
308 | void setStandardResource( Resource * ); | 309 | void setStandardResource( Resource * ); |
309 | Resource *standardResource(); | 310 | Resource *standardResource(); |
310 | KRES::Manager<Resource> *resourceManager(); | 311 | KRES::Manager<Resource> *resourceManager(); |
311 | 312 | ||
312 | void init(const QString &config, const QString &family); | 313 | void init(const QString &config, const QString &family); |
313 | 314 | ||
314 | private: | 315 | private: |
315 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 316 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
316 | 317 | ||
317 | 318 | ||
318 | struct AddressBookData; | 319 | struct AddressBookData; |
319 | AddressBookData *d; | 320 | AddressBookData *d; |
320 | }; | 321 | }; |
321 | 322 | ||
322 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 323 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
323 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 324 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
324 | 325 | ||
325 | } | 326 | } |
326 | 327 | ||
327 | #endif | 328 | #endif |