Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 191 |
1 files changed, 131 insertions, 60 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 3255269..cf2eddf 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -13,7 +13,7 @@ | |||
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 | ** OContact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
@@ -95,6 +95,8 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
95 | bAbEditFirstTime(TRUE), | 95 | bAbEditFirstTime(TRUE), |
96 | syncing(FALSE) | 96 | syncing(FALSE) |
97 | { | 97 | { |
98 | isLoading = true; | ||
99 | |||
98 | initFields(); | 100 | initFields(); |
99 | 101 | ||
100 | setCaption( tr("Contacts") ); | 102 | setCaption( tr("Contacts") ); |
@@ -187,7 +189,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
187 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 189 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
188 | a->addTo( edit ); | 190 | a->addTo( edit ); |
189 | 191 | ||
190 | |||
191 | edit->insertSeparator(); | 192 | edit->insertSeparator(); |
192 | 193 | ||
193 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | 194 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); |
@@ -207,7 +208,9 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
207 | // journaling... | 208 | // journaling... |
208 | QString str = addressbookXMLFilename(); | 209 | QString str = addressbookXMLFilename(); |
209 | if ( str.isNull() ) { | 210 | if ( str.isNull() ) { |
210 | QMessageBox::warning( this, tr("Out of Space"), | 211 | QMessageBox::warning( |
212 | this, | ||
213 | tr("Out of Space"), | ||
211 | tr("There is not enough space to create\n" | 214 | tr("There is not enough space to create\n" |
212 | "neccessary startup files.\n" | 215 | "neccessary startup files.\n" |
213 | "\nFree up some space before\nentering data!") | 216 | "\nFree up some space before\nentering data!") |
@@ -220,13 +223,10 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
220 | 223 | ||
221 | abList = new AbTable( &orderedFields, listContainer, "table" ); | 224 | abList = new AbTable( &orderedFields, listContainer, "table" ); |
222 | vb->addWidget(abList); | 225 | vb->addWidget(abList); |
223 | abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 226 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
224 | connect( abList, SIGNAL( empty( bool ) ), | 227 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); |
225 | this, SLOT( listIsEmpty( bool ) ) ); | 228 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); |
226 | connect( abList, SIGNAL( details() ), | 229 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); |
227 | this, SLOT( slotListView() ) ); | ||
228 | connect( abList, SIGNAL(currentChanged(int,int)), | ||
229 | this, SLOT(slotUpdateToolbar()) ); | ||
230 | 230 | ||
231 | mView = 0; | 231 | mView = 0; |
232 | 232 | ||
@@ -245,7 +245,7 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
245 | populateCategories(); | 245 | populateCategories(); |
246 | 246 | ||
247 | mbList->insertItem( tr("View"), catMenu ); | 247 | mbList->insertItem( tr("View"), catMenu ); |
248 | setCentralWidget( listContainer ); | 248 | // setCentralWidget( listContainer ); |
249 | 249 | ||
250 | fontMenu = new QPopupMenu(this); | 250 | fontMenu = new QPopupMenu(this); |
251 | fontMenu->setCheckable( true ); | 251 | fontMenu->setCheckable( true ); |
@@ -263,6 +263,10 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
263 | setCentralWidget(listContainer); | 263 | setCentralWidget(listContainer); |
264 | 264 | ||
265 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 265 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
266 | |||
267 | abList->setCurrentCell( 0, 0 ); | ||
268 | |||
269 | isLoading = false; | ||
266 | } | 270 | } |
267 | 271 | ||
268 | 272 | ||
@@ -282,7 +286,8 @@ void AddressbookWindow::slotSetFont( int size ) { | |||
282 | fontMenu->setItemChecked(2, false); | 286 | fontMenu->setItemChecked(2, false); |
283 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 287 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
284 | currentFont = new QFont (abList->font()); | 288 | currentFont = new QFont (abList->font()); |
285 | abList->resizeRows(currentFont->pixelSize() + 7); | 289 | // abList->resizeRows(currentFont->pixelSize() + 7); |
290 | abList->resizeRows(); | ||
286 | break; | 291 | break; |
287 | case 1: | 292 | case 1: |
288 | fontMenu->setItemChecked(0, false); | 293 | fontMenu->setItemChecked(0, false); |
@@ -290,7 +295,8 @@ void AddressbookWindow::slotSetFont( int size ) { | |||
290 | fontMenu->setItemChecked(2, false); | 295 | fontMenu->setItemChecked(2, false); |
291 | abList->setFont( *defaultFont ); | 296 | abList->setFont( *defaultFont ); |
292 | currentFont = new QFont (abList->font()); | 297 | currentFont = new QFont (abList->font()); |
293 | abList->resizeRows(currentFont->pixelSize() + 7); | 298 | // abList->resizeRows(currentFont->pixelSize() + 7); |
299 | abList->resizeRows(); | ||
294 | break; | 300 | break; |
295 | case 2: | 301 | case 2: |
296 | fontMenu->setItemChecked(0, false); | 302 | fontMenu->setItemChecked(0, false); |
@@ -298,7 +304,8 @@ void AddressbookWindow::slotSetFont( int size ) { | |||
298 | fontMenu->setItemChecked(2, true); | 304 | fontMenu->setItemChecked(2, true); |
299 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 305 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
300 | currentFont = new QFont (abList->font()); | 306 | currentFont = new QFont (abList->font()); |
301 | abList->resizeRows(currentFont->pixelSize() + 7); | 307 | //abList->resizeRows(currentFont->pixelSize() + 7); |
308 | abList->resizeRows(); | ||
302 | break; | 309 | break; |
303 | } | 310 | } |
304 | } | 311 | } |
@@ -314,10 +321,11 @@ void AddressbookWindow::importvCard() { | |||
314 | 321 | ||
315 | void AddressbookWindow::setDocument( const QString &filename ) | 322 | void AddressbookWindow::setDocument( const QString &filename ) |
316 | { | 323 | { |
317 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; | 324 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) |
325 | return; | ||
318 | 326 | ||
319 | QValueList<Contact> cl = Contact::readVCard( filename ); | 327 | QValueList<OContact> cl = OContact::readVCard( filename ); |
320 | for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { | 328 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { |
321 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") | 329 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") |
322 | // .arg( (*it).fullName() ); | 330 | // .arg( (*it).fullName() ); |
323 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == | 331 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == |
@@ -347,17 +355,30 @@ AddressbookWindow::~AddressbookWindow() | |||
347 | 355 | ||
348 | void AddressbookWindow::slotUpdateToolbar() | 356 | void AddressbookWindow::slotUpdateToolbar() |
349 | { | 357 | { |
350 | Contact ce = abList->currentEntry(); | 358 | OContact ce = abList->currentEntry(); |
351 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 359 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
352 | } | 360 | } |
353 | 361 | ||
354 | void AddressbookWindow::showList() | 362 | void AddressbookWindow::showList() |
355 | { | 363 | { |
356 | if ( mView ) mView->hide(); | 364 | bool visiblemView; |
365 | |||
366 | visiblemView = false; | ||
367 | if ( mView ) { | ||
368 | mView->hide(); | ||
369 | visiblemView = true; | ||
370 | } | ||
357 | setCentralWidget( listContainer ); | 371 | setCentralWidget( listContainer ); |
358 | listContainer->show(); | 372 | listContainer->show(); |
359 | // update our focues... (or use a stack widget!); | 373 | // update our focues... (or use a stack widget!); |
360 | abList->setFocus(); | 374 | abList->setFocus(); |
375 | |||
376 | // This makes sure we are scrolled all the way to the left | ||
377 | abList->setContentsPos( 0, abList->contentsY() ); | ||
378 | |||
379 | //if ( visiblemView && abList->showBook() == "Cards" ) | ||
380 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); | ||
381 | |||
361 | } | 382 | } |
362 | 383 | ||
363 | void AddressbookWindow::showView() | 384 | void AddressbookWindow::showView() |
@@ -372,14 +393,14 @@ void AddressbookWindow::showView() | |||
372 | 393 | ||
373 | void AddressbookWindow::slotListNew() | 394 | void AddressbookWindow::slotListNew() |
374 | { | 395 | { |
375 | Contact cnt; | 396 | OContact cnt; |
376 | if( !syncing ) { | 397 | if( !syncing ) { |
377 | if ( abEditor ) | 398 | if ( abEditor ) |
378 | abEditor->setEntry( cnt ); | 399 | abEditor->setEntry( cnt ); |
379 | abView()->init( cnt ); | 400 | abView()->init( cnt ); |
380 | editEntry( NewEntry ); | 401 | editEntry( NewEntry ); |
381 | } else { | 402 | } else { |
382 | QMessageBox::warning(this, tr("Contacts"), | 403 | QMessageBox::warning(this, tr("OContacts"), |
383 | tr("Can not edit data, currently syncing")); | 404 | tr("Can not edit data, currently syncing")); |
384 | } | 405 | } |
385 | } | 406 | } |
@@ -394,7 +415,7 @@ void AddressbookWindow::slotListView() | |||
394 | void AddressbookWindow::slotListDelete() | 415 | void AddressbookWindow::slotListDelete() |
395 | { | 416 | { |
396 | if(!syncing) { | 417 | if(!syncing) { |
397 | Contact tmpEntry = abList->currentEntry(); | 418 | OContact tmpEntry = abList->currentEntry(); |
398 | 419 | ||
399 | // get a name, do the best we can... | 420 | // get a name, do the best we can... |
400 | QString strName = tmpEntry.fullName(); | 421 | QString strName = tmpEntry.fullName(); |
@@ -441,32 +462,29 @@ void AddressbookWindow::slotViewEdit() | |||
441 | 462 | ||
442 | void AddressbookWindow::writeMail() | 463 | void AddressbookWindow::writeMail() |
443 | { | 464 | { |
444 | Contact c = abList->currentEntry(); | 465 | OContact c = abList->currentEntry(); |
445 | QString name = c.fileAs(); | 466 | QString name = c.fileAs(); |
446 | QString email = c.defaultEmail(); | 467 | QString email = c.defaultEmail(); |
447 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 468 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
448 | e << name << email; | 469 | e << name << email; |
449 | } | 470 | } |
450 | 471 | ||
451 | |||
452 | |||
453 | |||
454 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 472 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
455 | 473 | ||
456 | void AddressbookWindow::slotBeam() | 474 | void AddressbookWindow::slotBeam() |
457 | { | 475 | { |
458 | QString filename; | 476 | QString filename; |
459 | Contact c; | 477 | OContact c; |
460 | if ( actionPersonal->isOn() ) { | 478 | if ( actionPersonal->isOn() ) { |
461 | filename = addressbookPersonalVCardName(); | 479 | filename = addressbookPersonalVCardName(); |
462 | if (!QFile::exists(filename)) | 480 | if (!QFile::exists(filename)) |
463 | return; // can't beam a non-existent file | 481 | return; // can't beam a non-existent file |
464 | c = Contact::readVCard( filename )[0]; | 482 | c = OContact::readVCard( filename )[0]; |
465 | } else { | 483 | } else { |
466 | unlink( beamfile ); // delete if exists | 484 | unlink( beamfile ); // delete if exists |
467 | c = abList->currentEntry(); | 485 | c = abList->currentEntry(); |
468 | mkdir("/tmp/obex/", 0755); | 486 | mkdir("/tmp/obex/", 0755); |
469 | Contact::writeVCard( beamfile, c ); | 487 | OContact::writeVCard( beamfile, c ); |
470 | filename = beamfile; | 488 | filename = beamfile; |
471 | } | 489 | } |
472 | Ir *ir = new Ir( this ); | 490 | Ir *ir = new Ir( this ); |
@@ -522,7 +540,7 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
522 | QString name, email; | 540 | QString name, email; |
523 | stream >> name >> email; | 541 | stream >> name >> email; |
524 | 542 | ||
525 | Contact cnt; | 543 | OContact cnt; |
526 | QString fn, mn, ln; | 544 | QString fn, mn, ln; |
527 | parseName( name, &fn, &mn, &ln ); | 545 | parseName( name, &fn, &mn, &ln ); |
528 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 546 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
@@ -581,9 +599,9 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
581 | void AddressbookWindow::editPersonal() | 599 | void AddressbookWindow::editPersonal() |
582 | { | 600 | { |
583 | QString filename = addressbookPersonalVCardName(); | 601 | QString filename = addressbookPersonalVCardName(); |
584 | Contact me; | 602 | OContact me; |
585 | if (QFile::exists(filename)) | 603 | if (QFile::exists(filename)) |
586 | me = Contact::readVCard( filename )[0]; | 604 | me = OContact::readVCard( filename )[0]; |
587 | if (bAbEditFirstTime) { | 605 | if (bAbEditFirstTime) { |
588 | abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, | 606 | abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, |
589 | this, "editor" ); | 607 | this, "editor" ); |
@@ -599,9 +617,9 @@ void AddressbookWindow::editPersonal() | |||
599 | abEditor->setNameFocus(); | 617 | abEditor->setNameFocus(); |
600 | if ( abEditor->exec() ) { | 618 | if ( abEditor->exec() ) { |
601 | setFocus(); | 619 | setFocus(); |
602 | Contact new_personal = abEditor->entry(); | 620 | OContact new_personal = abEditor->entry(); |
603 | QString fname = addressbookPersonalVCardName(); | 621 | QString fname = addressbookPersonalVCardName(); |
604 | Contact::writeVCard( fname, new_personal ); | 622 | OContact::writeVCard( fname, new_personal ); |
605 | abView()->init(new_personal); | 623 | abView()->init(new_personal); |
606 | abView()->sync(); | 624 | abView()->sync(); |
607 | } | 625 | } |
@@ -633,9 +651,9 @@ void AddressbookWindow::slotPersonalView() | |||
633 | 651 | ||
634 | setCaption( tr("Contacts - My Personal Details") ); | 652 | setCaption( tr("Contacts - My Personal Details") ); |
635 | QString filename = addressbookPersonalVCardName(); | 653 | QString filename = addressbookPersonalVCardName(); |
636 | Contact me; | 654 | OContact me; |
637 | if (QFile::exists(filename)) | 655 | if (QFile::exists(filename)) |
638 | me = Contact::readVCard( filename )[0]; | 656 | me = OContact::readVCard( filename )[0]; |
639 | 657 | ||
640 | abView()->init( me ); | 658 | abView()->init( me ); |
641 | abView()->sync(); | 659 | abView()->sync(); |
@@ -647,7 +665,7 @@ void AddressbookWindow::slotPersonalView() | |||
647 | 665 | ||
648 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 666 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
649 | { | 667 | { |
650 | Contact entry; | 668 | OContact entry; |
651 | if ( bAbEditFirstTime ) { | 669 | if ( bAbEditFirstTime ) { |
652 | abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, | 670 | abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, |
653 | this, "editor" ); | 671 | this, "editor" ); |
@@ -666,11 +684,11 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) | |||
666 | if ( abEditor->exec() ) { | 684 | if ( abEditor->exec() ) { |
667 | setFocus(); | 685 | setFocus(); |
668 | if ( entryMode == NewEntry ) { | 686 | if ( entryMode == NewEntry ) { |
669 | Contact insertEntry = abEditor->entry(); | 687 | OContact insertEntry = abEditor->entry(); |
670 | insertEntry.assignUid(); | 688 | insertEntry.assignUid(); |
671 | abList->addEntry( insertEntry ); | 689 | abList->addEntry( insertEntry ); |
672 | } else { | 690 | } else { |
673 | Contact replaceEntry = abEditor->entry(); | 691 | OContact replaceEntry = abEditor->entry(); |
674 | if ( !replaceEntry.isValidUid() ) | 692 | if ( !replaceEntry.isValidUid() ) |
675 | replaceEntry.assignUid(); | 693 | replaceEntry.assignUid(); |
676 | abList->replaceCurrentEntry( replaceEntry ); | 694 | abList->replaceCurrentEntry( replaceEntry ); |
@@ -724,6 +742,7 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) | |||
724 | return; | 742 | return; |
725 | } | 743 | } |
726 | //################## shouldn't always save | 744 | //################## shouldn't always save |
745 | // True, but the database handles this automatically ! (se) | ||
727 | if ( save() ) | 746 | if ( save() ) |
728 | e->accept(); | 747 | e->accept(); |
729 | else | 748 | else |
@@ -792,14 +811,13 @@ void AddressbookWindow::initFields() | |||
792 | // only thing that is important are the important categories. So, | 811 | // only thing that is important are the important categories. So, |
793 | // Call the contact functions that correspond to these old functions... | 812 | // Call the contact functions that correspond to these old functions... |
794 | 813 | ||
795 | QStringList xmlFields = Contact::fields(); | 814 | QStringList xmlFields = OContact::fields(); |
796 | QStringList visibleFields = Contact::trfields(); | 815 | QStringList visibleFields = OContact::trfields(); |
797 | xmlFields.remove( "Title" ); | 816 | xmlFields.remove( "Title" ); |
798 | visibleFields.remove( tr("Name Title") ); | 817 | visibleFields.remove( tr("Name Title") ); |
799 | visibleFields.remove( tr("Notes") ); | 818 | visibleFields.remove( tr("Notes") ); |
800 | 819 | ||
801 | int i, | 820 | int i, version; |
802 | version; | ||
803 | Config cfg( "AddressBook" ); | 821 | Config cfg( "AddressBook" ); |
804 | QString zn; | 822 | QString zn; |
805 | 823 | ||
@@ -883,7 +901,7 @@ AbLabel *AddressbookWindow::abView() | |||
883 | { | 901 | { |
884 | if ( !mView ) { | 902 | if ( !mView ) { |
885 | mView = new AbLabel( this, "viewer" ); | 903 | mView = new AbLabel( this, "viewer" ); |
886 | mView->init( Contact() ); | 904 | mView->init( OContact() ); |
887 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); | 905 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); |
888 | } | 906 | } |
889 | return mView; | 907 | return mView; |
@@ -911,23 +929,53 @@ void AddressbookWindow::slotFind() | |||
911 | 929 | ||
912 | void AddressbookWindow::slotSetCategory( int c ) | 930 | void AddressbookWindow::slotSetCategory( int c ) |
913 | { | 931 | { |
932 | |||
933 | QString cat, book; | ||
934 | |||
914 | if ( c <= 0 ) | 935 | if ( c <= 0 ) |
915 | return; | 936 | return; |
916 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 937 | |
938 | // Checkmark Book Menu Item Selected | ||
939 | if ( c < 6 ) | ||
940 | for ( unsigned int i = 1; i < 6; i++ ) | ||
917 | catMenu->setItemChecked( i, c == (int)i ); | 941 | catMenu->setItemChecked( i, c == (int)i ); |
918 | if ( c == 1 ) { | 942 | |
919 | abList->setShowCategory( QString::null ); | 943 | // Checkmark Category Menu Item Selected |
920 | setCaption( tr("Contacts") + " - " + tr ( "All" ) ); | 944 | else |
921 | } else if ( c == (int)catMenu->count() ) { | 945 | for ( unsigned int i = 6; i < catMenu->count(); i++ ) |
922 | abList->setShowCategory( tr( "Unfiled" ) ); | 946 | catMenu->setItemChecked( i, c == (int)i ); |
923 | setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); | 947 | |
924 | } else { | 948 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
925 | QString cat = abList->categories()[c - 2]; | 949 | if (catMenu->isItemChecked( i )) { |
926 | abList->setShowCategory( cat ); | 950 | if ( i == 1 ) // default List view |
927 | setCaption( tr("Contacts") + " - " + cat ); | 951 | book = QString::null; |
952 | else if ( i == 2 ) | ||
953 | book = "Phone"; | ||
954 | else if ( i == 3 ) | ||
955 | book = "Company"; | ||
956 | else if ( i == 4 ) | ||
957 | book = "Email"; | ||
958 | else if ( i == 5 ) | ||
959 | book = "Cards"; | ||
960 | else if ( i == 6 ) // default All Categories | ||
961 | cat = QString::null; | ||
962 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled | ||
963 | cat = "Unfiled"; | ||
964 | else | ||
965 | cat = abList->categories()[i - 7]; | ||
928 | } | 966 | } |
929 | } | 967 | } |
930 | 968 | ||
969 | abList->setShowCategory( book, cat ); | ||
970 | |||
971 | if ( book.isEmpty() ) | ||
972 | book = "List"; | ||
973 | if ( cat.isEmpty() ) | ||
974 | cat = "All"; | ||
975 | |||
976 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); | ||
977 | } | ||
978 | |||
931 | void AddressbookWindow::slotSetLetter( char c ) { | 979 | void AddressbookWindow::slotSetLetter( char c ) { |
932 | 980 | ||
933 | abList->setShowByLetter( c ); | 981 | abList->setShowByLetter( c ); |
@@ -938,10 +986,17 @@ void AddressbookWindow::populateCategories() | |||
938 | { | 986 | { |
939 | catMenu->clear(); | 987 | catMenu->clear(); |
940 | 988 | ||
941 | int id, | 989 | int id, rememberId; |
942 | rememberId; | ||
943 | id = 1; | 990 | id = 1; |
944 | rememberId = 0; | 991 | rememberId = 0; |
992 | |||
993 | catMenu->insertItem( tr( "List" ), id++ ); | ||
994 | catMenu->insertItem( tr( "Phone Book" ), id++ ); | ||
995 | catMenu->insertItem( tr( "Company Book" ), id++ ); | ||
996 | catMenu->insertItem( tr( "Email Book" ), id++ ); | ||
997 | catMenu->insertItem( tr( "Cards" ), id++ ); | ||
998 | catMenu->insertSeparator(); | ||
999 | |||
945 | catMenu->insertItem( tr( "All" ), id++ ); | 1000 | catMenu->insertItem( tr( "All" ), id++ ); |
946 | QStringList categories = abList->categories(); | 1001 | QStringList categories = abList->categories(); |
947 | categories.append( tr( "Unfiled" ) ); | 1002 | categories.append( tr( "Unfiled" ) ); |
@@ -952,8 +1007,24 @@ void AddressbookWindow::populateCategories() | |||
952 | rememberId = id; | 1007 | rememberId = id; |
953 | ++id; | 1008 | ++id; |
954 | } | 1009 | } |
955 | if ( abList->showCategory().isEmpty() ) | 1010 | |
956 | slotSetCategory( 1 ); | 1011 | if ( abList->showBook().isEmpty() ) { |
957 | else | 1012 | catMenu->setItemChecked( 1, true ); |
1013 | } else if ( abList->showBook() == "Phone" ) { | ||
1014 | catMenu->setItemChecked( 2, true ); | ||
1015 | } else if ( abList->showBook() == "Company" ) { | ||
1016 | catMenu->setItemChecked( 3, true ); | ||
1017 | } else if ( abList->showBook() == "Email" ) { | ||
1018 | catMenu->setItemChecked( 4, true ); | ||
1019 | } else if ( abList->showBook() == "Cards" ) { | ||
1020 | catMenu->setItemChecked( 5, true ); | ||
1021 | } | ||
1022 | |||
1023 | if ( abList->showCategory().isEmpty() ) { | ||
1024 | slotSetCategory( 6 ); | ||
1025 | } | ||
1026 | else { | ||
958 | slotSetCategory( rememberId ); | 1027 | slotSetCategory( rememberId ); |
959 | } | 1028 | } |
1029 | } | ||
1030 | |||