-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 13 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 4 |
2 files changed, 12 insertions, 5 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index c2cce92..12dc24e 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -332,654 +332,665 @@ void AddressbookWindow::setDocument( const QString &filename ) | |||
332 | 332 | ||
333 | 333 | ||
334 | 334 | ||
335 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 335 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
336 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 336 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
337 | tr( "&Yes" ), tr( "&No" ), QString::null, | 337 | tr( "&Yes" ), tr( "&No" ), QString::null, |
338 | 0, // Enter == button 0 | 338 | 0, // Enter == button 0 |
339 | 2 ) ) { // Escape == button 2 | 339 | 2 ) ) { // Escape == button 2 |
340 | case 0: | 340 | case 0: |
341 | qWarning("YES clicked"); | 341 | qWarning("YES clicked"); |
342 | break; | 342 | break; |
343 | case 1: | 343 | case 1: |
344 | qWarning("NO clicked"); | 344 | qWarning("NO clicked"); |
345 | return; | 345 | return; |
346 | break; | 346 | break; |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 350 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
351 | filename ); | 351 | filename ); |
352 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 352 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
353 | OContactAccess::List allList = access->allRecords(); | 353 | OContactAccess::List allList = access->allRecords(); |
354 | qWarning( "Found number of contacts in File: %d", allList.count() ); | 354 | qWarning( "Found number of contacts in File: %d", allList.count() ); |
355 | 355 | ||
356 | if ( !allList.count() ) { | 356 | if ( !allList.count() ) { |
357 | QMessageBox::information( this, "Import VCard", | 357 | QMessageBox::information( this, "Import VCard", |
358 | "It was impossible to import the VCard.\n" | 358 | "It was impossible to import the VCard.\n" |
359 | "The VCard may be corrupted!" ); | 359 | "The VCard may be corrupted!" ); |
360 | } | 360 | } |
361 | 361 | ||
362 | bool doAsk = true; | 362 | bool doAsk = true; |
363 | OContactAccess::List::Iterator it; | 363 | OContactAccess::List::Iterator it; |
364 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 364 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
365 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); | 365 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); |
366 | if ( doAsk ){ | 366 | if ( doAsk ){ |
367 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), | 367 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), |
368 | tr( "Do you really want add contact for \n%1?" ) | 368 | tr( "Do you really want add contact for \n%1?" ) |
369 | .arg( (*it).fullName().latin1() ), | 369 | .arg( (*it).fullName().latin1() ), |
370 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), | 370 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), |
371 | 0, // Enter == button 0 | 371 | 0, // Enter == button 0 |
372 | 2 ) ) { // Escape == button 2 | 372 | 2 ) ) { // Escape == button 2 |
373 | case 0: | 373 | case 0: |
374 | qWarning("YES clicked"); | 374 | qWarning("YES clicked"); |
375 | m_abView->addEntry( *it ); | 375 | m_abView->addEntry( *it ); |
376 | break; | 376 | break; |
377 | case 1: | 377 | case 1: |
378 | qWarning("NO clicked"); | 378 | qWarning("NO clicked"); |
379 | break; | 379 | break; |
380 | case 2: | 380 | case 2: |
381 | qWarning("YesAll clicked"); | 381 | qWarning("YesAll clicked"); |
382 | doAsk = false; | 382 | doAsk = false; |
383 | break; | 383 | break; |
384 | } | 384 | } |
385 | }else | 385 | }else |
386 | m_abView->addEntry( *it ); | 386 | m_abView->addEntry( *it ); |
387 | 387 | ||
388 | } | 388 | } |
389 | 389 | ||
390 | delete access; | 390 | delete access; |
391 | } | 391 | } |
392 | 392 | ||
393 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 393 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
394 | { | 394 | { |
395 | QMainWindow::resizeEvent( e ); | 395 | QMainWindow::resizeEvent( e ); |
396 | 396 | ||
397 | 397 | ||
398 | } | 398 | } |
399 | 399 | ||
400 | AddressbookWindow::~AddressbookWindow() | 400 | AddressbookWindow::~AddressbookWindow() |
401 | { | 401 | { |
402 | ToolBarDock dock; | 402 | ToolBarDock dock; |
403 | int dummy; | 403 | int dummy; |
404 | bool bDummy; | 404 | bool bDummy; |
405 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 405 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
406 | m_config.setToolBarDock( dock ); | 406 | m_config.setToolBarDock( dock ); |
407 | m_config.save(); | 407 | m_config.save(); |
408 | } | 408 | } |
409 | 409 | ||
410 | void AddressbookWindow::slotUpdateToolbar() | 410 | void AddressbookWindow::slotUpdateToolbar() |
411 | { | 411 | { |
412 | OContact ce = m_abView->currentEntry(); | 412 | OContact ce = m_abView->currentEntry(); |
413 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 413 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
414 | } | 414 | } |
415 | 415 | ||
416 | void AddressbookWindow::slotListNew() | 416 | void AddressbookWindow::slotListNew() |
417 | { | 417 | { |
418 | OContact cnt; | 418 | OContact cnt; |
419 | if( !syncing ) { | 419 | if( !syncing ) { |
420 | editEntry( NewEntry ); | 420 | editEntry( NewEntry ); |
421 | } else { | 421 | } else { |
422 | QMessageBox::warning(this, tr("OContacts"), | 422 | QMessageBox::warning(this, tr("OContacts"), |
423 | tr("Can not edit data, currently syncing")); | 423 | tr("Can not edit data, currently syncing")); |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | // void AddressbookWindow::slotListView() | 427 | // void AddressbookWindow::slotListView() |
428 | // { | 428 | // { |
429 | // m_abView -> init( abList->currentEntry() ); | 429 | // m_abView -> init( abList->currentEntry() ); |
430 | // // :SX mView->sync(); | 430 | // // :SX mView->sync(); |
431 | // //:SXshowView(); | 431 | // //:SXshowView(); |
432 | // } | 432 | // } |
433 | 433 | ||
434 | void AddressbookWindow::slotListDelete() | 434 | void AddressbookWindow::slotListDelete() |
435 | { | 435 | { |
436 | if(!syncing) { | 436 | if(!syncing) { |
437 | OContact tmpEntry = m_abView ->currentEntry(); | 437 | OContact tmpEntry = m_abView ->currentEntry(); |
438 | 438 | ||
439 | // get a name, do the best we can... | 439 | // get a name, do the best we can... |
440 | QString strName = tmpEntry.fullName(); | 440 | QString strName = tmpEntry.fullName(); |
441 | if ( strName.isEmpty() ) { | 441 | if ( strName.isEmpty() ) { |
442 | strName = tmpEntry.company(); | 442 | strName = tmpEntry.company(); |
443 | if ( strName.isEmpty() ) | 443 | if ( strName.isEmpty() ) |
444 | strName = "No Name"; | 444 | strName = "No Name"; |
445 | } | 445 | } |
446 | 446 | ||
447 | 447 | ||
448 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 448 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
449 | strName ) ) { | 449 | strName ) ) { |
450 | m_abView->removeEntry( tmpEntry.uid() ); | 450 | m_abView->removeEntry( tmpEntry.uid() ); |
451 | } | 451 | } |
452 | } else { | 452 | } else { |
453 | QMessageBox::warning( this, tr("Contacts"), | 453 | QMessageBox::warning( this, tr("Contacts"), |
454 | tr("Can not edit data, currently syncing") ); | 454 | tr("Can not edit data, currently syncing") ); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | void AddressbookWindow::slotFindOpen() | 458 | void AddressbookWindow::slotFindOpen() |
459 | { | 459 | { |
460 | searchBar->show(); | 460 | searchBar->show(); |
461 | m_abView -> inSearch(); | 461 | m_abView -> inSearch(); |
462 | searchEdit->setFocus(); | 462 | searchEdit->setFocus(); |
463 | } | 463 | } |
464 | void AddressbookWindow::slotFindClose() | 464 | void AddressbookWindow::slotFindClose() |
465 | { | 465 | { |
466 | searchBar->hide(); | 466 | searchBar->hide(); |
467 | m_abView -> offSearch(); | 467 | m_abView -> offSearch(); |
468 | // m_abView->setFocus(); | 468 | // m_abView->setFocus(); |
469 | } | 469 | } |
470 | 470 | ||
471 | 471 | ||
472 | void AddressbookWindow::slotFind() | 472 | void AddressbookWindow::slotFind() |
473 | { | 473 | { |
474 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 474 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
475 | 475 | ||
476 | searchEdit->clearFocus(); | 476 | searchEdit->clearFocus(); |
477 | // m_abView->setFocus(); | 477 | // m_abView->setFocus(); |
478 | 478 | ||
479 | } | 479 | } |
480 | 480 | ||
481 | void AddressbookWindow::slotViewBack() | 481 | void AddressbookWindow::slotViewBack() |
482 | { | 482 | { |
483 | // :SX showList(); | 483 | // :SX showList(); |
484 | } | 484 | } |
485 | 485 | ||
486 | void AddressbookWindow::slotViewEdit() | 486 | void AddressbookWindow::slotViewEdit() |
487 | { | 487 | { |
488 | if(!syncing) { | 488 | if(!syncing) { |
489 | if (actionPersonal->isOn()) { | 489 | if (actionPersonal->isOn()) { |
490 | editPersonal(); | 490 | editPersonal(); |
491 | } else { | 491 | } else { |
492 | editEntry( EditEntry ); | 492 | editEntry( EditEntry ); |
493 | } | 493 | } |
494 | } else { | 494 | } else { |
495 | QMessageBox::warning( this, tr("Contacts"), | 495 | QMessageBox::warning( this, tr("Contacts"), |
496 | tr("Can not edit data, currently syncing") ); | 496 | tr("Can not edit data, currently syncing") ); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | 500 | ||
501 | 501 | ||
502 | void AddressbookWindow::writeMail() | 502 | void AddressbookWindow::writeMail() |
503 | { | 503 | { |
504 | OContact c = m_abView -> currentEntry(); | 504 | OContact c = m_abView -> currentEntry(); |
505 | QString name = c.fileAs(); | 505 | QString name = c.fileAs(); |
506 | QString email = c.defaultEmail(); | 506 | QString email = c.defaultEmail(); |
507 | 507 | ||
508 | // I prefer the OPIE-Environment variable before the | 508 | // I prefer the OPIE-Environment variable before the |
509 | // QPE-one.. | 509 | // QPE-one.. |
510 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 510 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
511 | if ( basepath.isEmpty() ) | 511 | if ( basepath.isEmpty() ) |
512 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 512 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
513 | 513 | ||
514 | // Try to access the preferred. If not possible, try to | 514 | // Try to access the preferred. If not possible, try to |
515 | // switch to the other one.. | 515 | // switch to the other one.. |
516 | if ( m_config.useQtMail() ){ | 516 | if ( m_config.useQtMail() ){ |
517 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 517 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
518 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 518 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
519 | qWarning ("QCop"); | 519 | qWarning ("QCop"); |
520 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 520 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
521 | e << name << email; | 521 | e << name << email; |
522 | return; | 522 | return; |
523 | } else | 523 | } else |
524 | m_config.setUseOpieMail( true ); | 524 | m_config.setUseOpieMail( true ); |
525 | } | 525 | } |
526 | if ( m_config.useOpieMail() ){ | 526 | if ( m_config.useOpieMail() ){ |
527 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 527 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
528 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 528 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
529 | qWarning ("QCop"); | 529 | qWarning ("QCop"); |
530 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 530 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
531 | e << name << email; | 531 | e << name << email; |
532 | return; | 532 | return; |
533 | } else | 533 | } else |
534 | m_config.setUseQtMail( true ); | 534 | m_config.setUseQtMail( true ); |
535 | } | 535 | } |
536 | 536 | ||
537 | } | 537 | } |
538 | 538 | ||
539 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 539 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
540 | 540 | ||
541 | void AddressbookWindow::slotBeam() | 541 | void AddressbookWindow::slotBeam() |
542 | { | 542 | { |
543 | QString filename; | 543 | QString filename; |
544 | OContact c; | 544 | OContact c; |
545 | if ( actionPersonal->isOn() ) { | 545 | if ( actionPersonal->isOn() ) { |
546 | filename = addressbookPersonalVCardName(); | 546 | filename = addressbookPersonalVCardName(); |
547 | if (!QFile::exists(filename)) | 547 | if (!QFile::exists(filename)) |
548 | return; // can't beam a non-existent file | 548 | return; // can't beam a non-existent file |
549 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 549 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
550 | filename ); | 550 | filename ); |
551 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 551 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
552 | OContactAccess::List allList = access->allRecords(); | 552 | OContactAccess::List allList = access->allRecords(); |
553 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 553 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
554 | c = *it; | 554 | c = *it; |
555 | 555 | ||
556 | delete access; | 556 | delete access; |
557 | } else { | 557 | } else { |
558 | unlink( beamfile ); // delete if exists | 558 | unlink( beamfile ); // delete if exists |
559 | mkdir("/tmp/obex/", 0755); | 559 | mkdir("/tmp/obex/", 0755); |
560 | c = m_abView -> currentEntry(); | 560 | c = m_abView -> currentEntry(); |
561 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 561 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
562 | beamfile ); | 562 | beamfile ); |
563 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 563 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
564 | access->add( c ); | 564 | access->add( c ); |
565 | access->save(); | 565 | access->save(); |
566 | delete access; | 566 | delete access; |
567 | 567 | ||
568 | filename = beamfile; | 568 | filename = beamfile; |
569 | } | 569 | } |
570 | 570 | ||
571 | 571 | ||
572 | Ir *ir = new Ir( this ); | 572 | Ir *ir = new Ir( this ); |
573 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 573 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
574 | QString description = c.fullName(); | 574 | QString description = c.fullName(); |
575 | ir->send( filename, description, "text/x-vCard" ); | 575 | ir->send( filename, description, "text/x-vCard" ); |
576 | } | 576 | } |
577 | 577 | ||
578 | void AddressbookWindow::beamDone( Ir *ir ) | 578 | void AddressbookWindow::beamDone( Ir *ir ) |
579 | { | 579 | { |
580 | delete ir; | 580 | delete ir; |
581 | unlink( beamfile ); | 581 | unlink( beamfile ); |
582 | } | 582 | } |
583 | 583 | ||
584 | 584 | ||
585 | static void parseName( const QString& name, QString *first, QString *middle, | 585 | static void parseName( const QString& name, QString *first, QString *middle, |
586 | QString * last ) | 586 | QString * last ) |
587 | { | 587 | { |
588 | 588 | ||
589 | int comma = name.find ( "," ); | 589 | int comma = name.find ( "," ); |
590 | QString rest; | 590 | QString rest; |
591 | if ( comma > 0 ) { | 591 | if ( comma > 0 ) { |
592 | *last = name.left( comma ); | 592 | *last = name.left( comma ); |
593 | comma++; | 593 | comma++; |
594 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 594 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
595 | comma++; | 595 | comma++; |
596 | rest = name.mid( comma ); | 596 | rest = name.mid( comma ); |
597 | } else { | 597 | } else { |
598 | int space = name.findRev( ' ' ); | 598 | int space = name.findRev( ' ' ); |
599 | *last = name.mid( space+1 ); | 599 | *last = name.mid( space+1 ); |
600 | rest = name.left( space ); | 600 | rest = name.left( space ); |
601 | } | 601 | } |
602 | int space = rest.find( ' ' ); | 602 | int space = rest.find( ' ' ); |
603 | if ( space <= 0 ) { | 603 | if ( space <= 0 ) { |
604 | *first = rest; | 604 | *first = rest; |
605 | } else { | 605 | } else { |
606 | *first = rest.left( space ); | 606 | *first = rest.left( space ); |
607 | *middle = rest.mid( space+1 ); | 607 | *middle = rest.mid( space+1 ); |
608 | } | 608 | } |
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | 612 | ||
613 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 613 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
614 | { | 614 | { |
615 | if (msg == "editPersonal()") { | 615 | if (msg == "editPersonal()") { |
616 | editPersonal(); | 616 | editPersonal(); |
617 | } else if (msg == "editPersonalAndClose()") { | 617 | } else if (msg == "editPersonalAndClose()") { |
618 | editPersonal(); | 618 | editPersonal(); |
619 | close(); | 619 | close(); |
620 | } else if ( msg == "addContact(QString,QString)" ) { | 620 | } else if ( msg == "addContact(QString,QString)" ) { |
621 | QDataStream stream(data,IO_ReadOnly); | 621 | QDataStream stream(data,IO_ReadOnly); |
622 | QString name, email; | 622 | QString name, email; |
623 | stream >> name >> email; | 623 | stream >> name >> email; |
624 | 624 | ||
625 | OContact cnt; | 625 | OContact cnt; |
626 | QString fn, mn, ln; | 626 | QString fn, mn, ln; |
627 | parseName( name, &fn, &mn, &ln ); | 627 | parseName( name, &fn, &mn, &ln ); |
628 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 628 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
629 | cnt.setFirstName( fn ); | 629 | cnt.setFirstName( fn ); |
630 | cnt.setMiddleName( mn ); | 630 | cnt.setMiddleName( mn ); |
631 | cnt.setLastName( ln ); | 631 | cnt.setLastName( ln ); |
632 | cnt.insertEmails( email ); | 632 | cnt.insertEmails( email ); |
633 | cnt.setDefaultEmail( email ); | 633 | cnt.setDefaultEmail( email ); |
634 | cnt.setFileAs(); | 634 | cnt.setFileAs(); |
635 | 635 | ||
636 | m_abView -> addEntry( cnt ); | 636 | m_abView -> addEntry( cnt ); |
637 | 637 | ||
638 | // :SXm_abView()->init( cnt ); | 638 | // :SXm_abView()->init( cnt ); |
639 | editEntry( EditEntry ); | 639 | editEntry( EditEntry ); |
640 | 640 | ||
641 | 641 | ||
642 | 642 | ||
643 | } | 643 | } |
644 | #if 0 | 644 | #if 0 |
645 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { | 645 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { |
646 | QDataStream stream(data,IO_ReadOnly); | 646 | QDataStream stream(data,IO_ReadOnly); |
647 | QCString ch,m; | 647 | QCString ch,m; |
648 | QStringList types; | 648 | QStringList types; |
649 | stream >> ch >> m >> types; | 649 | stream >> ch >> m >> types; |
650 | AddressPicker picker(abList,this,0,TRUE); | 650 | AddressPicker picker(abList,this,0,TRUE); |
651 | picker.showMaximized(); | 651 | picker.showMaximized(); |
652 | picker.setChoiceNames(types); | 652 | picker.setChoiceNames(types); |
653 | int i=0; | 653 | int i=0; |
654 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 654 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
655 | QStringList sel; | 655 | QStringList sel; |
656 | stream >> sel; | 656 | stream >> sel; |
657 | picker.setSelection(i++,sel); | 657 | picker.setSelection(i++,sel); |
658 | } | 658 | } |
659 | picker.showMaximized(); | 659 | picker.showMaximized(); |
660 | picker.exec(); | 660 | picker.exec(); |
661 | 661 | ||
662 | // ###### note: contacts may have been added - save here! | 662 | // ###### note: contacts may have been added - save here! |
663 | 663 | ||
664 | setCentralWidget(abList); | 664 | setCentralWidget(abList); |
665 | QCopEnvelope e(ch,m); | 665 | QCopEnvelope e(ch,m); |
666 | i=0; | 666 | i=0; |
667 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 667 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
668 | QStringList sel = picker.selection(i++); | 668 | QStringList sel = picker.selection(i++); |
669 | e << sel; | 669 | e << sel; |
670 | } | 670 | } |
671 | } | 671 | } |
672 | #endif | 672 | #endif |
673 | 673 | ||
674 | } | 674 | } |
675 | 675 | ||
676 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 676 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
677 | { | 677 | { |
678 | OContact entry; | 678 | OContact entry; |
679 | if ( !abEditor ) { | 679 | if ( !abEditor ) { |
680 | abEditor = new ContactEditor( entry, this, "editor" ); | 680 | abEditor = new ContactEditor( entry, this, "editor" ); |
681 | } | 681 | } |
682 | if ( entryMode == EditEntry ) | 682 | if ( entryMode == EditEntry ) |
683 | abEditor->setEntry( m_abView -> currentEntry() ); | 683 | abEditor->setEntry( m_abView -> currentEntry() ); |
684 | else if ( entryMode == NewEntry ) | 684 | else if ( entryMode == NewEntry ) |
685 | abEditor->setEntry( entry ); | 685 | abEditor->setEntry( entry ); |
686 | // other things may change the caption. | 686 | // other things may change the caption. |
687 | abEditor->setCaption( tr("Edit Address") ); | 687 | abEditor->setCaption( tr("Edit Address") ); |
688 | 688 | ||
689 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 689 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
690 | abEditor->showMaximized(); | 690 | abEditor->showMaximized(); |
691 | #endif | 691 | #endif |
692 | // fix the foxus... | 692 | // fix the foxus... |
693 | abEditor->setNameFocus(); | 693 | abEditor->setNameFocus(); |
694 | if ( abEditor->exec() ) { | 694 | if ( abEditor->exec() ) { |
695 | setFocus(); | 695 | setFocus(); |
696 | if ( entryMode == NewEntry ) { | 696 | if ( entryMode == NewEntry ) { |
697 | OContact insertEntry = abEditor->entry(); | 697 | OContact insertEntry = abEditor->entry(); |
698 | insertEntry.assignUid(); | 698 | insertEntry.assignUid(); |
699 | m_abView -> addEntry( insertEntry ); | 699 | m_abView -> addEntry( insertEntry ); |
700 | } else { | 700 | } else { |
701 | OContact replEntry = abEditor->entry(); | 701 | OContact replEntry = abEditor->entry(); |
702 | 702 | ||
703 | if ( !replEntry.isValidUid() ) | 703 | if ( !replEntry.isValidUid() ) |
704 | replEntry.assignUid(); | 704 | replEntry.assignUid(); |
705 | 705 | ||
706 | m_abView -> replaceEntry( replEntry ); | 706 | m_abView -> replaceEntry( replEntry ); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | // populateCategories(); | 709 | // populateCategories(); |
710 | 710 | ||
711 | } | 711 | } |
712 | 712 | ||
713 | void AddressbookWindow::editPersonal() | 713 | void AddressbookWindow::editPersonal() |
714 | { | 714 | { |
715 | OContact entry; | 715 | OContact entry; |
716 | |||
717 | // Switch to personal view if not selected | ||
718 | // but take care of the menu, too | ||
719 | if ( ! actionPersonal->isOn() ){ | ||
720 | qWarning("*** ++++"); | ||
721 | actionPersonal->setOn( true ); | ||
722 | slotPersonalView(); | ||
723 | } | ||
724 | |||
716 | if ( !abEditor ) { | 725 | if ( !abEditor ) { |
717 | abEditor = new ContactEditor( entry, this, "editor" ); | 726 | abEditor = new ContactEditor( entry, this, "editor" ); |
718 | } | 727 | } |
719 | 728 | ||
720 | m_abView->showPersonal( true ); | ||
721 | abEditor->setCaption(tr("Edit My Personal Details")); | 729 | abEditor->setCaption(tr("Edit My Personal Details")); |
722 | abEditor->setPersonalView( true ); | 730 | abEditor->setPersonalView( true ); |
723 | editEntry( EditEntry ); | 731 | editEntry( EditEntry ); |
724 | abEditor->setPersonalView( false ); | 732 | abEditor->setPersonalView( false ); |
725 | 733 | ||
726 | } | 734 | } |
727 | 735 | ||
728 | 736 | ||
729 | void AddressbookWindow::slotPersonalView() | 737 | void AddressbookWindow::slotPersonalView() |
730 | { | 738 | { |
739 | qWarning("slotPersonalView()"); | ||
731 | if (!actionPersonal->isOn()) { | 740 | if (!actionPersonal->isOn()) { |
732 | // we just turned it off | 741 | // we just turned it off |
742 | qWarning("slotPersonalView()-> OFF"); | ||
733 | setCaption( tr("Contacts") ); | 743 | setCaption( tr("Contacts") ); |
734 | actionNew->setEnabled(TRUE); | 744 | actionNew->setEnabled(TRUE); |
735 | actionTrash->setEnabled(TRUE); | 745 | actionTrash->setEnabled(TRUE); |
736 | actionFind->setEnabled(TRUE); | 746 | actionFind->setEnabled(TRUE); |
737 | actionMail->setEnabled(TRUE); | 747 | actionMail->setEnabled(TRUE); |
738 | // slotUpdateToolbar(); | 748 | // slotUpdateToolbar(); |
739 | 749 | ||
740 | m_abView->showPersonal( false ); | 750 | m_abView->showPersonal( false ); |
741 | 751 | ||
742 | return; | 752 | return; |
743 | } | 753 | } |
744 | 754 | ||
755 | qWarning("slotPersonalView()-> ON"); | ||
745 | // XXX need to disable some QActions. | 756 | // XXX need to disable some QActions. |
746 | actionNew->setEnabled(FALSE); | 757 | actionNew->setEnabled(FALSE); |
747 | actionTrash->setEnabled(FALSE); | 758 | actionTrash->setEnabled(FALSE); |
748 | actionFind->setEnabled(FALSE); | 759 | actionFind->setEnabled(FALSE); |
749 | actionMail->setEnabled(FALSE); | 760 | actionMail->setEnabled(FALSE); |
750 | 761 | ||
751 | setCaption( tr("Contacts - My Personal Details") ); | 762 | setCaption( tr("Contacts - My Personal Details") ); |
752 | 763 | ||
753 | m_abView->showPersonal( true ); | 764 | m_abView->showPersonal( true ); |
754 | 765 | ||
755 | } | 766 | } |
756 | 767 | ||
757 | 768 | ||
758 | void AddressbookWindow::listIsEmpty( bool empty ) | 769 | void AddressbookWindow::listIsEmpty( bool empty ) |
759 | { | 770 | { |
760 | if ( !empty ) { | 771 | if ( !empty ) { |
761 | deleteButton->setEnabled( TRUE ); | 772 | deleteButton->setEnabled( TRUE ); |
762 | } | 773 | } |
763 | } | 774 | } |
764 | 775 | ||
765 | void AddressbookWindow::reload() | 776 | void AddressbookWindow::reload() |
766 | { | 777 | { |
767 | syncing = FALSE; | 778 | syncing = FALSE; |
768 | m_abView->clear(); | 779 | m_abView->clear(); |
769 | m_abView->reload(); | 780 | m_abView->reload(); |
770 | } | 781 | } |
771 | 782 | ||
772 | void AddressbookWindow::flush() | 783 | void AddressbookWindow::flush() |
773 | { | 784 | { |
774 | syncing = TRUE; | 785 | syncing = TRUE; |
775 | m_abView->save(); | 786 | m_abView->save(); |
776 | } | 787 | } |
777 | 788 | ||
778 | 789 | ||
779 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 790 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
780 | { | 791 | { |
781 | if(active_view == AbView::CardView){ | 792 | if(active_view == AbView::CardView){ |
782 | slotViewSwitched( AbView::TableView ); | 793 | slotViewSwitched( AbView::TableView ); |
783 | e->ignore(); | 794 | e->ignore(); |
784 | return; | 795 | return; |
785 | } | 796 | } |
786 | if(syncing) { | 797 | if(syncing) { |
787 | /* shouldn't we save, I hear you say? well its already been set | 798 | /* shouldn't we save, I hear you say? well its already been set |
788 | so that an edit can not occur during a sync, and we flushed | 799 | so that an edit can not occur during a sync, and we flushed |
789 | at the start of the sync, so there is no need to save | 800 | at the start of the sync, so there is no need to save |
790 | Saving however itself would cause problems. */ | 801 | Saving however itself would cause problems. */ |
791 | e->accept(); | 802 | e->accept(); |
792 | return; | 803 | return; |
793 | } | 804 | } |
794 | //################## shouldn't always save | 805 | //################## shouldn't always save |
795 | // True, but the database handles this automatically ! (se) | 806 | // True, but the database handles this automatically ! (se) |
796 | if ( save() ) | 807 | if ( save() ) |
797 | e->accept(); | 808 | e->accept(); |
798 | else | 809 | else |
799 | e->ignore(); | 810 | e->ignore(); |
800 | } | 811 | } |
801 | 812 | ||
802 | /* | 813 | /* |
803 | Returns TRUE if it is OK to exit | 814 | Returns TRUE if it is OK to exit |
804 | */ | 815 | */ |
805 | 816 | ||
806 | bool AddressbookWindow::save() | 817 | bool AddressbookWindow::save() |
807 | { | 818 | { |
808 | if ( !m_abView->save() ) { | 819 | if ( !m_abView->save() ) { |
809 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 820 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
810 | tr("Unable to save information.\n" | 821 | tr("Unable to save information.\n" |
811 | "Free up some space\n" | 822 | "Free up some space\n" |
812 | "and try again.\n" | 823 | "and try again.\n" |
813 | "\nQuit anyway?"), | 824 | "\nQuit anyway?"), |
814 | QMessageBox::Yes|QMessageBox::Escape, | 825 | QMessageBox::Yes|QMessageBox::Escape, |
815 | QMessageBox::No|QMessageBox::Default ) | 826 | QMessageBox::No|QMessageBox::Default ) |
816 | != QMessageBox::No ) | 827 | != QMessageBox::No ) |
817 | return TRUE; | 828 | return TRUE; |
818 | else | 829 | else |
819 | return FALSE; | 830 | return FALSE; |
820 | } | 831 | } |
821 | return TRUE; | 832 | return TRUE; |
822 | } | 833 | } |
823 | 834 | ||
824 | #ifdef __DEBUG_RELEASE | 835 | #ifdef __DEBUG_RELEASE |
825 | void AddressbookWindow::slotSave() | 836 | void AddressbookWindow::slotSave() |
826 | { | 837 | { |
827 | save(); | 838 | save(); |
828 | } | 839 | } |
829 | #endif | 840 | #endif |
830 | 841 | ||
831 | 842 | ||
832 | void AddressbookWindow::slotNotFound() | 843 | void AddressbookWindow::slotNotFound() |
833 | { | 844 | { |
834 | qWarning("Got notfound signal!"); | 845 | qWarning("Got notfound signal!"); |
835 | QMessageBox::information( this, tr( "Not Found" ), | 846 | QMessageBox::information( this, tr( "Not Found" ), |
836 | tr( "Unable to find a contact for this \n search pattern!" ) ); | 847 | tr( "Unable to find a contact for this \n search pattern!" ) ); |
837 | 848 | ||
838 | 849 | ||
839 | } | 850 | } |
840 | void AddressbookWindow::slotWrapAround() | 851 | void AddressbookWindow::slotWrapAround() |
841 | { | 852 | { |
842 | qWarning("Got wrap signal!"); | 853 | qWarning("Got wrap signal!"); |
843 | // if ( doNotifyWrapAround ) | 854 | // if ( doNotifyWrapAround ) |
844 | // QMessageBox::information( this, tr( "End of list" ), | 855 | // QMessageBox::information( this, tr( "End of list" ), |
845 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 856 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
846 | 857 | ||
847 | } | 858 | } |
848 | 859 | ||
849 | void AddressbookWindow::slotSetCategory( int c ) | 860 | void AddressbookWindow::slotSetCategory( int c ) |
850 | { | 861 | { |
851 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); | 862 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); |
852 | 863 | ||
853 | QString cat, book; | 864 | QString cat, book; |
854 | AbView::Views view = AbView::TableView; | 865 | AbView::Views view = AbView::TableView; |
855 | 866 | ||
856 | if ( c <= 0 ) | 867 | if ( c <= 0 ) |
857 | return; | 868 | return; |
858 | 869 | ||
859 | // Switch view | 870 | // Switch view |
860 | if ( c < 3 ) | 871 | if ( c < 3 ) |
861 | for ( unsigned int i = 1; i < 3; i++ ){ | 872 | for ( unsigned int i = 1; i < 3; i++ ){ |
862 | if ( catMenu ) | 873 | if ( catMenu ) |
863 | catMenu->setItemChecked( i, c == (int)i ); | 874 | catMenu->setItemChecked( i, c == (int)i ); |
864 | } | 875 | } |
865 | else | 876 | else |
866 | // Checkmark Category Menu Item Selected | 877 | // Checkmark Category Menu Item Selected |
867 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) | 878 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) |
868 | catMenu->setItemChecked( i, c == (int)i ); | 879 | catMenu->setItemChecked( i, c == (int)i ); |
869 | 880 | ||
870 | // Now switch to the selected category | 881 | // Now switch to the selected category |
871 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 882 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
872 | if (catMenu->isItemChecked( i )) { | 883 | if (catMenu->isItemChecked( i )) { |
873 | if ( i == 1 ){ // default List view | 884 | if ( i == 1 ){ // default List view |
874 | book = QString::null; | 885 | book = QString::null; |
875 | view = AbView::TableView; | 886 | view = AbView::TableView; |
876 | }else if ( i == 2 ){ | 887 | }else if ( i == 2 ){ |
877 | book = tr( "Cards" ); | 888 | book = tr( "Cards" ); |
878 | view = AbView::CardView; | 889 | view = AbView::CardView; |
879 | // }else if ( i == 3 ){ | 890 | // }else if ( i == 3 ){ |
880 | // book = tr( "Personal" ); | 891 | // book = tr( "Personal" ); |
881 | // view = AbView:: PersonalView; | 892 | // view = AbView:: PersonalView; |
882 | }else if ( i == 3 ){ // default All Categories | 893 | }else if ( i == 3 ){ // default All Categories |
883 | cat = QString::null; | 894 | cat = QString::null; |
884 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled | 895 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled |
885 | cat = "Unfiled"; | 896 | cat = "Unfiled"; |
886 | qWarning ("Unfiled selected!!!"); | 897 | qWarning ("Unfiled selected!!!"); |
887 | }else{ | 898 | }else{ |
888 | cat = m_abView->categories()[i - 4]; | 899 | cat = m_abView->categories()[i - 4]; |
889 | } | 900 | } |
890 | } | 901 | } |
891 | } | 902 | } |
892 | 903 | ||
893 | // Switch to the selected View | 904 | // Switch to the selected View |
894 | slotViewSwitched( view ); | 905 | slotViewSwitched( view ); |
895 | 906 | ||
896 | // Tell the view about the selected category | 907 | // Tell the view about the selected category |
897 | m_abView -> setShowByCategory( cat ); | 908 | m_abView -> setShowByCategory( cat ); |
898 | 909 | ||
899 | if ( book.isEmpty() ) | 910 | if ( book.isEmpty() ) |
900 | book = "List"; | 911 | book = "List"; |
901 | if ( cat.isEmpty() ) | 912 | if ( cat.isEmpty() ) |
902 | cat = "All"; | 913 | cat = "All"; |
903 | 914 | ||
904 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); | 915 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); |
905 | } | 916 | } |
906 | 917 | ||
907 | void AddressbookWindow::slotViewSwitched( int view ) | 918 | void AddressbookWindow::slotViewSwitched( int view ) |
908 | { | 919 | { |
909 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); | 920 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); |
910 | int menu = 0; | 921 | int menu = 0; |
911 | 922 | ||
912 | // Switch to selected view | 923 | // Switch to selected view |
913 | switch ( view ){ | 924 | switch ( view ){ |
914 | case AbView::TableView: | 925 | case AbView::TableView: |
915 | menu = 1; | 926 | menu = 1; |
916 | m_tableViewButton->setOn(true); | 927 | m_tableViewButton->setOn(true); |
917 | m_cardViewButton->setOn(false); | 928 | m_cardViewButton->setOn(false); |
918 | break; | 929 | break; |
919 | case AbView::CardView: | 930 | case AbView::CardView: |
920 | menu = 2; | 931 | menu = 2; |
921 | m_tableViewButton->setOn(false); | 932 | m_tableViewButton->setOn(false); |
922 | m_cardViewButton->setOn(true); | 933 | m_cardViewButton->setOn(true); |
923 | break; | 934 | break; |
924 | } | 935 | } |
925 | for ( unsigned int i = 1; i < 3; i++ ){ | 936 | for ( unsigned int i = 1; i < 3; i++ ){ |
926 | if ( catMenu ) | 937 | if ( catMenu ) |
927 | catMenu->setItemChecked( i, menu == (int)i ); | 938 | catMenu->setItemChecked( i, menu == (int)i ); |
928 | } | 939 | } |
929 | 940 | ||
930 | // Tell the view about the selected view | 941 | // Tell the view about the selected view |
931 | m_abView -> setShowToView ( (AbView::Views) view ); | 942 | m_abView -> setShowToView ( (AbView::Views) view ); |
932 | active_view = view; | 943 | active_view = view; |
933 | } | 944 | } |
934 | 945 | ||
935 | 946 | ||
936 | void AddressbookWindow::slotListView() | 947 | void AddressbookWindow::slotListView() |
937 | { | 948 | { |
938 | slotViewSwitched( AbView::TableView ); | 949 | slotViewSwitched( AbView::TableView ); |
939 | } | 950 | } |
940 | 951 | ||
941 | void AddressbookWindow::slotCardView() | 952 | void AddressbookWindow::slotCardView() |
942 | { | 953 | { |
943 | slotViewSwitched( AbView::CardView ); | 954 | slotViewSwitched( AbView::CardView ); |
944 | } | 955 | } |
945 | 956 | ||
946 | void AddressbookWindow::slotSetLetter( char c ) { | 957 | void AddressbookWindow::slotSetLetter( char c ) { |
947 | 958 | ||
948 | m_abView->setShowByLetter( c ); | 959 | m_abView->setShowByLetter( c ); |
949 | 960 | ||
950 | } | 961 | } |
951 | 962 | ||
952 | 963 | ||
953 | void AddressbookWindow::populateCategories() | 964 | void AddressbookWindow::populateCategories() |
954 | { | 965 | { |
955 | catMenu->clear(); | 966 | catMenu->clear(); |
956 | 967 | ||
957 | int id, rememberId; | 968 | int id, rememberId; |
958 | id = 1; | 969 | id = 1; |
959 | rememberId = 0; | 970 | rememberId = 0; |
960 | 971 | ||
961 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); | 972 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); |
962 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); | 973 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); |
963 | // catMenu->insertItem( tr( "Personal" ), id++ ); | 974 | // catMenu->insertItem( tr( "Personal" ), id++ ); |
964 | catMenu->insertSeparator(); | 975 | catMenu->insertSeparator(); |
965 | 976 | ||
966 | catMenu->insertItem( tr( "All" ), id++ ); | 977 | catMenu->insertItem( tr( "All" ), id++ ); |
967 | QStringList categories = m_abView->categories(); | 978 | QStringList categories = m_abView->categories(); |
968 | categories.append( tr( "Unfiled" ) ); | 979 | categories.append( tr( "Unfiled" ) ); |
969 | for ( QStringList::Iterator it = categories.begin(); | 980 | for ( QStringList::Iterator it = categories.begin(); |
970 | it != categories.end(); ++it ) { | 981 | it != categories.end(); ++it ) { |
971 | catMenu->insertItem( *it, id ); | 982 | catMenu->insertItem( *it, id ); |
972 | if ( *it == m_abView -> showCategory() ) | 983 | if ( *it == m_abView -> showCategory() ) |
973 | rememberId = id; | 984 | rememberId = id; |
974 | ++id; | 985 | ++id; |
975 | } | 986 | } |
976 | 987 | ||
977 | 988 | ||
978 | if ( m_abView -> showCategory().isEmpty() ) { | 989 | if ( m_abView -> showCategory().isEmpty() ) { |
979 | slotSetCategory( 3 ); | 990 | slotSetCategory( 3 ); |
980 | } | 991 | } |
981 | else { | 992 | else { |
982 | slotSetCategory( rememberId ); | 993 | slotSetCategory( rememberId ); |
983 | } | 994 | } |
984 | } | 995 | } |
985 | 996 | ||
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 2bedc0b..69fe2f8 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h | |||
@@ -1,139 +1,135 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef Addressbook_H | 20 | #ifndef Addressbook_H |
21 | #define Addressbook_H | 21 | #define Addressbook_H |
22 | 22 | ||
23 | // Remove this for OPIE releae 1.0 ! | 23 | // Remove this for OPIE releae 1.0 ! |
24 | #define __DEBUG_RELEASE | 24 | #define __DEBUG_RELEASE |
25 | 25 | ||
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qvaluelist.h> | 27 | #include <qvaluelist.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include "ofloatbar.h" | 30 | #include "ofloatbar.h" |
31 | #include "abview.h" | 31 | #include "abview.h" |
32 | #include "abconfig.h" | 32 | #include "abconfig.h" |
33 | 33 | ||
34 | class ContactEditor; | 34 | class ContactEditor; |
35 | class AbLabel; | 35 | class AbLabel; |
36 | class AbTable; | 36 | class AbTable; |
37 | class QPEToolBar; | 37 | class QPEToolBar; |
38 | class QPopupMenu; | 38 | class QPopupMenu; |
39 | class QToolButton; | 39 | class QToolButton; |
40 | class QDialog; | 40 | class QDialog; |
41 | class Ir; | 41 | class Ir; |
42 | class QAction; | 42 | class QAction; |
43 | class LetterPicker; | 43 | class LetterPicker; |
44 | 44 | ||
45 | class AddressbookWindow: public QMainWindow | 45 | class AddressbookWindow: public QMainWindow |
46 | { | 46 | { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | enum EntryMode { NewEntry=0, EditEntry }; | 49 | enum EntryMode { NewEntry=0, EditEntry }; |
50 | 50 | ||
51 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 51 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
52 | ~AddressbookWindow(); | 52 | ~AddressbookWindow(); |
53 | 53 | ||
54 | protected: | 54 | protected: |
55 | void resizeEvent( QResizeEvent * e ); | 55 | void resizeEvent( QResizeEvent * e ); |
56 | 56 | ||
57 | void editPersonal(); | 57 | void editPersonal(); |
58 | void editEntry( EntryMode ); | 58 | void editEntry( EntryMode ); |
59 | void closeEvent( QCloseEvent *e ); | 59 | void closeEvent( QCloseEvent *e ); |
60 | bool save(); | 60 | bool save(); |
61 | 61 | ||
62 | public slots: | 62 | public slots: |
63 | void flush(); | 63 | void flush(); |
64 | void reload(); | 64 | void reload(); |
65 | void appMessage(const QCString &, const QByteArray &); | 65 | void appMessage(const QCString &, const QByteArray &); |
66 | void setDocument( const QString & ); | 66 | void setDocument( const QString & ); |
67 | #ifdef __DEBUG_RELEASE | 67 | #ifdef __DEBUG_RELEASE |
68 | void slotSave(); | 68 | void slotSave(); |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | private slots: | 71 | private slots: |
72 | void importvCard(); | 72 | void importvCard(); |
73 | void slotListNew(); | 73 | void slotListNew(); |
74 | /* void slotListView(); */ | 74 | /* void slotListView(); */ |
75 | void slotListDelete(); | 75 | void slotListDelete(); |
76 | void slotViewBack(); | 76 | void slotViewBack(); |
77 | void slotViewEdit(); | 77 | void slotViewEdit(); |
78 | void slotPersonalView(); | 78 | void slotPersonalView(); |
79 | void listIsEmpty( bool ); | 79 | void listIsEmpty( bool ); |
80 | /* void slotSettings(); */ | 80 | /* void slotSettings(); */ |
81 | void writeMail(); | 81 | void writeMail(); |
82 | void slotBeam(); | 82 | void slotBeam(); |
83 | void beamDone( Ir * ); | 83 | void beamDone( Ir * ); |
84 | void slotSetCategory( int ); | 84 | void slotSetCategory( int ); |
85 | void slotSetLetter( char ); | 85 | void slotSetLetter( char ); |
86 | void slotUpdateToolbar(); | 86 | void slotUpdateToolbar(); |
87 | void slotSetFont(int); | 87 | void slotSetFont(int); |
88 | 88 | ||
89 | void slotFindOpen(); | 89 | void slotFindOpen(); |
90 | void slotFindClose(); | 90 | void slotFindClose(); |
91 | void slotFind(); | 91 | void slotFind(); |
92 | void slotNotFound(); | 92 | void slotNotFound(); |
93 | void slotWrapAround(); | 93 | void slotWrapAround(); |
94 | 94 | ||
95 | void slotViewSwitched( int ); | 95 | void slotViewSwitched( int ); |
96 | void slotListView(); | 96 | void slotListView(); |
97 | void slotCardView(); | 97 | void slotCardView(); |
98 | 98 | ||
99 | void slotConfig(); | 99 | void slotConfig(); |
100 | 100 | ||
101 | private: | 101 | private: |
102 | //void initFields(); // inititialize our fields... | ||
103 | // AbLabel *abView(); | ||
104 | void populateCategories(); | 102 | void populateCategories(); |
105 | 103 | ||
106 | QPopupMenu *catMenu; | 104 | QPopupMenu *catMenu; |
107 | QPEToolBar *listTools; | 105 | QPEToolBar *listTools; |
108 | QToolButton *deleteButton; | 106 | QToolButton *deleteButton; |
109 | //QValueList<int> allFields, orderedFields; | ||
110 | //QStringList slOrderedFields; | ||
111 | enum Panes { paneList=0, paneView, paneEdit }; | 107 | enum Panes { paneList=0, paneView, paneEdit }; |
112 | ContactEditor *abEditor; | 108 | ContactEditor *abEditor; |
113 | LetterPicker *pLabel; | 109 | LetterPicker *pLabel; |
114 | AbView* m_abView; | 110 | AbView* m_abView; |
115 | QWidget *listContainer; | 111 | QWidget *listContainer; |
116 | 112 | ||
117 | // Searching stuff | 113 | // Searching stuff |
118 | OFloatBar* searchBar; | 114 | OFloatBar* searchBar; |
119 | QLineEdit* searchEdit; | 115 | QLineEdit* searchEdit; |
120 | 116 | ||
121 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; | 117 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; |
122 | 118 | ||
123 | int viewMargin; | 119 | int viewMargin; |
124 | 120 | ||
125 | bool syncing; | 121 | bool syncing; |
126 | QFont *defaultFont; | 122 | QFont *defaultFont; |
127 | int m_curFontSize; | 123 | int m_curFontSize; |
128 | 124 | ||
129 | bool isLoading; | 125 | bool isLoading; |
130 | 126 | ||
131 | AbConfig m_config; | 127 | AbConfig m_config; |
132 | 128 | ||
133 | QAction* m_tableViewButton; | 129 | QAction* m_tableViewButton; |
134 | QAction* m_cardViewButton; | 130 | QAction* m_cardViewButton; |
135 | 131 | ||
136 | int active_view; | 132 | int active_view; |
137 | }; | 133 | }; |
138 | 134 | ||
139 | #endif | 135 | #endif |