summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp62
-rw-r--r--core/pim/addressbook/contacteditor.h8
2 files changed, 29 insertions, 41 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 75dd2c1..7682399 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -68,50 +68,48 @@ ContactEditor::ContactEditor( const OContact &entry,
WFlags fl )
: QDialog( parent, name, TRUE, fl ),
defaultEmailChooserPosition( -1 ),
m_personalView ( false ),
cmbDefaultEmail( 0 ),
initializing ( false )
{
initializing = true;
init();
setEntry( entry );
// cmbDefaultEmail = 0;
// defaultEmailChooserPosition = -1;
initializing = false;
}
ContactEditor::~ContactEditor() {
}
void ContactEditor::init() {
qWarning("init() START");
- 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();
@@ -1010,98 +1008,101 @@ void ContactEditor::slotAddressTypeChange( int index ) {
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 ) {
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->insertItem( parseName( textChanged, NAME_FML ) );
+ if ( ! txtSuffix->text().isEmpty() )
+ cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() );
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) );
- }
+
+ 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() ) {
+ if ( txtLastName->text().contains( ' ', TRUE ) )
+ tmpName = txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text();
+ else
+ tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->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;
@@ -1158,50 +1159,50 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
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(" 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 + " " + txtSuffix->text();
+ case NAME_FML:
+ return strFirstName + " " + strMiddleName + " " + strLastName ;
case NAME_F:
return strFirstName;
case NAME_M:
return strMiddleName;
case NAME_L:
return strLastName;
case NAME_S:
return txtSuffix->text();
}
return QString::null;
}
void ContactEditor::cleanupFields() {
QStringList::Iterator it = slChooserValues.begin();
for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
(*it) = "";
}
@@ -1229,64 +1230,65 @@ void ContactEditor::cleanupFields() {
txtAddress->setText("");
txtCity->setText("");
txtState->setText("");
txtZip->setText("");
QLineEdit *txtTmp = cmbCountry->lineEdit();
txtTmp->setText("");
txtTmp = cmbFileAs->lineEdit();
txtTmp->setText("");
}
void ContactEditor::setEntry( const OContact &entry ) {
initializing = true;
cleanupFields();
ent = entry;
emails = QStringList(ent.emailList());
defaultEmail = ent.defaultEmail();
if (defaultEmail.isEmpty()) defaultEmail = emails[0];
qDebug("default email=%s",defaultEmail.latin1());
- 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() );
- // Lastnames with multiple words need to be protected by a comma !
- if ( ent.lastName().contains( ' ', TRUE ) )
- txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
- else
- txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
+ if ( !ent.isEmpty() ){
+ // Lastnames with multiple words need to be protected by a comma !
+ if ( ent.lastName().contains( ' ', TRUE ) )
+ txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
+ else
+ txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
+ }
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 (hasCity) {
slHomeAddress[3] = ent.homeCity();
slBusinessAddress[3] = ent.businessCity();
//}
//if (hasState) {
slHomeAddress[4] = ent.homeState();
@@ -1404,103 +1406,91 @@ void ContactEditor::setEntry( const OContact &entry ) {
*itV = ent.MSNIM();
if ( *it == "Yahoo IM" )
*itV = ent.yahooIM();
*/
if ( *it == "Home Web Page" )
*itV = ent.homeWebpage();
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() );
slotAddressTypeChange( cmbAddress->currentItem() );
- // Calling "show()" to arrange all widgets. Otherwise we will get
- // a wrong position of the textfields and are unable to put our
- // default-email combo over it.. This is very ugly !
- // Does anybody has a better solution ?
- // Basically we should rethink the strategy to hide
- // a textfield with overwriting.. (se)
- show();
-
// Get combo-settings from contact and set preset..
contactfields.loadFromRecord( ent );
cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) );
cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) );
cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) );
cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) );
cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) );
slotCmbChooser1Change( cmbChooserField1->currentItem() );
slotCmbChooser2Change( cmbChooserField2->currentItem() );
slotCmbChooser3Change( cmbChooserField3->currentItem() );
slotCmbChooser4Change( cmbChooserField4->currentItem() );
slotAddressTypeChange( cmbAddress->currentItem() );
updateDatePicker();
initializing = false;
}
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() {
// Store current combo into contact
contactfields.saveToRecord( ent );
- 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;
- }
+ 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 ) );
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] );
// }
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index 954c77e..c6fa48f 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -12,52 +12,52 @@
* 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>
#include <qwidgetstack.h>
#include "ocontactfields.h"
-const int NAME_LF = 0;
+const int NAME_LF = 0;
const int NAME_LFM = 1;
-const int NAME_FL = 2;
-const int NAME_FMLS = 3;
+const int NAME_FL = 2;
+const int NAME_FML = 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 );
@@ -94,50 +94,48 @@ class ContactEditor : public QDialog {
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;
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;