summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/contacteditor.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index 0e752ca..6edab2c 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,384 +1,403 @@
+/*
+ * 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.
+ *
+ */
#include "contacteditor.h"
#include "addresspicker.h"
#include <qpe/categoryselect.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpedialog.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>
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 Contact &entry,
const QValueList<int> *newOrderedValues,
QStringList *slNewOrdered,
QWidget *parent = 0,
const char *name = 0,
WFlags fl = 0 )
: QDialog( parent, name, TRUE, fl ),
orderedValues( newOrderedValues ),
slOrdered( slNewOrdered )
{
init();
initMap();
setEntry( entry );
qDebug("finish");
}
ContactEditor::~ContactEditor() {
}
void ContactEditor::init() {
useFullName = TRUE;
int i = 0;
slHomeAddress = new QStringList;
slBusinessAddress = new QStringList;
slChooserNames = new QStringList;
slChooserValues = new QStringList;
slDynamicEntries = new QStringList;
//*slDynamicEntries = *slOrdered;
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).right( 3 ) == tr( "Fax" ) ) {
slChooserNames->append( *it );
slChooserValues->append( tr( "" ) );
//slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 5 ) == tr( "Phone" ) ) {
slChooserNames->append( *it );
slChooserValues->append( "" );
//slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 2 ) == tr( "IM" ) ) {
slChooserNames->append( *it );
slChooserValues->append( "" );
//slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 6 ) == tr( "Mobile" ) ) {
slChooserNames->append( *it );
slChooserValues->append( "" );
//slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 4 ) == tr( "Page" ) ) {
slChooserNames->append( *it );
slChooserValues->append( "" );
//slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 5 ) == tr( "Pager" ) ) {
slChooserNames->append( *it );
slChooserValues->append( "" );
//slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Default Email" ) ) {
slChooserNames->append( *it );
slChooserValues->append( "" );
//slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Emails" ) ) {
slChooserNames->append( *it );
slChooserValues->append( "" );
//slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Name Title" ) ) {
//slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "First Name" ) ) {
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Middle Name" ) ) {
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Last Name" ) ) {
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Suffix" ) ) {
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "File As" ) ) {
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Gender" ) ) {
hasGender = TRUE;
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Job Title" ) ) {
hasTitle = TRUE;
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Company" ) ) {
hasCompany = TRUE;
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Notes" ) ) {
hasNotes = TRUE;
// slDynamicEntries->remove( it );
continue;
}
if ( *it == tr( "Groups" ) ) {
// slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 6 ) == tr( "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).right( 4 ) == tr( "City" ) ) {
hasCity = TRUE;
// slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 5 ) == tr( "State" ) ) {
hasState = TRUE;
// slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 3 ) == tr( "Zip" ) ) {
hasZip = TRUE;
// slDynamicEntries->remove( it );
continue;
}
if ( (*it).right( 7 ) == tr( "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, 3 );
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( 100 );
gl->addWidget( cmbChooserField1, 3, 0 );
txtChooserField1 = new QLineEdit( container );
gl->addWidget( txtChooserField1, 3, 1 );
cmbChooserField2 = new QComboBox( FALSE, container );
cmbChooserField2->setMaximumWidth( 100 );
gl->addWidget( cmbChooserField2, 4, 0 );
txtChooserField2 = new QLineEdit( container );
gl->addWidget( txtChooserField2, 4, 1 );
cmbChooserField3 = new QComboBox( FALSE, container );
cmbChooserField3->setMaximumWidth( 100 );
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 );
l = new QLabel( tr( "Category" ), container );
gl->addWidget( l, 7, 0 );
cmbCat = new CategorySelect( container );
gl->addWidget( cmbCat, 7, 1 );
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, 5, 3, 2, 3 );
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( "Japan" ) );
cmbCountry->insertItem( tr( "France" ) );
cmbCountry->insertItem( tr( "Germany" ) );
cmbCountry->insertItem( tr( "Norway" ) );
cmbCountry->insertItem( tr( "Canada" ) );
gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 );
tabMain->insertTab( tabViewport, tr( "Address" ) );
tabViewport = new QWidget ( tabMain );