author | eilers <eilers> | 2003-01-04 14:24:36 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-01-04 14:24:36 (UTC) |
commit | 4a9e13d7b9220b45cbbbdfab5f2ea56ea415d6a7 (patch) (side-by-side diff) | |
tree | 00babfde2cfd15687cb87d73800e75630afdab0b | |
parent | 851c182383c34fd4925677713bb5f6fd603c86a0 (diff) | |
download | opie-4a9e13d7b9220b45cbbbdfab5f2ea56ea415d6a7.zip opie-4a9e13d7b9220b45cbbbdfab5f2ea56ea415d6a7.tar.gz opie-4a9e13d7b9220b45cbbbdfab5f2ea56ea415d6a7.tar.bz2 |
Hope I fixed the default-email bugs..
-rw-r--r-- | core/pim/addressbook/TODO | 2 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 224 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 2 |
3 files changed, 186 insertions, 42 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO index 1eb537f..76247c1 100644 --- a/core/pim/addressbook/TODO +++ b/core/pim/addressbook/TODO @@ -1,110 +1,112 @@ Stuff todo until OPIE 1.0 : =========================== Feature requests: ----------------- - Dial by mobile phone by tapping the number.. (Maybe using gsmtool. And we may add a library class for this) - dial with dtmfdial incase it's installed and there's no mobile - 3rd column for 2. Contact - Implementing additional Views (Phonebook, ...) - Birthday & Anniversary Reminder - Plugin for Today for Birthdays and Anniversaries - Beaming of multiple contacts (current list/ by search or by category) Known Bugs: ----------- Bugs but not in addressbook: ----------------------------- - VCARD: If umlaut (äöüß) in address, the parser gets confused.. - Exporting and reimporting of Jobtitle was reported to fail (Could not reproduce this ! (se)) Urgent: -------- ContactEditor: - Contact-Editor is temporarely reenabled. Wait for replacement. - Redesign of Contacteditor - Store last settings of combo-boxes - Category is on the wrong position after changing to personal and back to normal ( Temporarily workaround: Category is never deactivated.. :S ) - Personal and Business Web-page is not editable Important: ---------- +- If new contact is added (contacteditor closed): focus (table, card) to + this entry ! - Implement a picker/combo for the default email. - After search (Started with Return): KeyFocus should be on Tabelle - "What's this" should be added (Deleyed after Feature Freeze) Less important: --------------- - Reload if contacts were changed externally - Overview window cleanup needed.. - The picker (alphabetical sort widget) should be placed verticaly or horizontally (configurable) - Find a smart solution for activating/deactivating the "send email" event Should be Fixed (not absolute sure, need further validation): ------------------------------------------------------------- Fixed: ------- - Syncing: abtable not reloaded after sync. - Find widget should be replaced by something like qpdf has. - Adding a configuration dialog - Picker: Activated letter schould be more visible - Advanced handling of cursor keys (search..) - Mail-Icon is missing - Use opie-mail insted of qt-mail if possible. - Font menu is invisible using german translation - Personal contact editor: Disable categories - "Nonenglish" translation bug has to be fixed. - contacteditor: Birthday, annyversary, ... : Use Dateselector - The names of the countries are sorted by there english names, only.. Even if they are translated.. :S - Cursor keys should work in detail-view (ablabel) -> Ablabel should be removed and Abtable should be increased with different views (as started by darwin zins).. - Use advanced database functions in abtable to decrease memory footprint and to make everything more easy ! (abtable should store Iterator for selected Category) - Abtable: Configure Contact column (internally already available, need configuration) - Select of primary contact (see #274 on mantis) - Category-select does not work completely: "Unfiled" is always in listview .. - Return from Contacteditor: Category resettet to all - Personal Details not working - If category changed, the letterpicker should be resetted - There should be some icons for List and Cardview - If in Cardview and a category change removes all entries: There are already entries in Cardview after up/down - Personal Details: Anniversary zeigt Fantasie-Werte - Unfiled shown just in Category "All" and "Unfiled". - After finising search and after Edit: Clear Picker - After Edit: Table position back to edited entry. - Optimize Table Update... - Change MyDialog to Config - Store position and state of toolbar - Searchwidget closed: Selected user is jumping - Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist) zu lange.. - VCARD: Import of Anniversary does not work correctly (currently disabled) - Name order selected in "contacteditor" not used in list view. - OK-Key does not switch from Detailview (ablable) to Listview - Receiving of beams should open a dialog - Fix start of opie-mail - Implement Button Pics - Add a dialog to accept and optionally edit received contacts by IRDA. - Language not English (tested with german opie-translation): 1. Configure nicht übersetzt (alles leer). 2. Contacteditor nur teilweise übersetzt. 3. Kategorie-Picker geht nicht. diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index c5ad0c4..37e3a54 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -1,176 +1,177 @@ /* * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) * * 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 "ocontactfields.h" #include <qpe/categoryselect.h> #include <qpe/qpeapplication.h> #include <qpe/qpedialog.h> #include <qpe/timeconversion.h> #include <opie/ocontact.h> #include <qpe/resource.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> #include <qpopupmenu.h> #include <qlistbox.h> #include <qhbox.h> #include <qaction.h> #include <qiconset.h> +#include <qmessagebox.h> #include <assert.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, QWidget *parent, const char *name, WFlags fl ) : QDialog( parent, name, TRUE, fl ), m_personalView ( false ) { init(); setEntry( entry ); cmbDefaultEmail = 0; defaultEmailChooserPosition = -1; } ContactEditor::~ContactEditor() { } void ContactEditor::init() { useFullName = true; uint i = 0; QStringList trlChooserNames; for (i = 0; i <= 6; i++) { slHomeAddress.append( "" ); slBusinessAddress.append( "" ); } trlChooserNames = OContactFields::trphonefields( false ); slChooserNames = OContactFields::untrphonefields( false ); slDynamicEntries = OContactFields::untrdetailsfields( false ); trlDynamicEntries = OContactFields::trdetailsfields( false ); // Ok, we have to remove elements from the list of dynamic entries // which are now stored in special (not dynamic) widgets.. // Otherwise we will get problems with field assignments! (se) slDynamicEntries.remove("Anniversary"); slDynamicEntries.remove("Birthday"); slDynamicEntries.remove("Gender"); // The same with translated fields.. But I will // use the translation map to avoid mismatches.. QMap<int, QString> translMap = OContactFields::idToTrFields(); trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); trlDynamicEntries.remove( translMap[Qtopia::Gender] ); // Last Check to be sure.. assert( slDynamicEntries.count() == trlDynamicEntries.count() ); assert( slChooserNames.count() == trlChooserNames.count() ); for (i = 0; i < slChooserNames.count(); i++) slChooserValues.append(""); 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 ); @@ -519,415 +520,551 @@ void ContactEditor::init() { deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), tr( "Delete" ), hBox, 0 ); gl->addWidget( hBox, counter , 1 ); connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); ++counter; // Gender l = new QLabel( tr("Gender"), container ); gl->addWidget( l, counter, 0 ); cmbGender = new QComboBox( container ); cmbGender->insertItem( "", 0 ); cmbGender->insertItem( tr("Male"), 1); cmbGender->insertItem( tr("Female"), 2); gl->addWidget( cmbGender, counter, 1 ); ++counter; // Create Labels and lineedit fields for every dynamic entry QStringList::ConstIterator it = slDynamicEntries.begin(); QStringList::ConstIterator trit = trlDynamicEntries.begin(); for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) { if (((*it) == "Anniversary") || ((*it) == "Birthday")|| ((*it) == "Gender")) continue; l = new QLabel( (*it).utf8() , container ); listName.append( l ); gl->addWidget( l, i, 0 ); QLineEdit *e = new QLineEdit( container ); listValue.append( e ); gl->addWidget( e, i, 1); } // Fill labels with names.. // loadFields(); tabMain->insertTab( tabViewport, tr( "Details" ) ); dlgNote = new QDialog( this, "Note Dialog", TRUE ); dlgNote->setCaption( tr("Enter Note") ); QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); txtNote = new QMultiLineEdit( dlgNote ); vbNote->addWidget( txtNote ); connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); dlgName = new QDialog( this, "Name Dialog", TRUE ); dlgName->setCaption( tr("Edit Name") ); gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); l = new QLabel( tr("First Name"), dlgName ); gl->addWidget( l, 0, 0 ); txtFirstName = new QLineEdit( dlgName ); gl->addWidget( txtFirstName, 0, 1 ); l = new QLabel( tr("Middle Name"), dlgName ); gl->addWidget( l, 1, 0 ); txtMiddleName = new QLineEdit( dlgName ); gl->addWidget( txtMiddleName, 1, 1 ); l = new QLabel( tr("Last Name"), dlgName ); gl->addWidget( l, 2, 0 ); txtLastName = new QLineEdit( dlgName ); gl->addWidget( txtLastName, 2, 1 ); l = new QLabel( tr("Suffix"), dlgName ); gl->addWidget( l, 3, 0 ); txtSuffix = new QLineEdit( dlgName ); gl->addWidget( txtSuffix, 3, 1 ); space = new QSpacerItem(1,1, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ); gl->addItem( space, 4, 0 ); cmbChooserField1->insertStringList( trlChooserNames ); cmbChooserField2->insertStringList( trlChooserNames ); cmbChooserField3->insertStringList( trlChooserNames ); cmbChooserField4->insertStringList( trlChooserNames ); cmbChooserField1->setCurrentItem( 0 ); cmbChooserField2->setCurrentItem( 1 ); cmbChooserField3->setCurrentItem( 2 ); connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); connect( txtChooserField1, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser1Change(const QString &)) ); connect( txtChooserField2, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser2Change(const QString &)) ); connect( txtChooserField3, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser3Change(const QString &)) ); connect( txtChooserField4, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser4Change(const QString &)) ); connect( txtAddress, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddressChange(const QString &)) ); connect( txtCity, SIGNAL(textChanged(const QString &)), this, SLOT(slotCityChange(const QString &)) ); connect( txtState, SIGNAL(textChanged(const QString &)), this, SLOT(slotStateChange(const QString &)) ); connect( txtZip, SIGNAL(textChanged(const QString &)), this, SLOT(slotZipChange(const QString &)) ); connect( cmbCountry, SIGNAL(textChanged(const QString &)), this, SLOT(slotCountryChange(const QString &)) ); connect( cmbCountry, SIGNAL(activated(const QString &)), this, SLOT(slotCountryChange(const QString &)) ); connect( cmbChooserField1, SIGNAL(activated(int)), this, SLOT(slotCmbChooser1Change(int)) ); connect( cmbChooserField2, SIGNAL(activated(int)), this, SLOT(slotCmbChooser2Change(int)) ); connect( cmbChooserField3, SIGNAL(activated(int)), this, SLOT(slotCmbChooser3Change(int)) ); connect( cmbChooserField4, SIGNAL(activated(int)), this, SLOT(slotCmbChooser4Change(int)) ); connect( cmbAddress, SIGNAL(activated(int)), this, SLOT(slotAddressTypeChange(int)) ); new QPEDialogListener(this); setPersonalView ( m_personalView ); } void ContactEditor::defaultEmailChanged(int i){ - qDebug("defaultEmailChanged"); + qDebug("defaultEmailChanged"); + int index = cmbChooserField1->currentItem(); slChooserValues[index] = cmbDefaultEmail->text(i); + defaultEmail = cmbDefaultEmail->text(i); + qDebug ("Changed to: %s", defaultEmail.latin1()); + } void ContactEditor::populateDefaultEmailCmb(){ + + // if the default-email combo was not selected and therfore not created + // we get a lot of trouble.. Therfore create an invisible one.. + if ( !cmbDefaultEmail ){ + cmbDefaultEmail = new QComboBox(this); + cmbDefaultEmail -> hide(); + } cmbDefaultEmail->clear(); - cmbDefaultEmail->insertStringList(emails); + cmbDefaultEmail->insertStringList( emails ); + // cmbDefaultEmail->show(); + + // Select default email in combo.. + bool found = false; for ( int i = 0; i < cmbDefaultEmail->count(); i++){ - qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",cmbDefaultEmail->text( i ).latin1(),defaultEmail.latin1()); - if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ - cmbDefaultEmail->setCurrentItem( i ); - qDebug("set"); + qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<", + cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1()); + + if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ + cmbDefaultEmail->setCurrentItem( i ); + qDebug("set"); + found = true; } } + + // If the current default email is not found in the list, we choose the + // first one.. + if ( !found ) + defaultEmail = cmbDefaultEmail->text(0); +} + +// Called when any combobox was changed. +// "true" returned if the change was chandled by this function, else it should +// be handled by something else.. +bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) { + QString type = slChooserNames[index]; + qWarning("ContactEditor::cmbChooserChange -> Type: %s", type.latin1() ); + + // Create and connect combobox for selecting the default email + if ( type == "Default Email"){ + qWarning("Choosing default-email "); + + // More than one defaul-email chooser is not allowed ! + if ( ( defaultEmailChooserPosition != -1 ) && + defaultEmailChooserPosition != widgetPos ){ + chooserError( widgetPos ); + return true; + } + + if ( cmbDefaultEmail ){ + delete cmbDefaultEmail; + cmbDefaultEmail = 0l; + } + cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); + cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); + + connect( cmbDefaultEmail,SIGNAL( activated(int) ), + SLOT( defaultEmailChanged(int) ) ); + + cmbDefaultEmail->clear(); + cmbDefaultEmail->insertStringList( emails ); + cmbDefaultEmail->show(); + + defaultEmailChooserPosition = widgetPos; + + // Set current default email + populateDefaultEmailCmb(); + + + } else { + // Something else was selected: Hide combo.. + qWarning(" Hiding default-email combo" ); + if ( defaultEmailChooserPosition == widgetPos ){ + defaultEmailChooserPosition = -1; + if ( cmbDefaultEmail ) + cmbDefaultEmail->hide(); + + } + + // Caller should initialize the responsible textfield, therefore + // "false" is returned + return false; + } + + // Everything is worked off .. + return true; + +} + +// Currently accessed when we select default-email more than once ! +void ContactEditor::chooserError( int index ) +{ + qWarning("ContactEditor::chooserError( %d )", index); + QMessageBox::warning( this, "Chooser Error", + "Multiple selection of this\n" + "Item is not allowed !\n\n" + "First deselect the previous one !", + "&OK", 0, 0, + 0, 0 ); + + // Reset the selected Chooser. Unfortunately the chooser + // generates no signal, therfore we have to + // call the cmbChooserChange function manually.. + switch( index ){ + case 1: + cmbChooserField1 -> setCurrentItem( 0 ); + slotCmbChooser1Change( 0 ); + break; + case 2: + cmbChooserField2 -> setCurrentItem( 0 ); + slotCmbChooser2Change( 0 ); + break; + case 3: + cmbChooserField3 -> setCurrentItem( 0 ); + slotCmbChooser3Change( 0 ); + break; + case 4: + cmbChooserField4 -> setCurrentItem( 0 ); + slotCmbChooser4Change( 0 ); + break; + } } -void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) { +// Called when something was changed in a textfield (shouldn't it called textchanged? (se)) +void ContactEditor::chooserChange( const QString &textChanged, int index, + QLineEdit* , int widgetPos ) { + QString type = slChooserNames[index]; - qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",type.latin1(),textChanged.latin1(), index, widgetPos ); + qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i", + type.latin1(),textChanged.latin1(), index, widgetPos ); + if ( type == "Default Email"){ - defaultEmail = textChanged; - if (cmbDefaultEmail){ - delete cmbDefaultEmail; - cmbDefaultEmail = 0l; - } - cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); - cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); - cmbDefaultEmail->show(); - populateDefaultEmailCmb(); - connect(cmbDefaultEmail,SIGNAL(activated(int)), - SLOT(defaultEmailChanged(int))); - defaultEmailChooserPosition = widgetPos; + qWarning ("??? Wozu??: %s", textChanged.latin1()); + defaultEmail = textChanged; + + populateDefaultEmailCmb(); + }else if (defaultEmailChooserPosition == widgetPos){ - qDebug("cmbDefaultEmail->hide()"); - if (cmbDefaultEmail) cmbDefaultEmail->hide(); - widgetPos=-1; + qDebug("cmbDefaultEmail->hide()"); + + if (cmbDefaultEmail) cmbDefaultEmail->hide(); + widgetPos=-1; + }else if (type == "Emails"){ - qDebug("emails"); - QString de; - emails = QStringList::split (",", textChanged ); + qDebug("emails"); + + QString de; + emails = QStringList::split (",", textChanged ); - if ( cmbDefaultEmail ) - populateDefaultEmailCmb(); + populateDefaultEmailCmb(); } - - slChooserValues[index] = textChanged; } void ContactEditor::slotChooser1Change( const QString &textChanged ) { + qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1()); chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); } void ContactEditor::slotChooser2Change( const QString &textChanged ) { + qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1()); chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); } void ContactEditor::slotChooser3Change( const QString &textChanged ) { + qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1()); chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); } void ContactEditor::slotChooser4Change( const QString &textChanged ) { + qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1()); chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); } void ContactEditor::slotAddressChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[0] = textChanged; } else { slHomeAddress[0] = textChanged; } } void ContactEditor::slotAddress2Change( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[1] = textChanged; } else { slHomeAddress[1] = textChanged; } } void ContactEditor::slotPOBoxChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[2] = textChanged; } else { slHomeAddress[2] = textChanged; } } void ContactEditor::slotCityChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[3] = textChanged; } else { slHomeAddress[3] = textChanged; } } void ContactEditor::slotStateChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[4] = textChanged; } else { slHomeAddress[4] = textChanged; } } void ContactEditor::slotZipChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[5] = textChanged; } else { slHomeAddress[5] = textChanged; } } void ContactEditor::slotCountryChange( const QString &textChanged ) { if ( cmbAddress->currentItem() == 0 ) { slBusinessAddress[6] = textChanged; } else { slHomeAddress[6] = textChanged; } } void ContactEditor::slotCmbChooser1Change( int index ) { + qWarning("ContactEditor::slotCmbChooser1Change( %d )", index); + + if ( !cmbChooserChange( cmbChooserField1->currentItem(), txtChooserField1, 1) ){ + + txtChooserField1->setText( slChooserValues[index] ); + txtChooserField1->setFocus(); + + } - txtChooserField1->setText( slChooserValues[index] ); - txtChooserField1->setFocus(); } void ContactEditor::slotCmbChooser2Change( int index ) { + qWarning("ContactEditor::slotCmbChooser2Change( %d )", index); + + if ( !cmbChooserChange( cmbChooserField2->currentItem(), txtChooserField2, 2) ){ - txtChooserField2->setText( slChooserValues[index] ); - txtChooserField2->setFocus(); + txtChooserField2->setText( slChooserValues[index] ); + txtChooserField2->setFocus(); + + } } void ContactEditor::slotCmbChooser3Change( int index ) { + qWarning("ContactEditor::slotCmbChooser3Change( %d )", index); + + if ( !cmbChooserChange( cmbChooserField3->currentItem(), txtChooserField3, 3) ){ - txtChooserField3->setText( slChooserValues[index] ); - txtChooserField3->setFocus(); + txtChooserField3->setText( slChooserValues[index] ); + txtChooserField3->setFocus(); + } } void ContactEditor::slotCmbChooser4Change( int index ) { + qWarning("ContactEditor::slotCmbChooser4Change( %d )", index); + + if ( !cmbChooserChange( cmbChooserField4->currentItem(), txtChooserField4, 4) ){ - txtChooserField4->setText( slChooserValues[index] ); - txtChooserField4->setFocus(); + txtChooserField4->setText( slChooserValues[index] ); + txtChooserField4->setFocus(); + } } void ContactEditor::slotAddressTypeChange( int index ) { if ( index == 0 ) { txtAddress->setText( slBusinessAddress[0] ); //txtAddress2->setText( (*slBusinessAddress)[1] ); //txtPOBox->setText( (*slBusinessAddress)[2] ); txtCity->setText( slBusinessAddress[3] ); txtState->setText( slBusinessAddress[4] ); txtZip->setText( slBusinessAddress[5] ); QLineEdit *txtTmp = cmbCountry->lineEdit(); txtTmp->setText( slBusinessAddress[6] ); } else { txtAddress->setText( slHomeAddress[0] ); //txtAddress2->setText( (*slHomeAddress)[1] ); //txtPOBox->setText( (*slHomeAddress)[2] ); txtCity->setText( slHomeAddress[3] ); txtState->setText( slHomeAddress[4] ); txtZip->setText( slHomeAddress[5] ); QLineEdit *txtTmp = cmbCountry->lineEdit(); txtTmp->setText( slHomeAddress[6] ); } } 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::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) { 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 ) { @@ -1323,264 +1460,267 @@ void ContactEditor::setEntry( const OContact &entry ) { slotCmbChooser3Change( cmbChooserField3->currentItem() ); slotAddressTypeChange( cmbAddress->currentItem() ); // loadFields(); :SX updateDatePicker(); } void ContactEditor::updateDatePicker() { // Set DatePicker if ( !ent.birthday().isNull() ){ birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); birthdayPicker->setDate( ent.birthday() ); } else birthdayButton->setText( tr ("Unknown") ); if ( !ent.anniversary().isNull() ){ anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); anniversaryPicker->setDate( ent.anniversary() ); } else anniversaryButton->setText( tr ("Unknown") ); } void ContactEditor::saveEntry() { if ( useFullName ) { 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; } 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 (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(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) { if ( *it == "Department" ) ent.setDepartment( (*itLE)->text() ); if ( *it == "Company" ) ent.setCompany( (*itLE)->text() ); if ( *it == "Office" ) ent.setOffice( (*itLE)->text() ); if ( *it == "Profession" ) ent.setProfession( (*itLE)->text() ); if ( *it == "Assistant" ) ent.setAssistant( (*itLE)->text() ); if ( *it == "Manager" ) ent.setManager( (*itLE)->text() ); if ( *it == "Spouse" ) ent.setSpouse( (*itLE)->text() ); if ( *it == "Nickname" ) ent.setNickname( (*itLE)->text() ); if ( *it == "Children" ) ent.setChildren( (*itLE)->text() ); } QStringList::ConstIterator itV; for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) ent.setBusinessPhone( *itV ); if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) ent.setBusinessFax( *itV ); if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) ent.setBusinessMobile( *itV ); if ( *it == "Emails" ){ QString allemail; QString defaultmail; - parseEmailFrom( *itV, defaultmail, allemail ); - // ent.clearEmails(); -// ent.setDefaultEmail( defaultmail ); + parseEmailFrom( emails.join(","), defaultmail, allemail ); + if ( defaultEmail.isEmpty() ){ + qWarning("Default email was not set by user!"); + qWarning("Using first email in list: %s", defaultmail.latin1()); + ent.setDefaultEmail( defaultmail ); + } ent.setEmails( allemail ); } if ( *it == "Default Email") - ent.setDefaultEmail( *itV ); + ent.setDefaultEmail( defaultEmail /* *itV */ ); if ( *it == "Home Phone" ) ent.setHomePhone( *itV ); if ( *it == "Home Fax" ) ent.setHomeFax( *itV ); if ( *it == "Home Mobile" ) ent.setHomeMobile( *itV ); if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) ent.setBusinessPager( *itV ); if ( *it == "Home Web Page" ) ent.setHomeWebpage( *itV ); 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; } void ContactEditor::setPersonalView( bool personal ) { m_personalView = personal; // Currently disbled due to the fact that // show will not work... return; if ( personal ){ cmbCat->hide(); labCat->hide(); } else{ cmbCat->show(); labCat->show(); } } void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) { QDate date; date.setYMD( year, month, day ); diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index bcef679..4fa48d1 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h @@ -1,179 +1,181 @@ /* * 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. * */ #ifndef CONTACTEDITOR_H #define CONTACTEDITOR_H #include <opie/ocontact.h> #include <qpe/datebookmonth.h> #include <qdialog.h> #include <qlist.h> #include <qmap.h> #include <qstringlist.h> const int NAME_LF = 0; const int NAME_LFM = 1; const int NAME_FL = 2; const int NAME_FMLS = 3; const int NAME_F = 4; const int NAME_M = 5; const int NAME_L = 6; const int NAME_S = 7; class QScrollView; class QTabWidget; class QMultiLineEdit; class QLineEdit; class QComboBox; class QPushButton; class CategorySelect; class QLabel; class ContactEditor : public QDialog { Q_OBJECT public: ContactEditor( const OContact &entry, QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); ~ContactEditor(); void setNameFocus(); void setPersonalView( bool personal = true ); OContact entry() const { return ent; } public slots: void slotNote(); void slotName(); void setEntry(const OContact &entry); protected slots: void accept(); private: void init(); void saveEntry(); bool isEmpty(); void cleanupFields(); void updateDatePicker(); QString parseName( QString fullName, int type ); + void chooserError( int index ); private slots: void slotChooser1Change( const QString &textChanged ); void slotChooser2Change( const QString &textChanged ); void slotChooser3Change( const QString &textChanged ); void slotChooser4Change( const QString &textChanged ); void slotCmbChooser1Change( int index ); void slotCmbChooser2Change( int index ); void slotCmbChooser3Change( int index ); void slotCmbChooser4Change( int index ); void slotAddressTypeChange( int index ); void slotAddressChange( const QString &textChanged ); void slotAddress2Change( const QString &textChanged ); void slotPOBoxChange( const QString &textChanged ); void slotCityChange( const QString &textChanged ); void slotStateChange( const QString &textChanged ); void slotZipChange( const QString &textChanged ); void slotCountryChange( const QString &textChanged ); void slotFullNameChange( const QString &textChanged ); void slotAnniversaryDateChanged( int year, int month, int day); void slotBirthdayDateChanged( int year, int month, int day); void slotRemoveBirthday(); void slotRemoveAnniversary(); void defaultEmailChanged(int); private: int defaultEmailChooserPosition; void populateDefaultEmailCmb(); void chooserChange( const QString&, int , QLineEdit*, int ); + bool cmbChooserChange( int , QLineEdit*, int ); bool useFullName; OContact ent; QDialog *dlgNote; QDialog *dlgName; QList<QLineEdit> listValue; QList<QLabel> listName; QStringList slDynamicEntries; QStringList trlDynamicEntries; bool m_personalView; QStringList slHomeAddress; QStringList slBusinessAddress; QStringList slChooserNames; QStringList slChooserValues; QStringList emails; QString defaultEmail; QMultiLineEdit *txtNote; QLabel *lblNote; //QLineEdit *txtTitle; QLineEdit *txtFirstName; QLineEdit *txtMiddleName; QLineEdit *txtLastName; QLineEdit *txtSuffix; QTabWidget *tabMain; QScrollView *svGeneral; QPushButton *btnFullName; QPushButton *btnNote; QLineEdit *txtFullName; QLineEdit *txtJobTitle; QLineEdit *txtOrganization; QLineEdit *txtChooserField1; QLineEdit *txtChooserField2; QLineEdit *txtChooserField3; QLineEdit *txtChooserField4; QComboBox *cmbChooserField1; QComboBox *cmbChooserField2; QComboBox *cmbChooserField3; QComboBox *cmbChooserField4; QComboBox *cmbDefaultEmail; QComboBox *cmbFileAs; CategorySelect *cmbCat; QLabel *labCat; QScrollView *svAddress; QLineEdit *txtAddress; //QLineEdit *txtAddress2; //QLineEdit *txtPOBox; QLineEdit *txtCity; QLineEdit *txtState; QLineEdit *txtZip; QComboBox *cmbAddress; QComboBox *cmbCountry; QScrollView *svDetails; QComboBox *cmbGender; DateBookMonth* birthdayPicker; QToolButton* birthdayButton; DateBookMonth* anniversaryPicker; QToolButton* anniversaryButton; }; #endif |