summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp191
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
@@ -15,3 +15,3 @@
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.
@@ -97,2 +97,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
97{ 97{
98 isLoading = true;
99
98 initFields(); 100 initFields();
@@ -189,3 +191,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
189 191
190
191 edit->insertSeparator(); 192 edit->insertSeparator();
@@ -209,3 +210,5 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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"
@@ -222,9 +225,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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
@@ -247,3 +247,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
247 mbList->insertItem( tr("View"), catMenu ); 247 mbList->insertItem( tr("View"), catMenu );
248 setCentralWidget( listContainer ); 248 // setCentralWidget( listContainer );
249 249
@@ -265,2 +265,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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}
@@ -284,3 +288,4 @@ void AddressbookWindow::slotSetFont( int size ) {
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;
@@ -292,3 +297,4 @@ void AddressbookWindow::slotSetFont( int size ) {
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;
@@ -300,3 +306,4 @@ void AddressbookWindow::slotSetFont( int size ) {
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;
@@ -316,6 +323,7 @@ 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?")
@@ -349,3 +357,3 @@ 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() );
@@ -355,3 +363,9 @@ 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 );
@@ -360,2 +374,9 @@ void AddressbookWindow::showList()
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}
@@ -374,3 +395,3 @@ void AddressbookWindow::slotListNew()
374{ 395{
375 Contact cnt; 396 OContact cnt;
376 if( !syncing ) { 397 if( !syncing ) {
@@ -381,3 +402,3 @@ void AddressbookWindow::slotListNew()
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"));
@@ -396,3 +417,3 @@ void AddressbookWindow::slotListDelete()
396 if(!syncing) { 417 if(!syncing) {
397 Contact tmpEntry = abList->currentEntry(); 418 OContact tmpEntry = abList->currentEntry();
398 419
@@ -443,3 +464,3 @@ 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();
@@ -450,5 +471,2 @@ void AddressbookWindow::writeMail()
450 471
451
452
453
454static const char * beamfile = "/tmp/obex/contact.vcf"; 472static const char * beamfile = "/tmp/obex/contact.vcf";
@@ -458,3 +476,3 @@ void AddressbookWindow::slotBeam()
458 QString filename; 476 QString filename;
459 Contact c; 477 OContact c;
460 if ( actionPersonal->isOn() ) { 478 if ( actionPersonal->isOn() ) {
@@ -463,3 +481,3 @@ void AddressbookWindow::slotBeam()
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 {
@@ -468,3 +486,3 @@ void AddressbookWindow::slotBeam()
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;
@@ -524,3 +542,3 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
524 542
525 Contact cnt; 543 OContact cnt;
526 QString fn, mn, ln; 544 QString fn, mn, ln;
@@ -583,5 +601,5 @@ void AddressbookWindow::editPersonal()
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) {
@@ -601,5 +619,5 @@ void AddressbookWindow::editPersonal()
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);
@@ -635,5 +653,5 @@ void AddressbookWindow::slotPersonalView()
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
@@ -649,3 +667,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
649{ 667{
650 Contact entry; 668 OContact entry;
651 if ( bAbEditFirstTime ) { 669 if ( bAbEditFirstTime ) {
@@ -668,3 +686,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
668 if ( entryMode == NewEntry ) { 686 if ( entryMode == NewEntry ) {
669 Contact insertEntry = abEditor->entry(); 687 OContact insertEntry = abEditor->entry();
670 insertEntry.assignUid(); 688 insertEntry.assignUid();
@@ -672,3 +690,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
672 } else { 690 } else {
673 Contact replaceEntry = abEditor->entry(); 691 OContact replaceEntry = abEditor->entry();
674 if ( !replaceEntry.isValidUid() ) 692 if ( !replaceEntry.isValidUid() )
@@ -726,2 +744,3 @@ void AddressbookWindow::closeEvent( QCloseEvent *e )
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() )
@@ -794,4 +813,4 @@ void AddressbookWindow::initFields()
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" );
@@ -800,4 +819,3 @@ void AddressbookWindow::initFields()
800 819
801 int i, 820 int i, version;
802 version;
803 Config cfg( "AddressBook" ); 821 Config cfg( "AddressBook" );
@@ -885,3 +903,3 @@ AbLabel *AddressbookWindow::abView()
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() ) );
@@ -913,16 +931,36 @@ 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 }
@@ -930,2 +968,12 @@ void AddressbookWindow::slotSetCategory( int c )
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
931void AddressbookWindow::slotSetLetter( char c ) { 979void AddressbookWindow::slotSetLetter( char c ) {
@@ -940,6 +988,13 @@ void AddressbookWindow::populateCategories()
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++ );
@@ -954,6 +1009,22 @@ void AddressbookWindow::populateCategories()
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