summaryrefslogtreecommitdiff
authoreilers <eilers>2003-03-04 17:23:03 (UTC)
committer eilers <eilers>2003-03-04 17:23:03 (UTC)
commitcaad9c7b3e7fc0c9046993f6a152cd37f91fdceb (patch) (side-by-side diff)
tree189006e4f369cf6a373fd20f277966ff42117b5b
parent55e5d2c95f70d296c541e4f2564713a593c3851c (diff)
downloadopie-caad9c7b3e7fc0c9046993f6a152cd37f91fdceb.zip
opie-caad9c7b3e7fc0c9046993f6a152cd37f91fdceb.tar.gz
opie-caad9c7b3e7fc0c9046993f6a152cd37f91fdceb.tar.bz2
Fixing suffix handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp15
-rw-r--r--core/pim/addressbook/contacteditor.h1
2 files changed, 11 insertions, 5 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index c4a7b10..75dd2c1 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -624,48 +624,50 @@ void ContactEditor::init() {
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( txtSuffix, SIGNAL(textChanged(const QString &)), this, SLOT(slotSuffixChange(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)) );
@@ -1016,118 +1018,122 @@ void ContactEditor::slotAddressTypeChange( int index ) {
}
}
void ContactEditor::slotFullNameChange( const QString &textChanged ) {
qWarning( "ContactEditor::slotFullNameChange( %s )", textChanged.latin1() );
int index = cmbFileAs->currentItem();
cmbFileAs->clear();
cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) );
cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) );
cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) );
cmbFileAs->insertItem( parseName( textChanged, NAME_FMLS ) );
cmbFileAs->setCurrentItem( index );
useFullName = true;
}
+void ContactEditor::slotSuffixChange( const QString& ) {
+ // Just want to update the FileAs combo if the suffix was changed..
+ slotFullNameChange( txtFullName->text() );
+}
+
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();
+ tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->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;
bool haveLastName = false;
qWarning("Fullname: %s", simplifiedName.latin1());
commapos = simplifiedName.find( ',', 0, TRUE);
if ( commapos >= 0 ) {
qWarning(" Commapos: %d", commapos );
// A comma (",") separates the lastname from one or
// many first names. Thus, remove the lastname from the
// String and parse the firstnames.
strLastName = simplifiedName.left( commapos );
simplifiedName= simplifiedName.mid( commapos + 1 );
haveLastName = true;
qWarning("Fullname without ',': %s", simplifiedName.latin1());
// If we have any lastname, we should now split all first names.
// The first one will be the used as first, the rest as "middle names"
QStringList allFirstNames = QStringList::split(" ", simplifiedName);
QStringList::Iterator it = allFirstNames.begin();
@@ -1140,75 +1146,74 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
} else {
// No comma separator used: We use the first word as firstname, the
// last as second/lastname and everything in the middle as middlename
QStringList allNames = QStringList::split(" ", simplifiedName);
QStringList::Iterator it = allNames.begin();
strFirstName = *it++;
QStringList allSecondNames;
for ( ; it != --allNames.end(); ++it )
allSecondNames.append( *it );
strMiddleName = allSecondNames.join(" ");
strLastName = *(--allNames.end());
}
if ( strFirstName == strLastName )
strFirstName = "";
qWarning(" strFirstName: %s", strFirstName.latin1());
qWarning(" strMiddleName: %s", strMiddleName.latin1());
qWarning(" strLastName: %s", strLastName.latin1());
- qWarning(" strSuffix: %s", strSuffix.latin1());
qWarning(" strTitle: %s", strTitle.latin1());
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;
+ return strFirstName + " " + strMiddleName + " " + strLastName + " " + txtSuffix->text();
case NAME_F:
return strFirstName;
case NAME_M:
return strMiddleName;
case NAME_L:
return strLastName;
case NAME_S:
- return strSuffix;
+ return txtSuffix->text();
}
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] = "";
}
QListIterator<QLineEdit> itLV( listValue );
for ( ; itLV.current(); ++itLV ) {
(*itLV)->setText( "" );
}
txtFirstName->setText("");
txtMiddleName->setText("");
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index 703e702..954c77e 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -79,48 +79,49 @@ class ContactEditor : public QDialog {
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 slotSuffixChange( 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:
enum StackWidgets { TextField = 1, Combo };
int defaultEmailChooserPosition;
void populateDefaultEmailCmb();
void chooserChange( const QString&, int , QLineEdit*, int );
bool cmbChooserChange( int , QWidgetStack*, int );
OContactFields contactfields;
bool useFullName;
OContact ent;
QDialog *dlgNote;
QDialog *dlgName;
QList<QLineEdit> listValue;
QList<QLabel> listName;