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 @@ -15,3 +15,3 @@ ** -** Contact info@trolltech.com if any conditions of this licensing are +** OContact info@trolltech.com if any conditions of this licensing are ** not clear to you. @@ -97,2 +97,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, { + isLoading = true; + initFields(); @@ -189,3 +191,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, - edit->insertSeparator(); @@ -209,3 +210,5 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, if ( str.isNull() ) { - QMessageBox::warning( this, tr("Out of Space"), + QMessageBox::warning( + this, + tr("Out of Space"), tr("There is not enough space to create\n" @@ -222,9 +225,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, vb->addWidget(abList); - abList->setHScrollBarMode( QScrollView::AlwaysOff ); - connect( abList, SIGNAL( empty( bool ) ), - this, SLOT( listIsEmpty( bool ) ) ); - connect( abList, SIGNAL( details() ), - this, SLOT( slotListView() ) ); - connect( abList, SIGNAL(currentChanged(int,int)), - this, SLOT(slotUpdateToolbar()) ); + // abList->setHScrollBarMode( QScrollView::AlwaysOff ); + connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); + connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); + connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); @@ -247,3 +247,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, mbList->insertItem( tr("View"), catMenu ); - setCentralWidget( listContainer ); + // setCentralWidget( listContainer ); @@ -265,2 +265,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); + + abList->setCurrentCell( 0, 0 ); + + isLoading = false; } @@ -284,3 +288,4 @@ void AddressbookWindow::slotSetFont( int size ) { currentFont = new QFont (abList->font()); - abList->resizeRows(currentFont->pixelSize() + 7); + // abList->resizeRows(currentFont->pixelSize() + 7); + abList->resizeRows(); break; @@ -292,3 +297,4 @@ void AddressbookWindow::slotSetFont( int size ) { currentFont = new QFont (abList->font()); - abList->resizeRows(currentFont->pixelSize() + 7); + // abList->resizeRows(currentFont->pixelSize() + 7); + abList->resizeRows(); break; @@ -300,3 +306,4 @@ void AddressbookWindow::slotSetFont( int size ) { currentFont = new QFont (abList->font()); - abList->resizeRows(currentFont->pixelSize() + 7); + //abList->resizeRows(currentFont->pixelSize() + 7); + abList->resizeRows(); break; @@ -316,6 +323,7 @@ void AddressbookWindow::setDocument( const QString &filename ) { - if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; + if ( filename.find(".vcf") != int(filename.length()) - 4 ) + return; - QValueList<Contact> cl = Contact::readVCard( filename ); - for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { + QValueList<OContact> cl = OContact::readVCard( filename ); + for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { // 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() { - Contact ce = abList->currentEntry(); + OContact ce = abList->currentEntry(); actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); @@ -355,3 +363,9 @@ void AddressbookWindow::showList() { - if ( mView ) mView->hide(); + bool visiblemView; + + visiblemView = false; + if ( mView ) { + mView->hide(); + visiblemView = true; + } setCentralWidget( listContainer ); @@ -360,2 +374,9 @@ void AddressbookWindow::showList() abList->setFocus(); + + // This makes sure we are scrolled all the way to the left + abList->setContentsPos( 0, abList->contentsY() ); + + //if ( visiblemView && abList->showBook() == "Cards" ) + // abList->setShowCategory( abList->showBook(), abList->showCategory() ); + } @@ -374,3 +395,3 @@ void AddressbookWindow::slotListNew() { - Contact cnt; + OContact cnt; if( !syncing ) { @@ -381,3 +402,3 @@ void AddressbookWindow::slotListNew() } else { - QMessageBox::warning(this, tr("Contacts"), + QMessageBox::warning(this, tr("OContacts"), tr("Can not edit data, currently syncing")); @@ -396,3 +417,3 @@ void AddressbookWindow::slotListDelete() if(!syncing) { - Contact tmpEntry = abList->currentEntry(); + OContact tmpEntry = abList->currentEntry(); @@ -443,3 +464,3 @@ void AddressbookWindow::writeMail() { - Contact c = abList->currentEntry(); + OContact c = abList->currentEntry(); QString name = c.fileAs(); @@ -450,5 +471,2 @@ void AddressbookWindow::writeMail() - - - static const char * beamfile = "/tmp/obex/contact.vcf"; @@ -458,3 +476,3 @@ void AddressbookWindow::slotBeam() QString filename; - Contact c; + OContact c; if ( actionPersonal->isOn() ) { @@ -463,3 +481,3 @@ void AddressbookWindow::slotBeam() return; // can't beam a non-existent file - c = Contact::readVCard( filename )[0]; + c = OContact::readVCard( filename )[0]; } else { @@ -468,3 +486,3 @@ void AddressbookWindow::slotBeam() mkdir("/tmp/obex/", 0755); - Contact::writeVCard( beamfile, c ); + OContact::writeVCard( beamfile, c ); filename = beamfile; @@ -524,3 +542,3 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) - Contact cnt; + OContact cnt; QString fn, mn, ln; @@ -583,5 +601,5 @@ void AddressbookWindow::editPersonal() QString filename = addressbookPersonalVCardName(); - Contact me; + OContact me; if (QFile::exists(filename)) - me = Contact::readVCard( filename )[0]; + me = OContact::readVCard( filename )[0]; if (bAbEditFirstTime) { @@ -601,5 +619,5 @@ void AddressbookWindow::editPersonal() setFocus(); - Contact new_personal = abEditor->entry(); + OContact new_personal = abEditor->entry(); QString fname = addressbookPersonalVCardName(); - Contact::writeVCard( fname, new_personal ); + OContact::writeVCard( fname, new_personal ); abView()->init(new_personal); @@ -635,5 +653,5 @@ void AddressbookWindow::slotPersonalView() QString filename = addressbookPersonalVCardName(); - Contact me; + OContact me; if (QFile::exists(filename)) - me = Contact::readVCard( filename )[0]; + me = OContact::readVCard( filename )[0]; @@ -649,3 +667,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) { - Contact entry; + OContact entry; if ( bAbEditFirstTime ) { @@ -668,3 +686,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) if ( entryMode == NewEntry ) { - Contact insertEntry = abEditor->entry(); + OContact insertEntry = abEditor->entry(); insertEntry.assignUid(); @@ -672,3 +690,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) } else { - Contact replaceEntry = abEditor->entry(); + OContact replaceEntry = abEditor->entry(); if ( !replaceEntry.isValidUid() ) @@ -726,2 +744,3 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) //################## shouldn't always save + // True, but the database handles this automatically ! (se) if ( save() ) @@ -794,4 +813,4 @@ void AddressbookWindow::initFields() - QStringList xmlFields = Contact::fields(); - QStringList visibleFields = Contact::trfields(); + QStringList xmlFields = OContact::fields(); + QStringList visibleFields = OContact::trfields(); xmlFields.remove( "Title" ); @@ -800,4 +819,3 @@ void AddressbookWindow::initFields() - int i, - version; + int i, version; Config cfg( "AddressBook" ); @@ -885,3 +903,3 @@ AbLabel *AddressbookWindow::abView() mView = new AbLabel( this, "viewer" ); - mView->init( Contact() ); + mView->init( OContact() ); connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); @@ -913,16 +931,36 @@ void AddressbookWindow::slotSetCategory( int c ) { + + QString cat, book; + if ( c <= 0 ) return; - for ( unsigned int i = 1; i < catMenu->count(); i++ ) + + // Checkmark Book Menu Item Selected + if ( c < 6 ) + for ( unsigned int i = 1; i < 6; i++ ) catMenu->setItemChecked( i, c == (int)i ); - if ( c == 1 ) { - abList->setShowCategory( QString::null ); - setCaption( tr("Contacts") + " - " + tr ( "All" ) ); - } else if ( c == (int)catMenu->count() ) { - abList->setShowCategory( tr( "Unfiled" ) ); - setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); - } else { - QString cat = abList->categories()[c - 2]; - abList->setShowCategory( cat ); - setCaption( tr("Contacts") + " - " + cat ); + + // Checkmark Category Menu Item Selected + else + for ( unsigned int i = 6; i < catMenu->count(); i++ ) + catMenu->setItemChecked( i, c == (int)i ); + + for ( unsigned int i = 1; i < catMenu->count(); i++ ) { + if (catMenu->isItemChecked( i )) { + if ( i == 1 ) // default List view + book = QString::null; + else if ( i == 2 ) + book = "Phone"; + else if ( i == 3 ) + book = "Company"; + else if ( i == 4 ) + book = "Email"; + else if ( i == 5 ) + book = "Cards"; + else if ( i == 6 ) // default All Categories + cat = QString::null; + else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled + cat = "Unfiled"; + else + cat = abList->categories()[i - 7]; } @@ -930,2 +968,12 @@ void AddressbookWindow::slotSetCategory( int c ) + abList->setShowCategory( book, cat ); + + if ( book.isEmpty() ) + book = "List"; + if ( cat.isEmpty() ) + cat = "All"; + + setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); +} + void AddressbookWindow::slotSetLetter( char c ) { @@ -940,6 +988,13 @@ void AddressbookWindow::populateCategories() - int id, - rememberId; + int id, rememberId; id = 1; rememberId = 0; + + catMenu->insertItem( tr( "List" ), id++ ); + catMenu->insertItem( tr( "Phone Book" ), id++ ); + catMenu->insertItem( tr( "Company Book" ), id++ ); + catMenu->insertItem( tr( "Email Book" ), id++ ); + catMenu->insertItem( tr( "Cards" ), id++ ); + catMenu->insertSeparator(); + catMenu->insertItem( tr( "All" ), id++ ); @@ -954,6 +1009,22 @@ void AddressbookWindow::populateCategories() } - if ( abList->showCategory().isEmpty() ) - slotSetCategory( 1 ); - else + + if ( abList->showBook().isEmpty() ) { + catMenu->setItemChecked( 1, true ); + } else if ( abList->showBook() == "Phone" ) { + catMenu->setItemChecked( 2, true ); + } else if ( abList->showBook() == "Company" ) { + catMenu->setItemChecked( 3, true ); + } else if ( abList->showBook() == "Email" ) { + catMenu->setItemChecked( 4, true ); + } else if ( abList->showBook() == "Cards" ) { + catMenu->setItemChecked( 5, true ); + } + + if ( abList->showCategory().isEmpty() ) { + slotSetCategory( 6 ); + } + else { slotSetCategory( rememberId ); } +} + |