-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 24 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 176 |
2 files changed, 102 insertions, 98 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index cf2eddf..472b13e 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp @@ -431,600 +431,602 @@ void AddressbookWindow::slotListDelete() abList->deleteCurrentEntry(); showList(); } } else { QMessageBox::warning( this, tr("Contacts"), tr("Can not edit data, currently syncing") ); } } void AddressbookWindow::slotViewBack() { showList(); } void AddressbookWindow::slotViewEdit() { if(!syncing) { if (actionPersonal->isOn()) { editPersonal(); } else { if ( !bAbEditFirstTime ) abEditor->setEntry( abList->currentEntry() ); editEntry( EditEntry ); } } else { QMessageBox::warning( this, tr("Contacts"), tr("Can not edit data, currently syncing") ); } } void AddressbookWindow::writeMail() { OContact c = abList->currentEntry(); QString name = c.fileAs(); QString email = c.defaultEmail(); QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); e << name << email; } static const char * beamfile = "/tmp/obex/contact.vcf"; void AddressbookWindow::slotBeam() { QString filename; OContact c; if ( actionPersonal->isOn() ) { filename = addressbookPersonalVCardName(); if (!QFile::exists(filename)) return; // can't beam a non-existent file c = OContact::readVCard( filename )[0]; } else { unlink( beamfile ); // delete if exists c = abList->currentEntry(); mkdir("/tmp/obex/", 0755); OContact::writeVCard( beamfile, c ); filename = beamfile; } Ir *ir = new Ir( this ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); QString description = c.fullName(); ir->send( filename, description, "text/x-vCard" ); } void AddressbookWindow::beamDone( Ir *ir ) { delete ir; unlink( beamfile ); } static void parseName( const QString& name, QString *first, QString *middle, QString * last ) { int comma = name.find ( "," ); QString rest; if ( comma > 0 ) { *last = name.left( comma ); comma++; while ( comma < int(name.length()) && name[comma] == ' ' ) comma++; rest = name.mid( comma ); } else { int space = name.findRev( ' ' ); *last = name.mid( space+1 ); rest = name.left( space ); } int space = rest.find( ' ' ); if ( space <= 0 ) { *first = rest; } else { *first = rest.left( space ); *middle = rest.mid( space+1 ); } } void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) { if (msg == "editPersonal()") { editPersonal(); } else if (msg == "editPersonalAndClose()") { editPersonal(); close(); } else if ( msg == "addContact(QString,QString)" ) { QDataStream stream(data,IO_ReadOnly); QString name, email; stream >> name >> email; OContact cnt; QString fn, mn, ln; parseName( name, &fn, &mn, &ln ); // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); cnt.setFirstName( fn ); cnt.setMiddleName( mn ); cnt.setLastName( ln ); cnt.insertEmails( email ); cnt.setDefaultEmail( email ); cnt.setFileAs(); if ( bAbEditFirstTime ) { abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, this, "editor" ); bAbEditFirstTime = FALSE; } else { abEditor->setEntry( cnt ); } abView()->init( cnt ); editEntry( NewEntry ); } #if 0 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { QDataStream stream(data,IO_ReadOnly); QCString ch,m; QStringList types; stream >> ch >> m >> types; AddressPicker picker(abList,this,0,TRUE); picker.showMaximized(); picker.setChoiceNames(types); int i=0; for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { QStringList sel; stream >> sel; picker.setSelection(i++,sel); } picker.showMaximized(); picker.exec(); // ###### note: contacts may have been added - save here! setCentralWidget(abList); QCopEnvelope e(ch,m); i=0; for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { QStringList sel = picker.selection(i++); e << sel; } } #endif } void AddressbookWindow::editPersonal() { QString filename = addressbookPersonalVCardName(); OContact me; if (QFile::exists(filename)) me = OContact::readVCard( filename )[0]; if (bAbEditFirstTime) { abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, this, "editor" ); // don't create a new editor every time bAbEditFirstTime = FALSE; } else abEditor->setEntry( me ); abEditor->setCaption(tr("Edit My Personal Details")); abEditor->showMaximized(); // fix the foxus... abEditor->setNameFocus(); if ( abEditor->exec() ) { setFocus(); OContact new_personal = abEditor->entry(); QString fname = addressbookPersonalVCardName(); OContact::writeVCard( fname, new_personal ); abView()->init(new_personal); abView()->sync(); } abEditor->setCaption( tr("Edit Address") ); } void AddressbookWindow::slotPersonalView() { if (!actionPersonal->isOn()) { // we just turned it off setCaption( tr("Contacts") ); actionNew->setEnabled(TRUE); actionTrash->setEnabled(TRUE); #ifndef MAKE_FOR_SHARP_ROM actionFind->setEnabled(TRUE); #endif slotUpdateToolbar(); // maybe some of the above could be moved there showList(); return; } // XXX need to disable some QActions. actionNew->setEnabled(FALSE); actionTrash->setEnabled(FALSE); #ifndef MAKE_FOR_SHARP_ROM actionFind->setEnabled(FALSE); #endif actionMail->setEnabled(FALSE); setCaption( tr("Contacts - My Personal Details") ); QString filename = addressbookPersonalVCardName(); OContact me; if (QFile::exists(filename)) me = OContact::readVCard( filename )[0]; abView()->init( me ); abView()->sync(); listContainer->hide(); setCentralWidget( abView() ); mView->show(); mView->setFocus(); } void AddressbookWindow::editEntry( EntryMode entryMode ) { OContact entry; if ( bAbEditFirstTime ) { abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, this, "editor" ); bAbEditFirstTime = FALSE; if ( entryMode == EditEntry ) abEditor->setEntry( abList->currentEntry() ); } // other things may chane the caption. abEditor->setCaption( tr("Edit Address") ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) abEditor->showMaximized(); #endif // fix the foxus... abEditor->setNameFocus(); if ( abEditor->exec() ) { setFocus(); if ( entryMode == NewEntry ) { OContact insertEntry = abEditor->entry(); insertEntry.assignUid(); abList->addEntry( insertEntry ); } else { OContact replaceEntry = abEditor->entry(); if ( !replaceEntry.isValidUid() ) replaceEntry.assignUid(); abList->replaceCurrentEntry( replaceEntry ); } } populateCategories(); showList(); } void AddressbookWindow::listIsEmpty( bool empty ) { if ( !empty ) { deleteButton->setEnabled( TRUE ); } } void AddressbookWindow::reload() { syncing = FALSE; abList->clear(); abList->load( addressbookXMLFilename() ); } void AddressbookWindow::flush() { syncing = TRUE; abList->save( addressbookXMLFilename() ); } void AddressbookWindow::closeEvent( QCloseEvent *e ) { if ( centralWidget() == mView ) { if (actionPersonal->isOn()) { // pretend we clicked it off actionPersonal->setOn(FALSE); slotPersonalView(); } else { showList(); } e->ignore(); return; } if(syncing) { /* shouldn't we save, I hear you say? well its already been set so that an edit can not occur during a sync, and we flushed at the start of the sync, so there is no need to save Saving however itself would cause problems. */ e->accept(); return; } //################## shouldn't always save // True, but the database handles this automatically ! (se) if ( save() ) e->accept(); else e->ignore(); } /* Returns TRUE if it is OK to exit */ bool AddressbookWindow::save() { QString str = addressbookXMLFilename(); if ( str.isNull() ) { if ( QMessageBox::critical( 0, tr("Out of space"), tr("Unable to save information.\n" "Free up some space\n" "and try again.\n" "\nQuit anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default ) != QMessageBox::No ) return TRUE; else return FALSE; } else { if ( !abList->save( str ) ) { if ( QMessageBox::critical( 0, tr( "Out of space" ), tr("Unable to save information.\n" "Free up some space\n" "and try again.\n" "\nQuit anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default ) != QMessageBox::No ) return TRUE; else return FALSE; } } return TRUE; } void AddressbookWindow::slotSettings() { AddressSettings frmSettings( this ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) frmSettings.showMaximized(); #endif if ( frmSettings.exec() ) { allFields.clear(); orderedFields.clear(); slOrderedFields.clear(); initFields(); if ( abEditor ) abEditor->loadFields(); abList->refresh(); } } void AddressbookWindow::initFields() { // we really don't need the things from the configuration, anymore // only thing that is important are the important categories. So, // Call the contact functions that correspond to these old functions... QStringList xmlFields = OContact::fields(); - QStringList visibleFields = OContact::trfields(); + QStringList visibleFields = OContact::untrfields(); + // QStringList trFields = OContact::trfields(); + xmlFields.remove( "Title" ); - visibleFields.remove( tr("Name Title") ); - visibleFields.remove( tr("Notes") ); + visibleFields.remove( "Name Title" ); + visibleFields.remove( "Notes" ); int i, version; Config cfg( "AddressBook" ); QString zn; // ### Write a function to keep this from happening again... QStringList::ConstIterator it; for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { allFields.append( i + 3 ); } cfg.setGroup( "Version" ); version = cfg.readNumEntry( "version" ); i = 0; startFontSize = 1; if ( version >= ADDRESSVERSION ) { cfg.setGroup( "ImportantCategory" ); zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); while ( !zn.isNull() ) { - if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) { + if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) { slOrderedFields.clear(); break; } slOrderedFields.append( zn ); zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); } cfg.setGroup( "Font" ); startFontSize = cfg.readNumEntry( "fontSize", 1 ); } else { QString str; str = getenv("HOME"); str += "/Settings/AddressBook.conf"; QFile::remove( str ); } if ( slOrderedFields.count() > 0 ) { for( QStringList::ConstIterator it = slOrderedFields.begin(); it != slOrderedFields.end(); ++it ) { QValueList<int>::ConstIterator itVl; QStringList::ConstIterator itVis; itVl = allFields.begin(); for ( itVis = visibleFields.begin(); itVis != visibleFields.end() && itVl != allFields.end(); ++itVis, ++itVl ) { if ( *it == *itVis && itVl != allFields.end() ) { orderedFields.append( *itVl ); } } } } else { QValueList<int>::ConstIterator it; for ( it = allFields.begin(); it != allFields.end(); ++it ) orderedFields.append( *it ); slOrderedFields = visibleFields; orderedFields.remove( Qtopia::AddressUid ); orderedFields.remove( Qtopia::Title ); orderedFields.remove( Qtopia::Groups ); orderedFields.remove( Qtopia::AddressCategory ); orderedFields.remove( Qtopia::FirstName ); orderedFields.remove( Qtopia::LastName ); orderedFields.remove( Qtopia::DefaultEmail ); orderedFields.remove( Qtopia::FileAs ); orderedFields.remove( Qtopia::Notes ); orderedFields.remove( Qtopia::Gender ); - slOrderedFields.remove( tr("Name Title") ); - slOrderedFields.remove( tr("First Name") ); - slOrderedFields.remove( tr("Last Name") ); - slOrderedFields.remove( tr("File As") ); - slOrderedFields.remove( tr("Default Email") ); - slOrderedFields.remove( tr("Notes") ); - slOrderedFields.remove( tr("Gender") ); + slOrderedFields.remove( "Name Title" ); + slOrderedFields.remove( "First Name" ); + slOrderedFields.remove( "Last Name" ); + slOrderedFields.remove( "File As" ); + slOrderedFields.remove( "Default Email" ); + slOrderedFields.remove( "Notes" ); + slOrderedFields.remove( "Gender" ); } } AbLabel *AddressbookWindow::abView() { if ( !mView ) { mView = new AbLabel( this, "viewer" ); mView->init( OContact() ); connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); } return mView; } void AddressbookWindow::slotFind() { #ifndef MAKE_FOR_SHARP_ROM if ( centralWidget() == abView() ) showList(); FindDialog frmFind( "Contacts", this ); QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int))); QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); frmFind.exec(); if ( abList->numSelections() ) abList->clearSelection(); abList->clearFindRow(); #endif } void AddressbookWindow::slotSetCategory( int c ) { QString cat, book; if ( c <= 0 ) return; // Checkmark Book Menu Item Selected if ( c < 6 ) for ( unsigned int i = 1; i < 6; i++ ) catMenu->setItemChecked( i, c == (int)i ); // 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]; } } 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 ) { abList->setShowByLetter( c ); } void AddressbookWindow::populateCategories() { catMenu->clear(); 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++ ); QStringList categories = abList->categories(); categories.append( tr( "Unfiled" ) ); for ( QStringList::Iterator it = categories.begin(); it != categories.end(); ++it ) { catMenu->insertItem( *it, id ); if ( *it == abList->showCategory() ) rememberId = id; ++id; } 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 ); } } diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 12d7421..b01583f 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -1,707 +1,707 @@ /* * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> * * This file is an add-on for the OPIE Palmtop Environment * * This file may be distributed and/or modified under the terms of the * GNU General Public License version 2 as published by the Free Software * Foundation and appearing in the file LICENSE.GPL included in the pacakaging * of this file. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * This is a rewrite of the abeditor.h file, modified to provide a more * intuitive interface to TrollTech's original Address Book editor. This * is made to operate exactly in interface with the exception of name. * */ #include "contacteditor.h" #include "addresspicker.h" #include <qpe/categoryselect.h> #include <qpe/qpeapplication.h> #include <qpe/qpedialog.h> #include <qcombobox.h> #include <qlabel.h> #include <qtabwidget.h> #include <qlayout.h> #include <qlineedit.h> #include <qmultilineedit.h> #include <qscrollview.h> #include <qtoolbutton.h> #include <qpushbutton.h> #include <qmainwindow.h> #include <qvaluelist.h> static inline bool containsAlphaNum( const QString &str ); static inline bool constainsWhiteSpace( const QString &str ); // helper functions, convert our comma delimited list to proper // file format... void parseEmailFrom( const QString &txt, QString &strDefaultEmail, QString &strAll ); // helper convert from file format to comma delimited... void parseEmailTo( const QString &strDefaultEmail, const QString &strOtherEmail, QString &strBack ); ContactEditor::ContactEditor( const OContact &entry, const QValueList<int> *newOrderedValues, QStringList *slNewOrdered, QWidget *parent, const char *name, WFlags fl ) : QDialog( parent, name, TRUE, fl ), orderedValues( newOrderedValues ), slOrdered( *slNewOrdered ) { init(); initMap(); setEntry( entry ); qDebug("finish"); } ContactEditor::~ContactEditor() { } void ContactEditor::init() { useFullName = TRUE; int i = 0; /** SHut up and stop leaking slHomeAddress = new QStringList; slBusinessAddress = new QStringList; slChooserNames = new QStringList; slChooserValues = new QStringList; slDynamicEntries = new QStringList; */ //*slDynamicEntries = *slOrdered; for (i = 0; i <= 6; i++) { slHomeAddress.append( "" ); slBusinessAddress.append( "" ); } { hasGender = FALSE; hasTitle = FALSE; hasCompany = FALSE; hasNotes = FALSE; hasStreet = FALSE; hasStreet2 = FALSE; hasPOBox = FALSE; hasCity = FALSE; hasState = FALSE; hasZip = FALSE; hasCountry = FALSE; QStringList::ConstIterator it = slOrdered.begin(); for ( i = 0; it != slOrdered.end(); i++, ++it ) { - if ( (*it) == tr( "Business Fax" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Business Fax" ) { + slChooserNames.append( tr( "Business Fax" ) ); slChooserValues.append("" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home Fax" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Home Fax" ) { + slChooserNames.append( tr( "Home Fax" ) ); slChooserValues.append("" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Business Phone" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Business Phone" ) { + slChooserNames.append( tr( "Business Phone" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home Phone" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Home Phone" ) { + slChooserNames.append( tr( "Home Phone" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } /* if ( (*it).right( 2 ) == tr( "IM" ) ) { slChooserNames.append( *it ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } */ - if ( (*it) == tr( "Business Mobile" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Business Mobile" ) { + slChooserNames.append( tr( "Business Mobile" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home Mobile" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Home Mobile" ) { + slChooserNames.append( tr( "Home Mobile" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Business WebPage" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Business WebPage" ) { + slChooserNames.append( tr( "Business WebPage" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home Web Page" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Home Web Page" ) { + slChooserNames.append( tr( "Home Web Page" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Business Pager" ) ) { - slChooserNames.append( *it ); + if ( (*it) == "Business Pager" ) { + slChooserNames.append( tr( "Business Pager" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Default Email" ) ) { - slChooserNames.append( *it ); + if ( *it == "Default Email" ) { + slChooserNames.append( tr( "Default Email" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Emails" ) ) { - slChooserNames.append( *it ); + if ( *it == "Emails" ) { + slChooserNames.append( tr( "Emails" ) ); slChooserValues.append( "" ); //slDynamicEntries->remove( it ); continue; } if ( *it == "Name Title" || *it == "First Name" || *it == "Middle Name" || *it == "Last Name" || *it == "File As" || *it == "Default Email" || *it == "Emails" || *it == "Groups" ) continue; - if ( *it == tr( "Name Title" ) ) { + if ( *it == "Name Title" ) { //slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "First Name" ) ) { + if ( *it == "First Name" ) { // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Middle Name" ) ) { + if ( *it == "Middle Name" ) { // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Last Name" ) ) { + if ( *it == "Last Name" ) { // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Suffix" ) ) { + if ( *it == "Suffix" ) { // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "File As" ) ) { + if ( *it == "File As" ) { // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Gender" ) ) { + if ( *it == "Gender" ) { hasGender = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Job Title" ) ) { + if ( *it == "Job Title" ) { hasTitle = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Company") || *it == tr( "Organization" ) ) { + if ( ( *it == "Company") || (*it == "Organization" ) ) { hasCompany = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Notes" ) ) { + if ( *it == "Notes" ) { hasNotes = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( *it == tr( "Groups" ) ) { + if ( *it == "Groups" ) { // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Business Street" ) ) { + if ( (*it) == "Business Street" ) { hasStreet = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home Street" ) ) { + if ( (*it) == "Home Street" ) { hasStreet = TRUE; // slDynamicEntries->remove( it ); continue; } /* if ( (*it).right( 8 ) == tr( "Street 2" ) ) { hasStreet2 = TRUE; // slDynamicEntries->remove( it ); continue; } if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) { hasPOBox = TRUE; // slDynamicEntries->remove( it ); continue; } */ - if ( (*it) == tr( "Business City" ) ) { + if ( (*it) == "Business City" ) { hasCity = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Business State" ) ) { + if ( (*it) == "Business State" ) { hasState = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Business Zip" ) ) { + if ( (*it) == "Business Zip" ) { hasZip = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Business Country" ) ) { + if ( (*it) == "Business Country" ) { hasCountry = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home City" ) ) { + if ( (*it) == "Home City" ) { hasCity = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home State" ) ) { + if ( (*it) == "Home State" ) { hasState = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home Zip" ) ) { + if ( (*it) == "Home Zip" ) { hasZip = TRUE; // slDynamicEntries->remove( it ); continue; } - if ( (*it) == tr( "Home Country" ) ) { + if ( (*it) == "Home Country" ) { hasCountry = TRUE; // slDynamicEntries->remove( it ); continue; } slDynamicEntries.append( *it ); } } QVBoxLayout *vb = new QVBoxLayout( this ); tabMain = new QTabWidget( this ); vb->addWidget( tabMain ); QWidget *tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); svGeneral = new QScrollView( tabViewport ); vb->addWidget( svGeneral, 0, 0 ); svGeneral->setResizePolicy( QScrollView::AutoOneFit ); svGeneral->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( svGeneral->viewport() ); svGeneral->addChild( container ); QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); gl->setResizeMode( QLayout::FreeResize ); btnFullName = new QPushButton( tr( "Full Name..." ), container ); gl->addWidget( btnFullName, 0, 0 ); txtFullName = new QLineEdit( container ); gl->addWidget( txtFullName, 0, 1 ); QLabel *l = new QLabel( tr( "Job Title" ), container ); gl->addWidget( l, 1, 0 ); txtJobTitle = new QLineEdit( container ); gl->addWidget( txtJobTitle, 1, 1 ); l = new QLabel( tr( "Organization" ), container ); gl->addWidget( l, 2, 0 ); txtOrganization = new QLineEdit( container ); gl->addWidget( txtOrganization, 2, 1 ); cmbChooserField1 = new QComboBox( FALSE, container ); cmbChooserField1->setMaximumWidth( 90 ); gl->addWidget( cmbChooserField1, 3, 0 ); txtChooserField1 = new QLineEdit( container ); gl->addWidget( txtChooserField1, 3, 1 ); cmbChooserField2 = new QComboBox( FALSE, container ); cmbChooserField2->setMaximumWidth( 90 ); gl->addWidget( cmbChooserField2, 4, 0 ); txtChooserField2 = new QLineEdit( container ); gl->addWidget( txtChooserField2, 4, 1 ); cmbChooserField3 = new QComboBox( FALSE, container ); cmbChooserField3->setMaximumWidth( 90 ); gl->addWidget( cmbChooserField3, 5, 0 ); txtChooserField3 = new QLineEdit( container ); gl->addWidget( txtChooserField3, 5, 1 ); l = new QLabel( tr( "File As" ), container ); gl->addWidget( l, 6, 0 ); cmbFileAs = new QComboBox( TRUE, container ); gl->addWidget( cmbFileAs, 6, 1 ); l = new QLabel( tr( "Category" ), container ); gl->addWidget( l, 7, 0 ); cmbCat = new CategorySelect( container ); gl->addWidget( cmbCat, 7, 1 ); btnNote = new QPushButton( tr( "Notes..." ), container ); gl->addWidget( btnNote, 8, 1 ); tabMain->insertTab( tabViewport, tr( "General" ) ); tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); svAddress = new QScrollView( tabViewport ); vb->addWidget( svAddress, 0, 0 ); svAddress->setResizePolicy( QScrollView::AutoOneFit ); svAddress->setFrameStyle( QFrame::NoFrame ); container = new QWidget( svAddress->viewport() ); svAddress->addChild( container ); gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem cmbAddress = new QComboBox( FALSE, container ); cmbAddress->insertItem( tr( "Business" ) ); cmbAddress->insertItem( tr( "Home" ) ); gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); l = new QLabel( tr( "Address" ), container ); gl->addWidget( l, 1, 0 ); txtAddress = new QLineEdit( container ); gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); /* l = new QLabel( tr( "Address 2" ), container ); gl->addWidget( l, 2, 0 ); txtAddress2 = new QLineEdit( container ); gl->addMultiCellWidget( txtAddress2, 2, 2, 1, 2 ); l = new QLabel( tr( "P.O. Box" ), container ); gl->addWidget( l, 3, 0 ); txtPOBox = new QLineEdit( container ); gl->addMultiCellWidget( txtPOBox, 3, 3, 1, 2 ); */ l = new QLabel( tr( "City" ), container ); gl->addWidget( l, 2, 0 ); txtCity = new QLineEdit( container ); gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); l = new QLabel( tr( "State" ), container ); gl->addWidget( l, 3, 0 ); txtState = new QLineEdit( container ); gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); l = new QLabel( tr( "Zip Code" ), container ); gl->addWidget( l, 4, 0 ); txtZip = new QLineEdit( container ); gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); l = new QLabel( tr( "Country" ), container ); gl->addWidget( l, 5, 0 ); cmbCountry = new QComboBox( TRUE, container ); cmbCountry->insertItem( tr( "" ) ); cmbCountry->insertItem( tr ( "United States" ) ); cmbCountry->insertItem( tr ( "United Kingdom" ) ); cmbCountry->insertItem( tr ( "Afganistan" ) ); cmbCountry->insertItem( tr ( "Albania" ) ); cmbCountry->insertItem( tr ( "Algeria" ) ); cmbCountry->insertItem( tr ( "American Samoa" ) ); cmbCountry->insertItem( tr ( "Andorra" ) ); cmbCountry->insertItem( tr ( "Angola" ) ); cmbCountry->insertItem( tr ( "Anguilla" ) ); cmbCountry->insertItem( tr ( "Antartica" ) ); cmbCountry->insertItem( tr ( "Argentina" ) ); cmbCountry->insertItem( tr ( "Armania" ) ); cmbCountry->insertItem( tr ( "Aruba" ) ); cmbCountry->insertItem( tr ( "Australia" ) ); cmbCountry->insertItem( tr ( "Austria" ) ); cmbCountry->insertItem( tr ( "Azerbaijan" ) ); cmbCountry->insertItem( tr ( "Bahamas" ) ); cmbCountry->insertItem( tr ( "Bahrain" ) ); cmbCountry->insertItem( tr ( "Bangladesh" ) ); cmbCountry->insertItem( tr ( "Barbados" ) ); cmbCountry->insertItem( tr ( "Belarus" ) ); cmbCountry->insertItem( tr ( "Belgium" ) ); cmbCountry->insertItem( tr ( "Belize" ) ); cmbCountry->insertItem( tr ( "Benin" ) ); cmbCountry->insertItem( tr ( "Bermuda" ) ); cmbCountry->insertItem( tr ( "Bhutan" ) ); cmbCountry->insertItem( tr ( "Boliva" ) ); cmbCountry->insertItem( tr ( "Botswana" ) ); cmbCountry->insertItem( tr ( "Bouvet Island" ) ); cmbCountry->insertItem( tr ( "Brazil" ) ); cmbCountry->insertItem( tr ( "Brunei Darussalam" ) ); cmbCountry->insertItem( tr ( "Bulgaria" ) ); cmbCountry->insertItem( tr ( "Burkina Faso" ) ); cmbCountry->insertItem( tr ( "Burundi" ) ); cmbCountry->insertItem( tr ( "Cambodia" ) ); cmbCountry->insertItem( tr ( "Camaroon" ) ); cmbCountry->insertItem( tr ( "Canada" ) ); cmbCountry->insertItem( tr ( "Cape Verde" ) ); cmbCountry->insertItem( tr ( "Cayman Islands" ) ); cmbCountry->insertItem( tr ( "Chad" ) ); cmbCountry->insertItem( tr ( "Chile" ) ); cmbCountry->insertItem( tr ( "China" ) ); cmbCountry->insertItem( tr ( "Christmas Island" ) ); cmbCountry->insertItem( tr ( "Colombia" ) ); cmbCountry->insertItem( tr ( "Comoros" ) ); cmbCountry->insertItem( tr ( "Congo" ) ); cmbCountry->insertItem( tr ( "Cook Island" ) ); cmbCountry->insertItem( tr ( "Costa Rica" ) ); cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) ); cmbCountry->insertItem( tr ( "Croatia" ) ); cmbCountry->insertItem( tr ( "Cuba" ) ); cmbCountry->insertItem( tr ( "Cyprus" ) ); cmbCountry->insertItem( tr ( "Czech Republic" ) ); cmbCountry->insertItem( tr ( "Denmark" ) ); cmbCountry->insertItem( tr ( "Djibouti" ) ); cmbCountry->insertItem( tr ( "Dominica" ) ); cmbCountry->insertItem( tr ( "Dominican Republic" ) ); cmbCountry->insertItem( tr ( "East Timor" ) ); cmbCountry->insertItem( tr ( "Ecuador" ) ); cmbCountry->insertItem( tr ( "Egypt" ) ); cmbCountry->insertItem( tr ( "El Salvador" ) ); cmbCountry->insertItem( tr ( "Equatorial Guinea" ) ); cmbCountry->insertItem( tr ( "Eritrea" ) ); cmbCountry->insertItem( tr ( "Estonia" ) ); cmbCountry->insertItem( tr ( "Ethiopia" ) ); cmbCountry->insertItem( tr ( "Falkland Islands" ) ); cmbCountry->insertItem( tr ( "Faroe Islands" ) ); cmbCountry->insertItem( tr ( "Fiji" ) ); cmbCountry->insertItem( tr ( "Finland" ) ); cmbCountry->insertItem( tr ( "France" ) ); cmbCountry->insertItem( tr ( "French Guiana" ) ); cmbCountry->insertItem( tr ( "French Polynesia" ) ); cmbCountry->insertItem( tr ( "Gabon" ) ); cmbCountry->insertItem( tr ( "Gambia" ) ); cmbCountry->insertItem( tr ( "Georgia" ) ); cmbCountry->insertItem( tr ( "Germany" ) ); cmbCountry->insertItem( tr ( "Gahna" ) ); cmbCountry->insertItem( tr ( "Gibraltar" ) ); cmbCountry->insertItem( tr ( "Greece" ) ); cmbCountry->insertItem( tr ( "Greenland" ) ); cmbCountry->insertItem( tr ( "Grenada" ) ); cmbCountry->insertItem( tr ( "Guadelupe" ) ); cmbCountry->insertItem( tr ( "Guam" ) ); cmbCountry->insertItem( tr ( "Guatemala" ) ); cmbCountry->insertItem( tr ( "Guinea" ) ); cmbCountry->insertItem( tr ( "Guinea-bissau" ) ); cmbCountry->insertItem( tr ( "Guyana" ) ); cmbCountry->insertItem( tr ( "Haiti" ) ); cmbCountry->insertItem( tr ( "Holy See" ) ); cmbCountry->insertItem( tr ( "Honduras" ) ); cmbCountry->insertItem( tr ( "Hong Kong" ) ); cmbCountry->insertItem( tr ( "Hungary" ) ); cmbCountry->insertItem( tr ( "Iceland" ) ); cmbCountry->insertItem( tr ( "India" ) ); cmbCountry->insertItem( tr ( "Indonesia" ) ); cmbCountry->insertItem( tr ( "Ireland" ) ); cmbCountry->insertItem( tr ( "Israel" ) ); cmbCountry->insertItem( tr ( "Italy" ) ); cmbCountry->insertItem( tr ( "Jamacia" ) ); cmbCountry->insertItem( tr ( "Japan" ) ); cmbCountry->insertItem( tr ( "Jordan" ) ); cmbCountry->insertItem( tr ( "Kazakhstan" ) ); cmbCountry->insertItem( tr ( "Kenya" ) ); cmbCountry->insertItem( tr ( "Kribati" ) ); cmbCountry->insertItem( tr ( "Korea" ) ); cmbCountry->insertItem( tr ( "Kuwait" ) ); cmbCountry->insertItem( tr ( "Kyrgystan" ) ); cmbCountry->insertItem( tr ( "Laos" ) ); cmbCountry->insertItem( tr ( "Latvia" ) ); cmbCountry->insertItem( tr ( "Lebanon" ) ); cmbCountry->insertItem( tr ( "Lesotho" ) ); cmbCountry->insertItem( tr ( "Liberia" ) ); cmbCountry->insertItem( tr ( "Liechtenstein" ) ); cmbCountry->insertItem( tr ( "Lithuania" ) ); cmbCountry->insertItem( tr ( "Luxembourg" ) ); cmbCountry->insertItem( tr ( "Macau" ) ); cmbCountry->insertItem( tr ( "Macedonia" ) ); cmbCountry->insertItem( tr ( "Madagascar" ) ); cmbCountry->insertItem( tr ( "Malawi" ) ); cmbCountry->insertItem( tr ( "Malaysia" ) ); cmbCountry->insertItem( tr ( "Maldives" ) ); cmbCountry->insertItem( tr ( "Mali" ) ); cmbCountry->insertItem( tr ( "Malta" ) ); cmbCountry->insertItem( tr ( "Martinique" ) ); cmbCountry->insertItem( tr ( "Mauritania" ) ); cmbCountry->insertItem( tr ( "Mauritius" ) ); cmbCountry->insertItem( tr ( "Mayotte" ) ); cmbCountry->insertItem( tr ( "Mexico" ) ); cmbCountry->insertItem( tr ( "Micronesia" ) ); cmbCountry->insertItem( tr ( "Moldova" ) ); cmbCountry->insertItem( tr ( "Monaco" ) ); cmbCountry->insertItem( tr ( "Mongolia" ) ); cmbCountry->insertItem( tr ( "Montserrat" ) ); cmbCountry->insertItem( tr ( "Morocco" ) ); cmbCountry->insertItem( tr ( "Mozambique" ) ); cmbCountry->insertItem( tr ( "Myanmar" ) ); cmbCountry->insertItem( tr ( "Namibia" ) ); cmbCountry->insertItem( tr ( "Nauru" ) ); cmbCountry->insertItem( tr ( "Nepal" ) ); cmbCountry->insertItem( tr ( "Netherlands" ) ); cmbCountry->insertItem( tr ( "New Caledonia" ) ); cmbCountry->insertItem( tr ( "New Zealand" ) ); cmbCountry->insertItem( tr ( "Nicaragua" ) ); cmbCountry->insertItem( tr ( "Niger" ) ); cmbCountry->insertItem( tr ( "Nigeria" ) ); cmbCountry->insertItem( tr ( "Niue" ) ); cmbCountry->insertItem( tr ( "Norway" ) ); cmbCountry->insertItem( tr ( "Oman" ) ); cmbCountry->insertItem( tr ( "Pakistan" ) ); cmbCountry->insertItem( tr ( "Palau" ) ); cmbCountry->insertItem( tr ( "Palestinian Territory" ) ); cmbCountry->insertItem( tr ( "Panama" ) ); cmbCountry->insertItem( tr ( "Papua New Guinea" ) ); cmbCountry->insertItem( tr ( "Paraguay" ) ); cmbCountry->insertItem( tr ( "Peru" ) ); cmbCountry->insertItem( tr ( "Philippines" ) ); cmbCountry->insertItem( tr ( "Pitcairn" ) ); cmbCountry->insertItem( tr ( "Poland" ) ); cmbCountry->insertItem( tr ( "Portugal" ) ); cmbCountry->insertItem( tr ( "Puerto Rico" ) ); cmbCountry->insertItem( tr ( "Qatar" ) ); cmbCountry->insertItem( tr ( "Reunion" ) ); cmbCountry->insertItem( tr ( "Romania" ) ); cmbCountry->insertItem( tr ( "Russia" ) ); cmbCountry->insertItem( tr ( "Rwanda" ) ); cmbCountry->insertItem( tr ( "Saint Lucia" ) ); cmbCountry->insertItem( tr ( "Samoa" ) ); cmbCountry->insertItem( tr ( "San Marino" ) ); cmbCountry->insertItem( tr ( "Saudi Arabia" ) ); cmbCountry->insertItem( tr ( "Senegal" ) ); cmbCountry->insertItem( tr ( "Seychelles" ) ); cmbCountry->insertItem( tr ( "Sierra Leone" ) ); cmbCountry->insertItem( tr ( "Singapore" ) ); cmbCountry->insertItem( tr ( "Slovakia" ) ); cmbCountry->insertItem( tr ( "Slovenia" ) ); cmbCountry->insertItem( tr ( "Solomon Islands" ) ); cmbCountry->insertItem( tr ( "Somalia" ) ); cmbCountry->insertItem( tr ( "South Africa" ) ); cmbCountry->insertItem( tr ( "Spain" ) ); cmbCountry->insertItem( tr ( "Sri Lanka" ) ); cmbCountry->insertItem( tr ( "St. Helena" ) ); cmbCountry->insertItem( tr ( "Sudan" ) ); cmbCountry->insertItem( tr ( "Suriname" ) ); cmbCountry->insertItem( tr ( "Swaziland" ) ); cmbCountry->insertItem( tr ( "Sweden" ) ); cmbCountry->insertItem( tr ( "Switzerland" ) ); cmbCountry->insertItem( tr ( "Taiwan" ) ); cmbCountry->insertItem( tr ( "Tajikistan" ) ); cmbCountry->insertItem( tr ( "Tanzania" ) ); cmbCountry->insertItem( tr ( "Thailand" ) ); cmbCountry->insertItem( tr ( "Togo" ) ); cmbCountry->insertItem( tr ( "Tokelau" ) ); cmbCountry->insertItem( tr ( "Tonga" ) ); cmbCountry->insertItem( tr ( "Tunisia" ) ); cmbCountry->insertItem( tr ( "Turkey" ) ); cmbCountry->insertItem( tr ( "Turkmenistan" ) ); cmbCountry->insertItem( tr ( "Tuvalu" ) ); cmbCountry->insertItem( tr ( "Uganda" ) ); cmbCountry->insertItem( tr ( "Ukraine" ) ); cmbCountry->insertItem( tr ( "Uruguay" ) ); cmbCountry->insertItem( tr ( "Uzbekistan" ) ); cmbCountry->insertItem( tr ( "Vanuatu" ) ); cmbCountry->insertItem( tr ( "Venezuela" ) ); cmbCountry->insertItem( tr ( "Viet Nam" ) ); cmbCountry->insertItem( tr ( "Virgin Islands" ) ); cmbCountry->insertItem( tr ( "Western Sahara" ) ); cmbCountry->insertItem( tr ( "Yemen" ) ); cmbCountry->insertItem( tr ( "Yugoslavia" ) ); cmbCountry->insertItem( tr ( "Zambia" ) ); cmbCountry->insertItem( tr ( "Zimbabwe" ) ); cmbCountry->setMaximumWidth( 135 ); gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); cmbChooserField4 = new QComboBox( FALSE, container ); cmbChooserField4->setMaximumWidth( 90 ); gl->addWidget( cmbChooserField4, 6, 0 ); txtChooserField4 = new QLineEdit( container ); gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 ); QSpacerItem *space = new QSpacerItem(1,1, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ); gl->addItem( space, 7, 0 ); tabMain->insertTab( tabViewport, tr( "Address" ) ); tabViewport = new QWidget ( tabMain ); vb = new QVBoxLayout( tabViewport ); svDetails = new QScrollView( tabViewport ); vb->addWidget( svDetails, 0, 0 ); svDetails->setResizePolicy( QScrollView::AutoOneFit ); svDetails->setFrameStyle( QFrame::NoFrame ); container = new QWidget( svDetails->viewport() ); svDetails->addChild( container ); gl = new QGridLayout( container, 1, 2, 2, 4 ); QStringList::ConstIterator it = slDynamicEntries.begin(); for (i = 0; it != slDynamicEntries.end(); i++, ++it) { l = new QLabel( *it, container ); listName.append( l ); gl->addWidget( l, i, 0 ); QLineEdit *e = new QLineEdit( container ); listValue.append( e ); gl->addWidget( e, i, 1); } l = new QLabel( tr("Gender"), container ); @@ -979,780 +979,782 @@ void ContactEditor::slotAddressTypeChange( int index ) { void ContactEditor::slotFullNameChange( const QString &textChanged ) { int index = cmbFileAs->currentItem(); cmbFileAs->clear(); cmbFileAs->insertItem( parseName( textChanged, 0 ) ); cmbFileAs->insertItem( parseName( textChanged, 1 ) ); cmbFileAs->insertItem( parseName( textChanged, 2 ) ); cmbFileAs->insertItem( parseName( textChanged, 3 ) ); cmbFileAs->setCurrentItem( index ); useFullName = TRUE; } void ContactEditor::loadFields() { QStringList::ConstIterator it; QListIterator<QLabel> lit( listName ); for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) { (*lit)->setText( *it ); } } void ContactEditor::accept() { if ( isEmpty() ) { cleanupFields(); reject(); } else { saveEntry(); cleanupFields(); QDialog::accept(); } } void ContactEditor::slotNote() { dlgNote->showMaximized(); if ( !dlgNote->exec() ) { txtNote->setText( ent.notes() ); } } void ContactEditor::slotName() { QString tmpName; if (useFullName == TRUE) { txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); } dlgName->showMaximized(); if ( dlgName->exec() ) { tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); txtFullName->setText( tmpName.simplifyWhiteSpace() ); slotFullNameChange( txtFullName->text() ); useFullName = FALSE; } } void ContactEditor::setNameFocus() { txtFullName->setFocus(); } bool ContactEditor::isEmpty() { // Test and see if the record should be saved. // More strict than the original qtopia, needs name or fileas to save QString t = txtFullName->text(); if ( !t.isEmpty() && containsAlphaNum( t ) ) return false; t = cmbFileAs->currentText(); if ( !t.isEmpty() && containsAlphaNum( t ) ) return false; return true; } QString ContactEditor::parseName( const QString fullName, int type ) { QString simplifiedName( fullName.simplifyWhiteSpace() ); QString strFirstName; QString strMiddleName; QString strLastName; QString strSuffix; QString strTitle; int commapos; int spCount; int spPos; int spPos2; commapos = simplifiedName.find( ',', 0, TRUE); spCount = simplifiedName.contains( ' ', TRUE ); if ( commapos == -1 ) { switch (spCount) { case 0: //return simplifiedName; if (txtLastName->text() != "") { strLastName = simplifiedName; break; } if (txtMiddleName->text() != "") { strMiddleName = simplifiedName; break; } if (txtSuffix->text() != "") { strSuffix = simplifiedName; break; } strFirstName = simplifiedName; break; case 1: spPos = simplifiedName.find( ' ', 0, TRUE ); strFirstName = simplifiedName.left( spPos ); strLastName = simplifiedName.mid( spPos + 1 ); break; case 2: spPos = simplifiedName.find( ' ', 0, TRUE ); strFirstName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strLastName = simplifiedName.mid( spPos2 + 1 ); break; case 3: spPos = simplifiedName.find( ' ', 0, TRUE ); strFirstName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); strSuffix = simplifiedName.mid( spPos + 1 ); break; case 4: spPos = simplifiedName.find( ' ', 0, TRUE ); strTitle = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strSuffix = simplifiedName.mid( spPos2 + 1 ); break; default: spPos = simplifiedName.find( ' ', 0, TRUE ); strTitle = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strSuffix = simplifiedName.mid( spPos2 + 1 ); break; } } else { simplifiedName.replace( commapos, 1, " " ); simplifiedName = simplifiedName.simplifyWhiteSpace(); switch (spCount) { case 0: //return simplifiedName; if (txtLastName->text() != "") { strLastName = simplifiedName; break; } if (txtMiddleName->text() != "") { strMiddleName = simplifiedName; break; } if (txtSuffix->text() != "") { strSuffix = simplifiedName; break; } strFirstName = simplifiedName; break; case 1: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); strFirstName = simplifiedName.mid( spPos + 1 ); break; case 2: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strMiddleName = simplifiedName.mid( spPos2 + 1 ); break; case 3: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); strSuffix = simplifiedName.mid( spPos + 1 ); break; case 4: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strSuffix = simplifiedName.mid( spPos2 + 1 ); break; default: spPos = simplifiedName.find( ' ', 0, TRUE ); strLastName = simplifiedName.left( spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); strSuffix = simplifiedName.mid( spPos2 + 1 ); break; } } switch (type) { case NAME_FL: return strFirstName + " " + strLastName; case NAME_LF: return strLastName + ", " + strFirstName; case NAME_LFM: return strLastName + ", " + strFirstName + " " + strMiddleName; case NAME_FMLS: return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; case NAME_F: return strFirstName; case NAME_M: return strMiddleName; case NAME_L: return strLastName; case NAME_S: return strSuffix; } return QString::null; } void ContactEditor::cleanupFields() { QStringList::Iterator it = slChooserValues.begin(); for ( int i = 0; it != slChooserValues.end(); i++, ++it ) { (*it) = ""; } for ( int i = 0; i < 7; i++ ) { slHomeAddress[i] = ""; slBusinessAddress[i] = ""; } QStringList::ConstIterator cit; QListIterator<QLineEdit> itLE( listValue ); for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) { (*itLE)->setText( "" ); } txtFirstName->setText(""); txtMiddleName->setText(""); txtLastName->setText(""); txtSuffix->setText(""); txtNote->setText(""); txtFullName->setText(""); txtJobTitle->setText(""); txtOrganization->setText(""); txtChooserField1->setText(""); txtChooserField2->setText(""); txtChooserField3->setText(""); txtAddress->setText(""); //txtAddress2->setText(""); txtCity->setText(""); //txtPOBox->setText(""); txtState->setText(""); txtZip->setText(""); QLineEdit *txtTmp = cmbCountry->lineEdit(); txtTmp->setText(""); txtTmp = cmbFileAs->lineEdit(); txtTmp->setText(""); } void ContactEditor::setEntry( const OContact &entry ) { cleanupFields(); ent = entry; useFullName = FALSE; txtFirstName->setText( ent.firstName() ); txtMiddleName->setText( ent.middleName() ); txtLastName->setText( ent.lastName() ); txtSuffix->setText( ent.suffix() ); QString *tmpString = new QString; *tmpString = ent.firstName() + " " + ent.middleName() + + " " + ent.lastName() + " " + ent.suffix(); txtFullName->setText( tmpString->simplifyWhiteSpace() ); cmbFileAs->setEditText( ent.fileAs() ); if (hasTitle) txtJobTitle->setText( ent.jobTitle() ); if (hasCompany) txtOrganization->setText( ent.company() ); if (hasNotes) txtNote->setText( ent.notes() ); if (hasStreet) { slHomeAddress[0] = ent.homeStreet(); slBusinessAddress[0] = ent.businessStreet(); } /* if (hasStreet2) { (*slHomeAddress)[1] = ent.homeStreet2(); (*slBusinessAddress)[1] = ent.businessStreet2(); } if (hasPOBox) { (*slHomeAddress)[2] = ent.homePOBox(); (*slBusinessAddress)[2] = ent.businessPOBox(); } */ if (hasCity) { slHomeAddress[3] = ent.homeCity(); slBusinessAddress[3] = ent.businessCity(); } if (hasState) { slHomeAddress[4] = ent.homeState(); slBusinessAddress[4] = ent.businessState(); } if (hasZip) { slHomeAddress[5] = ent.homeZip(); slBusinessAddress[5] = ent.businessZip(); } if (hasCountry) { slHomeAddress[6] = ent.homeCountry(); slBusinessAddress[6] = ent.businessCountry(); } QStringList::ConstIterator it; QListIterator<QLineEdit> itLE( listValue ); for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { - if ( *it == tr("Department") ) + if ( *it =="Department" ) (*itLE)->setText( ent.department() ); - if ( *it == tr("Company" )) + if ( *it == "Company" ) (*itLE)->setText( ent.company() ); - if ( *it == tr("Office" )) + if ( *it == "Office" ) (*itLE)->setText( ent.office() ); - if ( *it == tr("Profession" )) + if ( *it == "Profession" ) (*itLE)->setText( ent.profession() ); - if ( *it == tr("Assistant" )) + if ( *it == "Assistant" ) (*itLE)->setText( ent.assistant() ); - if ( *it == tr("Manager" )) + if ( *it == "Manager" ) (*itLE)->setText( ent.manager() ); - if ( *it == tr("Spouse" )) + if ( *it == "Spouse" ) (*itLE)->setText( ent.spouse() ); - if ( *it == tr("Birthday" )) + if ( *it == "Birthday" ) (*itLE)->setText( ent.birthday() ); - if ( *it == tr("Anniversary" )) + if ( *it == "Anniversary" ) (*itLE)->setText( ent.anniversary() ); - if ( *it == tr("Nickname" )) + if ( *it == "Nickname" ) (*itLE)->setText( ent.nickname() ); - if ( *it == tr("Children" )) + if ( *it == "Children" ) (*itLE)->setText( ent.children() ); } QStringList::Iterator itV; for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { - if ( *it == tr("Business Phone") || *it == tr("Work Phone" )) + if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) ) *itV = ent.businessPhone(); /* if ( *it == "Business 2 Phone" ) *itV = ent.business2Phone(); */ - if ( *it == tr("Business Fax") || *it == tr("Work Fax" )) + if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) ) *itV = ent.businessFax(); - if ( *it == tr("Business Mobile") || *it == tr("work Mobile" )) + if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) ) *itV = ent.businessMobile(); /* if ( *it == "Company Phone" ) *itV = ent.companyPhone(); */ - if ( *it == tr("Default Email" )) + if ( *it == "Default Email" ) *itV = ent.defaultEmail(); - if ( *it == tr("Emails" )) + if ( *it == "Emails" ) *itV = ent.emailList().join(", "); // :SX - if ( *it == tr("Home Phone" )) + if ( *it == "Home Phone" ) *itV = ent.homePhone(); /* if ( *it == "Home 2 Phone" ) *itV = ent.home2Phone(); */ - if ( *it == tr("Home Fax" )) + if ( *it == "Home Fax" ) *itV = ent.homeFax(); - if ( *it == tr("Home Mobile" )) + if ( *it == "Home Mobile" ) *itV = ent.homeMobile(); /* if ( *it == "Car Phone" ) *itV = ent.carPhone(); if ( *it == "ISDN Phone" ) *itV = ent.ISDNPhone(); if ( *it == "Other Phone" ) *itV = ent.otherPhone(); */ - if ( *it == tr("Business Pager") || *it == tr("Work Pager" )) + if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) *itV = ent.businessPager(); /* if ( *it == "Home Pager") *itV = ent.homePager(); if ( *it == "AIM IM" ) *itV = ent.AIMIM(); if ( *it == "ICQ IM" ) *itV = ent.ICQIM(); if ( *it == "Jabber IM" ) *itV = ent.jabberIM(); if ( *it == "MSN IM" ) *itV = ent.MSNIM(); if ( *it == "Yahoo IM" ) *itV = ent.yahooIM(); */ - if ( *it == tr("Home Web Page") ) + if ( *it == "Home Web Page" ) *itV = ent.homeWebpage(); - if ( *it == tr("Business WebPage") || *it == tr("Work Web Page") ) + + if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) *itV = ent.businessWebpage(); } cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); QString gender = ent.gender(); cmbGender->setCurrentItem( gender.toInt() ); txtNote->setText( ent.notes() ); slotCmbChooser1Change( cmbChooserField1->currentItem() ); slotCmbChooser2Change( cmbChooserField2->currentItem() ); slotCmbChooser3Change( cmbChooserField3->currentItem() ); slotAddressTypeChange( cmbAddress->currentItem() ); } void ContactEditor::saveEntry() { if ( useFullName == TRUE ) { txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); useFullName = FALSE; - } +} /*if ( ent.firstName() != txtFirstName->text() || ent.lastName != txtLastName->text() || ent.middleName != txtMiddleName->text() ) { */ ent.setFirstName( txtFirstName->text() ); ent.setLastName( txtLastName->text() ); ent.setMiddleName( txtMiddleName->text() ); ent.setSuffix( txtSuffix->text() ); //} ent.setFileAs( cmbFileAs->currentText() ); ent.setCategories( cmbCat->currentCategories() ); if (hasTitle) ent.setJobTitle( txtJobTitle->text() ); if (hasCompany) ent.setCompany( txtOrganization->text() ); if (hasNotes) ent.setNotes( txtNote->text() ); if (hasStreet) { ent.setHomeStreet( slHomeAddress[0] ); ent.setBusinessStreet( slBusinessAddress[0] ); } /* if (hasStreet2) { ent.setHomeStreet2( (*slHomeAddress)[1] ); ent.setBusinessStreet2( (*slBusinessAddress)[1] ); } if (hasPOBox) { ent.setHomePOBox( (*slHomeAddress)[2] ); ent.setBusinessPOBox( (*slBusinessAddress)[2] ); } */ if (hasCity) { ent.setHomeCity( slHomeAddress[3] ); ent.setBusinessCity( slBusinessAddress[3] ); } if (hasState) { ent.setHomeState( slHomeAddress[4] ); ent.setBusinessState( slBusinessAddress[4] ); } if (hasZip) { ent.setHomeZip( slHomeAddress[5] ); ent.setBusinessZip( slBusinessAddress[5] ); } if (hasCountry) { ent.setHomeCountry( slHomeAddress[6] ); ent.setBusinessCountry( slBusinessAddress[6] ); } QStringList::ConstIterator it; QListIterator<QLineEdit> itLE( listValue ); for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) { - if ( *it == tr("Department" )) + if ( *it == "Department" ) ent.setDepartment( (*itLE)->text() ); - if ( *it == tr("Company" )) + if ( *it == "Company" ) ent.setCompany( (*itLE)->text() ); - if ( *it == tr("Office" )) + if ( *it == "Office" ) ent.setOffice( (*itLE)->text() ); - if ( *it == tr("Profession" )) + if ( *it == "Profession" ) ent.setProfession( (*itLE)->text() ); - if ( *it == tr("Assistant" )) + if ( *it == "Assistant" ) ent.setAssistant( (*itLE)->text() ); - if ( *it == tr("Manager" )) + if ( *it == "Manager" ) ent.setManager( (*itLE)->text() ); - if ( *it == tr("Spouse" )) + if ( *it == "Spouse" ) ent.setSpouse( (*itLE)->text() ); - if ( *it == tr("Birthday" )) + if ( *it == "Birthday" ) ent.setBirthday( (*itLE)->text() ); - if ( *it == tr("Anniversary" )) + if ( *it == "Anniversary" ) ent.setAnniversary( (*itLE)->text() ); - if ( *it == tr("Nickname" )) + if ( *it == "Nickname" ) ent.setNickname( (*itLE)->text() ); - if ( *it == tr("Children" )) + if ( *it == "Children" ) ent.setChildren( (*itLE)->text() ); } QStringList::ConstIterator itV; for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { - if ( *it == tr("Business Phone") || *it == tr("Work Phone" )) + if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) ent.setBusinessPhone( *itV ); /* if ( *it == tr("Business 2 Phone" ) ent.setBusiness2Phone( *itV ); */ - if ( *it == tr("Business Fax") || *it == tr("Work Fax" )) + if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) ent.setBusinessFax( *itV ); - if ( *it == tr("Business Mobile") || *it == tr("Work Mobile" )) + if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) ent.setBusinessMobile( *itV ); /* if ( *it == "Company Phone" ) ent.setCompanyPhone( *itV ); */ //if ( *it == "Default Email" ) //ent.setDefaultEmail( *itV ); - if ( *it == tr("Emails" )) { + if ( *it == "Emails" ){ QString allemail; QString defaultmail; parseEmailFrom( *itV, defaultmail, allemail ); // ent.clearEmails(); ent.setDefaultEmail( defaultmail ); ent.setEmails( allemail ); } - if ( *it == tr("Home Phone" )) + if ( *it == "Home Phone" ) ent.setHomePhone( *itV ); /* if ( *it == "Home 2 Phone" ) ent.setHome2Phone( *itV ); */ - if ( *it == tr("Home Fax" )) + if ( *it == "Home Fax" ) ent.setHomeFax( *itV ); - if ( *it == tr("Home Mobile" )) + if ( *it == "Home Mobile" ) ent.setHomeMobile( *itV ); /* if ( *it == "Car Phone" ) ent.setCarPhone( *itV ); if ( *it == "ISDN Phone" ) ent.setISDNPhone( *itV ); if ( *it == "Other Phone" ) ent.setOtherPhone( *itV ); */ - if ( *it == tr("Business Pager") || *it == tr("Work Pager") ) + if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) ent.setBusinessPager( *itV ); /* if ( *it == "Home Pager" ) ent.setHomePager( *itV ); if ( *it == "AIM IM" ) ent.setAIMIM( *itV ); if ( *it == "ICQ IM" ) ent.setICQIM( *itV ); if ( *it == "Jabber IM" ) ent.setJabberIM( *itV ); if ( *it == "MSN IM" ) ent.setMSNIM( *itV ); if ( *it == "Yahoo IM" ) ent.setYahooIM( *itV ); */ - if ( *it == tr("Home Web Page") ) + if ( *it == "Home Web Page" ) ent.setHomeWebpage( *itV ); - if ( *it == tr("Business WebPage") || *it == tr("Work Web Page" )) + + if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) ent.setBusinessWebpage( *itV ); } int gender = cmbGender->currentItem(); ent.setGender( QString::number( gender ) ); QString str = txtNote->text(); if ( !str.isNull() ) ent.setNotes( str ); } void parseEmailFrom( const QString &txt, QString &strDefaultEmail, QString &strAll ) { int where, start; if ( txt.isEmpty() ) return; // find the first where = txt.find( ',' ); if ( where < 0 ) { strDefaultEmail = txt; strAll = txt; } else { strDefaultEmail = txt.left( where ).stripWhiteSpace(); strAll = strDefaultEmail; while ( where > -1 ) { strAll.append(" "); start = where; where = txt.find( ',', where + 1 ); if ( where > - 1 ) strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); else // grab until the end... strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); } } } void parseEmailTo( const QString &strDefaultEmail, const QString &strOtherEmail, QString &strBack ) { // create a comma dilimeted set of emails... // use the power of short circuiting... bool foundDefault = false; QString strTmp; int start = 0; int where; // start at the beginng. strBack = strDefaultEmail; where = 0; while ( where > -1 ) { start = where; where = strOtherEmail.find( ' ', where + 1 ); if ( where > 0 ) { strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); } else strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); if ( foundDefault || strTmp != strDefaultEmail ) { strBack.append( ", " ); strBack.append( strTmp ); } else foundDefault = true; } } static inline bool containsAlphaNum( const QString &str ) { int i, count = str.length(); for ( i = 0; i < count; i++ ) if ( !str[i].isSpace() ) return TRUE; return FALSE; } static inline bool constainsWhiteSpace( const QString &str ) { int i, count = str.length(); for (i = 0; i < count; i++ ) if ( str[i].isSpace() ) return TRUE; return FALSE; } |