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.cpp605
1 files changed, 118 insertions, 487 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index e034b35..5a7bf1a 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,383 +1,120 @@
/*
* 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,
- const QValueList<int> *newOrderedValues,
- QStringList *slNewOrdered,
QWidget *parent,
const char *name,
WFlags fl )
: QDialog( parent, name, TRUE, fl ),
- orderedValues( newOrderedValues ),
- slOrdered( *slNewOrdered ),
m_personalView ( false )
{
init();
- initMap();
setEntry( entry );
- qDebug("finish");
}
ContactEditor::~ContactEditor() {
}
void ContactEditor::init() {
- useFullName = TRUE;
+ useFullName = true;
- int i = 0;
-/** SHut up and stop leaking
- slHomeAddress = new QStringList;
- slBusinessAddress = new QStringList;
- slChooserNames = new QStringList;
- slChooserValues = new QStringList;
-
- slDynamicEntries = new QStringList;
-*/
- //*slDynamicEntries = *slOrdered;
+ uint i = 0;
QStringList trlChooserNames;
for (i = 0; i <= 6; i++) {
slHomeAddress.append( "" );
slBusinessAddress.append( "" );
}
- {
- hasGender = FALSE;
- hasTitle = FALSE;
- hasCompany = FALSE;
- hasNotes = FALSE;
- hasStreet = FALSE;
- hasStreet2 = FALSE;
- hasPOBox = FALSE;
- hasCity = FALSE;
- hasState = FALSE;
- hasZip = FALSE;
- hasCountry = FALSE;
-
- QStringList::ConstIterator it = slOrdered.begin();
-
- for ( i = 0; it != slOrdered.end(); i++, ++it ) {
-
- if ( (*it) == "Business Fax" ) {
- trlChooserNames.append( tr( "Business Fax" ) );
- slChooserNames.append( *it );
- slChooserValues.append("" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Fax" ) {
- trlChooserNames.append( tr( "Home Fax" ) );
- slChooserNames.append( *it );
- slChooserValues.append("" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
-
- if ( (*it) == "Business Phone" ) {
- trlChooserNames.append( tr( "Business Phone" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Phone" ) {
- trlChooserNames.append( tr( "Home Phone" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
+ trlChooserNames = OContactFields::trphonefields();
+ slChooserNames = OContactFields::untrphonefields();
+ slDynamicEntries = OContactFields::untrdetailsfields();
+ trlDynamicEntries = OContactFields::trdetailsfields();
+ for (i = 0; i < slChooserNames.count(); i++)
+ slChooserValues.append("");
-/*
- if ( (*it).right( 2 ) == tr( "IM" ) ) {
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- } */
-
- if ( (*it) == "Business Mobile" ) {
- trlChooserNames.append( tr( "Business Mobile" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Mobile" ) {
- trlChooserNames.append( tr( "Home Mobile" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
-
- if ( (*it) == "Business WebPage" ) {
- trlChooserNames.append( tr( "Business WebPage" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Web Page" ) {
- trlChooserNames.append( tr( "Home Web Page" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business Pager" ) {
- trlChooserNames.append( tr( "Business Pager" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Default Email" ) {
- trlChooserNames.append( tr( "Default Email" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Emails" ) {
- trlChooserNames.append( tr( "Emails" ) );
- slChooserNames.append( *it );
- slChooserValues.append( "" );
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Name Title" ||
- *it == "First Name" ||
- *it == "Middle Name" ||
- *it == "Last Name" ||
- *it == "File As" ||
- *it == "Default Email" ||
- *it == "Emails" ||
- *it == "Groups" ||
- *it == "Anniversary" ||
- *it == "Birthday" )
- continue;
-
- if ( *it == "Name Title" ) {
- //slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "First Name" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Middle Name" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Last Name" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Suffix" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "File As" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Gender" ) {
- hasGender = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Job Title" ) {
- hasTitle = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( ( *it == "Company") || (*it == "Organization" ) ) {
- hasCompany = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Notes" ) {
- hasNotes = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( *it == "Groups" ) {
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business Street" ) {
- hasStreet = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Street" ) {
- hasStreet = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-/*
- if ( (*it).right( 8 ) == tr( "Street 2" ) ) {
- hasStreet2 = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) {
- hasPOBox = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- } */
-
- if ( (*it) == "Business City" ) {
- hasCity = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business State" ) {
- hasState = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business Zip" ) {
- hasZip = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Business Country" ) {
- hasCountry = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home City" ) {
- hasCity = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home State" ) {
- hasState = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Zip" ) {
- hasZip = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- if ( (*it) == "Home Country" ) {
- hasCountry = TRUE;
- // slDynamicEntries->remove( it );
- continue;
- }
-
- slDynamicEntries.append( *it );
- }
- }
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 );
@@ -399,98 +136,80 @@ void ContactEditor::init() {
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 );
-
- // We don't need categories for the personal view
- if ( m_personalView ){
- qWarning("Disable Category..");
- labCat->hide();
- cmbCat->hide();
- } else {
- labCat->show();
- cmbCat->show();
- }
+ 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( "Address 2" ), container );
- gl->addWidget( l, 2, 0 );
- txtAddress2 = new QLineEdit( container );
- gl->addMultiCellWidget( txtAddress2, 2, 2, 1, 2 );
- l = new QLabel( tr( "P.O. Box" ), container );
- gl->addWidget( l, 3, 0 );
- txtPOBox = new QLineEdit( container );
- gl->addMultiCellWidget( txtPOBox, 3, 3, 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" ) );
@@ -715,104 +434,124 @@ void ContactEditor::init() {
QSpacerItem *space = new QSpacerItem(1,1,
QSizePolicy::Maximum,
QSizePolicy::MinimumExpanding );
gl->addItem( space, 7, 0 );
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( container, "buttonStart" );
+ birthdayButton= new QToolButton( hBox, "buttonStart" );
birthdayButton->setPopup( m1 );
birthdayButton->setPopupDelay(0);
- gl->addWidget( birthdayButton, counter , 1 );
+
+ 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( container, "buttonStart" );
+ anniversaryButton= new QToolButton( hBox, "buttonStart" );
anniversaryButton->setPopup( m1 );
anniversaryButton->setPopupDelay(0);
- gl->addWidget( anniversaryButton, counter , 1 );
+
+ 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();
- for (i = counter; it != slDynamicEntries.end(); i++, ++it) {
- l = new QLabel( QString::null , container );
+ 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();
+ // 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 );
@@ -857,76 +596,50 @@ void ContactEditor::init() {
//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);
-}
-void ContactEditor::initMap()
-{
- /*
- // since the fields and the XML fields exist, create a map
- // between them...
- Config cfg1( "AddressBook" );
- Config cfg2( "AddressBook" );
- QString strCfg1,
- strCfg2;
- int i;
-
- // This stuff better exist...
- cfg1.setGroup( "AddressFields" );
-o cfg2.setGroup( "XMLFields" );
- i = 0;
- strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null );
- strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++),
- QString::null );
- while ( !strCfg1.isNull() && !strCfg2.isNull() ) {
- mapField.insert( strCfg1, strCfg2 );
- strCfg1 = cfg1.readEntry( "Field" + QString::number(i),
- QString::null );
- strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++),
- QString::null );
- }
- */
+ setPersonalView ( m_personalView );
}
void ContactEditor::slotChooser1Change( const QString &textChanged ) {
int index = cmbChooserField1->currentItem();
slChooserValues[index] = textChanged;
}
void ContactEditor::slotChooser2Change( const QString &textChanged ) {
int index = cmbChooserField2->currentItem();
slChooserValues[index] = textChanged;
}
void ContactEditor::slotChooser3Change( const QString &textChanged ) {
int index = cmbChooserField3->currentItem();
slChooserValues[index] = textChanged;
@@ -1050,126 +763,89 @@ void ContactEditor::slotAddressTypeChange( int index ) {
//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;
-
-}
-
-// Loads the detail fields
-void ContactEditor::loadFields() {
-
- QStringList::ConstIterator it;
- QListIterator<QLabel> lit( listName );
- for ( it = slDynamicEntries.begin(); *lit; ++lit, ++it) {
-
- if ( *it == "Department" )
- (*lit)->setText( tr( "Department" ) );
-
- if ( *it == "Company" )
- (*lit)->setText( tr( "Company" ) );
-
- if ( *it == "Office" )
- (*lit)->setText( tr( "Office" ) );
-
- if ( *it == "Profession" )
- (*lit)->setText( tr( "Profession" ) );
-
- if ( *it == "Assistant" )
- (*lit)->setText( tr( "Assistant" ) );
-
- if ( *it == "Manager" )
- (*lit)->setText( tr( "Manager" ) );
-
- if ( *it == "Spouse" )
- (*lit)->setText( tr( "Spouse" ) );
-
- if ( *it == "Nickname" )
- (*lit)->setText( tr( "Nickname" ) );
-
- if ( *it == "Children" )
- (*lit)->setText( tr( "Children" ) );
- }
+ 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 == TRUE) {
+ 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;
+ 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;
@@ -1340,157 +1016,142 @@ QString ContactEditor::parseName( const QString fullName, int type ) {
case NAME_LFM:
return strLastName + ", " + strFirstName + " " + strMiddleName;
case NAME_FMLS:
return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix;
case NAME_F:
return strFirstName;
case NAME_M:
return strMiddleName;
case NAME_L:
return strLastName;
case NAME_S:
return strSuffix;
}
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] = "";
}
- QStringList::ConstIterator cit;
- QListIterator<QLineEdit> itLE( listValue );
- for ( cit = slDynamicEntries.begin(); cit != slDynamicEntries.end(); ++cit, ++itLE) {
- (*itLE)->setText( "" );
- }
-
+ 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("");
- //txtAddress2->setText("");
txtCity->setText("");
- //txtPOBox->setText("");
txtState->setText("");
txtZip->setText("");
QLineEdit *txtTmp = cmbCountry->lineEdit();
txtTmp->setText("");
txtTmp = cmbFileAs->lineEdit();
txtTmp->setText("");
}
void ContactEditor::setEntry( const OContact &entry ) {
cleanupFields();
-
ent = entry;
- useFullName = FALSE;
+ 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() );
cmbFileAs->setEditText( ent.fileAs() );
- if (hasTitle)
+ // if (hasTitle)
txtJobTitle->setText( ent.jobTitle() );
- if (hasCompany)
+ // if (hasCompany)
txtOrganization->setText( ent.company() );
- if (hasNotes)
+ // if (hasNotes)
txtNote->setText( ent.notes() );
- if (hasStreet) {
+ // if (hasStreet) {
slHomeAddress[0] = ent.homeStreet();
slBusinessAddress[0] = ent.businessStreet();
- }
-/*
- if (hasStreet2) {
- (*slHomeAddress)[1] = ent.homeStreet2();
- (*slBusinessAddress)[1] = ent.businessStreet2();
- }
+ // }
- if (hasPOBox) {
- (*slHomeAddress)[2] = ent.homePOBox();
- (*slBusinessAddress)[2] = ent.businessPOBox();
- }
-*/
- if (hasCity) {
+// if (hasCity) {
slHomeAddress[3] = ent.homeCity();
slBusinessAddress[3] = ent.businessCity();
- }
+//}
- if (hasState) {
+//if (hasState) {
slHomeAddress[4] = ent.homeState();
slBusinessAddress[4] = ent.businessState();
- }
+//}
- if (hasZip) {
+//if (hasZip) {
slHomeAddress[5] = ent.homeZip();
slBusinessAddress[5] = ent.businessZip();
- }
+//}
- if (hasCountry) {
+//if (hasCountry) {
slHomeAddress[6] = ent.homeCountry();
slBusinessAddress[6] = ent.businessCountry();
- }
+//}
QStringList::ConstIterator it;
QListIterator<QLineEdit> itLE( listValue );
- for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) {
+ for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
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" )
(*itLE)->setText( ent.nickname() );
@@ -1568,238 +1229,189 @@ void ContactEditor::setEntry( const OContact &entry ) {
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() );
slotCmbChooser1Change( cmbChooserField1->currentItem() );
slotCmbChooser2Change( cmbChooserField2->currentItem() );
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 == TRUE ) {
+ 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;
-}
-
- /*if ( ent.firstName() != txtFirstName->text() ||
- ent.lastName != txtLastName->text() ||
- ent.middleName != txtMiddleName->text() ) {
- */
- ent.setFirstName( txtFirstName->text() );
- ent.setLastName( txtLastName->text() );
- ent.setMiddleName( txtMiddleName->text() );
- ent.setSuffix( txtSuffix->text() );
+ 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)
+
+ //if (hasTitle)
ent.setJobTitle( txtJobTitle->text() );
- if (hasCompany)
+ //if (hasCompany)
ent.setCompany( txtOrganization->text() );
- if (hasNotes)
+// if (hasNotes)
ent.setNotes( txtNote->text() );
- if (hasStreet) {
+ //if (hasStreet) {
ent.setHomeStreet( slHomeAddress[0] );
ent.setBusinessStreet( slBusinessAddress[0] );
- }
-/*
- if (hasStreet2) {
- ent.setHomeStreet2( (*slHomeAddress)[1] );
- ent.setBusinessStreet2( (*slBusinessAddress)[1] );
- }
+ // }
- if (hasPOBox) {
- ent.setHomePOBox( (*slHomeAddress)[2] );
- ent.setBusinessPOBox( (*slBusinessAddress)[2] );
- }
-*/
- if (hasCity) {
+ // if (hasCity) {
ent.setHomeCity( slHomeAddress[3] );
ent.setBusinessCity( slBusinessAddress[3] );
- }
+ // }
- if (hasState) {
+ // if (hasState) {
ent.setHomeState( slHomeAddress[4] );
ent.setBusinessState( slBusinessAddress[4] );
- }
+ // }
- if (hasZip) {
+ // if (hasZip) {
ent.setHomeZip( slHomeAddress[5] );
ent.setBusinessZip( slBusinessAddress[5] );
- }
+ // }
- if (hasCountry) {
+ // if (hasCountry) {
ent.setHomeCountry( slHomeAddress[6] );
ent.setBusinessCountry( slBusinessAddress[6] );
- }
+ // }
QStringList::ConstIterator it;
QListIterator<QLineEdit> itLE( listValue );
- for ( it = slDynamicEntries.begin(); it != slDynamicEntries.end(); ++it, ++itLE) {
+ 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 == tr("Business 2 Phone" )
- ent.setBusiness2Phone( *itV );
-*/
+
if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
ent.setBusinessFax( *itV );
if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
ent.setBusinessMobile( *itV );
-/*
- if ( *it == "Company Phone" )
- ent.setCompanyPhone( *itV );
-*/
- //if ( *it == "Default Email" )
- //ent.setDefaultEmail( *itV );
if ( *it == "Emails" ){
QString allemail;
QString defaultmail;
parseEmailFrom( *itV, defaultmail, allemail );
// ent.clearEmails();
ent.setDefaultEmail( defaultmail );
ent.setEmails( allemail );
}
if ( *it == "Home Phone" )
ent.setHomePhone( *itV );
-/*
- if ( *it == "Home 2 Phone" )
- ent.setHome2Phone( *itV );
-*/
+
if ( *it == "Home Fax" )
ent.setHomeFax( *itV );
if ( *it == "Home Mobile" )
ent.setHomeMobile( *itV );
-/*
- if ( *it == "Car Phone" )
- ent.setCarPhone( *itV );
-
- if ( *it == "ISDN Phone" )
- ent.setISDNPhone( *itV );
- if ( *it == "Other Phone" )
- ent.setOtherPhone( *itV );
-*/
if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
ent.setBusinessPager( *itV );
-/*
- if ( *it == "Home Pager" )
- ent.setHomePager( *itV );
- if ( *it == "AIM IM" )
- ent.setAIMIM( *itV );
-
- if ( *it == "ICQ IM" )
- ent.setICQIM( *itV );
-
- if ( *it == "Jabber IM" )
- ent.setJabberIM( *itV );
-
- if ( *it == "MSN IM" )
- ent.setMSNIM( *itV );
-
- if ( *it == "Yahoo IM" )
- ent.setYahooIM( *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() )
@@ -1854,51 +1466,70 @@ void parseEmailTo( const QString &strDefaultEmail,
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();
-
+ 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 );
}
void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
{
QDate date;
date.setYMD( year, month, day );
QString dateString = TimeString::numberDateString( date );
birthdayButton->setText( dateString );
ent.setBirthday ( date );
}
+
+void ContactEditor::slotRemoveBirthday()
+{
+ qWarning("void ContactEditor::slotRemoveBirthday()");
+ ent.setBirthday( QDate() );
+ updateDatePicker();
+}
+
+void ContactEditor::slotRemoveAnniversary()
+{
+ qWarning("void ContactEditor::slotRemoveAnniversary()");
+ ent.setAnniversary( QDate() );
+ updateDatePicker();
+}