Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

contacteditor.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
00003  * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
00004  *
00005  * This file is an add-on for the OPIE Palmtop Environment
00006  *
00007  * This file may be distributed and/or modified under the terms of the
00008  * GNU General Public License version 2 as published by the Free Software
00009  * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
00010  * of this file.
00011  *
00012  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014  *
00015  *
00016  * This is a rewrite of the abeditor.h file, modified to provide a more
00017  * intuitive interface to TrollTech's original Address Book editor.  This
00018  * is made to operate exactly in interface with the exception of name.
00019  *
00020  */
00021 
00022 #include "contacteditor.h"
00023 #include "namelineedit.h"
00024 
00025 #include <opie2/odebug.h>
00026 #include <opie2/opimcontact.h>
00027 #include <opie2/oresource.h>
00028 
00029 #include <qpe/categoryselect.h>
00030 #include <qpe/qpeapplication.h>
00031 #include <qpe/qpedialog.h>
00032 
00033 #include <qlabel.h>
00034 #include <qlayout.h>
00035 #include <qlineedit.h>
00036 #include <qmultilineedit.h>
00037 #include <qtoolbutton.h>
00038 #include <qlistbox.h>
00039 #include <qmessagebox.h>
00040 #include <qwhatsthis.h>
00041 
00042 #include <assert.h>
00043 
00044 static inline bool containsAlphaNum( const QString &str );
00045 static inline bool constainsWhiteSpace( const QString &str );
00046 
00047 // helper functions, convert our comma delimited list to proper
00048 // file format...
00049 void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
00050                      QString &strAll );
00051 
00052 // helper convert from file format to comma delimited...
00053 void parseEmailTo( const QString &strDefaultEmail,
00054                    const QString &strOtherEmail, QString &strBack );
00055 
00056 ContactEditor::ContactEditor(   const Opie::OPimContact &entry,
00057                                 QWidget *parent,
00058                                 const char *name,
00059                                 WFlags )
00060         : QDialog( parent, name, true, WStyle_ContextHelp ),
00061           defaultEmailChooserPosition( -1 ),
00062           m_personalView ( false ),
00063           cmbDefaultEmail( 0 ),
00064           initializing ( false )
00065 {
00066 
00067         initializing = true;
00068 
00069         init();
00070         setEntry( entry );
00071 //      cmbDefaultEmail = 0;
00072 //      defaultEmailChooserPosition = -1;
00073 
00074         initializing = false;
00075 }
00076 
00077 ContactEditor::~ContactEditor() {
00078 }
00079 
00080 void ContactEditor::init() {
00081         odebug << "init() START" << oendl;
00082 
00083         uint i = 0;
00084 
00085         QStringList trlChooserNames;
00086 
00087         for (i = 0; i <= 6; i++) {
00088                 slHomeAddress.append( "" );
00089                 slBusinessAddress.append( "" );
00090         }
00091 
00092         trlChooserNames   = Opie::OPimContactFields::trphonefields( false );
00093         slChooserNames    = Opie::OPimContactFields::untrphonefields( false );
00094         slDynamicEntries  = Opie::OPimContactFields::untrdetailsfields( false );
00095         trlDynamicEntries = Opie::OPimContactFields::trdetailsfields( false );
00096 
00097         // Ok, we have to remove elements from the list of dynamic entries
00098         // which are now stored in special (not dynamic) widgets..
00099         // Otherwise we will get problems with field assignments! (se)
00100         slDynamicEntries.remove("Anniversary");
00101         slDynamicEntries.remove("Birthday");
00102         slDynamicEntries.remove("Gender");
00103 
00104         // The same with translated fields.. But I will
00105         // use the translation map to avoid mismatches..
00106         QMap<int, QString> translMap = Opie::OPimContactFields::idToTrFields();
00107         trlDynamicEntries.remove( translMap[Qtopia::Anniversary] );
00108         trlDynamicEntries.remove( translMap[Qtopia::Birthday] );
00109         trlDynamicEntries.remove( translMap[Qtopia::Gender] );
00110 
00111         // Last Check to be sure..
00112         assert( slDynamicEntries.count() == trlDynamicEntries.count() );
00113         assert( slChooserNames.count() == trlChooserNames.count() );
00114 
00115         for (i = 0; i < slChooserNames.count(); i++)
00116           slChooserValues.append("");
00117 
00118 
00119         QVBoxLayout *vb = new QVBoxLayout( this );
00120 
00121         tabMain = new Opie::Ui::OTabWidget( this );
00122         vb->addWidget( tabMain );
00123 
00124         m_generalWidget = new QWidget ( tabMain );
00125 
00126         vb = new QVBoxLayout( m_generalWidget );
00127 
00128         svGeneral = new QScrollView( m_generalWidget );
00129         vb->addWidget( svGeneral, 0, 0 );
00130         svGeneral->setResizePolicy( QScrollView::AutoOneFit );
00131         // svGeneral->setHScrollBarMode( QScrollView::AlwaysOff );
00132         // svGeneral->setVScrollBarMode( QScrollView::AlwaysOff );
00133         svGeneral->setFrameStyle( QFrame::NoFrame );
00134 
00135         QWidget *container = new QWidget( svGeneral->viewport() );
00136         svGeneral->addChild( container );
00137 
00138         QGridLayout *gl = new QGridLayout( container, 10, 2, 2, 4 );
00139 
00140         btnFullName = new QPushButton( tr( "Full Name..." ), container );
00141         QWhatsThis::add( btnFullName, tr( "Press to enter last- middle and firstname" ) );
00142         gl->addWidget( btnFullName, 0, 0 );
00143         txtFullName = new ABOOK::NameLineEdit( container );
00144         QWhatsThis::add( txtFullName, tr( "Enter fullname directly ! If you have a lastname with multiple words ( for instance \"de la Guerra\"), please write <lastname>,<firstnames> like this: \"de la Guerra, Carlos Pedro\"" ) );
00145         gl->addWidget( txtFullName, 0, 1 );
00146 
00147         QLabel *l = new QLabel( tr( "Job Title" ), container );
00148         QWhatsThis::add( l, tr( "The jobtitle.." ) );
00149         gl->addWidget( l, 1, 0 );
00150         txtJobTitle = new QLineEdit( container );
00151         QWhatsThis::add( txtJobTitle, tr( "The jobtitle.." ) );
00152         gl->addWidget( txtJobTitle, 1, 1 );
00153 
00154         l = new QLabel( tr("Suffix"), container );
00155         QWhatsThis::add( l, tr( "Something like \"jr.\".." ) );
00156         gl->addWidget( l, 2, 0 );
00157         txtSuffix = new QLineEdit( container );
00158         QWhatsThis::add( txtSuffix, tr( "Something like \"jr.\".." ) );
00159         gl->addWidget( txtSuffix, 2, 1 );
00160 
00161         l = new QLabel( tr( "Organization" ), container );
00162         QWhatsThis::add( l, tr( "The working place of the contact" ) );
00163         gl->addWidget( l, 3, 0 );
00164         txtOrganization = new QLineEdit( container );
00165         QWhatsThis::add( txtOrganization, tr( "The working place of the contact" ) );
00166         gl->addWidget( txtOrganization, 3, 1 );
00167 
00168         // Chooser 1
00169         cmbChooserField1 = new QComboBox( false, container );
00170         QWhatsThis::add( cmbChooserField1, tr( "Press to select attribute to change" ) );
00171         cmbChooserField1->setMaximumWidth( 90 );
00172         gl->addWidget( cmbChooserField1, 4, 0 );
00173         // Textfield for chooser 1.
00174         // Now use Widgetstack to contain the textfield and the default-email combo !
00175         m_widgetStack1 = new QWidgetStack( container );
00176         txtChooserField1 = new QLineEdit( m_widgetStack1 );
00177         m_widgetStack1 -> addWidget( txtChooserField1, TextField );
00178         gl->addWidget( m_widgetStack1, 4, 1 );
00179         m_widgetStack1 -> raiseWidget( TextField );
00180 
00181         // Chooser 2
00182         cmbChooserField2 = new QComboBox( false, container );
00183         QWhatsThis::add( cmbChooserField2, tr( "Press to select attribute to change" ) );
00184         cmbChooserField2->setMaximumWidth( 90 );
00185         gl->addWidget( cmbChooserField2, 5, 0 );
00186         // Textfield for chooser 2
00187         // Now use WidgetStack to contain the textfield and the default-email combo!
00188         m_widgetStack2 = new QWidgetStack( container );
00189         txtChooserField2 = new QLineEdit( m_widgetStack2 );
00190         m_widgetStack2 -> addWidget( txtChooserField2, TextField );
00191         gl->addWidget( m_widgetStack2, 5, 1 );
00192         m_widgetStack2 -> raiseWidget( TextField );
00193 
00194         // Chooser 3
00195         cmbChooserField3 = new QComboBox( false, container );
00196         QWhatsThis::add( cmbChooserField3, tr( "Press to select attribute to change" ) );
00197         cmbChooserField3->setMaximumWidth( 90 );
00198         gl->addWidget( cmbChooserField3, 6, 0 );
00199         // Textfield for chooser 2
00200         // Now use WidgetStack to contain the textfield and the default-email combo!
00201         m_widgetStack3 = new QWidgetStack( container );
00202         txtChooserField3 = new QLineEdit( m_widgetStack3 );
00203         m_widgetStack3 -> addWidget( txtChooserField3, TextField );
00204         gl->addWidget( m_widgetStack3, 6, 1 );
00205         m_widgetStack3 -> raiseWidget( TextField );
00206 
00207         l = new QLabel( tr( "File As" ), container );
00208         QWhatsThis::add( l, tr( "Press to select how to store the name (and howto show it in the listview)" ) );
00209         gl->addWidget( l, 7, 0 );
00210         cmbFileAs = new QComboBox( true, container );
00211         gl->addWidget( cmbFileAs, 7, 1 );
00212 
00213         labCat = new QLabel( tr( "Category" ), container );
00214         gl->addWidget( labCat, 8, 0 );
00215         cmbCat = new CategorySelect( container );
00216         gl->addWidget( cmbCat, 8, 1 );
00217         labCat->show();
00218         cmbCat->show();
00219 
00220         btnNote = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ),
00221                                tr( "Notes..." ), container );
00222         gl->addWidget( btnNote, 9, 1 );
00223 
00224         tabMain->addTab( m_generalWidget, "addressbook/AddressBookSmall", tr( "General" ) );
00225 
00226         QWidget *tabViewport = new QWidget ( tabMain );
00227 
00228         vb = new QVBoxLayout( tabViewport );
00229 
00230         svAddress = new QScrollView( tabViewport );
00231         vb->addWidget( svAddress, 0, 0 );
00232         svAddress->setResizePolicy( QScrollView::AutoOneFit );
00233         svAddress->setFrameStyle( QFrame::NoFrame );
00234 
00235         container = new QWidget( svAddress->viewport() );
00236         svAddress->addChild( container );
00237 
00238         gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem
00239 
00240         cmbAddress = new QComboBox( false, container );
00241         cmbAddress->insertItem( tr( "Business" ) );
00242         cmbAddress->insertItem( tr( "Home" ) );
00243         gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 );
00244 
00245         l = new QLabel( tr( "Address" ), container );
00246         gl->addWidget( l, 1, 0 );
00247         txtAddress = new QLineEdit( container );
00248         gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 );
00249 
00250         l = new QLabel( tr( "City" ), container );
00251         gl->addWidget( l, 2, 0 );
00252         txtCity = new QLineEdit( container );
00253         gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 );
00254 
00255         l = new QLabel( tr( "State" ), container );
00256         gl->addWidget( l, 3, 0 );
00257         txtState = new QLineEdit( container );
00258         gl->addMultiCellWidget( txtState, 3, 3, 1, 2 );
00259 
00260         l = new QLabel( tr( "Zip Code" ), container );
00261         gl->addWidget( l, 4, 0 );
00262         txtZip = new QLineEdit( container );
00263         gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 );
00264 
00265         l = new QLabel( tr( "Country" ), container );
00266         gl->addWidget( l, 5, 0 );
00267         cmbCountry = new QComboBox( true, container );
00268         cmbCountry->insertItem( "" );
00269         cmbCountry->insertItem( tr ( "United States" ) );
00270         cmbCountry->insertItem( tr ( "United Kingdom" ) );
00271         cmbCountry->insertItem( tr ( "Afghanistan" ) );
00272         cmbCountry->insertItem( tr ( "Albania" ) );
00273         cmbCountry->insertItem( tr ( "Algeria" ) );
00274         cmbCountry->insertItem( tr ( "American Samoa" ) );
00275         cmbCountry->insertItem( tr ( "Andorra" ) );
00276         cmbCountry->insertItem( tr ( "Angola" ) );
00277         cmbCountry->insertItem( tr ( "Anguilla" ) );
00278         cmbCountry->insertItem( tr ( "Antarctica" ) );
00279         cmbCountry->insertItem( tr ( "Argentina" ) );
00280         cmbCountry->insertItem( tr ( "Armenia" ) );
00281         cmbCountry->insertItem( tr ( "Aruba" ) );
00282         cmbCountry->insertItem( tr ( "Australia" ) );
00283         cmbCountry->insertItem( tr ( "Austria" ) );
00284         cmbCountry->insertItem( tr ( "Azerbaijan" ) );
00285         cmbCountry->insertItem( tr ( "Bahamas" ) );
00286         cmbCountry->insertItem( tr ( "Bahrain" ) );
00287         cmbCountry->insertItem( tr ( "Bangladesh" ) );
00288         cmbCountry->insertItem( tr ( "Barbados" ) );
00289         cmbCountry->insertItem( tr ( "Belarus" ) );
00290         cmbCountry->insertItem( tr ( "Belgium" ) );
00291         cmbCountry->insertItem( tr ( "Belize" ) );
00292         cmbCountry->insertItem( tr ( "Benin" ) );
00293         cmbCountry->insertItem( tr ( "Bermuda" ) );
00294         cmbCountry->insertItem( tr ( "Bhutan" ) );
00295         cmbCountry->insertItem( tr ( "Bolivia" ) );
00296         cmbCountry->insertItem( tr ( "Botswana" ) );
00297         cmbCountry->insertItem( tr ( "Bouvet Island" ) );
00298         cmbCountry->insertItem( tr ( "Brazil" ) );
00299         cmbCountry->insertItem( tr ( "Brunei Darussalam" ) );
00300         cmbCountry->insertItem( tr ( "Bulgaria" ) );
00301         cmbCountry->insertItem( tr ( "Burkina Faso" ) );
00302         cmbCountry->insertItem( tr ( "Burundi" ) );
00303         cmbCountry->insertItem( tr ( "Cambodia" ) );
00304         cmbCountry->insertItem( tr ( "Cameroon" ) );
00305         cmbCountry->insertItem( tr ( "Canada" ) );
00306         cmbCountry->insertItem( tr ( "Cape Verde" ) );
00307         cmbCountry->insertItem( tr ( "Cayman Islands" ) );
00308         cmbCountry->insertItem( tr ( "Chad" ) );
00309         cmbCountry->insertItem( tr ( "Chile" ) );
00310         cmbCountry->insertItem( tr ( "China" ) );
00311         cmbCountry->insertItem( tr ( "Christmas Island" ) );
00312         cmbCountry->insertItem( tr ( "Colombia" ) );
00313         cmbCountry->insertItem( tr ( "Comoros" ) );
00314         cmbCountry->insertItem( tr ( "Congo" ) );
00315         cmbCountry->insertItem( tr ( "Cook Island" ) );
00316         cmbCountry->insertItem( tr ( "Costa Rica" ) );
00317         cmbCountry->insertItem( tr ( "Cote d'Ivoire" ) );
00318         cmbCountry->insertItem( tr ( "Croatia" ) );
00319         cmbCountry->insertItem( tr ( "Cuba" ) );
00320         cmbCountry->insertItem( tr ( "Cyprus" ) );
00321         cmbCountry->insertItem( tr ( "Czech Republic" ) );
00322         cmbCountry->insertItem( tr ( "Denmark" ) );
00323         cmbCountry->insertItem( tr ( "Djibouti" ) );
00324         cmbCountry->insertItem( tr ( "Dominica" ) );
00325         cmbCountry->insertItem( tr ( "Dominican Republic" ) );
00326         cmbCountry->insertItem( tr ( "East Timor" ) );
00327         cmbCountry->insertItem( tr ( "Ecuador" ) );
00328         cmbCountry->insertItem( tr ( "Egypt" ) );
00329         cmbCountry->insertItem( tr ( "El Salvador" ) );
00330         cmbCountry->insertItem( tr ( "Equatorial Guinea" ) );
00331         cmbCountry->insertItem( tr ( "Eritrea" ) );
00332         cmbCountry->insertItem( tr ( "Estonia" ) );
00333         cmbCountry->insertItem( tr ( "Ethiopia" ) );
00334         cmbCountry->insertItem( tr ( "Falkland Islands" ) );
00335         cmbCountry->insertItem( tr ( "Faroe Islands" ) );
00336         cmbCountry->insertItem( tr ( "Fiji" ) );
00337         cmbCountry->insertItem( tr ( "Finland" ) );
00338         cmbCountry->insertItem( tr ( "France" ) );
00339         cmbCountry->insertItem( tr ( "French Guiana" ) );
00340         cmbCountry->insertItem( tr ( "French Polynesia" ) );
00341         cmbCountry->insertItem( tr ( "Gabon" ) );
00342         cmbCountry->insertItem( tr ( "Gambia" ) );
00343         cmbCountry->insertItem( tr ( "Georgia" ) );
00344         cmbCountry->insertItem( tr ( "Germany" ) );
00345         cmbCountry->insertItem( tr ( "Ghana" ) );
00346         cmbCountry->insertItem( tr ( "Gibraltar" ) );
00347         cmbCountry->insertItem( tr ( "Greece" ) );
00348         cmbCountry->insertItem( tr ( "Greenland" ) );
00349         cmbCountry->insertItem( tr ( "Grenada" ) );
00350         cmbCountry->insertItem( tr ( "Guadeloupe" ) );
00351         cmbCountry->insertItem( tr ( "Guam" ) );
00352         cmbCountry->insertItem( tr ( "Guatemala" ) );
00353         cmbCountry->insertItem( tr ( "Guinea" ) );
00354         cmbCountry->insertItem( tr ( "Guinea-Bissau" ) );
00355         cmbCountry->insertItem( tr ( "Guyana" ) );
00356         cmbCountry->insertItem( tr ( "Haiti" ) );
00357         cmbCountry->insertItem( tr ( "Holy See" ) );
00358         cmbCountry->insertItem( tr ( "Honduras" ) );
00359         cmbCountry->insertItem( tr ( "Hong Kong" ) );
00360         cmbCountry->insertItem( tr ( "Hungary" ) );
00361         cmbCountry->insertItem( tr ( "Iceland" ) );
00362         cmbCountry->insertItem( tr ( "India" ) );
00363         cmbCountry->insertItem( tr ( "Indonesia" ) );
00364         cmbCountry->insertItem( tr ( "Ireland" ) );
00365         cmbCountry->insertItem( tr ( "Israel" ) );
00366         cmbCountry->insertItem( tr ( "Italy" ) );
00367         cmbCountry->insertItem( tr ( "Jamaica" ) );
00368         cmbCountry->insertItem( tr ( "Japan" ) );
00369         cmbCountry->insertItem( tr ( "Jordan" ) );
00370         cmbCountry->insertItem( tr ( "Kazakhstan" ) );
00371         cmbCountry->insertItem( tr ( "Kenya" ) );
00372         cmbCountry->insertItem( tr ( "Kiribati" ) );
00373         cmbCountry->insertItem( tr ( "Korea" ) );
00374         cmbCountry->insertItem( tr ( "Kuwait" ) );
00375         cmbCountry->insertItem( tr ( "Kyrgyzstan" ) );
00376         cmbCountry->insertItem( tr ( "Laos" ) );
00377         cmbCountry->insertItem( tr ( "Latvia" ) );
00378         cmbCountry->insertItem( tr ( "Lebanon" ) );
00379         cmbCountry->insertItem( tr ( "Lesotho" ) );
00380         cmbCountry->insertItem( tr ( "Liberia" ) );
00381         cmbCountry->insertItem( tr ( "Liechtenstein" ) );
00382         cmbCountry->insertItem( tr ( "Lithuania" ) );
00383         cmbCountry->insertItem( tr ( "Luxembourg" ) );
00384         cmbCountry->insertItem( tr ( "Macau" ) );
00385         cmbCountry->insertItem( tr ( "Macedonia" ) );
00386         cmbCountry->insertItem( tr ( "Madagascar" ) );
00387         cmbCountry->insertItem( tr ( "Malawi" ) );
00388         cmbCountry->insertItem( tr ( "Malaysia" ) );
00389         cmbCountry->insertItem( tr ( "Maldives" ) );
00390         cmbCountry->insertItem( tr ( "Mali" ) );
00391         cmbCountry->insertItem( tr ( "Malta" ) );
00392         cmbCountry->insertItem( tr ( "Martinique" ) );
00393         cmbCountry->insertItem( tr ( "Mauritania" ) );
00394         cmbCountry->insertItem( tr ( "Mauritius" ) );
00395         cmbCountry->insertItem( tr ( "Mayotte" ) );
00396         cmbCountry->insertItem( tr ( "Mexico" ) );
00397         cmbCountry->insertItem( tr ( "Micronesia" ) );
00398         cmbCountry->insertItem( tr ( "Moldova" ) );
00399         cmbCountry->insertItem( tr ( "Monaco" ) );
00400         cmbCountry->insertItem( tr ( "Mongolia" ) );
00401         cmbCountry->insertItem( tr ( "Montserrat" ) );
00402         cmbCountry->insertItem( tr ( "Morocco" ) );
00403         cmbCountry->insertItem( tr ( "Mozambique" ) );
00404         cmbCountry->insertItem( tr ( "Myanmar" ) );
00405         cmbCountry->insertItem( tr ( "Namibia" ) );
00406         cmbCountry->insertItem( tr ( "Nauru" ) );
00407         cmbCountry->insertItem( tr ( "Nepal" ) );
00408         cmbCountry->insertItem( tr ( "Netherlands" ) );
00409         cmbCountry->insertItem( tr ( "New Caledonia" ) );
00410         cmbCountry->insertItem( tr ( "New Zealand" ) );
00411         cmbCountry->insertItem( tr ( "Nicaragua" ) );
00412         cmbCountry->insertItem( tr ( "Niger" ) );
00413         cmbCountry->insertItem( tr ( "Nigeria" ) );
00414         cmbCountry->insertItem( tr ( "Niue" ) );
00415         cmbCountry->insertItem( tr ( "Norway" ) );
00416         cmbCountry->insertItem( tr ( "Oman" ) );
00417         cmbCountry->insertItem( tr ( "Pakistan" ) );
00418         cmbCountry->insertItem( tr ( "Palau" ) );
00419         cmbCountry->insertItem( tr ( "Palestinian Sovereign Areas" ) );
00420         cmbCountry->insertItem( tr ( "Panama" ) );
00421         cmbCountry->insertItem( tr ( "Papua New Guinea" ) );
00422         cmbCountry->insertItem( tr ( "Paraguay" ) );
00423         cmbCountry->insertItem( tr ( "Peru" ) );
00424         cmbCountry->insertItem( tr ( "Philippines" ) );
00425         cmbCountry->insertItem( tr ( "Pitcairn Islands" ) );
00426         cmbCountry->insertItem( tr ( "Poland" ) );
00427         cmbCountry->insertItem( tr ( "Portugal" ) );
00428         cmbCountry->insertItem( tr ( "Puerto Rico" ) );
00429         cmbCountry->insertItem( tr ( "Qatar" ) );
00430         cmbCountry->insertItem( tr ( "Reunion" ) );
00431         cmbCountry->insertItem( tr ( "Romania" ) );
00432         cmbCountry->insertItem( tr ( "Russia" ) );
00433         cmbCountry->insertItem( tr ( "Rwanda" ) );
00434         cmbCountry->insertItem( tr ( "Saint Lucia" ) );
00435         cmbCountry->insertItem( tr ( "Samoa" ) );
00436         cmbCountry->insertItem( tr ( "San Marino" ) );
00437         cmbCountry->insertItem( tr ( "Saudi Arabia" ) );
00438         cmbCountry->insertItem( tr ( "Senegal" ) );
00439         cmbCountry->insertItem( tr ( "Seychelles" ) );
00440         cmbCountry->insertItem( tr ( "Sierra Leone" ) );
00441         cmbCountry->insertItem( tr ( "Singapore" ) );
00442         cmbCountry->insertItem( tr ( "Slovakia" ) );
00443         cmbCountry->insertItem( tr ( "Slovenia" ) );
00444         cmbCountry->insertItem( tr ( "Solomon Islands" ) );
00445         cmbCountry->insertItem( tr ( "Somalia" ) );
00446         cmbCountry->insertItem( tr ( "South Africa" ) );
00447         cmbCountry->insertItem( tr ( "Spain" ) );
00448         cmbCountry->insertItem( tr ( "Sri Lanka" ) );
00449         cmbCountry->insertItem( tr ( "St. Helena" ) );
00450         cmbCountry->insertItem( tr ( "Sudan" ) );
00451         cmbCountry->insertItem( tr ( "Suriname" ) );
00452         cmbCountry->insertItem( tr ( "Swaziland" ) );
00453         cmbCountry->insertItem( tr ( "Sweden" ) );
00454         cmbCountry->insertItem( tr ( "Switzerland" ) );
00455         cmbCountry->insertItem( tr ( "Taiwan" ) );
00456         cmbCountry->insertItem( tr ( "Tajikistan" ) );
00457         cmbCountry->insertItem( tr ( "Tanzania" ) );
00458         cmbCountry->insertItem( tr ( "Thailand" ) );
00459         cmbCountry->insertItem( tr ( "Togo" ) );
00460         cmbCountry->insertItem( tr ( "Tokelau" ) );
00461         cmbCountry->insertItem( tr ( "Tonga" ) );
00462         cmbCountry->insertItem( tr ( "Tunisia" ) );
00463         cmbCountry->insertItem( tr ( "Turkey" ) );
00464         cmbCountry->insertItem( tr ( "Turkmenistan" ) );
00465         cmbCountry->insertItem( tr ( "Tuvalu" ) );
00466         cmbCountry->insertItem( tr ( "Uganda" ) );
00467         cmbCountry->insertItem( tr ( "Ukraine" ) );
00468         cmbCountry->insertItem( tr ( "Uruguay" ) );
00469         cmbCountry->insertItem( tr ( "Uzbekistan" ) );
00470         cmbCountry->insertItem( tr ( "Vanuatu" ) );
00471         cmbCountry->insertItem( tr ( "Venezuela" ) );
00472         cmbCountry->insertItem( tr ( "Vietnam" ) );
00473         cmbCountry->insertItem( tr ( "Virgin Islands" ) );
00474         cmbCountry->insertItem( tr ( "Western Sahara" ) );
00475         cmbCountry->insertItem( tr ( "Yemen" ) );
00476         cmbCountry->insertItem( tr ( "Yugoslavia" ) );
00477         cmbCountry->insertItem( tr ( "Zambia" ) );
00478         cmbCountry->insertItem( tr ( "Zimbabwe" ) );
00479         if (cmbCountry->listBox()!=0)
00480           cmbCountry->listBox()->sort();
00481 
00482         cmbCountry->setMaximumWidth( 135 );
00483 
00484         gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 );
00485 
00486         // Chooser 4
00487         cmbChooserField4 = new QComboBox( false, container );
00488         cmbChooserField4->setMaximumWidth( 90 );
00489         gl->addWidget( cmbChooserField4, 6, 0 );
00490         // Textfield for chooser 2
00491         // Now use WidgetStack to contain the textfield and the default-email combo!
00492         m_widgetStack4 = new QWidgetStack( container );
00493         txtChooserField4 = new QLineEdit( m_widgetStack4 );
00494         m_widgetStack4 -> addWidget( txtChooserField4, TextField );
00495         gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 );
00496         m_widgetStack4 -> raiseWidget( TextField );
00497 
00498         QSpacerItem *space = new QSpacerItem(1,1,
00499                                              QSizePolicy::Maximum,
00500                                              QSizePolicy::MinimumExpanding );
00501         gl->addItem( space, 7, 0 );
00502 
00503         tabMain->addTab( tabViewport, "home", tr( "Address" ) );
00504 
00505         tabViewport = new QWidget ( tabMain );
00506 
00507         vb = new QVBoxLayout( tabViewport );
00508 
00509         svDetails = new QScrollView( tabViewport );
00510         vb->addWidget( svDetails, 0, 0 );
00511         svDetails->setResizePolicy( QScrollView::AutoOneFit );
00512         svDetails->setFrameStyle( QFrame::NoFrame );
00513 
00514         container = new QWidget( svDetails->viewport() );
00515         svDetails->addChild( container );
00516 
00517         gl = new QGridLayout( container, 1, 2, 2, 4 );
00518 
00519         int counter = 0;
00520 
00521         // Birthday
00522         QHBox* hBox = new QHBox( container );
00523         l = new QLabel( tr("Birthday"), container );
00524         gl->addWidget( l, counter, 0 );
00525 
00526         QPopupMenu* m1 = new QPopupMenu( container );
00527         birthdayPicker = new DateBookMonth( m1, 0, true );
00528         m1->insertItem( birthdayPicker );
00529 
00530         birthdayButton= new QToolButton( hBox, "buttonStart" );
00531         birthdayButton->setPopup( m1 );
00532         birthdayButton->setPopupDelay(0);
00533 
00534         QPushButton* deleteButton = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ),
00535                                                      tr( "Delete" ),
00536                                                      hBox, 0 );
00537 
00538         gl->addWidget( hBox, counter , 1  );
00539 
00540         connect( birthdayPicker, SIGNAL( dateClicked(int,int,int) ),
00541                  this, SLOT( slotBirthdayDateChanged(int,int,int) ) );
00542         connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
00543 
00544         ++counter;
00545 
00546         // Anniversary
00547         hBox = new QHBox( container );
00548         l = new QLabel( tr("Anniversary"), container );
00549         gl->addWidget( l, counter, 0 );
00550 
00551         m1 = new QPopupMenu( container );
00552         anniversaryPicker = new DateBookMonth( m1, 0, true );
00553         m1->insertItem( anniversaryPicker );
00554 
00555         anniversaryButton= new QToolButton( hBox, "buttonStart" );
00556         anniversaryButton->setPopup( m1 );
00557         anniversaryButton->setPopupDelay(0);
00558 
00559         deleteButton = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ),
00560                                                      tr( "Delete" ),
00561                                                      hBox, 0 );
00562         gl->addWidget( hBox, counter , 1  );
00563 
00564         connect( anniversaryPicker, SIGNAL( dateClicked(int,int,int) ),
00565                  this, SLOT( slotAnniversaryDateChanged(int,int,int) ) );
00566         connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) );
00567 
00568         ++counter;
00569 
00570         // Gender
00571         l = new QLabel( tr("Gender"), container );
00572         gl->addWidget( l, counter, 0 );
00573         cmbGender = new QComboBox( container );
00574         cmbGender->insertItem( "", 0 );
00575         cmbGender->insertItem( tr("Male"), 1);
00576         cmbGender->insertItem( tr("Female"), 2);
00577         gl->addWidget( cmbGender, counter, 1 );
00578 
00579         ++counter;
00580 
00581         // Create Labels and lineedit fields for every dynamic entry
00582         QStringList::ConstIterator it = slDynamicEntries.begin();
00583         QMap<QString, int> mapStrToID = Opie::OPimContactFields::untrFieldsToId();
00584         QMap<int, QString> mapIdToStr = Opie::OPimContactFields::idToTrFields();
00585         for (i = counter; it != slDynamicEntries.end(); i++, ++it ) {
00586 
00587           if (((*it) == "Anniversary") ||
00588               ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
00589 
00590           l = new QLabel( mapIdToStr[mapStrToID[*it]], container );
00591                 listName.append( l );
00592                 gl->addWidget( l, i, 0 );
00593                 QLineEdit *e = new QLineEdit( container );
00594                 listValue.append( e );
00595                 gl->addWidget( e, i, 1);
00596         }
00597         // Fill labels with names..
00598         //      loadFields();
00599 
00600 
00601         tabMain->addTab( tabViewport, "UtilsIcon", tr( "Details" ) );
00602 
00603         dlgNote = new QDialog( this, "Note Dialog", true );
00604         dlgNote->setCaption( tr("Enter Note") );
00605         QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
00606         txtNote = new QMultiLineEdit( dlgNote );
00607         vbNote->addWidget( txtNote );
00608         connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
00609 
00610         dlgName = new QDialog( this, "Name Dialog", true );
00611         dlgName->setCaption( tr("Edit Name") );
00612         gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
00613 
00614         l = new QLabel( tr("First Name"), dlgName );
00615         gl->addWidget( l, 0, 0 );
00616         txtFirstName = new ABOOK::NameLineEdit( dlgName );
00617         gl->addWidget( txtFirstName, 0, 1 );
00618 
00619         l = new QLabel( tr("Middle Name"), dlgName );
00620         gl->addWidget( l, 1, 0 );
00621         txtMiddleName = new ABOOK::NameLineEdit( dlgName );
00622         gl->addWidget( txtMiddleName, 1, 1 );
00623 
00624         l = new QLabel( tr("Last Name"), dlgName );
00625         gl->addWidget( l, 2, 0 );
00626         txtLastName = new ABOOK::NameLineEdit( dlgName );
00627         gl->addWidget( txtLastName, 2, 1 );
00628 
00629 //      l = new QLabel( tr("Suffix"), dlgName );
00630 //      gl->addWidget( l, 3, 0 );
00631 //      txtSuffix = new QLineEdit( dlgName );
00632 //      gl->addWidget( txtSuffix, 3, 1 );
00633         space = new QSpacerItem(1,1,
00634                                 QSizePolicy::Maximum,
00635                                 QSizePolicy::MinimumExpanding );
00636         gl->addItem( space, 4,  0 );
00637 
00638         cmbChooserField1->insertStringList( trlChooserNames );
00639         cmbChooserField2->insertStringList( trlChooserNames );
00640         cmbChooserField3->insertStringList( trlChooserNames );
00641         cmbChooserField4->insertStringList( trlChooserNames );
00642 
00643         cmbChooserField1->setCurrentItem( 0 );
00644         cmbChooserField2->setCurrentItem( 1 );
00645         cmbChooserField3->setCurrentItem( 2 );
00646 
00647         connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
00648 
00649         connect( txtFullName, SIGNAL(textChanged(const QString&)),
00650                  this, SLOT(slotFullNameChange(const QString&)) );
00651         connect( txtSuffix, SIGNAL(textChanged(const QString&)),
00652                  this, SLOT(slotSuffixChange(const QString&)) );
00653         connect( txtOrganization, SIGNAL(textChanged(const QString&)),
00654                  this, SLOT(slotOrganizationChange(const QString&)) );
00655         connect( txtChooserField1, SIGNAL(textChanged(const QString&)),
00656                  this, SLOT(slotChooser1Change(const QString&)) );
00657         connect( txtChooserField2, SIGNAL(textChanged(const QString&)),
00658                  this, SLOT(slotChooser2Change(const QString&)) );
00659         connect( txtChooserField3, SIGNAL(textChanged(const QString&)),
00660                  this, SLOT(slotChooser3Change(const QString&)) );
00661         connect( txtChooserField4, SIGNAL(textChanged(const QString&)),
00662                  this, SLOT(slotChooser4Change(const QString&)) );
00663         connect( txtAddress, SIGNAL(textChanged(const QString&)),
00664                  this, SLOT(slotAddressChange(const QString&)) );
00665         connect( txtCity, SIGNAL(textChanged(const QString&)),
00666                  this, SLOT(slotCityChange(const QString&)) );
00667         connect( txtState, SIGNAL(textChanged(const QString&)),
00668                  this, SLOT(slotStateChange(const QString&)) );
00669         connect( txtZip, SIGNAL(textChanged(const QString&)),
00670                  this, SLOT(slotZipChange(const QString&)) );
00671         connect( cmbCountry, SIGNAL(textChanged(const QString&)),
00672                  this, SLOT(slotCountryChange(const QString&)) );
00673         connect( cmbCountry, SIGNAL(activated(const QString&)),
00674                  this, SLOT(slotCountryChange(const QString&)) );
00675         connect( cmbChooserField1, SIGNAL(activated(int)),
00676                  this, SLOT(slotCmbChooser1Change(int)) );
00677         connect( cmbChooserField2, SIGNAL(activated(int)),
00678                  this, SLOT(slotCmbChooser2Change(int)) );
00679         connect( cmbChooserField3, SIGNAL(activated(int)),
00680                  this, SLOT(slotCmbChooser3Change(int)) );
00681         connect( cmbChooserField4, SIGNAL(activated(int)),
00682                  this, SLOT(slotCmbChooser4Change(int)) );
00683         connect( cmbAddress, SIGNAL(activated(int)),
00684                  this, SLOT(slotAddressTypeChange(int)) );
00685 
00686         new QPEDialogListener(this);
00687 
00688         setPersonalView ( m_personalView );
00689 
00690         odebug << "init() END" << oendl;
00691 }
00692 
00693 void ContactEditor::defaultEmailChanged(int i){
00694         odebug << "defaultEmailChanged" << oendl;
00695 
00696         // was sollte das ? (se)
00697 //      int index = cmbChooserField1->currentItem();
00698 //      slChooserValues[index] = cmbDefaultEmail->text(i);
00699 
00700         defaultEmail = cmbDefaultEmail->text(i);
00701         odebug << "Changed to: " << defaultEmail << oendl;
00702 
00703 }
00704 
00705 void ContactEditor::populateDefaultEmailCmb(){
00706 
00707         // if the default-email combo was not selected and therfore not created
00708         // we get a lot of trouble.. Therfore create an invisible one..
00709         if ( !cmbDefaultEmail ){
00710                 cmbDefaultEmail = new QComboBox(this);
00711                 cmbDefaultEmail -> hide();
00712         }
00713         cmbDefaultEmail->clear();
00714         cmbDefaultEmail->insertStringList( emails );
00715         // cmbDefaultEmail->show();
00716 
00717         // Select default email in combo..
00718         bool found = false;
00719         for ( int i = 0; i < cmbDefaultEmail->count(); i++){
00720                 odebug << " populateDefaultEmailCmb text >" << cmbDefaultEmail->text( i )
00721                                                         << "< defaultEmail >" << defaultEmail << "<" << oendl;
00722 
00723                 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
00724                         cmbDefaultEmail->setCurrentItem( i );
00725                         odebug << "set" << oendl;
00726                         found = true;
00727                 }
00728         }
00729 
00730         // If the current default email is not found in the list, we choose the
00731         // first one..
00732         if ( !found )
00733                 defaultEmail = cmbDefaultEmail->text(0);
00734 }
00735 
00736 // Called when any combobox was changed.
00737 // "true" returned if the change was chandled by this function, else it should
00738 // be handled by something else..
00739 bool ContactEditor::cmbChooserChange( int index, QWidgetStack* inputStack, int widgetPos ) {
00740         QString type = slChooserNames[index];
00741         odebug << "ContactEditor::cmbChooserChange -> Type: " << type
00742                                                 << ", WidgetPos: " << widgetPos << oendl;
00743 
00744         if ( !initializing )
00745                 contactfields.setFieldOrder( widgetPos-1, index );
00746 
00747         // Create and connect combobox for selecting the default email
00748         if ( type == "Default Email"){
00749                 odebug << "Choosing default-email (defaultEmailChooserPosition= "
00750                                                         << defaultEmailChooserPosition << ") " << oendl;
00751 
00752                 // More than one default-email chooser is not allowed !
00753                 if ( ( defaultEmailChooserPosition != -1 ) &&
00754                      defaultEmailChooserPosition != widgetPos && !initializing){
00755                         chooserError( widgetPos );
00756                         return true;
00757                 }
00758 
00759                 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
00760                 if ( cmbo ){
00761                         inputStack->raiseWidget( TextField );
00762                         inputStack -> removeWidget( cmbo );
00763                         delete cmbo;
00764                 }
00765                 cmbo = new QComboBox( inputStack );
00766                 cmbo -> insertStringList( emails );
00767 
00768                 inputStack -> addWidget( cmbo, Combo );
00769                 inputStack -> raiseWidget( Combo );
00770 
00771                 defaultEmailChooserPosition = widgetPos;
00772                 cmbDefaultEmail = cmbo;
00773 
00774                 connect( cmbo,SIGNAL( activated(int) ),
00775                          SLOT( defaultEmailChanged(int) ) );
00776 
00777                 // Set current default email
00778                 populateDefaultEmailCmb();
00779 
00780 
00781         } else {
00782                 // Something else was selected: Hide combo..
00783                 odebug << " Hiding default-email combo" << oendl;
00784                 if ( defaultEmailChooserPosition == widgetPos ){
00785                         defaultEmailChooserPosition = -1;
00786                 }
00787                 QComboBox* cmbo = ( QComboBox* ) inputStack -> widget( Combo );
00788                 if ( cmbo ){
00789                         inputStack->raiseWidget( TextField );
00790                         inputStack -> removeWidget( cmbo );
00791                         cmbDefaultEmail = 0l;
00792                         delete cmbo;
00793                 }
00794 
00795                 // Caller should initialize the responsible textfield, therefore
00796                 // "false" is returned
00797                 return false;
00798         }
00799 
00800         // Everything is worked off ..
00801         return true;
00802 
00803 }
00804 
00805 // Currently accessed when we select default-email more than once !
00806 void ContactEditor::chooserError( int index )
00807 {
00808         owarn << "ContactEditor::chooserError( " << index << " )" << oendl;
00809         QMessageBox::warning( this, "Chooser Error",
00810                               "Multiple selection of this\n"
00811                               "Item is not allowed !\n\n"
00812                               "First deselect the previous one !",
00813                               "&OK", 0, 0,
00814                               0, 0 );
00815 
00816         // Reset the selected Chooser. Unfortunately the chooser
00817         // generates no signal, therfore we have to
00818         // call the cmbChooserChange function manually..
00819         switch( index ){
00820         case 1:
00821                 cmbChooserField1 -> setCurrentItem( 0 );
00822                 slotCmbChooser1Change( 0 );
00823                 break;
00824         case 2:
00825                 cmbChooserField2 -> setCurrentItem( 0 );
00826                 slotCmbChooser2Change( 0 );
00827                 break;
00828         case 3:
00829                 cmbChooserField3 -> setCurrentItem( 0 );
00830                 slotCmbChooser3Change( 0 );
00831                 break;
00832         case 4:
00833                 cmbChooserField4 -> setCurrentItem( 0 );
00834                 slotCmbChooser4Change( 0 );
00835                 break;
00836         }
00837 }
00838 
00839 // Called when something was changed in a textfield (shouldn't it called textchanged? (se))
00840 void ContactEditor::chooserChange( const QString &textChanged, int index,
00841                                    QLineEdit* , int widgetPos ) {
00842 
00843         QString type = slChooserNames[index]; // :SX
00844         odebug << "ContactEditor::chooserChange( type=>" << type << "<, textChanged=>"
00845                                                 << textChanged << "< index=" << index << ", widgetPos=" << widgetPos
00846                                                 << " )" << oendl;
00847 
00848         if ( type == "Default Email"){
00849                 odebug << "??? Wozu??: " << textChanged << oendl;
00850                 defaultEmail = textChanged;
00851 
00852                 populateDefaultEmailCmb();
00853 
00854         }else if (type == "Emails"){
00855                 odebug << "emails" << oendl;
00856 
00857                 QString de;
00858                 emails = QStringList::split (",", textChanged );
00859 
00860                 populateDefaultEmailCmb();
00861         }
00862 
00863         slChooserValues[index] = textChanged;
00864 
00865 }
00866 
00867 void ContactEditor::slotChooser1Change( const QString &textChanged ) {
00868         odebug << "ContactEditor::slotChooser1Change( " << textChanged << " )" << oendl;
00869         chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
00870 }
00871 
00872 void ContactEditor::slotChooser2Change( const QString &textChanged ) {
00873         odebug << "ContactEditor::slotChooser2Change( " << textChanged << " )" << oendl;
00874         chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
00875 
00876 }
00877 
00878 void ContactEditor::slotChooser3Change( const QString &textChanged ) {
00879         odebug << "ContactEditor::slotChooser3Change( " << textChanged << " )" << oendl;
00880         chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
00881 }
00882 
00883 void ContactEditor::slotChooser4Change( const QString &textChanged ) {
00884         odebug << "ContactEditor::slotChooser4Change( " << textChanged << " )" << oendl;
00885         chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4);
00886 }
00887 
00888 void ContactEditor::slotAddressChange( const QString &textChanged ) {
00889 
00890         if ( cmbAddress->currentItem() == 0 ) {
00891                 slBusinessAddress[0] = textChanged;
00892         } else {
00893                 slHomeAddress[0] = textChanged;
00894         }
00895 }
00896 
00897 void ContactEditor::slotAddress2Change( const QString &textChanged ) {
00898 
00899         if ( cmbAddress->currentItem() == 0 ) {
00900                 slBusinessAddress[1] = textChanged;
00901         } else {
00902                 slHomeAddress[1] = textChanged;
00903         }
00904 }
00905 
00906 void ContactEditor::slotPOBoxChange( const QString &textChanged ) {
00907 
00908         if ( cmbAddress->currentItem() == 0 ) {
00909                 slBusinessAddress[2] = textChanged;
00910         } else {
00911                 slHomeAddress[2] = textChanged;
00912         }
00913 }
00914 
00915 void ContactEditor::slotCityChange( const QString &textChanged ) {
00916 
00917         if ( cmbAddress->currentItem() == 0 ) {
00918                 slBusinessAddress[3] = textChanged;
00919         } else {
00920                 slHomeAddress[3] = textChanged;
00921         }
00922 }
00923 
00924 void ContactEditor::slotStateChange( const QString &textChanged ) {
00925 
00926 
00927         if ( cmbAddress->currentItem() == 0 ) {
00928                 slBusinessAddress[4] = textChanged;
00929         } else {
00930                 slHomeAddress[4] = textChanged;
00931         }
00932 }
00933 
00934 void ContactEditor::slotZipChange( const QString &textChanged ) {
00935 
00936         if ( cmbAddress->currentItem() == 0 ) {
00937                 slBusinessAddress[5] = textChanged;
00938         } else {
00939                 slHomeAddress[5] = textChanged;
00940         }
00941 }
00942 
00943 void ContactEditor::slotCountryChange( const QString &textChanged ) {
00944 
00945         if ( cmbAddress->currentItem() == 0 ) {
00946                 slBusinessAddress[6] = textChanged;
00947         } else {
00948                 slHomeAddress[6] = textChanged;
00949         }
00950 }
00951 
00952 
00953 void ContactEditor::slotCmbChooser1Change( int index ) {
00954         odebug << "ContactEditor::slotCmbChooser1Change( " << index << " )" << oendl;
00955         if ( !cmbChooserChange( cmbChooserField1->currentItem(), m_widgetStack1, 1) ){
00956 
00957                 txtChooserField1->setText( slChooserValues[index] );
00958                 txtChooserField1->setFocus();
00959 
00960         }
00961 
00962 }
00963 
00964 void ContactEditor::slotCmbChooser2Change( int index ) {
00965         odebug << "ContactEditor::slotCmbChooser2Change( " << index << " )" << oendl;
00966 
00967         if ( !cmbChooserChange( cmbChooserField2->currentItem(), m_widgetStack2, 2) ){
00968 
00969                 txtChooserField2->setText( slChooserValues[index] );
00970                 txtChooserField2->setFocus();
00971 
00972         }
00973 }
00974 
00975 void ContactEditor::slotCmbChooser3Change( int index ) {
00976         odebug << "ContactEditor::slotCmbChooser3Change( " << index << " )" << oendl;
00977 
00978         if ( !cmbChooserChange( cmbChooserField3->currentItem(), m_widgetStack3, 3) ){
00979 
00980                 txtChooserField3->setText( slChooserValues[index] );
00981                 txtChooserField3->setFocus();
00982 
00983         }
00984 }
00985 
00986 void ContactEditor::slotCmbChooser4Change( int index ) {
00987         odebug << "ContactEditor::slotCmbChooser4Change( " << index << " )" << oendl;
00988 
00989         if ( !cmbChooserChange( cmbChooserField4->currentItem(), m_widgetStack4, 4) ){
00990 
00991                 txtChooserField4->setText( slChooserValues[index] );
00992                 txtChooserField4->setFocus();
00993 
00994         }
00995 }
00996 
00997 void ContactEditor::slotAddressTypeChange( int index ) {
00998 
00999 
01000         if ( !initializing )
01001                 contactfields.setFieldOrder( 4, index );
01002 
01003 
01004         if ( index == 0 ) {
01005 
01006                 txtAddress->setText( slBusinessAddress[0] );
01007                 //txtAddress2->setText( (*slBusinessAddress)[1] );
01008                 //txtPOBox->setText( (*slBusinessAddress)[2] );
01009                 txtCity->setText( slBusinessAddress[3] );
01010                 txtState->setText( slBusinessAddress[4] );
01011                 txtZip->setText( slBusinessAddress[5] );
01012                 QLineEdit *txtTmp = cmbCountry->lineEdit();
01013                 txtTmp->setText( slBusinessAddress[6] );
01014 
01015         } else {
01016 
01017                 txtAddress->setText( slHomeAddress[0] );
01018                 //txtAddress2->setText( (*slHomeAddress)[1] );
01019                 //txtPOBox->setText( (*slHomeAddress)[2] );
01020                 txtCity->setText( slHomeAddress[3] );
01021                 txtState->setText( slHomeAddress[4] );
01022                 txtZip->setText( slHomeAddress[5] );
01023                 QLineEdit *txtTmp = cmbCountry->lineEdit();
01024                 txtTmp->setText( slHomeAddress[6] );
01025 
01026         }
01027 
01028 }
01029 
01030 void ContactEditor::slotFullNameChange( const QString &textChanged ) {
01031 
01032         odebug << "ContactEditor::slotFullNameChange( " << textChanged << " )" << oendl;
01033 
01034         int index = cmbFileAs->currentItem();
01035 
01036         cmbFileAs->clear();
01037 
01038         cmbFileAs->insertItem( parseName( textChanged, NAME_LF ) );
01039         cmbFileAs->insertItem( parseName( textChanged, NAME_LFM ) );
01040         cmbFileAs->insertItem( parseName( textChanged, NAME_FL ) );
01041         cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) );
01042         if ( ! txtSuffix->text().isEmpty() )
01043                 cmbFileAs->insertItem( parseName( textChanged, NAME_FML ) + " " + txtSuffix->text() );
01044 
01045         cmbFileAs->setCurrentItem( index );
01046 
01047 
01048 }
01049 
01050 void ContactEditor::slotSuffixChange( const QString& ) {
01051         // Just want to update the FileAs combo if the suffix was changed..
01052         slotFullNameChange( txtFullName->text() );
01053 }
01054 
01055 void ContactEditor::slotOrganizationChange( const QString &textChanged ){
01056         odebug << "ContactEditor::slotOrganizationChange( " << textChanged << " )" << oendl;
01057         // Special handling for storing Companies:
01058         // If no Fullname is given, we store the Company-Name as lastname
01059         // to handle it like a person..
01060         if ( txtFullName->text() == txtOrganization->text().left( txtFullName->text().length() ) )
01061                 txtFullName->setText( textChanged );
01062 
01063 }
01064 
01065 void ContactEditor::accept() {
01066 
01067         if ( isEmpty() ) {
01068                 cleanupFields();
01069                 reject();
01070         } else {
01071                 saveEntry();
01072                 cleanupFields();
01073                 QDialog::accept();
01074         }
01075 
01076 }
01077 
01078 void ContactEditor::slotNote() {
01079 
01080     if ( ! QPEApplication::execDialog( dlgNote ) ) {
01081                 txtNote->setText( ent.notes() );
01082         }
01083 }
01084 
01085 void ContactEditor::slotName() {
01086 
01087         QString tmpName;
01088 
01089         txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
01090         txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
01091         txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
01092         // txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
01093 
01094         if ( QPEApplication::execDialog( dlgName ) ) {
01095                  if ( txtLastName->text().contains( ' ', true ) )
01096                          tmpName =  txtLastName->text() + ", " + txtFirstName->text() + " " + txtMiddleName->text();
01097                  else
01098                          tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text();
01099 
01100                 txtFullName->setText( tmpName.simplifyWhiteSpace() );
01101                 slotFullNameChange( txtFullName->text() );
01102         }
01103 
01104 }
01105 
01106 void ContactEditor::setNameFocus() {
01107 
01108         txtFullName->setFocus();
01109 
01110 }
01111 
01112 bool ContactEditor::isEmpty() {
01113         // Test and see if the record should be saved.
01114         // More strict than the original qtopia, needs name or fileas to save
01115 
01116         QString t = txtFullName->text();
01117         if ( !t.isEmpty() && containsAlphaNum( t ) )
01118                 return false;
01119 
01120         t = cmbFileAs->currentText();
01121         if ( !t.isEmpty() && containsAlphaNum( t ) )
01122                 return false;
01123 
01124         return true;
01125 
01126 }
01127 
01128 QString ContactEditor::parseName( const QString fullName, int type ) {
01129 
01130         QString simplifiedName( fullName.simplifyWhiteSpace() );
01131         QString strFirstName;
01132         QString strMiddleName;
01133         QString strLastName;
01134         QString strTitle;
01135         int commapos;
01136         bool haveLastName = false;
01137 
01138         odebug << "Fullname: " << simplifiedName << oendl;
01139 
01140         commapos = simplifiedName.find( ',', 0, true);
01141         if ( commapos >= 0 ) {
01142                 odebug << " Commapos: " << commapos << oendl;
01143 
01144                 // A comma (",") separates the lastname from one or
01145                 // many first names. Thus, remove the lastname from the
01146                 // String and parse the firstnames.
01147 
01148                 strLastName = simplifiedName.left( commapos );
01149                 simplifiedName= simplifiedName.mid( commapos + 1 );
01150                 haveLastName = true;
01151                 odebug << "Fullname without ',': " << simplifiedName << oendl;
01152 
01153                 // If we have any lastname, we should now split all first names.
01154                 // The first one will be the used as first, the rest as "middle names"
01155 
01156                 QStringList allFirstNames = QStringList::split(" ", simplifiedName);
01157                 QStringList::Iterator it = allFirstNames.begin();
01158                 strFirstName = *it++;
01159                 QStringList allSecondNames;
01160                 for ( ; it != allFirstNames.end(); ++it )
01161                         allSecondNames.append( *it );
01162 
01163                 strMiddleName = allSecondNames.join(" ");
01164 
01165         } else {
01166 
01167                 // No comma separator used: We use the first word as firstname, the
01168                 // last as second/lastname and everything in the middle as middlename
01169 
01170                 QStringList allNames = QStringList::split(" ", simplifiedName);
01171                 QStringList::Iterator it = allNames.begin();
01172                 strFirstName = *it++;
01173                 QStringList allSecondNames;
01174                 for ( ; it != --allNames.end(); ++it )
01175                         allSecondNames.append( *it );
01176 
01177                 strMiddleName = allSecondNames.join(" ");
01178                 strLastName = *(--allNames.end());
01179 
01180         }
01181 
01182         if ( strFirstName == strLastName )
01183                 strFirstName = "";
01184 
01185         odebug << "strFirstName: " << strFirstName << oendl;
01186         odebug << "strMiddletName: " << strMiddleName << oendl;
01187         odebug << "strLastName: " << strLastName << oendl;
01188         odebug << "strTitle: " << strTitle << oendl;
01189 
01190         switch (type) {
01191         case NAME_FL:
01192                 return strFirstName + " " + strLastName;
01193 
01194         case NAME_LF:
01195                 return strLastName + ", " + strFirstName;
01196 
01197         case NAME_LFM:
01198                 return strLastName + ", " + strFirstName + " " + strMiddleName;
01199 
01200         case NAME_FML:
01201                 return strFirstName + " " + strMiddleName + " " + strLastName ;
01202 
01203         case NAME_F:
01204                 return strFirstName;
01205 
01206         case NAME_M:
01207                 return strMiddleName;
01208 
01209         case NAME_L:
01210                 return strLastName;
01211 
01212         case NAME_S:
01213                 return txtSuffix->text();
01214 
01215         }
01216         return QString::null;
01217 }
01218 
01219 void ContactEditor::cleanupFields() {
01220         QStringList::Iterator it = slChooserValues.begin();
01221 
01222         for ( int i = 0; it != slChooserValues.end(); i++, ++it ) {
01223                 (*it) = "";
01224         }
01225 
01226         for ( int i = 0; i < 7; i++ ) {
01227                 slHomeAddress[i] = "";
01228                 slBusinessAddress[i] = "";
01229         }
01230 
01231         QListIterator<QLineEdit> itLV( listValue );
01232         for ( ; itLV.current(); ++itLV ) {
01233                 (*itLV)->setText( "" );
01234         }
01235 
01236         txtFirstName->setText("");
01237         txtMiddleName->setText("");
01238         txtLastName->setText("");
01239         txtSuffix->setText("");
01240         txtNote->setText("");
01241         txtFullName->setText("");
01242         txtJobTitle->setText("");
01243         txtOrganization->setText("");
01244         txtChooserField1->setText("");
01245         txtChooserField2->setText("");
01246         txtChooserField3->setText("");
01247         txtAddress->setText("");
01248         txtCity->setText("");
01249         txtState->setText("");
01250         txtZip->setText("");
01251         QLineEdit *txtTmp = cmbCountry->lineEdit();
01252         txtTmp->setText("");
01253         txtTmp = cmbFileAs->lineEdit();
01254         txtTmp->setText("");
01255 
01256 }
01257 
01258 void ContactEditor::setEntry( const Opie::OPimContact &entry ) {
01259 
01260         initializing = true;
01261 
01262         // Cleanup and activate the general Page ..
01263         cleanupFields();
01264         tabMain->setCurrentTab( m_generalWidget );
01265 
01266         ent = entry;
01267 
01268         emails = QStringList(ent.emailList());
01269         defaultEmail = ent.defaultEmail();
01270         if (defaultEmail.isEmpty()) defaultEmail = emails[0];
01271         odebug << "default email=" << defaultEmail << oendl;
01272 
01273         txtFirstName->setText( ent.firstName() );
01274         txtMiddleName->setText( ent.middleName() );
01275         txtLastName->setText( ent.lastName() );
01276         txtSuffix->setText( ent.suffix() );
01277 
01278 //      QString *tmpString = new QString;
01279 //      *tmpString = ent.firstName() + " " + ent.middleName() +
01280 //              + " " + ent.lastName() + " " + ent.suffix();
01281 //      txtFullName->setText( tmpString->simplifyWhiteSpace() );
01282 
01283         if ( !ent.isEmpty() ){
01284                 // Lastnames with multiple words need to be protected by a comma !
01285                 if ( ent.lastName().contains( ' ', true ) )
01286                         txtFullName->setText( ent.lastName() + ", " + ent.firstName() + " " + ent.middleName() );
01287                 else
01288                         txtFullName->setText( ent.firstName() + " " + ent.middleName() + " " + ent.lastName() );
01289         }
01290 
01291         cmbFileAs->setEditText( ent.fileAs() );
01292 
01293         //      if (hasTitle)
01294         txtJobTitle->setText( ent.jobTitle() );
01295 
01296         //      if (hasCompany)
01297         txtOrganization->setText( ent.company() );
01298 
01299         //      if (hasNotes)
01300         txtNote->setText( ent.notes() );
01301 
01302         //      if (hasStreet) {
01303         slHomeAddress[0] = ent.homeStreet();
01304         slBusinessAddress[0] = ent.businessStreet();
01305         //      }
01306 
01307         //      if (hasCity) {
01308         slHomeAddress[3] = ent.homeCity();
01309         slBusinessAddress[3] = ent.businessCity();
01310         //}
01311 
01312         //if (hasState) {
01313         slHomeAddress[4] = ent.homeState();
01314         slBusinessAddress[4] = ent.businessState();
01315         //}
01316 
01317         //if (hasZip) {
01318         slHomeAddress[5] = ent.homeZip();
01319         slBusinessAddress[5] = ent.businessZip();
01320         //}
01321 
01322         //if (hasCountry) {
01323         slHomeAddress[6] = ent.homeCountry();
01324         slBusinessAddress[6] = ent.businessCountry();
01325         //}
01326 
01327         QStringList::ConstIterator it;
01328         QListIterator<QLineEdit> itLE( listValue );
01329         for ( it = slDynamicEntries.begin(); itLE.current()/* != slDynamicEntries.end()*/; ++it, ++itLE) {
01330 
01331                 odebug << " Filling dynamic Field: " << (*it) << oendl;
01332 
01333                 if ( *it ==  "Department"  )
01334                         (*itLE)->setText( ent.department() );
01335 
01336                 if ( *it == "Company" )
01337                         (*itLE)->setText( ent.company() );
01338 
01339                 if ( *it ==  "Office" )
01340                         (*itLE)->setText( ent.office() );
01341 
01342                 if ( *it ==  "Profession" )
01343                         (*itLE)->setText( ent.profession() );
01344 
01345                 if ( *it == "Assistant" )
01346                         (*itLE)->setText( ent.assistant() );
01347 
01348                 if ( *it == "Manager" )
01349                         (*itLE)->setText( ent.manager() );
01350 
01351                 if ( *it == "Spouse" )
01352                         (*itLE)->setText( ent.spouse() );
01353 
01354                 if ( *it == "Nickname" ){
01355                         odebug << "**** Nichname: " << ent.nickname() << oendl;
01356                         (*itLE)->setText( ent.nickname() );
01357                 }
01358 
01359                 if ( *it == "Children" )
01360                         (*itLE)->setText( ent.children() );
01361 
01362         }
01363 
01364         QStringList::Iterator itV;
01365         for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
01366 
01367                 if ( ( *it == "Business Phone") || ( *it == "Work Phone" ) )
01368                         *itV = ent.businessPhone();
01369                 /*
01370                   if ( *it == "Business 2 Phone" )
01371                   *itV = ent.business2Phone();
01372                   */
01373                 if ( ( *it == "Business Fax") || ( *it == "Work Fax" ) )
01374                         *itV = ent.businessFax();
01375 
01376                 if ( ( *it == "Business Mobile" ) || ( *it == "work Mobile" ) )
01377                         *itV = ent.businessMobile();
01378                 /*
01379                   if ( *it == "Company Phone" )
01380                   *itV = ent.companyPhone();
01381                   */
01382                 if ( *it == "Default Email" )
01383                         *itV = ent.defaultEmail();
01384 
01385                 if ( *it == "Emails" )
01386                         *itV = ent.emailList().join(", ");  // :SX
01387 
01388                 if ( *it == "Home Phone" )
01389                         *itV = ent.homePhone();
01390                 /*
01391                   if ( *it == "Home 2 Phone" )
01392                   *itV = ent.home2Phone();
01393                   */
01394                 if ( *it == "Home Fax" )
01395                         *itV = ent.homeFax();
01396 
01397                 if ( *it == "Home Mobile" )
01398                         *itV = ent.homeMobile();
01399                 /*
01400                   if ( *it == "Car Phone" )
01401                   *itV = ent.carPhone();
01402 
01403                   if ( *it == "ISDN Phone" )
01404                   *itV = ent.ISDNPhone();
01405 
01406                   if ( *it == "Other Phone" )
01407                   *itV = ent.otherPhone();
01408                   */
01409                 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
01410                         *itV = ent.businessPager();
01411                 /*
01412                   if ( *it == "Home Pager")
01413                   *itV = ent.homePager();
01414 
01415                   if ( *it == "AIM IM" )
01416                   *itV = ent.AIMIM();
01417 
01418                   if ( *it == "ICQ IM" )
01419                   *itV = ent.ICQIM();
01420 
01421                   if ( *it == "Jabber IM" )
01422                   *itV = ent.jabberIM();
01423 
01424                   if ( *it == "MSN IM" )
01425                   *itV = ent.MSNIM();
01426 
01427                   if ( *it == "Yahoo IM" )
01428                   *itV = ent.yahooIM();
01429                   */
01430                 if ( *it == "Home Web Page" )
01431                         *itV = ent.homeWebpage();
01432 
01433                 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
01434                         *itV = ent.businessWebpage();
01435 
01436 
01437         }
01438 
01439 
01440         cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
01441 
01442         QString gender = ent.gender();
01443         cmbGender->setCurrentItem( gender.toInt() );
01444 
01445         txtNote->setText( ent.notes() );
01446 
01447         slotAddressTypeChange( cmbAddress->currentItem() );
01448 
01449         // Get combo-settings from contact and set preset..
01450         contactfields.loadFromRecord( ent );
01451         cmbChooserField1->setCurrentItem( contactfields.getFieldOrder(0, 7) );
01452         cmbChooserField2->setCurrentItem( contactfields.getFieldOrder(1, 9) );
01453         cmbChooserField3->setCurrentItem( contactfields.getFieldOrder(2, 0) );
01454         cmbChooserField4->setCurrentItem( contactfields.getFieldOrder(3, 6) );
01455         cmbAddress->setCurrentItem( contactfields.getFieldOrder(4, 1) );
01456         slotCmbChooser1Change( cmbChooserField1->currentItem() );
01457         slotCmbChooser2Change( cmbChooserField2->currentItem() );
01458         slotCmbChooser3Change( cmbChooserField3->currentItem() );
01459         slotCmbChooser4Change( cmbChooserField4->currentItem() );
01460         slotAddressTypeChange( cmbAddress->currentItem() );
01461 
01462         updateDatePicker();
01463 
01464         initializing = false;
01465 }
01466 void ContactEditor::updateDatePicker()
01467 {
01468         // Set DatePicker
01469         if ( !ent.birthday().isNull() ){
01470                 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) );
01471                 birthdayPicker->setDate( ent.birthday() );
01472         } else
01473                 birthdayButton->setText( tr ("Unknown") );
01474 
01475         if ( !ent.anniversary().isNull() ){
01476                 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) );
01477                 anniversaryPicker->setDate( ent.anniversary() );
01478         } else
01479                 anniversaryButton->setText( tr ("Unknown") );
01480 
01481 }
01482 
01483 void ContactEditor::saveEntry() {
01484 
01485         // Store current combo into contact
01486         contactfields.saveToRecord( ent );
01487 
01488         txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) );
01489         txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) );
01490         txtLastName->setText( parseName( txtFullName->text(), NAME_L ) );
01491         // txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) );
01492 
01493         ent.setFirstName( txtFirstName->text() );
01494         ent.setLastName( txtLastName->text() );
01495         ent.setMiddleName( txtMiddleName->text() );
01496         ent.setSuffix( txtSuffix->text() );
01497 
01498         ent.setFileAs( cmbFileAs->currentText() );
01499 
01500         ent.setCategories( cmbCat->currentCategories() );
01501 
01502 
01503         //if (hasTitle)
01504         ent.setJobTitle( txtJobTitle->text() );
01505 
01506         //if (hasCompany)
01507         ent.setCompany( txtOrganization->text() );
01508 
01509         //      if (hasNotes)
01510         ent.setNotes( txtNote->text() );
01511 
01512         //if (hasStreet) {
01513         ent.setHomeStreet( slHomeAddress[0] );
01514         ent.setBusinessStreet( slBusinessAddress[0] );
01515         //      }
01516 
01517         //      if (hasCity) {
01518         ent.setHomeCity( slHomeAddress[3] );
01519         ent.setBusinessCity( slBusinessAddress[3] );
01520         //      }
01521 
01522         //      if (hasState) {
01523         ent.setHomeState( slHomeAddress[4] );
01524         ent.setBusinessState( slBusinessAddress[4] );
01525         //      }
01526 
01527         //      if (hasZip) {
01528         ent.setHomeZip( slHomeAddress[5] );
01529         ent.setBusinessZip( slBusinessAddress[5] );
01530         //      }
01531 
01532         //      if (hasCountry) {
01533         ent.setHomeCountry( slHomeAddress[6] );
01534         ent.setBusinessCountry( slBusinessAddress[6] );
01535         //      }
01536 
01537         QStringList::ConstIterator it;
01538         QListIterator<QLineEdit> itLE( listValue );
01539         for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) {
01540 
01541                 if ( *it == "Department" )
01542                         ent.setDepartment( (*itLE)->text() );
01543 
01544                 if ( *it == "Company" )
01545                         ent.setCompany( (*itLE)->text() );
01546 
01547                 if ( *it == "Office" )
01548                         ent.setOffice( (*itLE)->text() );
01549 
01550                 if ( *it == "Profession" )
01551                         ent.setProfession( (*itLE)->text() );
01552 
01553                 if ( *it == "Assistant" )
01554                         ent.setAssistant( (*itLE)->text() );
01555 
01556                 if ( *it == "Manager" )
01557                         ent.setManager( (*itLE)->text() );
01558 
01559                 if ( *it == "Spouse" )
01560                         ent.setSpouse( (*itLE)->text() );
01561 
01562                 if ( *it == "Nickname" )
01563                         ent.setNickname( (*itLE)->text() );
01564 
01565                 if ( *it == "Children" )
01566                         ent.setChildren( (*itLE)->text() );
01567 
01568         }
01569 
01570 
01571         QStringList::ConstIterator itV;
01572         for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
01573 
01574                 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone"  ) )
01575                         ent.setBusinessPhone( *itV );
01576 
01577                 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
01578                         ent.setBusinessFax( *itV );
01579 
01580                 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
01581                         ent.setBusinessMobile( *itV );
01582 
01583                 if ( *it == "Emails" ){
01584                         QString allemail;
01585                         QString defaultmail;
01586                         parseEmailFrom( emails.join(","), defaultmail, allemail );
01587                         if ( defaultEmail.isEmpty() ){
01588                                 odebug << "Default email was not set by user!" << oendl;
01589                                 odebug << "Using first email in list: " << defaultmail << oendl;
01590                                 ent.setDefaultEmail( defaultmail );
01591                         }
01592                         ent.setEmails( allemail );
01593                 }
01594 
01595                 if ( *it == "Default Email")
01596                         ent.setDefaultEmail( defaultEmail /* *itV */ );
01597 
01598                 if ( *it == "Home Phone" )
01599                         ent.setHomePhone( *itV );
01600 
01601                 if ( *it == "Home Fax" )
01602                         ent.setHomeFax( *itV );
01603 
01604                 if ( *it == "Home Mobile" )
01605                         ent.setHomeMobile( *itV );
01606 
01607                 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
01608                         ent.setBusinessPager( *itV );
01609 
01610                 if ( *it == "Home Web Page" )
01611                         ent.setHomeWebpage( *itV );
01612 
01613                 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
01614                         ent.setBusinessWebpage( *itV );
01615 
01616 
01617         }
01618 
01619         int gender = cmbGender->currentItem();
01620         ent.setGender( QString::number( gender ) );
01621 
01622         QString str = txtNote->text();
01623         if ( !str.isNull() )
01624                 ent.setNotes( str );
01625 
01626 }
01627 
01628 void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
01629                      QString &strAll )
01630 {
01631         int where,
01632                 start;
01633         if ( txt.isEmpty() )
01634                 return;
01635         // find the first
01636         where = txt.find( ',' );
01637         if ( where < 0 ) {
01638                 strDefaultEmail = txt;
01639                 strAll = txt;
01640         } else {
01641                 strDefaultEmail = txt.left( where ).stripWhiteSpace();
01642                 strAll = strDefaultEmail;
01643                 while ( where > -1 ) {
01644                         strAll.append(" ");
01645                         start = where;
01646                         where = txt.find( ',', where + 1 );
01647                         if ( where > - 1 )
01648                                 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
01649                         else // grab until the end...
01650                                 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
01651                 }
01652         }
01653 }
01654 
01655 void parseEmailTo( const QString &strDefaultEmail,
01656                    const QString &strOtherEmail, QString &strBack )
01657 {
01658         // create a comma dilimeted set of emails...
01659         // use the power of short circuiting...
01660         bool foundDefault = false;
01661         QString strTmp;
01662         int start = 0;
01663         int where;
01664         // start at the beginng.
01665         strBack = strDefaultEmail;
01666         where = 0;
01667         while ( where > -1 ) {
01668                 start = where;
01669                 where = strOtherEmail.find( ' ', where + 1 );
01670                 if ( where > 0 ) {
01671                         strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
01672                 } else
01673                         strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
01674                 if ( foundDefault || strTmp != strDefaultEmail ) {
01675                         strBack.append( ", " );
01676                         strBack.append( strTmp );
01677                 } else
01678                         foundDefault = true;
01679         }
01680 }
01681 
01682 
01683 static inline bool containsAlphaNum( const QString &str )
01684 {
01685         int i,
01686                 count = str.length();
01687         for ( i = 0; i < count; i++ )
01688                 if ( !str[i].isSpace() )
01689                         return true;
01690         return false;
01691 }
01692 
01693 static inline bool constainsWhiteSpace( const QString &str )
01694 {
01695         int i,
01696                 count = str.length();
01697         for (i = 0; i < count; i++ )
01698                 if ( str[i].isSpace() )
01699                         return true;
01700         return false;
01701 }
01702 
01703 void ContactEditor::setPersonalView( bool personal )
01704 {
01705         m_personalView = personal;
01706 
01707         // Currently disbled due to the fact that
01708         // show will not work...
01709         return;
01710 
01711         if ( personal ){
01712                 cmbCat->hide();
01713                 labCat->hide();
01714 
01715         } else{
01716                 cmbCat->show();
01717                 labCat->show();
01718         }
01719 }
01720 
01721 void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
01722 {
01723         QDate date;
01724         date.setYMD( year, month, day );
01725         QString dateString = TimeString::numberDateString( date );
01726         anniversaryButton->setText( dateString );
01727         ent.setAnniversary ( date );
01728 }
01729 
01730 void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
01731 {
01732         QDate date;
01733         date.setYMD( year, month, day );
01734         QString dateString = TimeString::numberDateString( date );
01735         birthdayButton->setText( dateString );
01736         ent.setBirthday ( date );
01737 }
01738 
01739 void ContactEditor::slotRemoveBirthday()
01740 {
01741         odebug << "void ContactEditor::slotRemoveBirthday()" << oendl;
01742         ent.setBirthday( QDate() );
01743         updateDatePicker();
01744 }
01745 
01746 void ContactEditor::slotRemoveAnniversary()
01747 {
01748         odebug << "void ContactEditor::slotRemoveAnniversary()" << oendl;
01749         ent.setAnniversary( QDate() );
01750         updateDatePicker();
01751 }

Generated on Sat Nov 5 16:15:47 2005 for OPIE by  doxygen 1.4.2