-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 19 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 3 |
2 files changed, 14 insertions, 8 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index f125edb..cc3908a 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp @@ -1,266 +1,266 @@ /* * 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> 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(); slChooserNames = OContactFields::untrphonefields(); slDynamicEntries = OContactFields::untrdetailsfields(); trlDynamicEntries = OContactFields::trdetailsfields(); 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 ); cmbFileAs = new QComboBox( TRUE, container ); gl->addWidget( cmbFileAs, 6, 1 ); labCat = new QLabel( tr( "Category" ), container ); gl->addWidget( labCat, 7, 0 ); cmbCat = new CategorySelect( container ); gl->addWidget( cmbCat, 7, 1 ); labCat->show(); cmbCat->show(); 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( "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" ) ); @@ -442,421 +442,426 @@ void ContactEditor::init() { 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 ); int counter = 0; // Birthday QHBox* hBox = new QHBox( container ); l = new QLabel( tr("Birthday"), container ); gl->addWidget( l, counter, 0 ); QPopupMenu* m1 = new QPopupMenu( container ); birthdayPicker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( birthdayPicker ); birthdayButton= new QToolButton( hBox, "buttonStart" ); birthdayButton->setPopup( m1 ); birthdayButton->setPopupDelay(0); QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), tr( "Delete" ), hBox, 0 ); gl->addWidget( hBox, counter , 1 ); connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); ++counter; // Anniversary hBox = new QHBox( container ); l = new QLabel( tr("Anniversary"), container ); gl->addWidget( l, counter, 0 ); m1 = new QPopupMenu( container ); anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); m1->insertItem( anniversaryPicker ); anniversaryButton= new QToolButton( hBox, "buttonStart" ); anniversaryButton->setPopup( m1 ); anniversaryButton->setPopupDelay(0); 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( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) ); //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(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"); int index = cmbChooserField1->currentItem(); slChooserValues[index] = cmbDefaultEmail->text(i); } -void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid ) { +void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) { + qDebug("defaultEmailChooserPosition %i, widgetPos %i ",defaultEmailChooserPosition,widgetPos); if (slChooserNames[index] == "Default Email"){ if (cmbDefaultEmail) delete cmbDefaultEmail; cmbDefaultEmail = new QComboBox(inputWid->parentWidget()); cmbDefaultEmail->setGeometry(inputWid->frameGeometry()); cmbDefaultEmail->insertStringList(ent.emailList()); connect(cmbDefaultEmail,SIGNAL(activated(int)), SLOT(defaultEmailChanged(int))); QString demail = ent.defaultEmail(); for ( int i = 0; i < cmbDefaultEmail->count(); i++) if ( cmbDefaultEmail->text( i ) == demail ) cmbDefaultEmail->setCurrentItem( i ); cmbDefaultEmail->show(); - } + defaultEmailChooserPosition = widgetPos; + }else if (defaultEmailChooserPosition == widgetPos){ + qDebug("cmbDefaultEmail->hide()"); + if (cmbDefaultEmail) cmbDefaultEmail->hide(); + } slChooserValues[index] = textChanged; } void ContactEditor::slotChooser1Change( const QString &textChanged ) { - chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1); + chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); } void ContactEditor::slotChooser2Change( const QString &textChanged ) { - chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2); + chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); } void ContactEditor::slotChooser3Change( const QString &textChanged ) { - chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3); + chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); } void ContactEditor::slotChooser4Change( const QString &textChanged ) { - chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4); + 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 ) { txtChooserField1->setText( slChooserValues[index] ); txtChooserField1->setFocus(); } void ContactEditor::slotCmbChooser2Change( int index ) { txtChooserField2->setText( slChooserValues[index] ); txtChooserField2->setFocus(); } void ContactEditor::slotCmbChooser3Change( int index ) { txtChooserField3->setText( slChooserValues[index] ); txtChooserField3->setFocus(); } void ContactEditor::slotCmbChooser4Change( int index ) { 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; diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index d4b7f27..63257f8 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h @@ -1,174 +1,175 @@ /* * 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 ); 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: - void chooserChange( const QString&, int , QLineEdit* ); + int defaultEmailChooserPosition; + void chooserChange( const QString&, 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; 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 |