-rw-r--r-- | kabc/addressbook.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 97bd3ef..0838157 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -158,193 +158,193 @@ AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | |||
158 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 158 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
159 | { | 159 | { |
160 | if( this == &i ) return *this; // guard for self assignment | 160 | if( this == &i ) return *this; // guard for self assignment |
161 | delete d; // delete the old data because the Iterator was really constructed before | 161 | delete d; // delete the old data because the Iterator was really constructed before |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | return *this; | 164 | return *this; |
165 | } | 165 | } |
166 | 166 | ||
167 | AddressBook::ConstIterator::~ConstIterator() | 167 | AddressBook::ConstIterator::~ConstIterator() |
168 | { | 168 | { |
169 | delete d; | 169 | delete d; |
170 | } | 170 | } |
171 | 171 | ||
172 | const Addressee &AddressBook::ConstIterator::operator*() const | 172 | const Addressee &AddressBook::ConstIterator::operator*() const |
173 | { | 173 | { |
174 | return *(d->mIt); | 174 | return *(d->mIt); |
175 | } | 175 | } |
176 | 176 | ||
177 | const Addressee* AddressBook::ConstIterator::operator->() const | 177 | const Addressee* AddressBook::ConstIterator::operator->() const |
178 | { | 178 | { |
179 | return &(*(d->mIt)); | 179 | return &(*(d->mIt)); |
180 | } | 180 | } |
181 | 181 | ||
182 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 182 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
183 | { | 183 | { |
184 | (d->mIt)++; | 184 | (d->mIt)++; |
185 | return *this; | 185 | return *this; |
186 | } | 186 | } |
187 | 187 | ||
188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
189 | { | 189 | { |
190 | (d->mIt)++; | 190 | (d->mIt)++; |
191 | return *this; | 191 | return *this; |
192 | } | 192 | } |
193 | 193 | ||
194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
195 | { | 195 | { |
196 | (d->mIt)--; | 196 | (d->mIt)--; |
197 | return *this; | 197 | return *this; |
198 | } | 198 | } |
199 | 199 | ||
200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
201 | { | 201 | { |
202 | (d->mIt)--; | 202 | (d->mIt)--; |
203 | return *this; | 203 | return *this; |
204 | } | 204 | } |
205 | 205 | ||
206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
207 | { | 207 | { |
208 | return ( d->mIt == it.d->mIt ); | 208 | return ( d->mIt == it.d->mIt ); |
209 | } | 209 | } |
210 | 210 | ||
211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
212 | { | 212 | { |
213 | return ( d->mIt != it.d->mIt ); | 213 | return ( d->mIt != it.d->mIt ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | AddressBook::AddressBook() | 217 | AddressBook::AddressBook() |
218 | { | 218 | { |
219 | init(0); | 219 | init(0); |
220 | } | 220 | } |
221 | 221 | ||
222 | AddressBook::AddressBook( const QString &config ) | 222 | AddressBook::AddressBook( const QString &config ) |
223 | { | 223 | { |
224 | init(config); | 224 | init(config); |
225 | } | 225 | } |
226 | 226 | ||
227 | void AddressBook::init(const QString &config) | 227 | void AddressBook::init(const QString &config) |
228 | { | 228 | { |
229 | d = new AddressBookData; | 229 | d = new AddressBookData; |
230 | if (config != 0) { | 230 | if (config != 0) { |
231 | d->mConfig = new KConfig( config ); | 231 | d->mConfig = new KConfig( config ); |
232 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 232 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
233 | } | 233 | } |
234 | else { | 234 | else { |
235 | d->mConfig = 0; | 235 | d->mConfig = 0; |
236 | // qDebug("AddressBook::init 1 config=0"); | 236 | // qDebug("AddressBook::init 1 config=0"); |
237 | } | 237 | } |
238 | 238 | ||
239 | //US d->mErrorHandler = 0; | 239 | //US d->mErrorHandler = 0; |
240 | d->mManager = new KRES::Manager<Resource>( "contact" ); | 240 | d->mManager = new KRES::Manager<Resource>( "contact" ); |
241 | d->mManager->readConfig( d->mConfig ); | 241 | d->mManager->readConfig( d->mConfig ); |
242 | } | 242 | } |
243 | 243 | ||
244 | AddressBook::~AddressBook() | 244 | AddressBook::~AddressBook() |
245 | { | 245 | { |
246 | delete d->mConfig; d->mConfig = 0; | 246 | delete d->mConfig; d->mConfig = 0; |
247 | delete d->mManager; d->mManager = 0; | 247 | delete d->mManager; d->mManager = 0; |
248 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 248 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
249 | delete d; d = 0; | 249 | delete d; d = 0; |
250 | } | 250 | } |
251 | 251 | ||
252 | bool AddressBook::load() | 252 | bool AddressBook::load() |
253 | { | 253 | { |
254 | kdDebug(5700) << "AddressBook::load()" << endl; | 254 | |
255 | 255 | ||
256 | clear(); | 256 | clear(); |
257 | 257 | ||
258 | KRES::Manager<Resource>::ActiveIterator it; | 258 | KRES::Manager<Resource>::ActiveIterator it; |
259 | bool ok = true; | 259 | bool ok = true; |
260 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 260 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
261 | if ( !(*it)->load() ) { | 261 | if ( !(*it)->load() ) { |
262 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 262 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
263 | ok = false; | 263 | ok = false; |
264 | } | 264 | } |
265 | 265 | ||
266 | // mark all addressees as unchanged | 266 | // mark all addressees as unchanged |
267 | Addressee::List::Iterator addrIt; | 267 | Addressee::List::Iterator addrIt; |
268 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 268 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) |
269 | (*addrIt).setChanged( false ); | 269 | (*addrIt).setChanged( false ); |
270 | 270 | ||
271 | return ok; | 271 | return ok; |
272 | } | 272 | } |
273 | 273 | ||
274 | bool AddressBook::save( Ticket *ticket ) | 274 | bool AddressBook::save( Ticket *ticket ) |
275 | { | 275 | { |
276 | kdDebug(5700) << "AddressBook::save()"<< endl; | 276 | kdDebug(5700) << "AddressBook::save()"<< endl; |
277 | 277 | ||
278 | if ( ticket->resource() ) { | 278 | if ( ticket->resource() ) { |
279 | deleteRemovedAddressees(); | 279 | deleteRemovedAddressees(); |
280 | 280 | ||
281 | return ticket->resource()->save( ticket ); | 281 | return ticket->resource()->save( ticket ); |
282 | } | 282 | } |
283 | 283 | ||
284 | return false; | 284 | return false; |
285 | } | 285 | } |
286 | 286 | ||
287 | AddressBook::Iterator AddressBook::begin() | 287 | AddressBook::Iterator AddressBook::begin() |
288 | { | 288 | { |
289 | Iterator it = Iterator(); | 289 | Iterator it = Iterator(); |
290 | it.d->mIt = d->mAddressees.begin(); | 290 | it.d->mIt = d->mAddressees.begin(); |
291 | return it; | 291 | return it; |
292 | } | 292 | } |
293 | 293 | ||
294 | AddressBook::ConstIterator AddressBook::begin() const | 294 | AddressBook::ConstIterator AddressBook::begin() const |
295 | { | 295 | { |
296 | ConstIterator it = ConstIterator(); | 296 | ConstIterator it = ConstIterator(); |
297 | it.d->mIt = d->mAddressees.begin(); | 297 | it.d->mIt = d->mAddressees.begin(); |
298 | return it; | 298 | return it; |
299 | } | 299 | } |
300 | 300 | ||
301 | AddressBook::Iterator AddressBook::end() | 301 | AddressBook::Iterator AddressBook::end() |
302 | { | 302 | { |
303 | Iterator it = Iterator(); | 303 | Iterator it = Iterator(); |
304 | it.d->mIt = d->mAddressees.end(); | 304 | it.d->mIt = d->mAddressees.end(); |
305 | return it; | 305 | return it; |
306 | } | 306 | } |
307 | 307 | ||
308 | AddressBook::ConstIterator AddressBook::end() const | 308 | AddressBook::ConstIterator AddressBook::end() const |
309 | { | 309 | { |
310 | ConstIterator it = ConstIterator(); | 310 | ConstIterator it = ConstIterator(); |
311 | it.d->mIt = d->mAddressees.end(); | 311 | it.d->mIt = d->mAddressees.end(); |
312 | return it; | 312 | return it; |
313 | } | 313 | } |
314 | 314 | ||
315 | void AddressBook::clear() | 315 | void AddressBook::clear() |
316 | { | 316 | { |
317 | d->mAddressees.clear(); | 317 | d->mAddressees.clear(); |
318 | } | 318 | } |
319 | 319 | ||
320 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 320 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
321 | { | 321 | { |
322 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 322 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
323 | 323 | ||
324 | if ( !resource ) | 324 | if ( !resource ) |
325 | { | 325 | { |
326 | qDebug("AddressBook::requestSaveTicket no resource" ); | 326 | qDebug("AddressBook::requestSaveTicket no resource" ); |
327 | resource = standardResource(); | 327 | resource = standardResource(); |
328 | } | 328 | } |
329 | 329 | ||
330 | KRES::Manager<Resource>::ActiveIterator it; | 330 | KRES::Manager<Resource>::ActiveIterator it; |
331 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 331 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
332 | if ( (*it) == resource ) { | 332 | if ( (*it) == resource ) { |
333 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 333 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
334 | return 0; | 334 | return 0; |
335 | else | 335 | else |
336 | return (*it)->requestSaveTicket(); | 336 | return (*it)->requestSaveTicket(); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | return 0; | 340 | return 0; |
341 | } | 341 | } |
342 | 342 | ||
343 | void AddressBook::insertAddressee( const Addressee &a ) | 343 | void AddressBook::insertAddressee( const Addressee &a ) |
344 | { | 344 | { |
345 | Addressee::List::Iterator it; | 345 | Addressee::List::Iterator it; |
346 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 346 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
347 | if ( a.uid() == (*it).uid() ) { | 347 | if ( a.uid() == (*it).uid() ) { |
348 | bool changed = false; | 348 | bool changed = false; |
349 | Addressee addr = a; | 349 | Addressee addr = a; |
350 | if ( addr != (*it) ) | 350 | if ( addr != (*it) ) |