summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-07 22:37:40 (UTC)
committer zautrix <zautrix>2004-10-07 22:37:40 (UTC)
commit21ec296f7f2832920dac336bb9f9476c80d746f5 (patch) (unidiff)
tree69b2897665d70ad45da249b1cf374a01d3be6dc4
parent4a01915314201cbe2461ce68cdf9c556c687d727 (diff)
downloadkdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.zip
kdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.tar.gz
kdepimpi-21ec296f7f2832920dac336bb9f9476c80d746f5.tar.bz2
ab view fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp1
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp2
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp7
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
-rw-r--r--korganizer/mainwindow.cpp3
5 files changed, 12 insertions, 3 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index ed5e9c2..dc3cda1 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -338,128 +338,129 @@ AddressBook::~AddressBook()
338 338
339bool AddressBook::load() 339bool AddressBook::load()
340{ 340{
341 341
342 342
343 clear(); 343 clear();
344 344
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } 351 }
352 352
353 // mark all addressees as unchanged 353 // mark all addressees as unchanged
354 Addressee::List::Iterator addrIt; 354 Addressee::List::Iterator addrIt;
355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
356 (*addrIt).setChanged( false ); 356 (*addrIt).setChanged( false );
357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
358 if ( !id.isEmpty() ) { 358 if ( !id.isEmpty() ) {
359 //qDebug("setId aa %s ", id.latin1()); 359 //qDebug("setId aa %s ", id.latin1());
360 (*addrIt).setIDStr(id ); 360 (*addrIt).setIDStr(id );
361 } 361 }
362 } 362 }
363 blockLSEchange = true; 363 blockLSEchange = true;
364 return ok; 364 return ok;
365} 365}
366 366
367bool AddressBook::save( Ticket *ticket ) 367bool AddressBook::save( Ticket *ticket )
368{ 368{
369 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
370 370
371 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
372 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
373 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
374 } 374 }
375 375
376 return false; 376 return false;
377} 377}
378void AddressBook::export2File( QString fileName ) 378void AddressBook::export2File( QString fileName )
379{ 379{
380 380
381 QFile outFile( fileName ); 381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) { 382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) ); 384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ; 385 return ;
386 } 386 }
387 QTextStream t( &outFile ); 387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 ); 388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it; 389 Iterator it;
390 KABC::VCardConverter::Version version; 390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0; 391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) { 392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) { 393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 } 395 }
396 KABC::VCardConverter converter; 396 KABC::VCardConverter converter;
397 QString vcard; 397 QString vcard;
398 //Resource *resource() const; 398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version ); 399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n"; 400 t << vcard << "\r\n";
401 } 401 }
402 t << "\r\n\r\n";
402 outFile.close(); 403 outFile.close();
403} 404}
404void AddressBook::importFromFile( QString fileName ) 405void AddressBook::importFromFile( QString fileName )
405{ 406{
406 407
407 KABC::Addressee::List list; 408 KABC::Addressee::List list;
408 QFile file( fileName ); 409 QFile file( fileName );
409 410
410 file.open( IO_ReadOnly ); 411 file.open( IO_ReadOnly );
411 QByteArray rawData = file.readAll(); 412 QByteArray rawData = file.readAll();
412 file.close(); 413 file.close();
413 414
414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 415 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
415 KABC::VCardTool tool; 416 KABC::VCardTool tool;
416 list = tool.parseVCards( data ); 417 list = tool.parseVCards( data );
417 KABC::Addressee::List::Iterator it; 418 KABC::Addressee::List::Iterator it;
418 for ( it = list.begin(); it != list.end(); ++it ) { 419 for ( it = list.begin(); it != list.end(); ++it ) {
419 (*it).setResource( 0 ); 420 (*it).setResource( 0 );
420 insertAddressee( (*it), false, true ); 421 insertAddressee( (*it), false, true );
421 } 422 }
422 423
423} 424}
424 425
425bool AddressBook::saveAB() 426bool AddressBook::saveAB()
426{ 427{
427 bool ok = true; 428 bool ok = true;
428 429
429 deleteRemovedAddressees(); 430 deleteRemovedAddressees();
430 Iterator ait; 431 Iterator ait;
431 for ( ait = begin(); ait != end(); ++ait ) { 432 for ( ait = begin(); ait != end(); ++ait ) {
432 if ( !(*ait).IDStr().isEmpty() ) { 433 if ( !(*ait).IDStr().isEmpty() ) {
433 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 434 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
434 } 435 }
435 } 436 }
436 KRES::Manager<Resource>::ActiveIterator it; 437 KRES::Manager<Resource>::ActiveIterator it;
437 KRES::Manager<Resource> *manager = d->mManager; 438 KRES::Manager<Resource> *manager = d->mManager;
438 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 439 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
439 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 440 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
440 Ticket *ticket = requestSaveTicket( *it ); 441 Ticket *ticket = requestSaveTicket( *it );
441// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 442// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
442 if ( !ticket ) { 443 if ( !ticket ) {
443 error( i18n( "Unable to save to resource '%1'. It is locked." ) 444 error( i18n( "Unable to save to resource '%1'. It is locked." )
444 .arg( (*it)->resourceName() ) ); 445 .arg( (*it)->resourceName() ) );
445 return false; 446 return false;
446 } 447 }
447 448
448 //if ( !save( ticket ) ) 449 //if ( !save( ticket ) )
449 if ( ticket->resource() ) { 450 if ( ticket->resource() ) {
450 if ( ! ticket->resource()->save( ticket ) ) 451 if ( ! ticket->resource()->save( ticket ) )
451 ok = false; 452 ok = false;
452 } else 453 } else
453 ok = false; 454 ok = false;
454 455
455 } 456 }
456 } 457 }
457 return ok; 458 return ok;
458} 459}
459 460
460AddressBook::Iterator AddressBook::begin() 461AddressBook::Iterator AddressBook::begin()
461{ 462{
462 Iterator it = Iterator(); 463 Iterator it = Iterator();
463 it.d->mIt = d->mAddressees.begin(); 464 it.d->mIt = d->mAddressees.begin();
464 return it; 465 return it;
465} 466}
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 8d0fca1..4babf67 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -270,128 +270,130 @@ void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
270 addressBook(), *it, mCardView); 270 addressBook(), *it, mCardView);
271 271
272 } 272 }
273 } else { 273 } else {
274 KABC::Field::List fieldList = fields(); 274 KABC::Field::List fieldList = fields();
275 KABC::Field::List::ConstIterator fieldIt; 275 KABC::Field::List::ConstIterator fieldIt;
276 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 276 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
277 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 277 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
278#if QT_VERSION >= 300 278#if QT_VERSION >= 300
279 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 279 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
280#else 280#else
281 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 281 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
282#endif 282#endif
283 { 283 {
284 new AddresseeCardViewItem(fields(), mShowEmptyFields, 284 new AddresseeCardViewItem(fields(), mShowEmptyFields,
285 addressBook(), *it, mCardView); 285 addressBook(), *it, mCardView);
286 continue; 286 continue;
287 } 287 }
288 } 288 }
289 } 289 }
290 } 290 }
291 mCardView->viewport()->setUpdatesEnabled( true ); 291 mCardView->viewport()->setUpdatesEnabled( true );
292 mCardView->viewport()->update(); 292 mCardView->viewport()->update();
293 // by default nothing is selected 293 // by default nothing is selected
294 emit selected(QString::null); 294 emit selected(QString::null);
295} 295}
296QStringList KAddressBookCardView::selectedUids() 296QStringList KAddressBookCardView::selectedUids()
297{ 297{
298 QStringList uidList; 298 QStringList uidList;
299 CardViewItem *item; 299 CardViewItem *item;
300 AddresseeCardViewItem *aItem; 300 AddresseeCardViewItem *aItem;
301 301
302 for (item = mCardView->firstItem(); item; item = item->nextItem()) 302 for (item = mCardView->firstItem(); item; item = item->nextItem())
303 { 303 {
304 if (item->isSelected()) 304 if (item->isSelected())
305 { 305 {
306#ifndef KAB_EMBEDDED 306#ifndef KAB_EMBEDDED
307 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 307 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
308#else //KAB_EMBEDDED 308#else //KAB_EMBEDDED
309 aItem = (AddresseeCardViewItem*)(item); 309 aItem = (AddresseeCardViewItem*)(item);
310#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
311 if (aItem) 311 if (aItem)
312 uidList << aItem->addressee().uid(); 312 uidList << aItem->addressee().uid();
313 } 313 }
314 } 314 }
315 315
316 return uidList; 316 return uidList;
317} 317}
318 318
319void KAddressBookCardView::refresh(QString uid) 319void KAddressBookCardView::refresh(QString uid)
320{ 320{
321 CardViewItem *item; 321 CardViewItem *item;
322 AddresseeCardViewItem *aItem; 322 AddresseeCardViewItem *aItem;
323 323
324 if (uid.isNull()) 324 if (uid.isNull())
325 { 325 {
326 // Rebuild the view 326 // Rebuild the view
327 mCardView->viewport()->setUpdatesEnabled( false ); 327 mCardView->viewport()->setUpdatesEnabled( false );
328 mCardView->clear(); 328 mCardView->clear();
329 329
330 KABC::Addressee::List addresseeList = addressees(); 330 KABC::Addressee::List addresseeList = addressees();
331 KABC::Addressee::List::Iterator iter; 331 KABC::Addressee::List::Iterator iter;
332 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) 332 for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter)
333 { 333 {
334 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
335 continue;
334 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, 336 aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields,
335 addressBook(), *iter, mCardView); 337 addressBook(), *iter, mCardView);
336 } 338 }
337 mCardView->viewport()->setUpdatesEnabled( true ); 339 mCardView->viewport()->setUpdatesEnabled( true );
338 mCardView->viewport()->update(); 340 mCardView->viewport()->update();
339 341
340 // by default nothing is selected 342 // by default nothing is selected
341 emit selected(QString::null); 343 emit selected(QString::null);
342 } 344 }
343 else 345 else
344 { 346 {
345 // Try to find the one to refresh 347 // Try to find the one to refresh
346 bool found = false; 348 bool found = false;
347 for (item = mCardView->firstItem(); item && !found; 349 for (item = mCardView->firstItem(); item && !found;
348 item = item->nextItem()) 350 item = item->nextItem())
349 { 351 {
350#ifndef KAB_EMBEDDED 352#ifndef KAB_EMBEDDED
351 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 353 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
352#else //KAB_EMBEDDED 354#else //KAB_EMBEDDED
353 aItem = (AddresseeCardViewItem*)(item); 355 aItem = (AddresseeCardViewItem*)(item);
354#endif //KAB_EMBEDDED 356#endif //KAB_EMBEDDED
355 357
356 if ((aItem) && (aItem->addressee().uid() == uid)) 358 if ((aItem) && (aItem->addressee().uid() == uid))
357 { 359 {
358 aItem->refresh(); 360 aItem->refresh();
359 found = true; 361 found = true;
360 } 362 }
361 } 363 }
362 } 364 }
363} 365}
364 366
365void KAddressBookCardView::setSelected(QString uid, bool selected) 367void KAddressBookCardView::setSelected(QString uid, bool selected)
366{ 368{
367 CardViewItem *item; 369 CardViewItem *item;
368 AddresseeCardViewItem *aItem; 370 AddresseeCardViewItem *aItem;
369 371
370 if (uid.isNull()) 372 if (uid.isNull())
371 { 373 {
372 mCardView->selectAll(selected); 374 mCardView->selectAll(selected);
373 } 375 }
374 else 376 else
375 { 377 {
376 bool found = false; 378 bool found = false;
377 for (item = mCardView->firstItem(); item && !found; 379 for (item = mCardView->firstItem(); item && !found;
378 item = item->nextItem()) 380 item = item->nextItem())
379 { 381 {
380#ifndef KAB_EMBEDDED 382#ifndef KAB_EMBEDDED
381 aItem = dynamic_cast<AddresseeCardViewItem*>(item); 383 aItem = dynamic_cast<AddresseeCardViewItem*>(item);
382#else //KAB_EMBEDDED 384#else //KAB_EMBEDDED
383 aItem = (AddresseeCardViewItem*)(item); 385 aItem = (AddresseeCardViewItem*)(item);
384#endif //KAB_EMBEDDED 386#endif //KAB_EMBEDDED
385 387
386 if ((aItem) && (aItem->addressee().uid() == uid)) 388 if ((aItem) && (aItem->addressee().uid() == uid))
387 { 389 {
388 mCardView->setSelected(aItem, selected); 390 mCardView->setSelected(aItem, selected);
389 mCardView->ensureItemVisible(item); 391 mCardView->ensureItemVisible(item);
390 found = true; 392 found = true;
391 } 393 }
392 } 394 }
393 } 395 }
394} 396}
395 397
396//US added an additional method without parameter 398//US added an additional method without parameter
397void KAddressBookCardView::setSelected() 399void KAddressBookCardView::setSelected()
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index 0ffc674..fdc0db9 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -255,130 +255,133 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
255 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 255 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
256#if QT_VERSION >= 300 256#if QT_VERSION >= 300
257 if (re.search(field->value( *it ).lower()) != -1) 257 if (re.search(field->value( *it ).lower()) != -1)
258#else 258#else
259 if (re.match(field->value( *it ).lower()) != -1) 259 if (re.match(field->value( *it ).lower()) != -1)
260#endif 260#endif
261 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 261 mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
262 262
263 263
264 } 264 }
265 } else { 265 } else {
266 KABC::Field::List fieldList = fields(); 266 KABC::Field::List fieldList = fields();
267 KABC::Field::List::ConstIterator fieldIt; 267 KABC::Field::List::ConstIterator fieldIt;
268 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 268 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
269 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 269 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
270#if QT_VERSION >= 300 270#if QT_VERSION >= 300
271 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 271 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
272#else 272#else
273 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 273 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
274#endif 274#endif
275 { 275 {
276 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); 276 mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
277 continue; 277 continue;
278 } 278 }
279 } 279 }
280 } 280 }
281 } 281 }
282 mIconView->arrangeItemsInGrid( true ); 282 mIconView->arrangeItemsInGrid( true );
283} 283}
284QStringList KAddressBookIconView::selectedUids() 284QStringList KAddressBookIconView::selectedUids()
285{ 285{
286 QStringList uidList; 286 QStringList uidList;
287 QIconViewItem *item; 287 QIconViewItem *item;
288 AddresseeIconViewItem *aItem; 288 AddresseeIconViewItem *aItem;
289 289
290 for (item = mIconView->firstItem(); item; item = item->nextItem()) 290 for (item = mIconView->firstItem(); item; item = item->nextItem())
291 { 291 {
292 if (item->isSelected()) 292 if (item->isSelected())
293 { 293 {
294#ifndef KAB_EMBEDDED 294#ifndef KAB_EMBEDDED
295 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 295 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
296#else //KAB_EMBEDDED 296#else //KAB_EMBEDDED
297 aItem = (AddresseeIconViewItem*)(item); 297 aItem = (AddresseeIconViewItem*)(item);
298#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
299 if (aItem) 299 if (aItem)
300 uidList << aItem->addressee().uid(); 300 uidList << aItem->addressee().uid();
301 } 301 }
302 } 302 }
303 303
304 return uidList; 304 return uidList;
305} 305}
306 306
307void KAddressBookIconView::refresh(QString uid) 307void KAddressBookIconView::refresh(QString uid)
308{ 308{
309 QIconViewItem *item; 309 QIconViewItem *item;
310 AddresseeIconViewItem *aItem; 310 AddresseeIconViewItem *aItem;
311 311
312 if ( uid.isNull() ) { 312 if ( uid.isNull() ) {
313 // Rebuild the view 313 // Rebuild the view
314 mIconView->clear(); 314 mIconView->clear();
315 mIconList.clear(); 315 mIconList.clear();
316 316
317 KABC::Addressee::List addresseeList = addressees(); 317 KABC::Addressee::List addresseeList = addressees();
318 KABC::Addressee::List::Iterator iter; 318 KABC::Addressee::List::Iterator iter;
319 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) 319 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) {
320 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); 320 if ( (*iter).uid().left(2) == "la" && (*iter).uid().left(19) == QString("last-syncAddressee-") )
321 continue;
322 aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView );
323 }
321 324
322 mIconView->arrangeItemsInGrid( true ); 325 mIconView->arrangeItemsInGrid( true );
323 326
324 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) 327 for ( item = mIconView->firstItem(); item; item = item->nextItem() )
325 { 328 {
326#ifndef KAB_EMBEDDED 329#ifndef KAB_EMBEDDED
327 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); 330 AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item );
328#else //KAB_EMBEDDED 331#else //KAB_EMBEDDED
329 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); 332 AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item );
330#endif //KAB_EMBEDDED 333#endif //KAB_EMBEDDED
331 mIconList.append( aivi ); 334 mIconList.append( aivi );
332 } 335 }
333 336
334 } else { 337 } else {
335 // Try to find the one to refresh 338 // Try to find the one to refresh
336 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { 339 for ( item = mIconView->firstItem(); item; item = item->nextItem() ) {
337#ifndef KAB_EMBEDDED 340#ifndef KAB_EMBEDDED
338 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 341 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
339#else //KAB_EMBEDDED 342#else //KAB_EMBEDDED
340 aItem = (AddresseeIconViewItem*)(item); 343 aItem = (AddresseeIconViewItem*)(item);
341#endif //KAB_EMBEDDED 344#endif //KAB_EMBEDDED
342 if ((aItem) && (aItem->addressee().uid() == uid)) { 345 if ((aItem) && (aItem->addressee().uid() == uid)) {
343 aItem->refresh(); 346 aItem->refresh();
344 mIconView->arrangeItemsInGrid( true ); 347 mIconView->arrangeItemsInGrid( true );
345 return; 348 return;
346 } 349 }
347 } 350 }
348 refresh( QString::null ); 351 refresh( QString::null );
349 } 352 }
350} 353}
351 354
352void KAddressBookIconView::setSelected(QString uid, bool selected) 355void KAddressBookIconView::setSelected(QString uid, bool selected)
353{ 356{
354 QIconViewItem *item; 357 QIconViewItem *item;
355 AddresseeIconViewItem *aItem; 358 AddresseeIconViewItem *aItem;
356 359
357 if (uid.isNull()) 360 if (uid.isNull())
358 { 361 {
359 mIconView->selectAll(selected); 362 mIconView->selectAll(selected);
360 } 363 }
361 else 364 else
362 { 365 {
363 bool found = false; 366 bool found = false;
364 for (item = mIconView->firstItem(); item && !found; 367 for (item = mIconView->firstItem(); item && !found;
365 item = item->nextItem()) 368 item = item->nextItem())
366 { 369 {
367#ifndef KAB_EMBEDDED 370#ifndef KAB_EMBEDDED
368 aItem = dynamic_cast<AddresseeIconViewItem*>(item); 371 aItem = dynamic_cast<AddresseeIconViewItem*>(item);
369#else //KAB_EMBEDDED 372#else //KAB_EMBEDDED
370 aItem = (AddresseeIconViewItem*)(item); 373 aItem = (AddresseeIconViewItem*)(item);
371#endif //KAB_EMBEDDED 374#endif //KAB_EMBEDDED
372 375
373 if ((aItem) && (aItem->addressee().uid() == uid)) 376 if ((aItem) && (aItem->addressee().uid() == uid))
374 { 377 {
375 mIconView->setSelected(aItem, selected); 378 mIconView->setSelected(aItem, selected);
376 mIconView->ensureItemVisible( aItem ); 379 mIconView->ensureItemVisible( aItem );
377 found = true; 380 found = true;
378 } 381 }
379 } 382 }
380 } 383 }
381} 384}
382 385
383void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) 386void KAddressBookIconView::addresseeExecuted(QIconViewItem *item)
384{ 387{
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 1dc9198..fbfddba 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -216,128 +216,130 @@ void KAddressBookTableView::readConfig(KConfig *config)
216 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 216 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
217 { 217 {
218 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 218 mListView->setFont( config->readFontEntry( "TextFont", &f) );
219 f.setBold( true ); 219 f.setBold( true );
220 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 220 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
221 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 221 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
222 } 222 }
223 else 223 else
224 { 224 {
225 mListView->setFont( f ); 225 mListView->setFont( f );
226 f.setBold( true ); 226 f.setBold( true );
227 //US mListView->setHeaderFont( f ); 227 //US mListView->setHeaderFont( f );
228 mListView->header()->setFont( f ); 228 mListView->header()->setFont( f );
229 } 229 }
230 230
231 231
232 232
233 233
234 234
235 // Set the list view options 235 // Set the list view options
236 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 236 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
237 true)); 237 true));
238 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 238 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
239 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 239 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
240 240
241 if (config->readBoolEntry("Background", false)) 241 if (config->readBoolEntry("Background", false))
242 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 242 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
243 243
244 // Restore the layout of the listview 244 // Restore the layout of the listview
245 mListView->restoreLayout(config, config->group()); 245 mListView->restoreLayout(config, config->group());
246} 246}
247 247
248void KAddressBookTableView::refresh(QString uid) 248void KAddressBookTableView::refresh(QString uid)
249{ 249{
250 // For now just repopulate. In reality this method should 250 // For now just repopulate. In reality this method should
251 // check the value of uid, and if valid iterate through 251 // check the value of uid, and if valid iterate through
252 // the listview to find the entry, then tell it to refresh. 252 // the listview to find the entry, then tell it to refresh.
253 253
254 if (uid.isNull()) { 254 if (uid.isNull()) {
255 // Clear the list view 255 // Clear the list view
256 QString currentUID, nextUID; 256 QString currentUID, nextUID;
257#ifndef KAB_EMBEDDED 257#ifndef KAB_EMBEDDED
258 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 258 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
259#else //KAB_EMBEDDED 259#else //KAB_EMBEDDED
260 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 260 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
261#endif //KAB_EMBEDDED 261#endif //KAB_EMBEDDED
262 262
263 if ( currentItem ) { 263 if ( currentItem ) {
264#ifndef KAB_EMBEDDED 264#ifndef KAB_EMBEDDED
265 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 265 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
266#else //KAB_EMBEDDED 266#else //KAB_EMBEDDED
267 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 267 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
268#endif //KAB_EMBEDDED 268#endif //KAB_EMBEDDED
269 if ( nextItem ) 269 if ( nextItem )
270 nextUID = nextItem->addressee().uid(); 270 nextUID = nextItem->addressee().uid();
271 currentUID = currentItem->addressee().uid(); 271 currentUID = currentItem->addressee().uid();
272 } 272 }
273 273
274 mListView->clear(); 274 mListView->clear();
275 275
276 currentItem = 0; 276 currentItem = 0;
277 KABC::Addressee::List addresseeList = addressees(); 277 KABC::Addressee::List addresseeList = addressees();
278 KABC::Addressee::List::Iterator it; 278 KABC::Addressee::List::Iterator it;
279 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 279 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
280 if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
281 continue;
280 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 282 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
281 if ( (*it).uid() == currentUID ) 283 if ( (*it).uid() == currentUID )
282 currentItem = item; 284 currentItem = item;
283 else if ( (*it).uid() == nextUID && !currentItem ) 285 else if ( (*it).uid() == nextUID && !currentItem )
284 currentItem = item; 286 currentItem = item;
285 } 287 }
286 288
287 // Sometimes the background pixmap gets messed up when we add lots 289 // Sometimes the background pixmap gets messed up when we add lots
288 // of items. 290 // of items.
289 mListView->repaint(); 291 mListView->repaint();
290 292
291 if ( currentItem ) { 293 if ( currentItem ) {
292 mListView->setCurrentItem( currentItem ); 294 mListView->setCurrentItem( currentItem );
293 mListView->ensureItemVisible( currentItem ); 295 mListView->ensureItemVisible( currentItem );
294 } 296 }
295 } else { 297 } else {
296 // Only need to update on entry. Iterate through and try to find it 298 // Only need to update on entry. Iterate through and try to find it
297 ContactListViewItem *ceItem; 299 ContactListViewItem *ceItem;
298 QListViewItemIterator it( mListView ); 300 QListViewItemIterator it( mListView );
299 while ( it.current() ) { 301 while ( it.current() ) {
300#ifndef KAB_EMBEDDED 302#ifndef KAB_EMBEDDED
301 ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); 303 ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
302#else //KAB_EMBEDDED 304#else //KAB_EMBEDDED
303 ceItem = (ContactListViewItem*)( it.current() ); 305 ceItem = (ContactListViewItem*)( it.current() );
304#endif //KAB_EMBEDDED 306#endif //KAB_EMBEDDED
305 307
306 if ( ceItem && ceItem->addressee().uid() == uid ) { 308 if ( ceItem && ceItem->addressee().uid() == uid ) {
307 ceItem->refresh(); 309 ceItem->refresh();
308 return; 310 return;
309 } 311 }
310 ++it; 312 ++it;
311 } 313 }
312 314
313 refresh( QString::null ); 315 refresh( QString::null );
314 } 316 }
315} 317}
316 318
317QStringList KAddressBookTableView::selectedUids() 319QStringList KAddressBookTableView::selectedUids()
318{ 320{
319 QStringList uidList; 321 QStringList uidList;
320 QListViewItem *item; 322 QListViewItem *item;
321 ContactListViewItem *ceItem; 323 ContactListViewItem *ceItem;
322 324
323 for(item = mListView->firstChild(); item; item = item->itemBelow()) 325 for(item = mListView->firstChild(); item; item = item->itemBelow())
324 { 326 {
325 if (mListView->isSelected( item )) 327 if (mListView->isSelected( item ))
326 { 328 {
327#ifndef KAB_EMBEDDED 329#ifndef KAB_EMBEDDED
328 ceItem = dynamic_cast<ContactListViewItem*>(item); 330 ceItem = dynamic_cast<ContactListViewItem*>(item);
329#else //KAB_EMBEDDED 331#else //KAB_EMBEDDED
330 ceItem = (ContactListViewItem*)(item); 332 ceItem = (ContactListViewItem*)(item);
331#endif //KAB_EMBEDDED 333#endif //KAB_EMBEDDED
332 334
333 if (ceItem != 0L) 335 if (ceItem != 0L)
334 uidList << ceItem->addressee().uid(); 336 uidList << ceItem->addressee().uid();
335 } 337 }
336 } 338 }
337 if ( uidList.count() == 0 ) 339 if ( uidList.count() == 0 )
338 if ( mListView->currentItem() ) { 340 if ( mListView->currentItem() ) {
339 ceItem = (ContactListViewItem*)(mListView->currentItem()) ; 341 ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
340 uidList << ceItem->addressee().uid(); 342 uidList << ceItem->addressee().uid();
341 } 343 }
342 344
343 return uidList; 345 return uidList;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index f7766f8..c7ce8cb 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -195,129 +195,130 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
195 } 195 }
196 //mView->setMaximumSize( splash->size() ); 196 //mView->setMaximumSize( splash->size() );
197 //mView->resize( splash->size() ); 197 //mView->resize( splash->size() );
198 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 198 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
199 mView->readSettings(); 199 mView->readSettings();
200 bool newFile = false; 200 bool newFile = false;
201 if( !QFile::exists( defaultFileName() ) ) { 201 if( !QFile::exists( defaultFileName() ) ) {
202 QFileInfo finfo ( defaultFileName() ); 202 QFileInfo finfo ( defaultFileName() );
203 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 203 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
204 qDebug("oldfile %s ", oldFile.latin1()); 204 qDebug("oldfile %s ", oldFile.latin1());
205 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 205 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
206 finfo.setFile( oldFile ); 206 finfo.setFile( oldFile );
207 if (finfo.exists() ) { 207 if (finfo.exists() ) {
208 KMessageBox::information( this, message); 208 KMessageBox::information( this, message);
209 mView->openCalendar( oldFile ); 209 mView->openCalendar( oldFile );
210 qApp->processEvents(); 210 qApp->processEvents();
211 } else { 211 } else {
212 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 212 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
213 finfo.setFile( oldFile ); 213 finfo.setFile( oldFile );
214 if (finfo.exists() ) { 214 if (finfo.exists() ) {
215 KMessageBox::information( this, message); 215 KMessageBox::information( this, message);
216 mView->openCalendar( oldFile ); 216 mView->openCalendar( oldFile );
217 qApp->processEvents(); 217 qApp->processEvents();
218 } 218 }
219 } 219 }
220 mView->saveCalendar( defaultFileName() ); 220 mView->saveCalendar( defaultFileName() );
221 newFile = true; 221 newFile = true;
222 } 222 }
223 223
224 QTime neededSaveTime = QDateTime::currentDateTime().time(); 224 QTime neededSaveTime = QDateTime::currentDateTime().time();
225 mView->openCalendar( defaultFileName() ); 225 mView->openCalendar( defaultFileName() );
226 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 226 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
227 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 227 qDebug("KO: Calendar loading time: %d ms",msNeeded );
228 228
229 if ( KOPrefs::instance()->mLanguageChanged ) { 229 if ( KOPrefs::instance()->mLanguageChanged ) {
230 KOPrefs::instance()->setCategoryDefaults(); 230 KOPrefs::instance()->setCategoryDefaults();
231 int count = mView->addCategories(); 231 int count = mView->addCategories();
232 KOPrefs::instance()->mLanguageChanged = false; 232 KOPrefs::instance()->mLanguageChanged = false;
233 } 233 }
234 processIncidenceSelection( 0 ); 234 processIncidenceSelection( 0 );
235 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 235 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
236 SLOT( processIncidenceSelection( Incidence * ) ) ); 236 SLOT( processIncidenceSelection( Incidence * ) ) );
237 connect( mView, SIGNAL( modifiedChanged( bool ) ), 237 connect( mView, SIGNAL( modifiedChanged( bool ) ),
238 SLOT( slotModifiedChanged( bool ) ) ); 238 SLOT( slotModifiedChanged( bool ) ) );
239 239
240 240
241 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 241 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
242 mView->setModified( false ); 242 mView->setModified( false );
243 mBlockAtStartup = false; 243 mBlockAtStartup = false;
244 mView->setModified( false ); 244 mView->setModified( false );
245 setCentralWidget( mView ); 245 setCentralWidget( mView );
246 globalFlagBlockStartup = 0; 246 globalFlagBlockStartup = 0;
247 mView->show(); 247 mView->show();
248 delete splash; 248 delete splash;
249 if ( newFile ) 249 if ( newFile )
250 mView->updateConfig(); 250 mView->updateConfig();
251 // qApp->processEvents(); 251 // qApp->processEvents();
252 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 252 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
253 //fillSyncMenu(); 253 //fillSyncMenu();
254 254
255 255
256 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 256 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
257 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 257 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
258 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 258 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
259 mSyncManager->setDefaultFileName( defaultFileName()); 259 mSyncManager->setDefaultFileName( defaultFileName());
260 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
260 mSyncManager->fillSyncMenu(); 261 mSyncManager->fillSyncMenu();
261 262
262 263
263 264
264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 265 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
265 if ( showWarning ) { 266 if ( showWarning ) {
266 KMessageBox::information( this, 267 KMessageBox::information( this,
267 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 268 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
268 qApp->processEvents(); 269 qApp->processEvents();
269 mView->dialogManager()->showSyncOptions(); 270 mView->dialogManager()->showSyncOptions();
270 } 271 }
271 272
272 //US listen for result adressed from Ka/Pi 273 //US listen for result adressed from Ka/Pi
273#ifndef DESKTOP_VERSION 274#ifndef DESKTOP_VERSION
274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 275 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
275#endif 276#endif
276} 277}
277MainWindow::~MainWindow() 278MainWindow::~MainWindow()
278{ 279{
279 //qDebug("MainWindow::~MainWindow() "); 280 //qDebug("MainWindow::~MainWindow() ");
280 //save toolbar location 281 //save toolbar location
281 delete mServerSocket; 282 delete mServerSocket;
282 delete mCalendar; 283 delete mCalendar;
283 delete KOPrefs::instance(); 284 delete KOPrefs::instance();
284 delete KIncidenceFormatter::instance(); 285 delete KIncidenceFormatter::instance();
285 286
286 287
287} 288}
288void MainWindow::showMaximized () 289void MainWindow::showMaximized ()
289{ 290{
290#ifndef DESKTOP_VERSION 291#ifndef DESKTOP_VERSION
291 if ( ! globalFlagBlockStartup ) 292 if ( ! globalFlagBlockStartup )
292 if ( mClosed ) 293 if ( mClosed )
293 mView->goToday(); 294 mView->goToday();
294#endif 295#endif
295 QWidget::showMaximized () ; 296 QWidget::showMaximized () ;
296 mClosed = false; 297 mClosed = false;
297} 298}
298void MainWindow::closeEvent( QCloseEvent* ce ) 299void MainWindow::closeEvent( QCloseEvent* ce )
299{ 300{
300 301
301 302
302 303
303 if ( ! KOPrefs::instance()->mAskForQuit ) { 304 if ( ! KOPrefs::instance()->mAskForQuit ) {
304 saveOnClose(); 305 saveOnClose();
305 mClosed = true; 306 mClosed = true;
306 ce->accept(); 307 ce->accept();
307 return; 308 return;
308 309
309 } 310 }
310 311
311 switch( QMessageBox::information( this, "KO/Pi", 312 switch( QMessageBox::information( this, "KO/Pi",
312 i18n("Do you really want\nto close KO/Pi?"), 313 i18n("Do you really want\nto close KO/Pi?"),
313 i18n("Close"), i18n("No"), 314 i18n("Close"), i18n("No"),
314 0, 0 ) ) { 315 0, 0 ) ) {
315 case 0: 316 case 0:
316 saveOnClose(); 317 saveOnClose();
317 mClosed = true; 318 mClosed = true;
318 ce->accept(); 319 ce->accept();
319 break; 320 break;
320 case 1: 321 case 1:
321 ce->ignore(); 322 ce->ignore();
322 break; 323 break;
323 case 2: 324 case 2: