summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/contacteditor.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/addressbook/contacteditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp327
1 files changed, 164 insertions, 163 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 8acf570..534666d 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -12,55 +12,56 @@
* 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 <opie2/opimcontact.h>
+
#include <qpe/categoryselect.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpedialog.h>
-#include <opie/ocontact.h>
#include <qpe/resource.h>
#include <qlabel.h>
#include <qtabwidget.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qtoolbutton.h>
-#include <qlistbox.h>
-#include <qmessagebox.h>
+#include <qlistbox.h>
+#include <qmessagebox.h>
#include <qwhatsthis.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,
+ContactEditor::ContactEditor( const Opie::OPimContact &entry,
QWidget *parent,
const char *name,
WFlags )
: QDialog( parent, name, TRUE, WStyle_ContextHelp ),
defaultEmailChooserPosition( -1 ),
m_personalView ( false ),
cmbDefaultEmail( 0 ),
initializing ( false )
{
initializing = true;
@@ -68,49 +69,49 @@ ContactEditor::ContactEditor( const OContact &entry,
setEntry( entry );
// cmbDefaultEmail = 0;
// defaultEmailChooserPosition = -1;
initializing = false;
}
ContactEditor::~ContactEditor() {
}
void ContactEditor::init() {
qWarning("init() START");
-
+
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 );
+ trlChooserNames = Opie::OPimContactFields::trphonefields( false );
+ slChooserNames = Opie::OPimContactFields::untrphonefields( false );
+ slDynamicEntries = Opie::OPimContactFields::untrdetailsfields( false );
+ trlDynamicEntries = Opie::OPimContactFields::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();
+ QMap<int, QString> translMap = Opie::OPimContactFields::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("");
@@ -155,25 +156,25 @@ void ContactEditor::init() {
gl->addWidget( l, 2, 0 );
txtSuffix = new QLineEdit( container );
QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) );
gl->addWidget( txtSuffix, 2, 1 );
l = new QLabel( tr( "Organization" ), container );
QWhatsThis::add( l, tr( "The working place of the contact" ) );
gl->addWidget( l, 3, 0 );
txtOrganization = new QLineEdit( container );
QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) );
gl->addWidget( txtOrganization, 3, 1 );
- // Chooser 1
+ // Chooser 1
cmbChooserField1 = new QComboBox( FALSE, container );
QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) );
cmbChooserField1->setMaximumWidth( 90 );
gl->addWidget( cmbChooserField1, 4, 0 );
// Textfield for chooser 1.
// Now use Widgetstack to contain the textfield and the default-email combo !
m_widgetStack1 = new QWidgetStack( container );
txtChooserField1 = new QLineEdit( m_widgetStack1 );
m_widgetStack1 -> addWidget( txtChooserField1, TextField );
gl->addWidget( m_widgetStack1, 4, 1 );
m_widgetStack1 -> raiseWidget( TextField );
@@ -520,78 +521,78 @@ void ContactEditor::init() {
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" ) ),
+ 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" ) ),
+ 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();
- QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId();
- QMap<int, QString> mapIdToStr = OContactFields::idToTrFields();
+ QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId();
+ QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields();
for (i = counter; it != slDynamicEntries.end(); i++, ++it ) {
-
- if (((*it) == "Anniversary") ||
+
+ if (((*it) == "Anniversary") ||
((*it) == "Birthday")|| ((*it) == "Gender")) continue;
l = new QLabel( mapIdToStr[mapStrToID[*it]], 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();
@@ -635,29 +636,29 @@ void ContactEditor::init() {
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&)),
+ connect( txtFullName, SIGNAL(textChanged(const QString&)),
this, SLOT(slotFullNameChange(const QString&)) );
- connect( txtSuffix, SIGNAL(textChanged(const QString&)),
+ connect( txtSuffix, SIGNAL(textChanged(const QString&)),
this, SLOT(slotSuffixChange(const QString&)) );
- connect( txtOrganization, SIGNAL(textChanged(const QString&)),
+ connect( txtOrganization, SIGNAL(textChanged(const QString&)),
this, SLOT(slotOrganizationChange(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&)),
@@ -691,179 +692,179 @@ void ContactEditor::init() {
void ContactEditor::defaultEmailChanged(int i){
qDebug("defaultEmailChanged");
// was sollte das ? (se)
// int index = cmbChooserField1->currentItem();
// slChooserValues[index] = cmbDefaultEmail->text(i);
defaultEmail = cmbDefaultEmail->text(i);
qDebug ("Changed to: %s", defaultEmail.latin1());
}
-void ContactEditor::populateDefaultEmailCmb(){
+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 = new QComboBox(this);
cmbDefaultEmail -> hide();
}
- cmbDefaultEmail->clear();
+ cmbDefaultEmail->clear();
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");
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, QWidgetStack* inputStack, int widgetPos ) {
QString type = slChooserNames[index];
qWarning("ContactEditor::cmbChooserChange -> Type: %s, WidgetPos: %d", type.latin1(), widgetPos );
if ( !initializing )
contactfields.setFieldOrder( widgetPos-1, index );
- // Create and connect combobox for selecting the default email
- if ( type == "Default Email"){
+ // Create and connect combobox for selecting the default email
+ if ( type == "Default Email"){
qWarning("Choosing default-email (defaultEmailChooserPosition= %d) ", defaultEmailChooserPosition);
-
+
// More than one default-email chooser is not allowed !
- if ( ( defaultEmailChooserPosition != -1 ) &&
+ if ( ( defaultEmailChooserPosition != -1 ) &&
defaultEmailChooserPosition != widgetPos && !initializing){
chooserError( widgetPos );
return true;
}
QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
- if ( cmbo ){
+ if ( cmbo ){
inputStack->raiseWidget( TextField );
inputStack -> removeWidget( cmbo );
delete cmbo;
}
cmbo = new QComboBox( inputStack );
cmbo -> insertStringList( emails );
inputStack -> addWidget( cmbo, Combo );
inputStack -> raiseWidget( Combo );
defaultEmailChooserPosition = widgetPos;
cmbDefaultEmail = cmbo;
connect( cmbo,SIGNAL( activated(int) ),
- SLOT( defaultEmailChanged(int) ) );
+ SLOT( defaultEmailChanged(int) ) );
// Set current default email
populateDefaultEmailCmb();
-
+
} else {
// Something else was selected: Hide combo..
qWarning(" Hiding default-email combo" );
if ( defaultEmailChooserPosition == widgetPos ){
defaultEmailChooserPosition = -1;
}
QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
- if ( cmbo ){
+ if ( cmbo ){
inputStack->raiseWidget( TextField );
inputStack -> removeWidget( cmbo );
cmbDefaultEmail = 0l;
delete cmbo;
}
// 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);
+ 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
+ // generates no signal, therfore we have to
// call the cmbChooserChange function manually..
switch( index ){
case 1:
cmbChooserField1 -> setCurrentItem( 0 );
slotCmbChooser1Change( 0 );
break;
- case 2:
+ case 2:
cmbChooserField2 -> setCurrentItem( 0 );
slotCmbChooser2Change( 0 );
break;
- case 3:
+ case 3:
cmbChooserField3 -> setCurrentItem( 0 );
slotCmbChooser3Change( 0 );
break;
- case 4:
+ case 4:
cmbChooserField4 -> setCurrentItem( 0 );
slotCmbChooser4Change( 0 );
break;
}
}
// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
-void ContactEditor::chooserChange( const QString &textChanged, int index,
+void ContactEditor::chooserChange( const QString &textChanged, int index,
QLineEdit* , int widgetPos ) {
QString type = slChooserNames[index]; // :SX
qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",
type.latin1(),textChanged.latin1(), index, widgetPos );
- if ( type == "Default Email"){
+ if ( type == "Default Email"){
qWarning ("??? Wozu??: %s", textChanged.latin1());
defaultEmail = textChanged;
populateDefaultEmailCmb();
}else if (type == "Emails"){
qDebug("emails");
QString de;
emails = QStringList::split (",", textChanged );
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);
@@ -939,25 +940,25 @@ 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(), m_widgetStack1, 1) ){
-
+
txtChooserField1->setText( slChooserValues[index] );
txtChooserField1->setFocus();
}
}
void ContactEditor::slotCmbChooser2Change( int index ) {
qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){
@@ -1040,30 +1041,30 @@ void ContactEditor::slotFullNameChange( const QString &textChanged ) {
cmbFileAs->setCurrentItem( index );
}
void ContactEditor::slotSuffixChange( const QString& ) {
// Just want to update the FileAs combo if the suffix was changed..
slotFullNameChange( txtFullName->text() );
}
void ContactEditor::slotOrganizationChange( const QString &textChanged ){
qWarning( "ContactEditor::slotOrganizationChange( %s )", textChanged.latin1() );
- // Special handling for storing Companies:
+ // Special handling for storing Companies:
// If no Fullname is given, we store the Company-Name as lastname
// to handle it like a person..
if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) )
txtFullName->setText( textChanged );
-
+
}
void ContactEditor::accept() {
if ( isEmpty() ) {
cleanupFields();
reject();
} else {
saveEntry();
cleanupFields();
QDialog::accept();
}
@@ -1128,505 +1129,505 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
QString strLastName;
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
+ // 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();
strFirstName = *it++;
QStringList allSecondNames;
for ( ; it != allFirstNames.end(); ++it )
allSecondNames.append( *it );
-
+
strMiddleName = allSecondNames.join(" ");
} else {
- // No comma separator used: We use the first word as firstname, the
+ // 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(" 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_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) = "";
}
-
+
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("");
txtLastName->setText("");
txtSuffix->setText("");
txtNote->setText("");
txtFullName->setText("");
txtJobTitle->setText("");
txtOrganization->setText("");
txtChooserField1->setText("");
txtChooserField2->setText("");
txtChooserField3->setText("");
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 ) {
-
+void ContactEditor::setEntry( const Opie::OPimContact &entry ) {
+
initializing = true;
-
+
// Cleanup and activate the general Page ..
cleanupFields();
tabMain->setCurrentPage( 0 );
-
+
ent = entry;
-
+
emails = QStringList(ent.emailList());
defaultEmail = ent.defaultEmail();
if (defaultEmail.isEmpty()) defaultEmail = emails[0];
qDebug("default email=%s",defaultEmail.latin1());
-
+
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() );
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();
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(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
-
+
qWarning(" Filling dynamic Field: %s", (*it).latin1() );
-
+
if ( *it == "Department" )
(*itLE)->setText( ent.department() );
-
+
if ( *it == "Company" )
(*itLE)->setText( ent.company() );
-
+
if ( *it == "Office" )
(*itLE)->setText( ent.office() );
-
+
if ( *it == "Profession" )
(*itLE)->setText( ent.profession() );
-
+
if ( *it == "Assistant" )
(*itLE)->setText( ent.assistant() );
-
+
if ( *it == "Manager" )
(*itLE)->setText( ent.manager() );
-
+
if ( *it == "Spouse" )
(*itLE)->setText( ent.spouse() );
-
+
if ( *it == "Nickname" ){
qWarning("**** Nichname: %s", ent.nickname().latin1() );
(*itLE)->setText( ent.nickname() );
}
-
+
if ( *it == "Children" )
(*itLE)->setText( ent.children() );
-
+
}
-
+
QStringList::Iterator itV;
for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
-
+
if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) )
*itV = ent.businessPhone();
/*
if ( *it == "Business 2 Phone" )
*itV = ent.business2Phone();
*/
if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) )
*itV = ent.businessFax();
-
+
if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) )
*itV = ent.businessMobile();
/*
if ( *it == "Company Phone" )
*itV = ent.companyPhone();
*/
if ( *it == "Default Email" )
*itV = ent.defaultEmail();
-
+
if ( *it == "Emails" )
*itV = ent.emailList().join(", "); // :SX
-
+
if ( *it == "Home Phone" )
*itV = ent.homePhone();
/*
if ( *it == "Home 2 Phone" )
*itV = ent.home2Phone();
*/
if ( *it == "Home Fax" )
*itV = ent.homeFax();
-
+
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 == "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 == "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() );
-
+
// 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 );
-
+
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] );
// }
-
+
// 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( 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( 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 ) {
@@ -1689,36 +1690,36 @@ 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();
+ labCat->show();
}
}
void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
{
QDate date;
date.setYMD( year, month, day );
QString dateString = TimeString::numberDateString( date );
anniversaryButton->setText( dateString );
ent.setAnniversary ( date );
}