summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/TODO2
-rw-r--r--core/pim/addressbook/contacteditor.cpp224
-rw-r--r--core/pim/addressbook/contacteditor.h2
3 files changed, 186 insertions, 42 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO
index 1eb537f..76247c1 100644
--- a/core/pim/addressbook/TODO
+++ b/core/pim/addressbook/TODO
@@ -1,110 +1,112 @@
1Stuff todo until OPIE 1.0 : 1Stuff todo until OPIE 1.0 :
2=========================== 2===========================
3 3
4Feature requests: 4Feature requests:
5----------------- 5-----------------
6- Dial by mobile phone by tapping the number.. 6- Dial by mobile phone by tapping the number..
7 (Maybe using gsmtool. And we may 7 (Maybe using gsmtool. And we may
8 add a library class for this) 8 add a library class for this)
9- dial with dtmfdial incase it's installed and there's no mobile 9- dial with dtmfdial incase it's installed and there's no mobile
10- 3rd column for 2. Contact 10- 3rd column for 2. Contact
11- Implementing additional Views (Phonebook, ...) 11- Implementing additional Views (Phonebook, ...)
12- Birthday & Anniversary Reminder 12- Birthday & Anniversary Reminder
13- Plugin for Today for Birthdays and Anniversaries 13- Plugin for Today for Birthdays and Anniversaries
14- Beaming of multiple contacts (current list/ by search or by category) 14- Beaming of multiple contacts (current list/ by search or by category)
15 15
16Known Bugs: 16Known Bugs:
17----------- 17-----------
18 18
19 19
20Bugs but not in addressbook: 20Bugs but not in addressbook:
21----------------------------- 21-----------------------------
22- VCARD: If umlaut (äöüß) in address, the parser gets confused.. 22- VCARD: If umlaut (äöüß) in address, the parser gets confused..
23 23
24- Exporting and reimporting of Jobtitle was reported to fail (Could not reproduce this ! (se)) 24- Exporting and reimporting of Jobtitle was reported to fail (Could not reproduce this ! (se))
25 25
26 26
27Urgent: 27Urgent:
28-------- 28--------
29ContactEditor: 29ContactEditor:
30- Contact-Editor is temporarely reenabled. Wait for replacement. 30- Contact-Editor is temporarely reenabled. Wait for replacement.
31- Redesign of Contacteditor 31- Redesign of Contacteditor
32- Store last settings of combo-boxes 32- Store last settings of combo-boxes
33- Category is on the wrong position after changing to personal and back to normal 33- Category is on the wrong position after changing to personal and back to normal
34 ( Temporarily workaround: Category is never deactivated.. :S ) 34 ( Temporarily workaround: Category is never deactivated.. :S )
35 35
36- Personal and Business Web-page is not editable 36- Personal and Business Web-page is not editable
37 37
38Important: 38Important:
39---------- 39----------
40 40
41- If new contact is added (contacteditor closed): focus (table, card) to
42 this entry !
41- Implement a picker/combo for the default email. 43- Implement a picker/combo for the default email.
42- After search (Started with Return): KeyFocus should be on Tabelle 44- After search (Started with Return): KeyFocus should be on Tabelle
43 45
44- "What's this" should be added (Deleyed after Feature Freeze) 46- "What's this" should be added (Deleyed after Feature Freeze)
45 47
46Less important: 48Less important:
47--------------- 49---------------
48- Reload if contacts were changed externally 50- Reload if contacts were changed externally
49- Overview window cleanup needed.. 51- Overview window cleanup needed..
50- The picker (alphabetical sort widget) should be 52- The picker (alphabetical sort widget) should be
51 placed verticaly or horizontally (configurable) 53 placed verticaly or horizontally (configurable)
52- Find a smart solution for activating/deactivating the "send email" event 54- Find a smart solution for activating/deactivating the "send email" event
53 55
54Should be Fixed (not absolute sure, need further validation): 56Should be Fixed (not absolute sure, need further validation):
55------------------------------------------------------------- 57-------------------------------------------------------------
56 58
57 59
58Fixed: 60Fixed:
59------- 61-------
60- Syncing: abtable not reloaded after sync. 62- Syncing: abtable not reloaded after sync.
61- Find widget should be replaced by something like 63- Find widget should be replaced by something like
62 qpdf has. 64 qpdf has.
63- Adding a configuration dialog 65- Adding a configuration dialog
64- Picker: Activated letter schould be more visible 66- Picker: Activated letter schould be more visible
65- Advanced handling of cursor keys (search..) 67- Advanced handling of cursor keys (search..)
66- Mail-Icon is missing 68- Mail-Icon is missing
67- Use opie-mail insted of qt-mail if possible. 69- Use opie-mail insted of qt-mail if possible.
68- Font menu is invisible using german translation 70- Font menu is invisible using german translation
69- Personal contact editor: Disable categories 71- Personal contact editor: Disable categories
70- "Nonenglish" translation bug has to be fixed. 72- "Nonenglish" translation bug has to be fixed.
71- contacteditor: Birthday, annyversary, ... : Use Dateselector 73- contacteditor: Birthday, annyversary, ... : Use Dateselector
72- The names of the countries are sorted by there english names, only.. 74- The names of the countries are sorted by there english names, only..
73 Even if they are translated.. :S 75 Even if they are translated.. :S
74- Cursor keys should work in detail-view (ablabel) 76- Cursor keys should work in detail-view (ablabel)
75 -> Ablabel should be removed and Abtable should be increased with 77 -> Ablabel should be removed and Abtable should be increased with
76 different views (as started by darwin zins).. 78 different views (as started by darwin zins)..
77- Use advanced database functions in abtable to decrease 79- Use advanced database functions in abtable to decrease
78 memory footprint and to make everything more easy ! 80 memory footprint and to make everything more easy !
79 (abtable should store Iterator for selected Category) 81 (abtable should store Iterator for selected Category)
80- Abtable: Configure Contact column (internally already available, 82- Abtable: Configure Contact column (internally already available,
81 need configuration) 83 need configuration)
82- Select of primary contact (see #274 on mantis) 84- Select of primary contact (see #274 on mantis)
83- Category-select does not work completely: "Unfiled" is always in listview .. 85- Category-select does not work completely: "Unfiled" is always in listview ..
84- Return from Contacteditor: Category resettet to all 86- Return from Contacteditor: Category resettet to all
85- Personal Details not working 87- Personal Details not working
86- If category changed, the letterpicker should be resetted 88- If category changed, the letterpicker should be resetted
87- There should be some icons for List and Cardview 89- There should be some icons for List and Cardview
88- If in Cardview and a category change removes all entries: 90- If in Cardview and a category change removes all entries:
89 There are already entries in Cardview after up/down 91 There are already entries in Cardview after up/down
90- Personal Details: Anniversary zeigt Fantasie-Werte 92- Personal Details: Anniversary zeigt Fantasie-Werte
91- Unfiled shown just in Category "All" and "Unfiled". 93- Unfiled shown just in Category "All" and "Unfiled".
92- After finising search and after Edit: Clear Picker 94- After finising search and after Edit: Clear Picker
93- After Edit: Table position back to edited entry. 95- After Edit: Table position back to edited entry.
94- Optimize Table Update... 96- Optimize Table Update...
95- Change MyDialog to Config 97- Change MyDialog to Config
96- Store position and state of toolbar 98- Store position and state of toolbar
97- Searchwidget closed: Selected user is jumping 99- Searchwidget closed: Selected user is jumping
98- Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist) 100- Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist)
99 zu lange.. 101 zu lange..
100- VCARD: Import of Anniversary does not work correctly (currently disabled) 102- VCARD: Import of Anniversary does not work correctly (currently disabled)
101- Name order selected in "contacteditor" not used in list view. 103- Name order selected in "contacteditor" not used in list view.
102- OK-Key does not switch from Detailview (ablable) to Listview 104- OK-Key does not switch from Detailview (ablable) to Listview
103- Receiving of beams should open a dialog 105- Receiving of beams should open a dialog
104- Fix start of opie-mail 106- Fix start of opie-mail
105- Implement Button Pics 107- Implement Button Pics
106- Add a dialog to accept and optionally edit received contacts by IRDA. 108- Add a dialog to accept and optionally edit received contacts by IRDA.
107- Language not English (tested with german opie-translation): 109- Language not English (tested with german opie-translation):
108 1. Configure nicht übersetzt (alles leer). 110 1. Configure nicht übersetzt (alles leer).
109 2. Contacteditor nur teilweise übersetzt. 111 2. Contacteditor nur teilweise übersetzt.
110 3. Kategorie-Picker geht nicht. 112 3. Kategorie-Picker geht nicht.
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp
index c5ad0c4..37e3a54 100644
--- a/core/pim/addressbook/contacteditor.cpp
+++ b/core/pim/addressbook/contacteditor.cpp
@@ -1,240 +1,241 @@
1/* 1/*
2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> 2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
3 * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) 3 * Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de)
4 * 4 *
5 * This file is an add-on for the OPIE Palmtop Environment 5 * This file is an add-on for the OPIE Palmtop Environment
6 * 6 *
7 * This file may be distributed and/or modified under the terms of the 7 * This file may be distributed and/or modified under the terms of the
8 * GNU General Public License version 2 as published by the Free Software 8 * GNU General Public License version 2 as published by the Free Software
9 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging 9 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
10 * of this file. 10 * of this file.
11 * 11 *
12 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 * 14 *
15 * 15 *
16 * This is a rewrite of the abeditor.h file, modified to provide a more 16 * This is a rewrite of the abeditor.h file, modified to provide a more
17 * intuitive interface to TrollTech's original Address Book editor. This 17 * intuitive interface to TrollTech's original Address Book editor. This
18 * is made to operate exactly in interface with the exception of name. 18 * is made to operate exactly in interface with the exception of name.
19 * 19 *
20 */ 20 */
21 21
22#include "contacteditor.h" 22#include "contacteditor.h"
23#include "addresspicker.h" 23#include "addresspicker.h"
24#include "ocontactfields.h" 24#include "ocontactfields.h"
25 25
26#include <qpe/categoryselect.h> 26#include <qpe/categoryselect.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/qpedialog.h> 28#include <qpe/qpedialog.h>
29#include <qpe/timeconversion.h> 29#include <qpe/timeconversion.h>
30#include <opie/ocontact.h> 30#include <opie/ocontact.h>
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32 32
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qtabwidget.h> 35#include <qtabwidget.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qmultilineedit.h> 38#include <qmultilineedit.h>
39#include <qscrollview.h> 39#include <qscrollview.h>
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qmainwindow.h> 42#include <qmainwindow.h>
43#include <qvaluelist.h> 43#include <qvaluelist.h>
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45#include <qlistbox.h> 45#include <qlistbox.h>
46#include <qhbox.h> 46#include <qhbox.h>
47#include <qaction.h> 47#include <qaction.h>
48#include <qiconset.h> 48#include <qiconset.h>
49#include <qmessagebox.h>
49 50
50#include <assert.h> 51#include <assert.h>
51 52
52static inline bool containsAlphaNum( const QString &str ); 53static inline bool containsAlphaNum( const QString &str );
53static inline bool constainsWhiteSpace( const QString &str ); 54static inline bool constainsWhiteSpace( const QString &str );
54 55
55// helper functions, convert our comma delimited list to proper 56// helper functions, convert our comma delimited list to proper
56// file format... 57// file format...
57void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 58void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
58 QString &strAll ); 59 QString &strAll );
59 60
60// helper convert from file format to comma delimited... 61// helper convert from file format to comma delimited...
61void parseEmailTo( const QString &strDefaultEmail, 62void parseEmailTo( const QString &strDefaultEmail,
62 const QString &strOtherEmail, QString &strBack ); 63 const QString &strOtherEmail, QString &strBack );
63 64
64 ContactEditor::ContactEditor(const OContact &entry, 65 ContactEditor::ContactEditor(const OContact &entry,
65 QWidget *parent, 66 QWidget *parent,
66 const char *name, 67 const char *name,
67 WFlags fl ) 68 WFlags fl )
68 : QDialog( parent, name, TRUE, fl ), 69 : QDialog( parent, name, TRUE, fl ),
69 m_personalView ( false ) 70 m_personalView ( false )
70 71
71{ 72{
72 73
73 init(); 74 init();
74 setEntry( entry ); 75 setEntry( entry );
75 cmbDefaultEmail = 0; 76 cmbDefaultEmail = 0;
76 defaultEmailChooserPosition = -1; 77 defaultEmailChooserPosition = -1;
77} 78}
78 79
79ContactEditor::~ContactEditor() { 80ContactEditor::~ContactEditor() {
80} 81}
81 82
82void ContactEditor::init() { 83void ContactEditor::init() {
83 84
84 useFullName = true; 85 useFullName = true;
85 86
86 uint i = 0; 87 uint i = 0;
87 88
88 QStringList trlChooserNames; 89 QStringList trlChooserNames;
89 90
90 for (i = 0; i <= 6; i++) { 91 for (i = 0; i <= 6; i++) {
91 slHomeAddress.append( "" ); 92 slHomeAddress.append( "" );
92 slBusinessAddress.append( "" ); 93 slBusinessAddress.append( "" );
93 } 94 }
94 95
95 trlChooserNames = OContactFields::trphonefields( false ); 96 trlChooserNames = OContactFields::trphonefields( false );
96 slChooserNames = OContactFields::untrphonefields( false ); 97 slChooserNames = OContactFields::untrphonefields( false );
97 slDynamicEntries = OContactFields::untrdetailsfields( false ); 98 slDynamicEntries = OContactFields::untrdetailsfields( false );
98 trlDynamicEntries = OContactFields::trdetailsfields( false ); 99 trlDynamicEntries = OContactFields::trdetailsfields( false );
99 100
100 // Ok, we have to remove elements from the list of dynamic entries 101 // Ok, we have to remove elements from the list of dynamic entries
101 // which are now stored in special (not dynamic) widgets.. 102 // which are now stored in special (not dynamic) widgets..
102 // Otherwise we will get problems with field assignments! (se) 103 // Otherwise we will get problems with field assignments! (se)
103 slDynamicEntries.remove("Anniversary"); 104 slDynamicEntries.remove("Anniversary");
104 slDynamicEntries.remove("Birthday"); 105 slDynamicEntries.remove("Birthday");
105 slDynamicEntries.remove("Gender"); 106 slDynamicEntries.remove("Gender");
106 107
107 // The same with translated fields.. But I will 108 // The same with translated fields.. But I will
108 // use the translation map to avoid mismatches.. 109 // use the translation map to avoid mismatches..
109 QMap<int, QString> translMap = OContactFields::idToTrFields(); 110 QMap<int, QString> translMap = OContactFields::idToTrFields();
110 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] ); 111 trlDynamicEntries.remove( translMap[Qtopia::Anniversary] );
111 trlDynamicEntries.remove( translMap[Qtopia::Birthday] ); 112 trlDynamicEntries.remove( translMap[Qtopia::Birthday] );
112 trlDynamicEntries.remove( translMap[Qtopia::Gender] ); 113 trlDynamicEntries.remove( translMap[Qtopia::Gender] );
113 114
114 // Last Check to be sure.. 115 // Last Check to be sure..
115 assert( slDynamicEntries.count() == trlDynamicEntries.count() ); 116 assert( slDynamicEntries.count() == trlDynamicEntries.count() );
116 assert( slChooserNames.count() == trlChooserNames.count() ); 117 assert( slChooserNames.count() == trlChooserNames.count() );
117 118
118 for (i = 0; i < slChooserNames.count(); i++) 119 for (i = 0; i < slChooserNames.count(); i++)
119 slChooserValues.append(""); 120 slChooserValues.append("");
120 121
121 122
122 QVBoxLayout *vb = new QVBoxLayout( this ); 123 QVBoxLayout *vb = new QVBoxLayout( this );
123 124
124 tabMain = new QTabWidget( this ); 125 tabMain = new QTabWidget( this );
125 vb->addWidget( tabMain ); 126 vb->addWidget( tabMain );
126 127
127 QWidget *tabViewport = new QWidget ( tabMain ); 128 QWidget *tabViewport = new QWidget ( tabMain );
128 129
129 vb = new QVBoxLayout( tabViewport ); 130 vb = new QVBoxLayout( tabViewport );
130 131
131 svGeneral = new QScrollView( tabViewport ); 132 svGeneral = new QScrollView( tabViewport );
132 vb->addWidget( svGeneral, 0, 0 ); 133 vb->addWidget( svGeneral, 0, 0 );
133 svGeneral->setResizePolicy( QScrollView::AutoOneFit ); 134 svGeneral->setResizePolicy( QScrollView::AutoOneFit );
134 svGeneral->setFrameStyle( QFrame::NoFrame ); 135 svGeneral->setFrameStyle( QFrame::NoFrame );
135 136
136 QWidget *container = new QWidget( svGeneral->viewport() ); 137 QWidget *container = new QWidget( svGeneral->viewport() );
137 svGeneral->addChild( container ); 138 svGeneral->addChild( container );
138 139
139 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 ); 140 QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 4 );
140 gl->setResizeMode( QLayout::FreeResize ); 141 gl->setResizeMode( QLayout::FreeResize );
141 142
142 btnFullName = new QPushButton( tr( "Full Name..." ), container ); 143 btnFullName = new QPushButton( tr( "Full Name..." ), container );
143 gl->addWidget( btnFullName, 0, 0 ); 144 gl->addWidget( btnFullName, 0, 0 );
144 txtFullName = new QLineEdit( container ); 145 txtFullName = new QLineEdit( container );
145 gl->addWidget( txtFullName, 0, 1 ); 146 gl->addWidget( txtFullName, 0, 1 );
146 147
147 QLabel *l = new QLabel( tr( "Job Title" ), container ); 148 QLabel *l = new QLabel( tr( "Job Title" ), container );
148 gl->addWidget( l, 1, 0 ); 149 gl->addWidget( l, 1, 0 );
149 txtJobTitle = new QLineEdit( container ); 150 txtJobTitle = new QLineEdit( container );
150 gl->addWidget( txtJobTitle, 1, 1 ); 151 gl->addWidget( txtJobTitle, 1, 1 );
151 152
152 l = new QLabel( tr( "Organization" ), container ); 153 l = new QLabel( tr( "Organization" ), container );
153 gl->addWidget( l, 2, 0 ); 154 gl->addWidget( l, 2, 0 );
154 txtOrganization = new QLineEdit( container ); 155 txtOrganization = new QLineEdit( container );
155 gl->addWidget( txtOrganization, 2, 1 ); 156 gl->addWidget( txtOrganization, 2, 1 );
156 157
157 cmbChooserField1 = new QComboBox( FALSE, container ); 158 cmbChooserField1 = new QComboBox( FALSE, container );
158 cmbChooserField1->setMaximumWidth( 90 ); 159 cmbChooserField1->setMaximumWidth( 90 );
159 gl->addWidget( cmbChooserField1, 3, 0 ); 160 gl->addWidget( cmbChooserField1, 3, 0 );
160 txtChooserField1 = new QLineEdit( container ); 161 txtChooserField1 = new QLineEdit( container );
161 gl->addWidget( txtChooserField1, 3, 1 ); 162 gl->addWidget( txtChooserField1, 3, 1 );
162 163
163 cmbChooserField2 = new QComboBox( FALSE, container ); 164 cmbChooserField2 = new QComboBox( FALSE, container );
164 cmbChooserField2->setMaximumWidth( 90 ); 165 cmbChooserField2->setMaximumWidth( 90 );
165 gl->addWidget( cmbChooserField2, 4, 0 ); 166 gl->addWidget( cmbChooserField2, 4, 0 );
166 txtChooserField2 = new QLineEdit( container ); 167 txtChooserField2 = new QLineEdit( container );
167 gl->addWidget( txtChooserField2, 4, 1 ); 168 gl->addWidget( txtChooserField2, 4, 1 );
168 169
169 cmbChooserField3 = new QComboBox( FALSE, container ); 170 cmbChooserField3 = new QComboBox( FALSE, container );
170 cmbChooserField3->setMaximumWidth( 90 ); 171 cmbChooserField3->setMaximumWidth( 90 );
171 gl->addWidget( cmbChooserField3, 5, 0 ); 172 gl->addWidget( cmbChooserField3, 5, 0 );
172 txtChooserField3 = new QLineEdit( container ); 173 txtChooserField3 = new QLineEdit( container );
173 gl->addWidget( txtChooserField3, 5, 1 ); 174 gl->addWidget( txtChooserField3, 5, 1 );
174 175
175 l = new QLabel( tr( "File As" ), container ); 176 l = new QLabel( tr( "File As" ), container );
176 gl->addWidget( l, 6, 0 ); 177 gl->addWidget( l, 6, 0 );
177 cmbFileAs = new QComboBox( TRUE, container ); 178 cmbFileAs = new QComboBox( TRUE, container );
178 gl->addWidget( cmbFileAs, 6, 1 ); 179 gl->addWidget( cmbFileAs, 6, 1 );
179 180
180 labCat = new QLabel( tr( "Category" ), container ); 181 labCat = new QLabel( tr( "Category" ), container );
181 gl->addWidget( labCat, 7, 0 ); 182 gl->addWidget( labCat, 7, 0 );
182 cmbCat = new CategorySelect( container ); 183 cmbCat = new CategorySelect( container );
183 gl->addWidget( cmbCat, 7, 1 ); 184 gl->addWidget( cmbCat, 7, 1 );
184 labCat->show(); 185 labCat->show();
185 cmbCat->show(); 186 cmbCat->show();
186 187
187 btnNote = new QPushButton( tr( "Notes..." ), container ); 188 btnNote = new QPushButton( tr( "Notes..." ), container );
188 gl->addWidget( btnNote, 8, 1 ); 189 gl->addWidget( btnNote, 8, 1 );
189 190
190 tabMain->insertTab( tabViewport, tr( "General" ) ); 191 tabMain->insertTab( tabViewport, tr( "General" ) );
191 192
192 tabViewport = new QWidget ( tabMain ); 193 tabViewport = new QWidget ( tabMain );
193 194
194 vb = new QVBoxLayout( tabViewport ); 195 vb = new QVBoxLayout( tabViewport );
195 196
196 svAddress = new QScrollView( tabViewport ); 197 svAddress = new QScrollView( tabViewport );
197 vb->addWidget( svAddress, 0, 0 ); 198 vb->addWidget( svAddress, 0, 0 );
198 svAddress->setResizePolicy( QScrollView::AutoOneFit ); 199 svAddress->setResizePolicy( QScrollView::AutoOneFit );
199 svAddress->setFrameStyle( QFrame::NoFrame ); 200 svAddress->setFrameStyle( QFrame::NoFrame );
200 201
201 container = new QWidget( svAddress->viewport() ); 202 container = new QWidget( svAddress->viewport() );
202 svAddress->addChild( container ); 203 svAddress->addChild( container );
203 204
204 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem 205 gl = new QGridLayout( container, 8, 3, 2, 4 ); // row 7 QSpacerItem
205 206
206 cmbAddress = new QComboBox( FALSE, container ); 207 cmbAddress = new QComboBox( FALSE, container );
207 cmbAddress->insertItem( tr( "Business" ) ); 208 cmbAddress->insertItem( tr( "Business" ) );
208 cmbAddress->insertItem( tr( "Home" ) ); 209 cmbAddress->insertItem( tr( "Home" ) );
209 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); 210 gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 );
210 211
211 l = new QLabel( tr( "Address" ), container ); 212 l = new QLabel( tr( "Address" ), container );
212 gl->addWidget( l, 1, 0 ); 213 gl->addWidget( l, 1, 0 );
213 txtAddress = new QLineEdit( container ); 214 txtAddress = new QLineEdit( container );
214 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); 215 gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 );
215 216
216 l = new QLabel( tr( "City" ), container ); 217 l = new QLabel( tr( "City" ), container );
217 gl->addWidget( l, 2, 0 ); 218 gl->addWidget( l, 2, 0 );
218 txtCity = new QLineEdit( container ); 219 txtCity = new QLineEdit( container );
219 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); 220 gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 );
220 221
221 l = new QLabel( tr( "State" ), container ); 222 l = new QLabel( tr( "State" ), container );
222 gl->addWidget( l, 3, 0 ); 223 gl->addWidget( l, 3, 0 );
223 txtState = new QLineEdit( container ); 224 txtState = new QLineEdit( container );
224 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); 225 gl->addMultiCellWidget( txtState, 3, 3, 1, 2 );
225 226
226 l = new QLabel( tr( "Zip Code" ), container ); 227 l = new QLabel( tr( "Zip Code" ), container );
227 gl->addWidget( l, 4, 0 ); 228 gl->addWidget( l, 4, 0 );
228 txtZip = new QLineEdit( container ); 229 txtZip = new QLineEdit( container );
229 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); 230 gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 );
230 231
231 l = new QLabel( tr( "Country" ), container ); 232 l = new QLabel( tr( "Country" ), container );
232 gl->addWidget( l, 5, 0 ); 233 gl->addWidget( l, 5, 0 );
233 cmbCountry = new QComboBox( TRUE, container ); 234 cmbCountry = new QComboBox( TRUE, container );
234 cmbCountry->insertItem( tr( "" ) ); 235 cmbCountry->insertItem( tr( "" ) );
235 cmbCountry->insertItem( tr ( "United States" ) ); 236 cmbCountry->insertItem( tr ( "United States" ) );
236 cmbCountry->insertItem( tr ( "United Kingdom" ) ); 237 cmbCountry->insertItem( tr ( "United Kingdom" ) );
237 cmbCountry->insertItem( tr ( "Afghanistan" ) ); 238 cmbCountry->insertItem( tr ( "Afghanistan" ) );
238 cmbCountry->insertItem( tr ( "Albania" ) ); 239 cmbCountry->insertItem( tr ( "Albania" ) );
239 cmbCountry->insertItem( tr ( "Algeria" ) ); 240 cmbCountry->insertItem( tr ( "Algeria" ) );
240 cmbCountry->insertItem( tr ( "American Samoa" ) ); 241 cmbCountry->insertItem( tr ( "American Samoa" ) );
@@ -455,543 +456,679 @@ void ContactEditor::init() {
455 txtChooserField4 = new QLineEdit( container ); 456 txtChooserField4 = new QLineEdit( container );
456 gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 ); 457 gl->addMultiCellWidget( txtChooserField4, 6, 6, 1, 2 );
457 458
458 QSpacerItem *space = new QSpacerItem(1,1, 459 QSpacerItem *space = new QSpacerItem(1,1,
459 QSizePolicy::Maximum, 460 QSizePolicy::Maximum,
460 QSizePolicy::MinimumExpanding ); 461 QSizePolicy::MinimumExpanding );
461 gl->addItem( space, 7, 0 ); 462 gl->addItem( space, 7, 0 );
462 463
463 tabMain->insertTab( tabViewport, tr( "Address" ) ); 464 tabMain->insertTab( tabViewport, tr( "Address" ) );
464 465
465 tabViewport = new QWidget ( tabMain ); 466 tabViewport = new QWidget ( tabMain );
466 467
467 vb = new QVBoxLayout( tabViewport ); 468 vb = new QVBoxLayout( tabViewport );
468 469
469 svDetails = new QScrollView( tabViewport ); 470 svDetails = new QScrollView( tabViewport );
470 vb->addWidget( svDetails, 0, 0 ); 471 vb->addWidget( svDetails, 0, 0 );
471 svDetails->setResizePolicy( QScrollView::AutoOneFit ); 472 svDetails->setResizePolicy( QScrollView::AutoOneFit );
472 svDetails->setFrameStyle( QFrame::NoFrame ); 473 svDetails->setFrameStyle( QFrame::NoFrame );
473 474
474 container = new QWidget( svDetails->viewport() ); 475 container = new QWidget( svDetails->viewport() );
475 svDetails->addChild( container ); 476 svDetails->addChild( container );
476 477
477 gl = new QGridLayout( container, 1, 2, 2, 4 ); 478 gl = new QGridLayout( container, 1, 2, 2, 4 );
478 479
479 int counter = 0; 480 int counter = 0;
480 481
481 // Birthday 482 // Birthday
482 QHBox* hBox = new QHBox( container ); 483 QHBox* hBox = new QHBox( container );
483 l = new QLabel( tr("Birthday"), container ); 484 l = new QLabel( tr("Birthday"), container );
484 gl->addWidget( l, counter, 0 ); 485 gl->addWidget( l, counter, 0 );
485 486
486 QPopupMenu* m1 = new QPopupMenu( container ); 487 QPopupMenu* m1 = new QPopupMenu( container );
487 birthdayPicker = new DateBookMonth( m1, 0, TRUE ); 488 birthdayPicker = new DateBookMonth( m1, 0, TRUE );
488 m1->insertItem( birthdayPicker ); 489 m1->insertItem( birthdayPicker );
489 490
490 birthdayButton= new QToolButton( hBox, "buttonStart" ); 491 birthdayButton= new QToolButton( hBox, "buttonStart" );
491 birthdayButton->setPopup( m1 ); 492 birthdayButton->setPopup( m1 );
492 birthdayButton->setPopupDelay(0); 493 birthdayButton->setPopupDelay(0);
493 494
494 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 495 QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
495 tr( "Delete" ), 496 tr( "Delete" ),
496 hBox, 0 ); 497 hBox, 0 );
497 498
498 gl->addWidget( hBox, counter , 1 ); 499 gl->addWidget( hBox, counter , 1 );
499 500
500 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), 501 connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ),
501 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); 502 this, SLOT( slotBirthdayDateChanged( int, int, int ) ) );
502 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); 503 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) );
503 504
504 ++counter; 505 ++counter;
505 506
506 // Anniversary 507 // Anniversary
507 hBox = new QHBox( container ); 508 hBox = new QHBox( container );
508 l = new QLabel( tr("Anniversary"), container ); 509 l = new QLabel( tr("Anniversary"), container );
509 gl->addWidget( l, counter, 0 ); 510 gl->addWidget( l, counter, 0 );
510 511
511 m1 = new QPopupMenu( container ); 512 m1 = new QPopupMenu( container );
512 anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); 513 anniversaryPicker = new DateBookMonth( m1, 0, TRUE );
513 m1->insertItem( anniversaryPicker ); 514 m1->insertItem( anniversaryPicker );
514 515
515 anniversaryButton= new QToolButton( hBox, "buttonStart" ); 516 anniversaryButton= new QToolButton( hBox, "buttonStart" );
516 anniversaryButton->setPopup( m1 ); 517 anniversaryButton->setPopup( m1 );
517 anniversaryButton->setPopupDelay(0); 518 anniversaryButton->setPopupDelay(0);
518 519
519 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), 520 deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ),
520 tr( "Delete" ), 521 tr( "Delete" ),
521 hBox, 0 ); 522 hBox, 0 );
522 gl->addWidget( hBox, counter , 1 ); 523 gl->addWidget( hBox, counter , 1 );
523 524
524 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), 525 connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ),
525 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); 526 this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) );
526 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); 527 connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) );
527 528
528 ++counter; 529 ++counter;
529 530
530 // Gender 531 // Gender
531 l = new QLabel( tr("Gender"), container ); 532 l = new QLabel( tr("Gender"), container );
532 gl->addWidget( l, counter, 0 ); 533 gl->addWidget( l, counter, 0 );
533 cmbGender = new QComboBox( container ); 534 cmbGender = new QComboBox( container );
534 cmbGender->insertItem( "", 0 ); 535 cmbGender->insertItem( "", 0 );
535 cmbGender->insertItem( tr("Male"), 1); 536 cmbGender->insertItem( tr("Male"), 1);
536 cmbGender->insertItem( tr("Female"), 2); 537 cmbGender->insertItem( tr("Female"), 2);
537 gl->addWidget( cmbGender, counter, 1 ); 538 gl->addWidget( cmbGender, counter, 1 );
538 539
539 ++counter; 540 ++counter;
540 541
541 // Create Labels and lineedit fields for every dynamic entry 542 // Create Labels and lineedit fields for every dynamic entry
542 QStringList::ConstIterator it = slDynamicEntries.begin(); 543 QStringList::ConstIterator it = slDynamicEntries.begin();
543 QStringList::ConstIterator trit = trlDynamicEntries.begin(); 544 QStringList::ConstIterator trit = trlDynamicEntries.begin();
544 for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) { 545 for (i = counter; it != slDynamicEntries.end(); i++, ++it, ++trit) {
545 546
546 if (((*it) == "Anniversary") || 547 if (((*it) == "Anniversary") ||
547 ((*it) == "Birthday")|| ((*it) == "Gender")) continue; 548 ((*it) == "Birthday")|| ((*it) == "Gender")) continue;
548 549
549 l = new QLabel( (*it).utf8() , container ); 550 l = new QLabel( (*it).utf8() , container );
550 listName.append( l ); 551 listName.append( l );
551 gl->addWidget( l, i, 0 ); 552 gl->addWidget( l, i, 0 );
552 QLineEdit *e = new QLineEdit( container ); 553 QLineEdit *e = new QLineEdit( container );
553 listValue.append( e ); 554 listValue.append( e );
554 gl->addWidget( e, i, 1); 555 gl->addWidget( e, i, 1);
555 } 556 }
556 // Fill labels with names.. 557 // Fill labels with names..
557 //loadFields(); 558 //loadFields();
558 559
559 560
560 tabMain->insertTab( tabViewport, tr( "Details" ) ); 561 tabMain->insertTab( tabViewport, tr( "Details" ) );
561 562
562 dlgNote = new QDialog( this, "Note Dialog", TRUE ); 563 dlgNote = new QDialog( this, "Note Dialog", TRUE );
563 dlgNote->setCaption( tr("Enter Note") ); 564 dlgNote->setCaption( tr("Enter Note") );
564 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); 565 QVBoxLayout *vbNote = new QVBoxLayout( dlgNote );
565 txtNote = new QMultiLineEdit( dlgNote ); 566 txtNote = new QMultiLineEdit( dlgNote );
566 vbNote->addWidget( txtNote ); 567 vbNote->addWidget( txtNote );
567 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); 568 connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) );
568 569
569 dlgName = new QDialog( this, "Name Dialog", TRUE ); 570 dlgName = new QDialog( this, "Name Dialog", TRUE );
570 dlgName->setCaption( tr("Edit Name") ); 571 dlgName->setCaption( tr("Edit Name") );
571 gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); 572 gl = new QGridLayout( dlgName, 5, 2, 2, 3 );
572 573
573 l = new QLabel( tr("First Name"), dlgName ); 574 l = new QLabel( tr("First Name"), dlgName );
574 gl->addWidget( l, 0, 0 ); 575 gl->addWidget( l, 0, 0 );
575 txtFirstName = new QLineEdit( dlgName ); 576 txtFirstName = new QLineEdit( dlgName );
576 gl->addWidget( txtFirstName, 0, 1 ); 577 gl->addWidget( txtFirstName, 0, 1 );
577 578
578 l = new QLabel( tr("Middle Name"), dlgName ); 579 l = new QLabel( tr("Middle Name"), dlgName );
579 gl->addWidget( l, 1, 0 ); 580 gl->addWidget( l, 1, 0 );
580 txtMiddleName = new QLineEdit( dlgName ); 581 txtMiddleName = new QLineEdit( dlgName );
581 gl->addWidget( txtMiddleName, 1, 1 ); 582 gl->addWidget( txtMiddleName, 1, 1 );
582 583
583 l = new QLabel( tr("Last Name"), dlgName ); 584 l = new QLabel( tr("Last Name"), dlgName );
584 gl->addWidget( l, 2, 0 ); 585 gl->addWidget( l, 2, 0 );
585 txtLastName = new QLineEdit( dlgName ); 586 txtLastName = new QLineEdit( dlgName );
586 gl->addWidget( txtLastName, 2, 1 ); 587 gl->addWidget( txtLastName, 2, 1 );
587 588
588 l = new QLabel( tr("Suffix"), dlgName ); 589 l = new QLabel( tr("Suffix"), dlgName );
589 gl->addWidget( l, 3, 0 ); 590 gl->addWidget( l, 3, 0 );
590 txtSuffix = new QLineEdit( dlgName ); 591 txtSuffix = new QLineEdit( dlgName );
591 gl->addWidget( txtSuffix, 3, 1 ); 592 gl->addWidget( txtSuffix, 3, 1 );
592 space = new QSpacerItem(1,1, 593 space = new QSpacerItem(1,1,
593 QSizePolicy::Maximum, 594 QSizePolicy::Maximum,
594 QSizePolicy::MinimumExpanding ); 595 QSizePolicy::MinimumExpanding );
595 gl->addItem( space, 4, 0 ); 596 gl->addItem( space, 4, 0 );
596 597
597 cmbChooserField1->insertStringList( trlChooserNames ); 598 cmbChooserField1->insertStringList( trlChooserNames );
598 cmbChooserField2->insertStringList( trlChooserNames ); 599 cmbChooserField2->insertStringList( trlChooserNames );
599 cmbChooserField3->insertStringList( trlChooserNames ); 600 cmbChooserField3->insertStringList( trlChooserNames );
600 cmbChooserField4->insertStringList( trlChooserNames ); 601 cmbChooserField4->insertStringList( trlChooserNames );
601 602
602 cmbChooserField1->setCurrentItem( 0 ); 603 cmbChooserField1->setCurrentItem( 0 );
603 cmbChooserField2->setCurrentItem( 1 ); 604 cmbChooserField2->setCurrentItem( 1 );
604 cmbChooserField3->setCurrentItem( 2 ); 605 cmbChooserField3->setCurrentItem( 2 );
605 606
606 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); 607 connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) );
607 608
608 connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); 609 connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) );
609 610
610 connect( txtChooserField1, SIGNAL(textChanged(const QString &)), 611 connect( txtChooserField1, SIGNAL(textChanged(const QString &)),
611 this, SLOT(slotChooser1Change(const QString &)) ); 612 this, SLOT(slotChooser1Change(const QString &)) );
612 connect( txtChooserField2, SIGNAL(textChanged(const QString &)), 613 connect( txtChooserField2, SIGNAL(textChanged(const QString &)),
613 this, SLOT(slotChooser2Change(const QString &)) ); 614 this, SLOT(slotChooser2Change(const QString &)) );
614 connect( txtChooserField3, SIGNAL(textChanged(const QString &)), 615 connect( txtChooserField3, SIGNAL(textChanged(const QString &)),
615 this, SLOT(slotChooser3Change(const QString &)) ); 616 this, SLOT(slotChooser3Change(const QString &)) );
616 connect( txtChooserField4, SIGNAL(textChanged(const QString &)), 617 connect( txtChooserField4, SIGNAL(textChanged(const QString &)),
617 this, SLOT(slotChooser4Change(const QString &)) ); 618 this, SLOT(slotChooser4Change(const QString &)) );
618 connect( txtAddress, SIGNAL(textChanged(const QString &)), 619 connect( txtAddress, SIGNAL(textChanged(const QString &)),
619 this, SLOT(slotAddressChange(const QString &)) ); 620 this, SLOT(slotAddressChange(const QString &)) );
620 connect( txtCity, SIGNAL(textChanged(const QString &)), 621 connect( txtCity, SIGNAL(textChanged(const QString &)),
621 this, SLOT(slotCityChange(const QString &)) ); 622 this, SLOT(slotCityChange(const QString &)) );
622 connect( txtState, SIGNAL(textChanged(const QString &)), 623 connect( txtState, SIGNAL(textChanged(const QString &)),
623 this, SLOT(slotStateChange(const QString &)) ); 624 this, SLOT(slotStateChange(const QString &)) );
624 connect( txtZip, SIGNAL(textChanged(const QString &)), 625 connect( txtZip, SIGNAL(textChanged(const QString &)),
625 this, SLOT(slotZipChange(const QString &)) ); 626 this, SLOT(slotZipChange(const QString &)) );
626 connect( cmbCountry, SIGNAL(textChanged(const QString &)), 627 connect( cmbCountry, SIGNAL(textChanged(const QString &)),
627 this, SLOT(slotCountryChange(const QString &)) ); 628 this, SLOT(slotCountryChange(const QString &)) );
628 connect( cmbCountry, SIGNAL(activated(const QString &)), 629 connect( cmbCountry, SIGNAL(activated(const QString &)),
629 this, SLOT(slotCountryChange(const QString &)) ); 630 this, SLOT(slotCountryChange(const QString &)) );
630 connect( cmbChooserField1, SIGNAL(activated(int)), 631 connect( cmbChooserField1, SIGNAL(activated(int)),
631 this, SLOT(slotCmbChooser1Change(int)) ); 632 this, SLOT(slotCmbChooser1Change(int)) );
632 connect( cmbChooserField2, SIGNAL(activated(int)), 633 connect( cmbChooserField2, SIGNAL(activated(int)),
633 this, SLOT(slotCmbChooser2Change(int)) ); 634 this, SLOT(slotCmbChooser2Change(int)) );
634 connect( cmbChooserField3, SIGNAL(activated(int)), 635 connect( cmbChooserField3, SIGNAL(activated(int)),
635 this, SLOT(slotCmbChooser3Change(int)) ); 636 this, SLOT(slotCmbChooser3Change(int)) );
636 connect( cmbChooserField4, SIGNAL(activated(int)), 637 connect( cmbChooserField4, SIGNAL(activated(int)),
637 this, SLOT(slotCmbChooser4Change(int)) ); 638 this, SLOT(slotCmbChooser4Change(int)) );
638 connect( cmbAddress, SIGNAL(activated(int)), 639 connect( cmbAddress, SIGNAL(activated(int)),
639 this, SLOT(slotAddressTypeChange(int)) ); 640 this, SLOT(slotAddressTypeChange(int)) );
640 641
641 new QPEDialogListener(this); 642 new QPEDialogListener(this);
642 643
643 setPersonalView ( m_personalView ); 644 setPersonalView ( m_personalView );
644} 645}
645 646
646void ContactEditor::defaultEmailChanged(int i){ 647void ContactEditor::defaultEmailChanged(int i){
647 qDebug("defaultEmailChanged"); 648 qDebug("defaultEmailChanged");
649
648 int index = cmbChooserField1->currentItem(); 650 int index = cmbChooserField1->currentItem();
649 slChooserValues[index] = cmbDefaultEmail->text(i); 651 slChooserValues[index] = cmbDefaultEmail->text(i);
650 652
653 defaultEmail = cmbDefaultEmail->text(i);
654 qDebug ("Changed to: %s", defaultEmail.latin1());
655
651} 656}
652 657
653void ContactEditor::populateDefaultEmailCmb(){ 658void ContactEditor::populateDefaultEmailCmb(){
659
660 // if the default-email combo was not selected and therfore not created
661 // we get a lot of trouble.. Therfore create an invisible one..
662 if ( !cmbDefaultEmail ){
663 cmbDefaultEmail = new QComboBox(this);
664 cmbDefaultEmail -> hide();
665 }
654 cmbDefaultEmail->clear(); 666 cmbDefaultEmail->clear();
655 cmbDefaultEmail->insertStringList(emails); 667 cmbDefaultEmail->insertStringList( emails );
668 // cmbDefaultEmail->show();
669
670 // Select default email in combo..
671 bool found = false;
656 for ( int i = 0; i < cmbDefaultEmail->count(); i++){ 672 for ( int i = 0; i < cmbDefaultEmail->count(); i++){
657 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",cmbDefaultEmail->text( i ).latin1(),defaultEmail.latin1()); 673 qDebug(" populateDefaultEmailCmb text >%s< defaultEmail >%s<",
658 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){ 674 cmbDefaultEmail->text( i ).latin1(), defaultEmail.latin1());
659 cmbDefaultEmail->setCurrentItem( i ); 675
660 qDebug("set"); 676 if ( cmbDefaultEmail->text( i ).stripWhiteSpace() == defaultEmail.stripWhiteSpace() ){
677 cmbDefaultEmail->setCurrentItem( i );
678 qDebug("set");
679 found = true;
661 } 680 }
662 } 681 }
682
683 // If the current default email is not found in the list, we choose the
684 // first one..
685 if ( !found )
686 defaultEmail = cmbDefaultEmail->text(0);
687}
688
689// Called when any combobox was changed.
690// "true" returned if the change was chandled by this function, else it should
691// be handled by something else..
692bool ContactEditor::cmbChooserChange( int index, QLineEdit *inputWid, int widgetPos ) {
693 QString type = slChooserNames[index];
694 qWarning("ContactEditor::cmbChooserChange -> Type: %s", type.latin1() );
695
696 // Create and connect combobox for selecting the default email
697 if ( type == "Default Email"){
698 qWarning("Choosing default-email ");
699
700 // More than one defaul-email chooser is not allowed !
701 if ( ( defaultEmailChooserPosition != -1 ) &&
702 defaultEmailChooserPosition != widgetPos ){
703 chooserError( widgetPos );
704 return true;
705 }
706
707 if ( cmbDefaultEmail ){
708 delete cmbDefaultEmail;
709 cmbDefaultEmail = 0l;
710 }
711 cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
712 cmbDefaultEmail->setGeometry(inputWid->frameGeometry());
713
714 connect( cmbDefaultEmail,SIGNAL( activated(int) ),
715 SLOT( defaultEmailChanged(int) ) );
716
717 cmbDefaultEmail->clear();
718 cmbDefaultEmail->insertStringList( emails );
719 cmbDefaultEmail->show();
720
721 defaultEmailChooserPosition = widgetPos;
722
723 // Set current default email
724 populateDefaultEmailCmb();
725
726
727 } else {
728 // Something else was selected: Hide combo..
729 qWarning(" Hiding default-email combo" );
730 if ( defaultEmailChooserPosition == widgetPos ){
731 defaultEmailChooserPosition = -1;
732 if ( cmbDefaultEmail )
733 cmbDefaultEmail->hide();
734
735 }
736
737 // Caller should initialize the responsible textfield, therefore
738 // "false" is returned
739 return false;
740 }
741
742 // Everything is worked off ..
743 return true;
744
745}
746
747// Currently accessed when we select default-email more than once !
748void ContactEditor::chooserError( int index )
749{
750 qWarning("ContactEditor::chooserError( %d )", index);
751 QMessageBox::warning( this, "Chooser Error",
752 "Multiple selection of this\n"
753 "Item is not allowed !\n\n"
754 "First deselect the previous one !",
755 "&OK", 0, 0,
756 0, 0 );
757
758 // Reset the selected Chooser. Unfortunately the chooser
759 // generates no signal, therfore we have to
760 // call the cmbChooserChange function manually..
761 switch( index ){
762 case 1:
763 cmbChooserField1 -> setCurrentItem( 0 );
764 slotCmbChooser1Change( 0 );
765 break;
766 case 2:
767 cmbChooserField2 -> setCurrentItem( 0 );
768 slotCmbChooser2Change( 0 );
769 break;
770 case 3:
771 cmbChooserField3 -> setCurrentItem( 0 );
772 slotCmbChooser3Change( 0 );
773 break;
774 case 4:
775 cmbChooserField4 -> setCurrentItem( 0 );
776 slotCmbChooser4Change( 0 );
777 break;
778 }
663} 779}
664 780
665void ContactEditor::chooserChange( const QString &textChanged, int index, QLineEdit *inputWid, int widgetPos ) { 781// Called when something was changed in a textfield (shouldn't it called textchanged? (se))
782void ContactEditor::chooserChange( const QString &textChanged, int index,
783 QLineEdit* , int widgetPos ) {
784
666 QString type = slChooserNames[index]; 785 QString type = slChooserNames[index];
667 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",type.latin1(),textChanged.latin1(), index, widgetPos ); 786 qDebug("ContactEditor::chooserChange( type=>%s<, textChanged=>%s< index=%i, widgetPos=%i",
787 type.latin1(),textChanged.latin1(), index, widgetPos );
788
668 if ( type == "Default Email"){ 789 if ( type == "Default Email"){
669 defaultEmail = textChanged; 790 qWarning ("??? Wozu??: %s", textChanged.latin1());
670 if (cmbDefaultEmail){ 791 defaultEmail = textChanged;
671 delete cmbDefaultEmail; 792
672 cmbDefaultEmail = 0l; 793 populateDefaultEmailCmb();
673 } 794
674 cmbDefaultEmail = new QComboBox(inputWid->parentWidget());
675 cmbDefaultEmail->setGeometry(inputWid->frameGeometry());
676 cmbDefaultEmail->show();
677 populateDefaultEmailCmb();
678 connect(cmbDefaultEmail,SIGNAL(activated(int)),
679 SLOT(defaultEmailChanged(int)));
680 defaultEmailChooserPosition = widgetPos;
681 }else if (defaultEmailChooserPosition == widgetPos){ 795 }else if (defaultEmailChooserPosition == widgetPos){
682 qDebug("cmbDefaultEmail->hide()"); 796 qDebug("cmbDefaultEmail->hide()");
683 if (cmbDefaultEmail) cmbDefaultEmail->hide(); 797
684 widgetPos=-1; 798 if (cmbDefaultEmail) cmbDefaultEmail->hide();
799 widgetPos=-1;
800
685 }else if (type == "Emails"){ 801 }else if (type == "Emails"){
686 qDebug("emails"); 802 qDebug("emails");
687 QString de; 803
688 emails = QStringList::split (",", textChanged ); 804 QString de;
805 emails = QStringList::split (",", textChanged );
689 806
690 if ( cmbDefaultEmail ) 807 populateDefaultEmailCmb();
691 populateDefaultEmailCmb();
692 } 808 }
693 809
694
695
696 slChooserValues[index] = textChanged; 810 slChooserValues[index] = textChanged;
697 811
698} 812}
699 813
700void ContactEditor::slotChooser1Change( const QString &textChanged ) { 814void ContactEditor::slotChooser1Change( const QString &textChanged ) {
815 qWarning("ContactEditor::slotChooser1Change( %s )", textChanged.latin1());
701 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1); 816 chooserChange( textChanged, cmbChooserField1->currentItem(), txtChooserField1, 1);
702} 817}
703 818
704void ContactEditor::slotChooser2Change( const QString &textChanged ) { 819void ContactEditor::slotChooser2Change( const QString &textChanged ) {
820 qWarning("ContactEditor::slotChooser2Change( %s )", textChanged.latin1());
705 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2); 821 chooserChange( textChanged, cmbChooserField2->currentItem(), txtChooserField2, 2);
706 822
707} 823}
708 824
709void ContactEditor::slotChooser3Change( const QString &textChanged ) { 825void ContactEditor::slotChooser3Change( const QString &textChanged ) {
826 qWarning("ContactEditor::slotChooser3Change( %s )", textChanged.latin1());
710 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3); 827 chooserChange( textChanged, cmbChooserField3->currentItem(), txtChooserField3, 3);
711} 828}
712 829
713void ContactEditor::slotChooser4Change( const QString &textChanged ) { 830void ContactEditor::slotChooser4Change( const QString &textChanged ) {
831 qWarning("ContactEditor::slotChooser4Change( %s )", textChanged.latin1());
714 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4); 832 chooserChange( textChanged, cmbChooserField4->currentItem(), txtChooserField4, 4);
715} 833}
716 834
717void ContactEditor::slotAddressChange( const QString &textChanged ) { 835void ContactEditor::slotAddressChange( const QString &textChanged ) {
718 836
719 if ( cmbAddress->currentItem() == 0 ) { 837 if ( cmbAddress->currentItem() == 0 ) {
720 slBusinessAddress[0] = textChanged; 838 slBusinessAddress[0] = textChanged;
721 } else { 839 } else {
722 slHomeAddress[0] = textChanged; 840 slHomeAddress[0] = textChanged;
723 } 841 }
724} 842}
725 843
726void ContactEditor::slotAddress2Change( const QString &textChanged ) { 844void ContactEditor::slotAddress2Change( const QString &textChanged ) {
727 845
728 if ( cmbAddress->currentItem() == 0 ) { 846 if ( cmbAddress->currentItem() == 0 ) {
729 slBusinessAddress[1] = textChanged; 847 slBusinessAddress[1] = textChanged;
730 } else { 848 } else {
731 slHomeAddress[1] = textChanged; 849 slHomeAddress[1] = textChanged;
732 } 850 }
733} 851}
734 852
735void ContactEditor::slotPOBoxChange( const QString &textChanged ) { 853void ContactEditor::slotPOBoxChange( const QString &textChanged ) {
736 854
737 if ( cmbAddress->currentItem() == 0 ) { 855 if ( cmbAddress->currentItem() == 0 ) {
738 slBusinessAddress[2] = textChanged; 856 slBusinessAddress[2] = textChanged;
739 } else { 857 } else {
740 slHomeAddress[2] = textChanged; 858 slHomeAddress[2] = textChanged;
741 } 859 }
742} 860}
743 861
744void ContactEditor::slotCityChange( const QString &textChanged ) { 862void ContactEditor::slotCityChange( const QString &textChanged ) {
745 863
746 if ( cmbAddress->currentItem() == 0 ) { 864 if ( cmbAddress->currentItem() == 0 ) {
747 slBusinessAddress[3] = textChanged; 865 slBusinessAddress[3] = textChanged;
748 } else { 866 } else {
749 slHomeAddress[3] = textChanged; 867 slHomeAddress[3] = textChanged;
750 } 868 }
751} 869}
752 870
753void ContactEditor::slotStateChange( const QString &textChanged ) { 871void ContactEditor::slotStateChange( const QString &textChanged ) {
754 872
755 873
756 if ( cmbAddress->currentItem() == 0 ) { 874 if ( cmbAddress->currentItem() == 0 ) {
757 slBusinessAddress[4] = textChanged; 875 slBusinessAddress[4] = textChanged;
758 } else { 876 } else {
759 slHomeAddress[4] = textChanged; 877 slHomeAddress[4] = textChanged;
760 } 878 }
761} 879}
762 880
763void ContactEditor::slotZipChange( const QString &textChanged ) { 881void ContactEditor::slotZipChange( const QString &textChanged ) {
764 882
765 if ( cmbAddress->currentItem() == 0 ) { 883 if ( cmbAddress->currentItem() == 0 ) {
766 slBusinessAddress[5] = textChanged; 884 slBusinessAddress[5] = textChanged;
767 } else { 885 } else {
768 slHomeAddress[5] = textChanged; 886 slHomeAddress[5] = textChanged;
769 } 887 }
770} 888}
771 889
772void ContactEditor::slotCountryChange( const QString &textChanged ) { 890void ContactEditor::slotCountryChange( const QString &textChanged ) {
773 891
774 if ( cmbAddress->currentItem() == 0 ) { 892 if ( cmbAddress->currentItem() == 0 ) {
775 slBusinessAddress[6] = textChanged; 893 slBusinessAddress[6] = textChanged;
776 } else { 894 } else {
777 slHomeAddress[6] = textChanged; 895 slHomeAddress[6] = textChanged;
778 } 896 }
779} 897}
780 898
781 899
782void ContactEditor::slotCmbChooser1Change( int index ) { 900void ContactEditor::slotCmbChooser1Change( int index ) {
901 qWarning("ContactEditor::slotCmbChooser1Change( %d )", index);
902
903 if ( !cmbChooserChange( cmbChooserField1->currentItem(), txtChooserField1, 1) ){
904
905 txtChooserField1->setText( slChooserValues[index] );
906 txtChooserField1->setFocus();
907
908 }
783 909
784 txtChooserField1->setText( slChooserValues[index] );
785 txtChooserField1->setFocus();
786} 910}
787 911
788void ContactEditor::slotCmbChooser2Change( int index ) { 912void ContactEditor::slotCmbChooser2Change( int index ) {
913 qWarning("ContactEditor::slotCmbChooser2Change( %d )", index);
914
915 if ( !cmbChooserChange( cmbChooserField2->currentItem(), txtChooserField2, 2) ){
789 916
790 txtChooserField2->setText( slChooserValues[index] ); 917 txtChooserField2->setText( slChooserValues[index] );
791 txtChooserField2->setFocus(); 918 txtChooserField2->setFocus();
919
920 }
792} 921}
793 922
794void ContactEditor::slotCmbChooser3Change( int index ) { 923void ContactEditor::slotCmbChooser3Change( int index ) {
924 qWarning("ContactEditor::slotCmbChooser3Change( %d )", index);
925
926 if ( !cmbChooserChange( cmbChooserField3->currentItem(), txtChooserField3, 3) ){
795 927
796 txtChooserField3->setText( slChooserValues[index] ); 928 txtChooserField3->setText( slChooserValues[index] );
797 txtChooserField3->setFocus(); 929 txtChooserField3->setFocus();
798 930
931 }
799} 932}
800 933
801void ContactEditor::slotCmbChooser4Change( int index ) { 934void ContactEditor::slotCmbChooser4Change( int index ) {
935 qWarning("ContactEditor::slotCmbChooser4Change( %d )", index);
936
937 if ( !cmbChooserChange( cmbChooserField4->currentItem(), txtChooserField4, 4) ){
802 938
803 txtChooserField4->setText( slChooserValues[index] ); 939 txtChooserField4->setText( slChooserValues[index] );
804 txtChooserField4->setFocus(); 940 txtChooserField4->setFocus();
805 941
942 }
806} 943}
807 944
808void ContactEditor::slotAddressTypeChange( int index ) { 945void ContactEditor::slotAddressTypeChange( int index ) {
809 946
810 if ( index == 0 ) { 947 if ( index == 0 ) {
811 948
812 txtAddress->setText( slBusinessAddress[0] ); 949 txtAddress->setText( slBusinessAddress[0] );
813 //txtAddress2->setText( (*slBusinessAddress)[1] ); 950 //txtAddress2->setText( (*slBusinessAddress)[1] );
814 //txtPOBox->setText( (*slBusinessAddress)[2] ); 951 //txtPOBox->setText( (*slBusinessAddress)[2] );
815 txtCity->setText( slBusinessAddress[3] ); 952 txtCity->setText( slBusinessAddress[3] );
816 txtState->setText( slBusinessAddress[4] ); 953 txtState->setText( slBusinessAddress[4] );
817 txtZip->setText( slBusinessAddress[5] ); 954 txtZip->setText( slBusinessAddress[5] );
818 QLineEdit *txtTmp = cmbCountry->lineEdit(); 955 QLineEdit *txtTmp = cmbCountry->lineEdit();
819 txtTmp->setText( slBusinessAddress[6] ); 956 txtTmp->setText( slBusinessAddress[6] );
820 957
821 } else { 958 } else {
822 959
823 txtAddress->setText( slHomeAddress[0] ); 960 txtAddress->setText( slHomeAddress[0] );
824 //txtAddress2->setText( (*slHomeAddress)[1] ); 961 //txtAddress2->setText( (*slHomeAddress)[1] );
825 //txtPOBox->setText( (*slHomeAddress)[2] ); 962 //txtPOBox->setText( (*slHomeAddress)[2] );
826 txtCity->setText( slHomeAddress[3] ); 963 txtCity->setText( slHomeAddress[3] );
827 txtState->setText( slHomeAddress[4] ); 964 txtState->setText( slHomeAddress[4] );
828 txtZip->setText( slHomeAddress[5] ); 965 txtZip->setText( slHomeAddress[5] );
829 QLineEdit *txtTmp = cmbCountry->lineEdit(); 966 QLineEdit *txtTmp = cmbCountry->lineEdit();
830 txtTmp->setText( slHomeAddress[6] ); 967 txtTmp->setText( slHomeAddress[6] );
831 968
832 } 969 }
833 970
834} 971}
835 972
836void ContactEditor::slotFullNameChange( const QString &textChanged ) { 973void ContactEditor::slotFullNameChange( const QString &textChanged ) {
837 974
838 int index = cmbFileAs->currentItem(); 975 int index = cmbFileAs->currentItem();
839 976
840 cmbFileAs->clear(); 977 cmbFileAs->clear();
841 978
842 cmbFileAs->insertItem( parseName( textChanged, 0 ) ); 979 cmbFileAs->insertItem( parseName( textChanged, 0 ) );
843 cmbFileAs->insertItem( parseName( textChanged, 1 ) ); 980 cmbFileAs->insertItem( parseName( textChanged, 1 ) );
844 cmbFileAs->insertItem( parseName( textChanged, 2 ) ); 981 cmbFileAs->insertItem( parseName( textChanged, 2 ) );
845 cmbFileAs->insertItem( parseName( textChanged, 3 ) ); 982 cmbFileAs->insertItem( parseName( textChanged, 3 ) );
846 983
847 cmbFileAs->setCurrentItem( index ); 984 cmbFileAs->setCurrentItem( index );
848 985
849 useFullName = true; 986 useFullName = true;
850 987
851} 988}
852 989
853void ContactEditor::accept() { 990void ContactEditor::accept() {
854 991
855 if ( isEmpty() ) { 992 if ( isEmpty() ) {
856 cleanupFields(); 993 cleanupFields();
857 reject(); 994 reject();
858 } else { 995 } else {
859 saveEntry(); 996 saveEntry();
860 cleanupFields(); 997 cleanupFields();
861 QDialog::accept(); 998 QDialog::accept();
862 } 999 }
863 1000
864} 1001}
865 1002
866void ContactEditor::slotNote() { 1003void ContactEditor::slotNote() {
867 1004
868 dlgNote->showMaximized(); 1005 dlgNote->showMaximized();
869 if ( !dlgNote->exec() ) { 1006 if ( !dlgNote->exec() ) {
870 txtNote->setText( ent.notes() ); 1007 txtNote->setText( ent.notes() );
871 } 1008 }
872} 1009}
873 1010
874void ContactEditor::slotName() { 1011void ContactEditor::slotName() {
875 1012
876 QString tmpName; 1013 QString tmpName;
877 if (useFullName) { 1014 if (useFullName) {
878 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); 1015 txtFirstName->setText( parseName(txtFullName->text(), NAME_F) );
879 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); 1016 txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) );
880 txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); 1017 txtLastName->setText( parseName(txtFullName->text(), NAME_L) );
881 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); 1018 txtSuffix->setText( parseName(txtFullName->text(), NAME_S) );
882 } 1019 }
883 dlgName->showMaximized(); 1020 dlgName->showMaximized();
884 if ( dlgName->exec() ) { 1021 if ( dlgName->exec() ) {
885 1022
886 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text(); 1023 tmpName = txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text();
887 txtFullName->setText( tmpName.simplifyWhiteSpace() ); 1024 txtFullName->setText( tmpName.simplifyWhiteSpace() );
888 slotFullNameChange( txtFullName->text() ); 1025 slotFullNameChange( txtFullName->text() );
889 useFullName = false; 1026 useFullName = false;
890 } 1027 }
891 1028
892} 1029}
893 1030
894void ContactEditor::setNameFocus() { 1031void ContactEditor::setNameFocus() {
895 1032
896 txtFullName->setFocus(); 1033 txtFullName->setFocus();
897 1034
898} 1035}
899 1036
900bool ContactEditor::isEmpty() { 1037bool ContactEditor::isEmpty() {
901 // Test and see if the record should be saved. 1038 // Test and see if the record should be saved.
902 // More strict than the original qtopia, needs name or fileas to save 1039 // More strict than the original qtopia, needs name or fileas to save
903 1040
904 QString t = txtFullName->text(); 1041 QString t = txtFullName->text();
905 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1042 if ( !t.isEmpty() && containsAlphaNum( t ) )
906 return false; 1043 return false;
907 1044
908 t = cmbFileAs->currentText(); 1045 t = cmbFileAs->currentText();
909 if ( !t.isEmpty() && containsAlphaNum( t ) ) 1046 if ( !t.isEmpty() && containsAlphaNum( t ) )
910 return false; 1047 return false;
911 1048
912 return true; 1049 return true;
913 1050
914} 1051}
915 1052
916QString ContactEditor::parseName( const QString fullName, int type ) { 1053QString ContactEditor::parseName( const QString fullName, int type ) {
917 1054
918 QString simplifiedName( fullName.simplifyWhiteSpace() ); 1055 QString simplifiedName( fullName.simplifyWhiteSpace() );
919 QString strFirstName; 1056 QString strFirstName;
920 QString strMiddleName; 1057 QString strMiddleName;
921 QString strLastName; 1058 QString strLastName;
922 QString strSuffix; 1059 QString strSuffix;
923 QString strTitle; 1060 QString strTitle;
924 int commapos; 1061 int commapos;
925 int spCount; 1062 int spCount;
926 int spPos; 1063 int spPos;
927 int spPos2; 1064 int spPos2;
928 1065
929 1066
930 commapos = simplifiedName.find( ',', 0, TRUE); 1067 commapos = simplifiedName.find( ',', 0, TRUE);
931 spCount = simplifiedName.contains( ' ', TRUE ); 1068 spCount = simplifiedName.contains( ' ', TRUE );
932 1069
933 if ( commapos == -1 ) { 1070 if ( commapos == -1 ) {
934 1071
935 switch (spCount) { 1072 switch (spCount) {
936 case 0: 1073 case 0:
937 //return simplifiedName; 1074 //return simplifiedName;
938 if (txtLastName->text() != "") { 1075 if (txtLastName->text() != "") {
939 strLastName = simplifiedName; 1076 strLastName = simplifiedName;
940 break; 1077 break;
941 } 1078 }
942 if (txtMiddleName->text() != "") { 1079 if (txtMiddleName->text() != "") {
943 strMiddleName = simplifiedName; 1080 strMiddleName = simplifiedName;
944 break; 1081 break;
945 } 1082 }
946 if (txtSuffix->text() != "") { 1083 if (txtSuffix->text() != "") {
947 strSuffix = simplifiedName; 1084 strSuffix = simplifiedName;
948 break; 1085 break;
949 } 1086 }
950 strFirstName = simplifiedName; 1087 strFirstName = simplifiedName;
951 break; 1088 break;
952 1089
953 case 1: 1090 case 1:
954 spPos = simplifiedName.find( ' ', 0, TRUE ); 1091 spPos = simplifiedName.find( ' ', 0, TRUE );
955 strFirstName = simplifiedName.left( spPos ); 1092 strFirstName = simplifiedName.left( spPos );
956 strLastName = simplifiedName.mid( spPos + 1 ); 1093 strLastName = simplifiedName.mid( spPos + 1 );
957 break; 1094 break;
958 1095
959 case 2: 1096 case 2:
960 spPos = simplifiedName.find( ' ', 0, TRUE ); 1097 spPos = simplifiedName.find( ' ', 0, TRUE );
961 strFirstName = simplifiedName.left( spPos ); 1098 strFirstName = simplifiedName.left( spPos );
962 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1099 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
963 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1100 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
964 strLastName = simplifiedName.mid( spPos2 + 1 ); 1101 strLastName = simplifiedName.mid( spPos2 + 1 );
965 break; 1102 break;
966 1103
967 case 3: 1104 case 3:
968 spPos = simplifiedName.find( ' ', 0, TRUE ); 1105 spPos = simplifiedName.find( ' ', 0, TRUE );
969 strFirstName = simplifiedName.left( spPos ); 1106 strFirstName = simplifiedName.left( spPos );
970 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1107 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
971 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1108 strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
972 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1109 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
973 strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1110 strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
974 strSuffix = simplifiedName.mid( spPos + 1 ); 1111 strSuffix = simplifiedName.mid( spPos + 1 );
975 break; 1112 break;
976 1113
977 case 4: 1114 case 4:
978 spPos = simplifiedName.find( ' ', 0, TRUE ); 1115 spPos = simplifiedName.find( ' ', 0, TRUE );
979 strTitle = simplifiedName.left( spPos ); 1116 strTitle = simplifiedName.left( spPos );
980 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1117 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
981 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1118 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
982 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1119 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
983 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1120 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
984 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1121 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
985 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1122 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
986 strSuffix = simplifiedName.mid( spPos2 + 1 ); 1123 strSuffix = simplifiedName.mid( spPos2 + 1 );
987 break; 1124 break;
988 1125
989 default: 1126 default:
990 spPos = simplifiedName.find( ' ', 0, TRUE ); 1127 spPos = simplifiedName.find( ' ', 0, TRUE );
991 strTitle = simplifiedName.left( spPos ); 1128 strTitle = simplifiedName.left( spPos );
992 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1129 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
993 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1130 strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
994 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); 1131 spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE );
995 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 ); 1132 strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos2 );
996 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); 1133 spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE );
997 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); 1134 strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos );
@@ -1259,355 +1396,358 @@ void ContactEditor::setEntry( const OContact &entry ) {
1259 if ( *it == "Emails" ) 1396 if ( *it == "Emails" )
1260 *itV = ent.emailList().join(", "); // :SX 1397 *itV = ent.emailList().join(", "); // :SX
1261 1398
1262 if ( *it == "Home Phone" ) 1399 if ( *it == "Home Phone" )
1263 *itV = ent.homePhone(); 1400 *itV = ent.homePhone();
1264/* 1401/*
1265 if ( *it == "Home 2 Phone" ) 1402 if ( *it == "Home 2 Phone" )
1266 *itV = ent.home2Phone(); 1403 *itV = ent.home2Phone();
1267*/ 1404*/
1268 if ( *it == "Home Fax" ) 1405 if ( *it == "Home Fax" )
1269 *itV = ent.homeFax(); 1406 *itV = ent.homeFax();
1270 1407
1271 if ( *it == "Home Mobile" ) 1408 if ( *it == "Home Mobile" )
1272 *itV = ent.homeMobile(); 1409 *itV = ent.homeMobile();
1273/* 1410/*
1274 if ( *it == "Car Phone" ) 1411 if ( *it == "Car Phone" )
1275 *itV = ent.carPhone(); 1412 *itV = ent.carPhone();
1276 1413
1277 if ( *it == "ISDN Phone" ) 1414 if ( *it == "ISDN Phone" )
1278 *itV = ent.ISDNPhone(); 1415 *itV = ent.ISDNPhone();
1279 1416
1280 if ( *it == "Other Phone" ) 1417 if ( *it == "Other Phone" )
1281 *itV = ent.otherPhone(); 1418 *itV = ent.otherPhone();
1282*/ 1419*/
1283 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1420 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1284 *itV = ent.businessPager(); 1421 *itV = ent.businessPager();
1285/* 1422/*
1286 if ( *it == "Home Pager") 1423 if ( *it == "Home Pager")
1287 *itV = ent.homePager(); 1424 *itV = ent.homePager();
1288 1425
1289 if ( *it == "AIM IM" ) 1426 if ( *it == "AIM IM" )
1290 *itV = ent.AIMIM(); 1427 *itV = ent.AIMIM();
1291 1428
1292 if ( *it == "ICQ IM" ) 1429 if ( *it == "ICQ IM" )
1293 *itV = ent.ICQIM(); 1430 *itV = ent.ICQIM();
1294 1431
1295 if ( *it == "Jabber IM" ) 1432 if ( *it == "Jabber IM" )
1296 *itV = ent.jabberIM(); 1433 *itV = ent.jabberIM();
1297 1434
1298 if ( *it == "MSN IM" ) 1435 if ( *it == "MSN IM" )
1299 *itV = ent.MSNIM(); 1436 *itV = ent.MSNIM();
1300 1437
1301 if ( *it == "Yahoo IM" ) 1438 if ( *it == "Yahoo IM" )
1302 *itV = ent.yahooIM(); 1439 *itV = ent.yahooIM();
1303*/ 1440*/
1304 if ( *it == "Home Web Page" ) 1441 if ( *it == "Home Web Page" )
1305 *itV = ent.homeWebpage(); 1442 *itV = ent.homeWebpage();
1306 1443
1307 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1444 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1308 *itV = ent.businessWebpage(); 1445 *itV = ent.businessWebpage();
1309 1446
1310 1447
1311 } 1448 }
1312 1449
1313 1450
1314 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); 1451 cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") );
1315 1452
1316 QString gender = ent.gender(); 1453 QString gender = ent.gender();
1317 cmbGender->setCurrentItem( gender.toInt() ); 1454 cmbGender->setCurrentItem( gender.toInt() );
1318 1455
1319 txtNote->setText( ent.notes() ); 1456 txtNote->setText( ent.notes() );
1320 1457
1321 slotCmbChooser1Change( cmbChooserField1->currentItem() ); 1458 slotCmbChooser1Change( cmbChooserField1->currentItem() );
1322 slotCmbChooser2Change( cmbChooserField2->currentItem() ); 1459 slotCmbChooser2Change( cmbChooserField2->currentItem() );
1323 slotCmbChooser3Change( cmbChooserField3->currentItem() ); 1460 slotCmbChooser3Change( cmbChooserField3->currentItem() );
1324 1461
1325 slotAddressTypeChange( cmbAddress->currentItem() ); 1462 slotAddressTypeChange( cmbAddress->currentItem() );
1326 1463
1327 // loadFields(); :SX 1464 // loadFields(); :SX
1328 updateDatePicker(); 1465 updateDatePicker();
1329} 1466}
1330void ContactEditor::updateDatePicker() 1467void ContactEditor::updateDatePicker()
1331{ 1468{
1332 // Set DatePicker 1469 // Set DatePicker
1333 if ( !ent.birthday().isNull() ){ 1470 if ( !ent.birthday().isNull() ){
1334 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) ); 1471 birthdayButton->setText( TimeString::numberDateString( ent.birthday() ) );
1335 birthdayPicker->setDate( ent.birthday() ); 1472 birthdayPicker->setDate( ent.birthday() );
1336 } else 1473 } else
1337 birthdayButton->setText( tr ("Unknown") ); 1474 birthdayButton->setText( tr ("Unknown") );
1338 1475
1339 if ( !ent.anniversary().isNull() ){ 1476 if ( !ent.anniversary().isNull() ){
1340 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) ); 1477 anniversaryButton->setText( TimeString::numberDateString( ent.anniversary() ) );
1341 anniversaryPicker->setDate( ent.anniversary() ); 1478 anniversaryPicker->setDate( ent.anniversary() );
1342 } else 1479 } else
1343 anniversaryButton->setText( tr ("Unknown") ); 1480 anniversaryButton->setText( tr ("Unknown") );
1344 1481
1345} 1482}
1346 1483
1347void ContactEditor::saveEntry() { 1484void ContactEditor::saveEntry() {
1348 1485
1349 if ( useFullName ) { 1486 if ( useFullName ) {
1350 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); 1487 txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) );
1351 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); 1488 txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) );
1352 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); 1489 txtLastName->setText( parseName( txtFullName->text(), NAME_L ) );
1353 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); 1490 txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) );
1354 1491
1355 useFullName = false; 1492 useFullName = false;
1356 } 1493 }
1357 1494
1358 ent.setFirstName( txtFirstName->text() ); 1495 ent.setFirstName( txtFirstName->text() );
1359 ent.setLastName( txtLastName->text() ); 1496 ent.setLastName( txtLastName->text() );
1360 ent.setMiddleName( txtMiddleName->text() ); 1497 ent.setMiddleName( txtMiddleName->text() );
1361 ent.setSuffix( txtSuffix->text() ); 1498 ent.setSuffix( txtSuffix->text() );
1362 1499
1363 ent.setFileAs( cmbFileAs->currentText() ); 1500 ent.setFileAs( cmbFileAs->currentText() );
1364 1501
1365 ent.setCategories( cmbCat->currentCategories() ); 1502 ent.setCategories( cmbCat->currentCategories() );
1366 1503
1367 1504
1368 //if (hasTitle) 1505 //if (hasTitle)
1369 ent.setJobTitle( txtJobTitle->text() ); 1506 ent.setJobTitle( txtJobTitle->text() );
1370 1507
1371 //if (hasCompany) 1508 //if (hasCompany)
1372 ent.setCompany( txtOrganization->text() ); 1509 ent.setCompany( txtOrganization->text() );
1373 1510
1374 //if (hasNotes) 1511 //if (hasNotes)
1375 ent.setNotes( txtNote->text() ); 1512 ent.setNotes( txtNote->text() );
1376 1513
1377 //if (hasStreet) { 1514 //if (hasStreet) {
1378 ent.setHomeStreet( slHomeAddress[0] ); 1515 ent.setHomeStreet( slHomeAddress[0] );
1379 ent.setBusinessStreet( slBusinessAddress[0] ); 1516 ent.setBusinessStreet( slBusinessAddress[0] );
1380 //} 1517 //}
1381 1518
1382 //if (hasCity) { 1519 //if (hasCity) {
1383 ent.setHomeCity( slHomeAddress[3] ); 1520 ent.setHomeCity( slHomeAddress[3] );
1384 ent.setBusinessCity( slBusinessAddress[3] ); 1521 ent.setBusinessCity( slBusinessAddress[3] );
1385 //} 1522 //}
1386 1523
1387 //if (hasState) { 1524 //if (hasState) {
1388 ent.setHomeState( slHomeAddress[4] ); 1525 ent.setHomeState( slHomeAddress[4] );
1389 ent.setBusinessState( slBusinessAddress[4] ); 1526 ent.setBusinessState( slBusinessAddress[4] );
1390 //} 1527 //}
1391 1528
1392 //if (hasZip) { 1529 //if (hasZip) {
1393 ent.setHomeZip( slHomeAddress[5] ); 1530 ent.setHomeZip( slHomeAddress[5] );
1394 ent.setBusinessZip( slBusinessAddress[5] ); 1531 ent.setBusinessZip( slBusinessAddress[5] );
1395 //} 1532 //}
1396 1533
1397 //if (hasCountry) { 1534 //if (hasCountry) {
1398 ent.setHomeCountry( slHomeAddress[6] ); 1535 ent.setHomeCountry( slHomeAddress[6] );
1399 ent.setBusinessCountry( slBusinessAddress[6] ); 1536 ent.setBusinessCountry( slBusinessAddress[6] );
1400 //} 1537 //}
1401 1538
1402 QStringList::ConstIterator it; 1539 QStringList::ConstIterator it;
1403 QListIterator<QLineEdit> itLE( listValue ); 1540 QListIterator<QLineEdit> itLE( listValue );
1404 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) { 1541 for ( it = slDynamicEntries.begin(); itLE.current() && it != slDynamicEntries.end(); ++it, ++itLE) {
1405 1542
1406 if ( *it == "Department" ) 1543 if ( *it == "Department" )
1407 ent.setDepartment( (*itLE)->text() ); 1544 ent.setDepartment( (*itLE)->text() );
1408 1545
1409 if ( *it == "Company" ) 1546 if ( *it == "Company" )
1410 ent.setCompany( (*itLE)->text() ); 1547 ent.setCompany( (*itLE)->text() );
1411 1548
1412 if ( *it == "Office" ) 1549 if ( *it == "Office" )
1413 ent.setOffice( (*itLE)->text() ); 1550 ent.setOffice( (*itLE)->text() );
1414 1551
1415 if ( *it == "Profession" ) 1552 if ( *it == "Profession" )
1416 ent.setProfession( (*itLE)->text() ); 1553 ent.setProfession( (*itLE)->text() );
1417 1554
1418 if ( *it == "Assistant" ) 1555 if ( *it == "Assistant" )
1419 ent.setAssistant( (*itLE)->text() ); 1556 ent.setAssistant( (*itLE)->text() );
1420 1557
1421 if ( *it == "Manager" ) 1558 if ( *it == "Manager" )
1422 ent.setManager( (*itLE)->text() ); 1559 ent.setManager( (*itLE)->text() );
1423 1560
1424 if ( *it == "Spouse" ) 1561 if ( *it == "Spouse" )
1425 ent.setSpouse( (*itLE)->text() ); 1562 ent.setSpouse( (*itLE)->text() );
1426 1563
1427 if ( *it == "Nickname" ) 1564 if ( *it == "Nickname" )
1428 ent.setNickname( (*itLE)->text() ); 1565 ent.setNickname( (*itLE)->text() );
1429 1566
1430 if ( *it == "Children" ) 1567 if ( *it == "Children" )
1431 ent.setChildren( (*itLE)->text() ); 1568 ent.setChildren( (*itLE)->text() );
1432 1569
1433 } 1570 }
1434 1571
1435 1572
1436 QStringList::ConstIterator itV; 1573 QStringList::ConstIterator itV;
1437 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) { 1574 for ( it = slChooserNames.begin(), itV = slChooserValues.begin(); it != slChooserNames.end(); ++it, ++itV ) {
1438 1575
1439 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) ) 1576 if ( ( *it == "Business Phone" ) || ( *it == "Work Phone" ) )
1440 ent.setBusinessPhone( *itV ); 1577 ent.setBusinessPhone( *itV );
1441 1578
1442 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) ) 1579 if ( ( *it == "Business Fax" ) || ( *it == "Work Fax" ) )
1443 ent.setBusinessFax( *itV ); 1580 ent.setBusinessFax( *itV );
1444 1581
1445 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) ) 1582 if ( ( *it == "Business Mobile" ) || ( *it == "Work Mobile" ) )
1446 ent.setBusinessMobile( *itV ); 1583 ent.setBusinessMobile( *itV );
1447 1584
1448 if ( *it == "Emails" ){ 1585 if ( *it == "Emails" ){
1449 QString allemail; 1586 QString allemail;
1450 QString defaultmail; 1587 QString defaultmail;
1451 parseEmailFrom( *itV, defaultmail, allemail ); 1588 parseEmailFrom( emails.join(","), defaultmail, allemail );
1452 // ent.clearEmails(); 1589 if ( defaultEmail.isEmpty() ){
1453 // ent.setDefaultEmail( defaultmail ); 1590 qWarning("Default email was not set by user!");
1591 qWarning("Using first email in list: %s", defaultmail.latin1());
1592 ent.setDefaultEmail( defaultmail );
1593 }
1454 ent.setEmails( allemail ); 1594 ent.setEmails( allemail );
1455 } 1595 }
1456 1596
1457 if ( *it == "Default Email") 1597 if ( *it == "Default Email")
1458 ent.setDefaultEmail( *itV ); 1598 ent.setDefaultEmail( defaultEmail /* *itV */ );
1459 1599
1460 if ( *it == "Home Phone" ) 1600 if ( *it == "Home Phone" )
1461 ent.setHomePhone( *itV ); 1601 ent.setHomePhone( *itV );
1462 1602
1463 if ( *it == "Home Fax" ) 1603 if ( *it == "Home Fax" )
1464 ent.setHomeFax( *itV ); 1604 ent.setHomeFax( *itV );
1465 1605
1466 if ( *it == "Home Mobile" ) 1606 if ( *it == "Home Mobile" )
1467 ent.setHomeMobile( *itV ); 1607 ent.setHomeMobile( *itV );
1468 1608
1469 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) ) 1609 if ( ( *it == "Business Pager" ) || ( *it == "Work Pager" ) )
1470 ent.setBusinessPager( *itV ); 1610 ent.setBusinessPager( *itV );
1471 1611
1472 if ( *it == "Home Web Page" ) 1612 if ( *it == "Home Web Page" )
1473 ent.setHomeWebpage( *itV ); 1613 ent.setHomeWebpage( *itV );
1474 1614
1475 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) ) 1615 if ( ( *it == "Business WebPage" ) || ( *it == "Work Web Page" ) )
1476 ent.setBusinessWebpage( *itV ); 1616 ent.setBusinessWebpage( *itV );
1477 1617
1478 1618
1479 } 1619 }
1480 1620
1481 int gender = cmbGender->currentItem(); 1621 int gender = cmbGender->currentItem();
1482 ent.setGender( QString::number( gender ) ); 1622 ent.setGender( QString::number( gender ) );
1483 1623
1484 QString str = txtNote->text(); 1624 QString str = txtNote->text();
1485 if ( !str.isNull() ) 1625 if ( !str.isNull() )
1486 ent.setNotes( str ); 1626 ent.setNotes( str );
1487 1627
1488} 1628}
1489 1629
1490void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 1630void parseEmailFrom( const QString &txt, QString &strDefaultEmail,
1491 QString &strAll ) 1631 QString &strAll )
1492{ 1632{
1493 int where, 1633 int where,
1494 start; 1634 start;
1495 if ( txt.isEmpty() ) 1635 if ( txt.isEmpty() )
1496 return; 1636 return;
1497 // find the first 1637 // find the first
1498 where = txt.find( ',' ); 1638 where = txt.find( ',' );
1499 if ( where < 0 ) { 1639 if ( where < 0 ) {
1500 strDefaultEmail = txt; 1640 strDefaultEmail = txt;
1501 strAll = txt; 1641 strAll = txt;
1502 } else { 1642 } else {
1503 strDefaultEmail = txt.left( where ).stripWhiteSpace(); 1643 strDefaultEmail = txt.left( where ).stripWhiteSpace();
1504 strAll = strDefaultEmail; 1644 strAll = strDefaultEmail;
1505 while ( where > -1 ) { 1645 while ( where > -1 ) {
1506 strAll.append(" "); 1646 strAll.append(" ");
1507 start = where; 1647 start = where;
1508 where = txt.find( ',', where + 1 ); 1648 where = txt.find( ',', where + 1 );
1509 if ( where > - 1 ) 1649 if ( where > - 1 )
1510 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); 1650 strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() );
1511 else // grab until the end... 1651 else // grab until the end...
1512 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); 1652 strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() );
1513 } 1653 }
1514 } 1654 }
1515} 1655}
1516 1656
1517void parseEmailTo( const QString &strDefaultEmail, 1657void parseEmailTo( const QString &strDefaultEmail,
1518 const QString &strOtherEmail, QString &strBack ) 1658 const QString &strOtherEmail, QString &strBack )
1519{ 1659{
1520 // create a comma dilimeted set of emails... 1660 // create a comma dilimeted set of emails...
1521 // use the power of short circuiting... 1661 // use the power of short circuiting...
1522 bool foundDefault = false; 1662 bool foundDefault = false;
1523 QString strTmp; 1663 QString strTmp;
1524 int start = 0; 1664 int start = 0;
1525 int where; 1665 int where;
1526 // start at the beginng. 1666 // start at the beginng.
1527 strBack = strDefaultEmail; 1667 strBack = strDefaultEmail;
1528 where = 0; 1668 where = 0;
1529 while ( where > -1 ) { 1669 while ( where > -1 ) {
1530 start = where; 1670 start = where;
1531 where = strOtherEmail.find( ' ', where + 1 ); 1671 where = strOtherEmail.find( ' ', where + 1 );
1532 if ( where > 0 ) { 1672 if ( where > 0 ) {
1533 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); 1673 strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace();
1534 } else 1674 } else
1535 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); 1675 strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace();
1536 if ( foundDefault || strTmp != strDefaultEmail ) { 1676 if ( foundDefault || strTmp != strDefaultEmail ) {
1537 strBack.append( ", " ); 1677 strBack.append( ", " );
1538 strBack.append( strTmp ); 1678 strBack.append( strTmp );
1539 } else 1679 } else
1540 foundDefault = true; 1680 foundDefault = true;
1541 } 1681 }
1542} 1682}
1543 1683
1544 1684
1545static inline bool containsAlphaNum( const QString &str ) 1685static inline bool containsAlphaNum( const QString &str )
1546{ 1686{
1547 int i, 1687 int i,
1548 count = str.length(); 1688 count = str.length();
1549 for ( i = 0; i < count; i++ ) 1689 for ( i = 0; i < count; i++ )
1550 if ( !str[i].isSpace() ) 1690 if ( !str[i].isSpace() )
1551 return TRUE; 1691 return TRUE;
1552 return FALSE; 1692 return FALSE;
1553} 1693}
1554 1694
1555static inline bool constainsWhiteSpace( const QString &str ) 1695static inline bool constainsWhiteSpace( const QString &str )
1556{ 1696{
1557 int i, 1697 int i,
1558 count = str.length(); 1698 count = str.length();
1559 for (i = 0; i < count; i++ ) 1699 for (i = 0; i < count; i++ )
1560 if ( str[i].isSpace() ) 1700 if ( str[i].isSpace() )
1561 return TRUE; 1701 return TRUE;
1562 return FALSE; 1702 return FALSE;
1563} 1703}
1564 1704
1565void ContactEditor::setPersonalView( bool personal ) 1705void ContactEditor::setPersonalView( bool personal )
1566{ 1706{
1567 m_personalView = personal; 1707 m_personalView = personal;
1568 1708
1569 // Currently disbled due to the fact that 1709 // Currently disbled due to the fact that
1570 // show will not work... 1710 // show will not work...
1571 return; 1711 return;
1572 1712
1573 if ( personal ){ 1713 if ( personal ){
1574 cmbCat->hide(); 1714 cmbCat->hide();
1575 labCat->hide(); 1715 labCat->hide();
1576 1716
1577 } else{ 1717 } else{
1578 cmbCat->show(); 1718 cmbCat->show();
1579 labCat->show(); 1719 labCat->show();
1580 } 1720 }
1581} 1721}
1582 1722
1583void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day) 1723void ContactEditor::slotAnniversaryDateChanged( int year, int month, int day)
1584{ 1724{
1585 QDate date; 1725 QDate date;
1586 date.setYMD( year, month, day ); 1726 date.setYMD( year, month, day );
1587 QString dateString = TimeString::numberDateString( date ); 1727 QString dateString = TimeString::numberDateString( date );
1588 anniversaryButton->setText( dateString ); 1728 anniversaryButton->setText( dateString );
1589 ent.setAnniversary ( date ); 1729 ent.setAnniversary ( date );
1590} 1730}
1591 1731
1592void ContactEditor::slotBirthdayDateChanged( int year, int month, int day) 1732void ContactEditor::slotBirthdayDateChanged( int year, int month, int day)
1593{ 1733{
1594 QDate date; 1734 QDate date;
1595 date.setYMD( year, month, day ); 1735 date.setYMD( year, month, day );
1596 QString dateString = TimeString::numberDateString( date ); 1736 QString dateString = TimeString::numberDateString( date );
1597 birthdayButton->setText( dateString ); 1737 birthdayButton->setText( dateString );
1598 ent.setBirthday ( date ); 1738 ent.setBirthday ( date );
1599} 1739}
1600 1740
1601void ContactEditor::slotRemoveBirthday() 1741void ContactEditor::slotRemoveBirthday()
1602{ 1742{
1603 qWarning("void ContactEditor::slotRemoveBirthday()"); 1743 qWarning("void ContactEditor::slotRemoveBirthday()");
1604 ent.setBirthday( QDate() ); 1744 ent.setBirthday( QDate() );
1605 updateDatePicker(); 1745 updateDatePicker();
1606} 1746}
1607 1747
1608void ContactEditor::slotRemoveAnniversary() 1748void ContactEditor::slotRemoveAnniversary()
1609{ 1749{
1610 qWarning("void ContactEditor::slotRemoveAnniversary()"); 1750 qWarning("void ContactEditor::slotRemoveAnniversary()");
1611 ent.setAnniversary( QDate() ); 1751 ent.setAnniversary( QDate() );
1612 updateDatePicker(); 1752 updateDatePicker();
1613} 1753}
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h
index bcef679..4fa48d1 100644
--- a/core/pim/addressbook/contacteditor.h
+++ b/core/pim/addressbook/contacteditor.h
@@ -1,179 +1,181 @@
1/* 1/*
2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> 2 * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org>
3 * 3 *
4 * This file is an add-on for the OPIE Palmtop Environment 4 * This file is an add-on for the OPIE Palmtop Environment
5 * 5 *
6 * This file may be distributed and/or modified under the terms of the 6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software 7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging 8 * Foundation and appearing in the file LICENSE.GPL included in the pacakaging
9 * of this file. 9 * of this file.
10 * 10 *
11 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 * 13 *
14 * 14 *
15 * This is a rewrite of the abeditor.h file, modified to provide a more 15 * This is a rewrite of the abeditor.h file, modified to provide a more
16 * intuitive interface to TrollTech's original Address Book editor. This 16 * intuitive interface to TrollTech's original Address Book editor. This
17 * is made to operate exactly in interface with the exception of name. 17 * is made to operate exactly in interface with the exception of name.
18 * 18 *
19 */ 19 */
20 20
21#ifndef CONTACTEDITOR_H 21#ifndef CONTACTEDITOR_H
22#define CONTACTEDITOR_H 22#define CONTACTEDITOR_H
23 23
24#include <opie/ocontact.h> 24#include <opie/ocontact.h>
25 25
26#include <qpe/datebookmonth.h> 26#include <qpe/datebookmonth.h>
27 27
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qlist.h> 29#include <qlist.h>
30#include <qmap.h> 30#include <qmap.h>
31#include <qstringlist.h> 31#include <qstringlist.h>
32 32
33const int NAME_LF = 0; 33const int NAME_LF = 0;
34const int NAME_LFM = 1; 34const int NAME_LFM = 1;
35const int NAME_FL = 2; 35const int NAME_FL = 2;
36const int NAME_FMLS = 3; 36const int NAME_FMLS = 3;
37 37
38const int NAME_F = 4; 38const int NAME_F = 4;
39const int NAME_M = 5; 39const int NAME_M = 5;
40const int NAME_L = 6; 40const int NAME_L = 6;
41const int NAME_S = 7; 41const int NAME_S = 7;
42 42
43 43
44class QScrollView; 44class QScrollView;
45class QTabWidget; 45class QTabWidget;
46class QMultiLineEdit; 46class QMultiLineEdit;
47class QLineEdit; 47class QLineEdit;
48class QComboBox; 48class QComboBox;
49class QPushButton; 49class QPushButton;
50class CategorySelect; 50class CategorySelect;
51class QLabel; 51class QLabel;
52 52
53class ContactEditor : public QDialog { 53class ContactEditor : public QDialog {
54 Q_OBJECT 54 Q_OBJECT
55 55
56 public: 56 public:
57 ContactEditor(const OContact &entry, 57 ContactEditor(const OContact &entry,
58 QWidget *parent = 0, 58 QWidget *parent = 0,
59 const char *name = 0, 59 const char *name = 0,
60 WFlags fl = 0 ); 60 WFlags fl = 0 );
61 ~ContactEditor(); 61 ~ContactEditor();
62 void setNameFocus(); 62 void setNameFocus();
63 void setPersonalView( bool personal = true ); 63 void setPersonalView( bool personal = true );
64 OContact entry() const { return ent; } 64 OContact entry() const { return ent; }
65 65
66 public slots: 66 public slots:
67 void slotNote(); 67 void slotNote();
68 void slotName(); 68 void slotName();
69 void setEntry(const OContact &entry); 69 void setEntry(const OContact &entry);
70 70
71 protected slots: 71 protected slots:
72 void accept(); 72 void accept();
73 73
74 private: 74 private:
75 void init(); 75 void init();
76 void saveEntry(); 76 void saveEntry();
77 bool isEmpty(); 77 bool isEmpty();
78 void cleanupFields(); 78 void cleanupFields();
79 void updateDatePicker(); 79 void updateDatePicker();
80 QString parseName( QString fullName, int type ); 80 QString parseName( QString fullName, int type );
81 void chooserError( int index );
81 private slots: 82 private slots:
82 void slotChooser1Change( const QString &textChanged ); 83 void slotChooser1Change( const QString &textChanged );
83 void slotChooser2Change( const QString &textChanged ); 84 void slotChooser2Change( const QString &textChanged );
84 void slotChooser3Change( const QString &textChanged ); 85 void slotChooser3Change( const QString &textChanged );
85 void slotChooser4Change( const QString &textChanged ); 86 void slotChooser4Change( const QString &textChanged );
86 void slotCmbChooser1Change( int index ); 87 void slotCmbChooser1Change( int index );
87 void slotCmbChooser2Change( int index ); 88 void slotCmbChooser2Change( int index );
88 void slotCmbChooser3Change( int index ); 89 void slotCmbChooser3Change( int index );
89 void slotCmbChooser4Change( int index ); 90 void slotCmbChooser4Change( int index );
90 void slotAddressTypeChange( int index ); 91 void slotAddressTypeChange( int index );
91 void slotAddressChange( const QString &textChanged ); 92 void slotAddressChange( const QString &textChanged );
92 void slotAddress2Change( const QString &textChanged ); 93 void slotAddress2Change( const QString &textChanged );
93 void slotPOBoxChange( const QString &textChanged ); 94 void slotPOBoxChange( const QString &textChanged );
94 void slotCityChange( const QString &textChanged ); 95 void slotCityChange( const QString &textChanged );
95 void slotStateChange( const QString &textChanged ); 96 void slotStateChange( const QString &textChanged );
96 void slotZipChange( const QString &textChanged ); 97 void slotZipChange( const QString &textChanged );
97 void slotCountryChange( const QString &textChanged ); 98 void slotCountryChange( const QString &textChanged );
98 void slotFullNameChange( const QString &textChanged ); 99 void slotFullNameChange( const QString &textChanged );
99 void slotAnniversaryDateChanged( int year, int month, int day); 100 void slotAnniversaryDateChanged( int year, int month, int day);
100 void slotBirthdayDateChanged( int year, int month, int day); 101 void slotBirthdayDateChanged( int year, int month, int day);
101 void slotRemoveBirthday(); 102 void slotRemoveBirthday();
102 void slotRemoveAnniversary(); 103 void slotRemoveAnniversary();
103 void defaultEmailChanged(int); 104 void defaultEmailChanged(int);
104 105
105 private: 106 private:
106 int defaultEmailChooserPosition; 107 int defaultEmailChooserPosition;
107 void populateDefaultEmailCmb(); 108 void populateDefaultEmailCmb();
108 void chooserChange( const QString&, int , QLineEdit*, int ); 109 void chooserChange( const QString&, int , QLineEdit*, int );
110 bool cmbChooserChange( int , QLineEdit*, int );
109 111
110 bool useFullName; 112 bool useFullName;
111 113
112 OContact ent; 114 OContact ent;
113 115
114 QDialog *dlgNote; 116 QDialog *dlgNote;
115 QDialog *dlgName; 117 QDialog *dlgName;
116 118
117 QList<QLineEdit> listValue; 119 QList<QLineEdit> listValue;
118 QList<QLabel> listName; 120 QList<QLabel> listName;
119 121
120 QStringList slDynamicEntries; 122 QStringList slDynamicEntries;
121 QStringList trlDynamicEntries; 123 QStringList trlDynamicEntries;
122 124
123 bool m_personalView; 125 bool m_personalView;
124 126
125 QStringList slHomeAddress; 127 QStringList slHomeAddress;
126 QStringList slBusinessAddress; 128 QStringList slBusinessAddress;
127 QStringList slChooserNames; 129 QStringList slChooserNames;
128 QStringList slChooserValues; 130 QStringList slChooserValues;
129 QStringList emails; 131 QStringList emails;
130 QString defaultEmail; 132 QString defaultEmail;
131 133
132 QMultiLineEdit *txtNote; 134 QMultiLineEdit *txtNote;
133 QLabel *lblNote; 135 QLabel *lblNote;
134 136
135 //QLineEdit *txtTitle; 137 //QLineEdit *txtTitle;
136 QLineEdit *txtFirstName; 138 QLineEdit *txtFirstName;
137 QLineEdit *txtMiddleName; 139 QLineEdit *txtMiddleName;
138 QLineEdit *txtLastName; 140 QLineEdit *txtLastName;
139 QLineEdit *txtSuffix; 141 QLineEdit *txtSuffix;
140 142
141 QTabWidget *tabMain; 143 QTabWidget *tabMain;
142 QScrollView *svGeneral; 144 QScrollView *svGeneral;
143 QPushButton *btnFullName; 145 QPushButton *btnFullName;
144 QPushButton *btnNote; 146 QPushButton *btnNote;
145 QLineEdit *txtFullName; 147 QLineEdit *txtFullName;
146 QLineEdit *txtJobTitle; 148 QLineEdit *txtJobTitle;
147 QLineEdit *txtOrganization; 149 QLineEdit *txtOrganization;
148 QLineEdit *txtChooserField1; 150 QLineEdit *txtChooserField1;
149 QLineEdit *txtChooserField2; 151 QLineEdit *txtChooserField2;
150 QLineEdit *txtChooserField3; 152 QLineEdit *txtChooserField3;
151 QLineEdit *txtChooserField4; 153 QLineEdit *txtChooserField4;
152 QComboBox *cmbChooserField1; 154 QComboBox *cmbChooserField1;
153 QComboBox *cmbChooserField2; 155 QComboBox *cmbChooserField2;
154 QComboBox *cmbChooserField3; 156 QComboBox *cmbChooserField3;
155 QComboBox *cmbChooserField4; 157 QComboBox *cmbChooserField4;
156 QComboBox *cmbDefaultEmail; 158 QComboBox *cmbDefaultEmail;
157 QComboBox *cmbFileAs; 159 QComboBox *cmbFileAs;
158 CategorySelect *cmbCat; 160 CategorySelect *cmbCat;
159 QLabel *labCat; 161 QLabel *labCat;
160 162
161 QScrollView *svAddress; 163 QScrollView *svAddress;
162 QLineEdit *txtAddress; 164 QLineEdit *txtAddress;
163 //QLineEdit *txtAddress2; 165 //QLineEdit *txtAddress2;
164 //QLineEdit *txtPOBox; 166 //QLineEdit *txtPOBox;
165 QLineEdit *txtCity; 167 QLineEdit *txtCity;
166 QLineEdit *txtState; 168 QLineEdit *txtState;
167 QLineEdit *txtZip; 169 QLineEdit *txtZip;
168 QComboBox *cmbAddress; 170 QComboBox *cmbAddress;
169 QComboBox *cmbCountry; 171 QComboBox *cmbCountry;
170 172
171 QScrollView *svDetails; 173 QScrollView *svDetails;
172 QComboBox *cmbGender; 174 QComboBox *cmbGender;
173 DateBookMonth* birthdayPicker; 175 DateBookMonth* birthdayPicker;
174 QToolButton* birthdayButton; 176 QToolButton* birthdayButton;
175 DateBookMonth* anniversaryPicker; 177 DateBookMonth* anniversaryPicker;
176 QToolButton* anniversaryButton; 178 QToolButton* anniversaryButton;
177 }; 179 };
178 180
179#endif 181#endif