-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index 0e752ca..6edab2c 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -1,1387 +1,1406 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2002 Michael R. Crawford <mike@tuxnami.org> | ||
3 | * | ||
4 | * This file is an add-on for the OPIE Palmtop Environment | ||
5 | * | ||
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 | ||
8 | * Foundation and appearing in the file LICENSE.GPL included in the pacakaging | ||
9 | * of this file. | ||
10 | * | ||
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. | ||
13 | * | ||
14 | * | ||
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 | ||
17 | * is made to operate exactly in interface with the exception of name. | ||
18 | * | ||
19 | */ | ||
1 | 20 | ||
2 | #include "contacteditor.h" | 21 | #include "contacteditor.h" |
3 | #include "addresspicker.h" | 22 | #include "addresspicker.h" |
4 | 23 | ||
5 | #include <qpe/categoryselect.h> | 24 | #include <qpe/categoryselect.h> |
6 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
7 | #include <qpe/qpedialog.h> | 26 | #include <qpe/qpedialog.h> |
8 | 27 | ||
9 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
10 | #include <qlabel.h> | 29 | #include <qlabel.h> |
11 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
12 | #include <qlayout.h> | 31 | #include <qlayout.h> |
13 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
14 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
15 | #include <qscrollview.h> | 34 | #include <qscrollview.h> |
16 | #include <qtoolbutton.h> | 35 | #include <qtoolbutton.h> |
17 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
18 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
19 | #include <qvaluelist.h> | 38 | #include <qvaluelist.h> |
20 | 39 | ||
21 | static inline bool containsAlphaNum( const QString &str ); | 40 | static inline bool containsAlphaNum( const QString &str ); |
22 | static inline bool constainsWhiteSpace( const QString &str ); | 41 | static inline bool constainsWhiteSpace( const QString &str ); |
23 | 42 | ||
24 | // helper functions, convert our comma delimited list to proper | 43 | // helper functions, convert our comma delimited list to proper |
25 | // file format... | 44 | // file format... |
26 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
27 | QString &strAll ); | 46 | QString &strAll ); |
28 | 47 | ||
29 | // helper convert from file format to comma delimited... | 48 | // helper convert from file format to comma delimited... |
30 | void parseEmailTo( const QString &strDefaultEmail, | 49 | void parseEmailTo( const QString &strDefaultEmail, |
31 | const QString &strOtherEmail, QString &strBack ); | 50 | const QString &strOtherEmail, QString &strBack ); |
32 | 51 | ||
33 | ContactEditor::ContactEditor(const Contact &entry, | 52 | ContactEditor::ContactEditor(const Contact &entry, |
34 | const QValueList<int> *newOrderedValues, | 53 | const QValueList<int> *newOrderedValues, |
35 | QStringList *slNewOrdered, | 54 | QStringList *slNewOrdered, |
36 | QWidget *parent = 0, | 55 | QWidget *parent = 0, |
37 | const char *name = 0, | 56 | const char *name = 0, |
38 | WFlags fl = 0 ) | 57 | WFlags fl = 0 ) |
39 | : QDialog( parent, name, TRUE, fl ), | 58 | : QDialog( parent, name, TRUE, fl ), |
40 | orderedValues( newOrderedValues ), | 59 | orderedValues( newOrderedValues ), |
41 | slOrdered( slNewOrdered ) | 60 | slOrdered( slNewOrdered ) |
42 | { | 61 | { |
43 | 62 | ||
44 | init(); | 63 | init(); |
45 | initMap(); | 64 | initMap(); |
46 | setEntry( entry ); | 65 | setEntry( entry ); |
47 | qDebug("finish"); | 66 | qDebug("finish"); |
48 | } | 67 | } |
49 | 68 | ||
50 | ContactEditor::~ContactEditor() { | 69 | ContactEditor::~ContactEditor() { |
51 | } | 70 | } |
52 | 71 | ||
53 | void ContactEditor::init() { | 72 | void ContactEditor::init() { |
54 | 73 | ||
55 | useFullName = TRUE; | 74 | useFullName = TRUE; |
56 | 75 | ||
57 | int i = 0; | 76 | int i = 0; |
58 | 77 | ||
59 | slHomeAddress = new QStringList; | 78 | slHomeAddress = new QStringList; |
60 | slBusinessAddress = new QStringList; | 79 | slBusinessAddress = new QStringList; |
61 | slChooserNames = new QStringList; | 80 | slChooserNames = new QStringList; |
62 | slChooserValues = new QStringList; | 81 | slChooserValues = new QStringList; |
63 | 82 | ||
64 | slDynamicEntries = new QStringList; | 83 | slDynamicEntries = new QStringList; |
65 | 84 | ||
66 | //*slDynamicEntries = *slOrdered; | 85 | //*slDynamicEntries = *slOrdered; |
67 | 86 | ||
68 | for (i = 0; i <= 6; i++) { | 87 | for (i = 0; i <= 6; i++) { |
69 | slHomeAddress->append( "" ); | 88 | slHomeAddress->append( "" ); |
70 | slBusinessAddress->append( "" ); | 89 | slBusinessAddress->append( "" ); |
71 | } | 90 | } |
72 | 91 | ||
73 | { | 92 | { |
74 | hasGender = FALSE; | 93 | hasGender = FALSE; |
75 | hasTitle = FALSE; | 94 | hasTitle = FALSE; |
76 | hasCompany = FALSE; | 95 | hasCompany = FALSE; |
77 | hasNotes = FALSE; | 96 | hasNotes = FALSE; |
78 | hasStreet = FALSE; | 97 | hasStreet = FALSE; |
79 | hasStreet2 = FALSE; | 98 | hasStreet2 = FALSE; |
80 | hasPOBox = FALSE; | 99 | hasPOBox = FALSE; |
81 | hasCity = FALSE; | 100 | hasCity = FALSE; |
82 | hasState = FALSE; | 101 | hasState = FALSE; |
83 | hasZip = FALSE; | 102 | hasZip = FALSE; |
84 | hasCountry = FALSE; | 103 | hasCountry = FALSE; |
85 | 104 | ||
86 | QStringList::ConstIterator it = slOrdered->begin(); | 105 | QStringList::ConstIterator it = slOrdered->begin(); |
87 | for ( i = 0; it != slOrdered->end(); i++, ++it ) { | 106 | for ( i = 0; it != slOrdered->end(); i++, ++it ) { |
88 | 107 | ||
89 | if ( (*it).right( 3 ) == tr( "Fax" ) ) { | 108 | if ( (*it).right( 3 ) == tr( "Fax" ) ) { |
90 | slChooserNames->append( *it ); | 109 | slChooserNames->append( *it ); |
91 | slChooserValues->append( tr( "" ) ); | 110 | slChooserValues->append( tr( "" ) ); |
92 | //slDynamicEntries->remove( it ); | 111 | //slDynamicEntries->remove( it ); |
93 | continue; | 112 | continue; |
94 | } | 113 | } |
95 | 114 | ||
96 | if ( (*it).right( 5 ) == tr( "Phone" ) ) { | 115 | if ( (*it).right( 5 ) == tr( "Phone" ) ) { |
97 | slChooserNames->append( *it ); | 116 | slChooserNames->append( *it ); |
98 | slChooserValues->append( "" ); | 117 | slChooserValues->append( "" ); |
99 | //slDynamicEntries->remove( it ); | 118 | //slDynamicEntries->remove( it ); |
100 | continue; | 119 | continue; |
101 | } | 120 | } |
102 | 121 | ||
103 | if ( (*it).right( 2 ) == tr( "IM" ) ) { | 122 | if ( (*it).right( 2 ) == tr( "IM" ) ) { |
104 | slChooserNames->append( *it ); | 123 | slChooserNames->append( *it ); |
105 | slChooserValues->append( "" ); | 124 | slChooserValues->append( "" ); |
106 | //slDynamicEntries->remove( it ); | 125 | //slDynamicEntries->remove( it ); |
107 | continue; | 126 | continue; |
108 | } | 127 | } |
109 | 128 | ||
110 | if ( (*it).right( 6 ) == tr( "Mobile" ) ) { | 129 | if ( (*it).right( 6 ) == tr( "Mobile" ) ) { |
111 | slChooserNames->append( *it ); | 130 | slChooserNames->append( *it ); |
112 | slChooserValues->append( "" ); | 131 | slChooserValues->append( "" ); |
113 | //slDynamicEntries->remove( it ); | 132 | //slDynamicEntries->remove( it ); |
114 | continue; | 133 | continue; |
115 | } | 134 | } |
116 | 135 | ||
117 | if ( (*it).right( 4 ) == tr( "Page" ) ) { | 136 | if ( (*it).right( 4 ) == tr( "Page" ) ) { |
118 | slChooserNames->append( *it ); | 137 | slChooserNames->append( *it ); |
119 | slChooserValues->append( "" ); | 138 | slChooserValues->append( "" ); |
120 | //slDynamicEntries->remove( it ); | 139 | //slDynamicEntries->remove( it ); |
121 | continue; | 140 | continue; |
122 | } | 141 | } |
123 | 142 | ||
124 | if ( (*it).right( 5 ) == tr( "Pager" ) ) { | 143 | if ( (*it).right( 5 ) == tr( "Pager" ) ) { |
125 | slChooserNames->append( *it ); | 144 | slChooserNames->append( *it ); |
126 | slChooserValues->append( "" ); | 145 | slChooserValues->append( "" ); |
127 | //slDynamicEntries->remove( it ); | 146 | //slDynamicEntries->remove( it ); |
128 | continue; | 147 | continue; |
129 | } | 148 | } |
130 | 149 | ||
131 | if ( *it == tr( "Default Email" ) ) { | 150 | if ( *it == tr( "Default Email" ) ) { |
132 | slChooserNames->append( *it ); | 151 | slChooserNames->append( *it ); |
133 | slChooserValues->append( "" ); | 152 | slChooserValues->append( "" ); |
134 | //slDynamicEntries->remove( it ); | 153 | //slDynamicEntries->remove( it ); |
135 | continue; | 154 | continue; |
136 | } | 155 | } |
137 | 156 | ||
138 | if ( *it == tr( "Emails" ) ) { | 157 | if ( *it == tr( "Emails" ) ) { |
139 | slChooserNames->append( *it ); | 158 | slChooserNames->append( *it ); |
140 | slChooserValues->append( "" ); | 159 | slChooserValues->append( "" ); |
141 | //slDynamicEntries->remove( it ); | 160 | //slDynamicEntries->remove( it ); |
142 | continue; | 161 | continue; |
143 | } | 162 | } |
144 | 163 | ||
145 | if ( *it == tr( "Name Title" ) ) { | 164 | if ( *it == tr( "Name Title" ) ) { |
146 | //slDynamicEntries->remove( it ); | 165 | //slDynamicEntries->remove( it ); |
147 | continue; | 166 | continue; |
148 | } | 167 | } |
149 | 168 | ||
150 | if ( *it == tr( "First Name" ) ) { | 169 | if ( *it == tr( "First Name" ) ) { |
151 | //slDynamicEntries->remove( it ); | 170 | //slDynamicEntries->remove( it ); |
152 | continue; | 171 | continue; |
153 | } | 172 | } |
154 | 173 | ||
155 | if ( *it == tr( "Middle Name" ) ) { | 174 | if ( *it == tr( "Middle Name" ) ) { |
156 | //slDynamicEntries->remove( it ); | 175 | //slDynamicEntries->remove( it ); |
157 | continue; | 176 | continue; |
158 | } | 177 | } |
159 | 178 | ||
160 | if ( *it == tr( "Last Name" ) ) { | 179 | if ( *it == tr( "Last Name" ) ) { |
161 | //slDynamicEntries->remove( it ); | 180 | //slDynamicEntries->remove( it ); |
162 | continue; | 181 | continue; |
163 | } | 182 | } |
164 | 183 | ||
165 | if ( *it == tr( "Suffix" ) ) { | 184 | if ( *it == tr( "Suffix" ) ) { |
166 | //slDynamicEntries->remove( it ); | 185 | //slDynamicEntries->remove( it ); |
167 | continue; | 186 | continue; |
168 | } | 187 | } |
169 | 188 | ||
170 | if ( *it == tr( "File As" ) ) { | 189 | if ( *it == tr( "File As" ) ) { |
171 | //slDynamicEntries->remove( it ); | 190 | //slDynamicEntries->remove( it ); |
172 | continue; | 191 | continue; |
173 | } | 192 | } |
174 | 193 | ||
175 | if ( *it == tr( "Gender" ) ) { | 194 | if ( *it == tr( "Gender" ) ) { |
176 | hasGender = TRUE; | 195 | hasGender = TRUE; |
177 | //slDynamicEntries->remove( it ); | 196 | //slDynamicEntries->remove( it ); |
178 | continue; | 197 | continue; |
179 | } | 198 | } |
180 | 199 | ||
181 | if ( *it == tr( "Job Title" ) ) { | 200 | if ( *it == tr( "Job Title" ) ) { |
182 | hasTitle = TRUE; | 201 | hasTitle = TRUE; |
183 | //slDynamicEntries->remove( it ); | 202 | //slDynamicEntries->remove( it ); |
184 | continue; | 203 | continue; |
185 | } | 204 | } |
186 | 205 | ||
187 | if ( *it == tr( "Company" ) ) { | 206 | if ( *it == tr( "Company" ) ) { |
188 | hasCompany = TRUE; | 207 | hasCompany = TRUE; |
189 | //slDynamicEntries->remove( it ); | 208 | //slDynamicEntries->remove( it ); |
190 | continue; | 209 | continue; |
191 | } | 210 | } |
192 | 211 | ||
193 | if ( *it == tr( "Notes" ) ) { | 212 | if ( *it == tr( "Notes" ) ) { |
194 | hasNotes = TRUE; | 213 | hasNotes = TRUE; |
195 | //slDynamicEntries->remove( it ); | 214 | //slDynamicEntries->remove( it ); |
196 | continue; | 215 | continue; |
197 | } | 216 | } |
198 | 217 | ||
199 | if ( *it == tr( "Groups" ) ) { | 218 | if ( *it == tr( "Groups" ) ) { |
200 | //slDynamicEntries->remove( it ); | 219 | //slDynamicEntries->remove( it ); |
201 | continue; | 220 | continue; |
202 | } | 221 | } |
203 | 222 | ||
204 | if ( (*it).right( 6 ) == tr( "Street" ) ) { | 223 | if ( (*it).right( 6 ) == tr( "Street" ) ) { |
205 | hasStreet = TRUE; | 224 | hasStreet = TRUE; |
206 | //slDynamicEntries->remove( it ); | 225 | //slDynamicEntries->remove( it ); |
207 | continue; | 226 | continue; |
208 | } | 227 | } |
209 | 228 | ||
210 | if ( (*it).right( 8 ) == tr( "Street 2" ) ) { | 229 | if ( (*it).right( 8 ) == tr( "Street 2" ) ) { |
211 | hasStreet2 = TRUE; | 230 | hasStreet2 = TRUE; |
212 | //slDynamicEntries->remove( it ); | 231 | //slDynamicEntries->remove( it ); |
213 | continue; | 232 | continue; |
214 | } | 233 | } |
215 | 234 | ||
216 | if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) { | 235 | if ( (*it).right( 8 ) == tr( "P.O. Box" ) ) { |
217 | hasPOBox = TRUE; | 236 | hasPOBox = TRUE; |
218 | //slDynamicEntries->remove( it ); | 237 | //slDynamicEntries->remove( it ); |
219 | continue; | 238 | continue; |
220 | } | 239 | } |
221 | 240 | ||
222 | if ( (*it).right( 4 ) == tr( "City" ) ) { | 241 | if ( (*it).right( 4 ) == tr( "City" ) ) { |
223 | hasCity = TRUE; | 242 | hasCity = TRUE; |
224 | //slDynamicEntries->remove( it ); | 243 | //slDynamicEntries->remove( it ); |
225 | continue; | 244 | continue; |
226 | } | 245 | } |
227 | 246 | ||
228 | if ( (*it).right( 5 ) == tr( "State" ) ) { | 247 | if ( (*it).right( 5 ) == tr( "State" ) ) { |
229 | hasState = TRUE; | 248 | hasState = TRUE; |
230 | //slDynamicEntries->remove( it ); | 249 | //slDynamicEntries->remove( it ); |
231 | continue; | 250 | continue; |
232 | } | 251 | } |
233 | 252 | ||
234 | if ( (*it).right( 3 ) == tr( "Zip" ) ) { | 253 | if ( (*it).right( 3 ) == tr( "Zip" ) ) { |
235 | hasZip = TRUE; | 254 | hasZip = TRUE; |
236 | //slDynamicEntries->remove( it ); | 255 | //slDynamicEntries->remove( it ); |
237 | continue; | 256 | continue; |
238 | } | 257 | } |
239 | 258 | ||
240 | if ( (*it).right( 7 ) == tr( "Country" ) ) { | 259 | if ( (*it).right( 7 ) == tr( "Country" ) ) { |
241 | hasCountry = TRUE; | 260 | hasCountry = TRUE; |
242 | //slDynamicEntries->remove( it ); | 261 | //slDynamicEntries->remove( it ); |
243 | continue; | 262 | continue; |
244 | } | 263 | } |
245 | 264 | ||
246 | slDynamicEntries->append( *it ); | 265 | slDynamicEntries->append( *it ); |
247 | } | 266 | } |
248 | } | 267 | } |
249 | 268 | ||
250 | QVBoxLayout *vb = new QVBoxLayout( this ); | 269 | QVBoxLayout *vb = new QVBoxLayout( this ); |
251 | 270 | ||
252 | tabMain = new QTabWidget( this ); | 271 | tabMain = new QTabWidget( this ); |
253 | vb->addWidget( tabMain ); | 272 | vb->addWidget( tabMain ); |
254 | 273 | ||
255 | QWidget *tabViewport = new QWidget ( tabMain ); | 274 | QWidget *tabViewport = new QWidget ( tabMain ); |
256 | 275 | ||
257 | vb = new QVBoxLayout( tabViewport ); | 276 | vb = new QVBoxLayout( tabViewport ); |
258 | 277 | ||
259 | svGeneral = new QScrollView( tabViewport ); | 278 | svGeneral = new QScrollView( tabViewport ); |
260 | vb->addWidget( svGeneral, 0, 0 ); | 279 | vb->addWidget( svGeneral, 0, 0 ); |
261 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); | 280 | svGeneral->setResizePolicy( QScrollView::AutoOneFit ); |
262 | svGeneral->setFrameStyle( QFrame::NoFrame ); | 281 | svGeneral->setFrameStyle( QFrame::NoFrame ); |
263 | 282 | ||
264 | QWidget *container = new QWidget( svGeneral->viewport() ); | 283 | QWidget *container = new QWidget( svGeneral->viewport() ); |
265 | svGeneral->addChild( container ); | 284 | svGeneral->addChild( container ); |
266 | 285 | ||
267 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 3 ); | 286 | QGridLayout *gl = new QGridLayout( container, 1, 1, 2, 3 ); |
268 | gl->setResizeMode( QLayout::FreeResize ); | 287 | gl->setResizeMode( QLayout::FreeResize ); |
269 | 288 | ||
270 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); | 289 | btnFullName = new QPushButton( tr( "Full Name..." ), container ); |
271 | gl->addWidget( btnFullName, 0, 0 ); | 290 | gl->addWidget( btnFullName, 0, 0 ); |
272 | txtFullName = new QLineEdit( container ); | 291 | txtFullName = new QLineEdit( container ); |
273 | gl->addWidget( txtFullName, 0, 1 ); | 292 | gl->addWidget( txtFullName, 0, 1 ); |
274 | 293 | ||
275 | QLabel *l = new QLabel( tr( "Job Title" ), container ); | 294 | QLabel *l = new QLabel( tr( "Job Title" ), container ); |
276 | gl->addWidget( l, 1, 0 ); | 295 | gl->addWidget( l, 1, 0 ); |
277 | txtJobTitle = new QLineEdit( container ); | 296 | txtJobTitle = new QLineEdit( container ); |
278 | gl->addWidget( txtJobTitle, 1, 1 ); | 297 | gl->addWidget( txtJobTitle, 1, 1 ); |
279 | 298 | ||
280 | l = new QLabel( tr( "Organization" ), container ); | 299 | l = new QLabel( tr( "Organization" ), container ); |
281 | gl->addWidget( l, 2, 0 ); | 300 | gl->addWidget( l, 2, 0 ); |
282 | txtOrganization = new QLineEdit( container ); | 301 | txtOrganization = new QLineEdit( container ); |
283 | gl->addWidget( txtOrganization, 2, 1 ); | 302 | gl->addWidget( txtOrganization, 2, 1 ); |
284 | 303 | ||
285 | cmbChooserField1 = new QComboBox( FALSE, container ); | 304 | cmbChooserField1 = new QComboBox( FALSE, container ); |
286 | cmbChooserField1->setMaximumWidth( 100 ); | 305 | cmbChooserField1->setMaximumWidth( 100 ); |
287 | gl->addWidget( cmbChooserField1, 3, 0 ); | 306 | gl->addWidget( cmbChooserField1, 3, 0 ); |
288 | txtChooserField1 = new QLineEdit( container ); | 307 | txtChooserField1 = new QLineEdit( container ); |
289 | gl->addWidget( txtChooserField1, 3, 1 ); | 308 | gl->addWidget( txtChooserField1, 3, 1 ); |
290 | 309 | ||
291 | cmbChooserField2 = new QComboBox( FALSE, container ); | 310 | cmbChooserField2 = new QComboBox( FALSE, container ); |
292 | cmbChooserField2->setMaximumWidth( 100 ); | 311 | cmbChooserField2->setMaximumWidth( 100 ); |
293 | gl->addWidget( cmbChooserField2, 4, 0 ); | 312 | gl->addWidget( cmbChooserField2, 4, 0 ); |
294 | txtChooserField2 = new QLineEdit( container ); | 313 | txtChooserField2 = new QLineEdit( container ); |
295 | gl->addWidget( txtChooserField2, 4, 1 ); | 314 | gl->addWidget( txtChooserField2, 4, 1 ); |
296 | 315 | ||
297 | cmbChooserField3 = new QComboBox( FALSE, container ); | 316 | cmbChooserField3 = new QComboBox( FALSE, container ); |
298 | cmbChooserField3->setMaximumWidth( 100 ); | 317 | cmbChooserField3->setMaximumWidth( 100 ); |
299 | gl->addWidget( cmbChooserField3, 5, 0 ); | 318 | gl->addWidget( cmbChooserField3, 5, 0 ); |
300 | txtChooserField3 = new QLineEdit( container ); | 319 | txtChooserField3 = new QLineEdit( container ); |
301 | gl->addWidget( txtChooserField3, 5, 1 ); | 320 | gl->addWidget( txtChooserField3, 5, 1 ); |
302 | 321 | ||
303 | l = new QLabel( tr( "File As" ), container ); | 322 | l = new QLabel( tr( "File As" ), container ); |
304 | gl->addWidget( l, 6, 0 ); | 323 | gl->addWidget( l, 6, 0 ); |
305 | cmbFileAs = new QComboBox( TRUE, container ); | 324 | cmbFileAs = new QComboBox( TRUE, container ); |
306 | gl->addWidget( cmbFileAs, 6, 1 ); | 325 | gl->addWidget( cmbFileAs, 6, 1 ); |
307 | 326 | ||
308 | l = new QLabel( tr( "Category" ), container ); | 327 | l = new QLabel( tr( "Category" ), container ); |
309 | gl->addWidget( l, 7, 0 ); | 328 | gl->addWidget( l, 7, 0 ); |
310 | cmbCat = new CategorySelect( container ); | 329 | cmbCat = new CategorySelect( container ); |
311 | gl->addWidget( cmbCat, 7, 1 ); | 330 | gl->addWidget( cmbCat, 7, 1 ); |
312 | 331 | ||
313 | btnNote = new QPushButton( tr( "Notes..." ), container ); | 332 | btnNote = new QPushButton( tr( "Notes..." ), container ); |
314 | gl->addWidget( btnNote, 8, 1 ); | 333 | gl->addWidget( btnNote, 8, 1 ); |
315 | 334 | ||
316 | tabMain->insertTab( tabViewport, tr( "General" ) ); | 335 | tabMain->insertTab( tabViewport, tr( "General" ) ); |
317 | 336 | ||
318 | tabViewport = new QWidget ( tabMain ); | 337 | tabViewport = new QWidget ( tabMain ); |
319 | 338 | ||
320 | vb = new QVBoxLayout( tabViewport ); | 339 | vb = new QVBoxLayout( tabViewport ); |
321 | 340 | ||
322 | svAddress = new QScrollView( tabViewport ); | 341 | svAddress = new QScrollView( tabViewport ); |
323 | vb->addWidget( svAddress, 0, 0 ); | 342 | vb->addWidget( svAddress, 0, 0 ); |
324 | svAddress->setResizePolicy( QScrollView::AutoOneFit ); | 343 | svAddress->setResizePolicy( QScrollView::AutoOneFit ); |
325 | svAddress->setFrameStyle( QFrame::NoFrame ); | 344 | svAddress->setFrameStyle( QFrame::NoFrame ); |
326 | 345 | ||
327 | container = new QWidget( svAddress->viewport() ); | 346 | container = new QWidget( svAddress->viewport() ); |
328 | svAddress->addChild( container ); | 347 | svAddress->addChild( container ); |
329 | 348 | ||
330 | gl = new QGridLayout( container, 5, 3, 2, 3 ); | 349 | gl = new QGridLayout( container, 5, 3, 2, 3 ); |
331 | 350 | ||
332 | cmbAddress = new QComboBox( FALSE, container ); | 351 | cmbAddress = new QComboBox( FALSE, container ); |
333 | cmbAddress->insertItem( tr( "Business" ) ); | 352 | cmbAddress->insertItem( tr( "Business" ) ); |
334 | cmbAddress->insertItem( tr( "Home" ) ); | 353 | cmbAddress->insertItem( tr( "Home" ) ); |
335 | gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); | 354 | gl->addMultiCellWidget( cmbAddress, 0, 0, 0, 1 ); |
336 | 355 | ||
337 | l = new QLabel( tr( "Address" ), container ); | 356 | l = new QLabel( tr( "Address" ), container ); |
338 | gl->addWidget( l, 1, 0 ); | 357 | gl->addWidget( l, 1, 0 ); |
339 | txtAddress = new QLineEdit( container ); | 358 | txtAddress = new QLineEdit( container ); |
340 | gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); | 359 | gl->addMultiCellWidget( txtAddress, 1, 1, 1, 2 ); |
341 | /* | 360 | /* |
342 | l = new QLabel( tr( "Address 2" ), container ); | 361 | l = new QLabel( tr( "Address 2" ), container ); |
343 | gl->addWidget( l, 2, 0 ); | 362 | gl->addWidget( l, 2, 0 ); |
344 | txtAddress2 = new QLineEdit( container ); | 363 | txtAddress2 = new QLineEdit( container ); |
345 | gl->addMultiCellWidget( txtAddress2, 2, 2, 1, 2 ); | 364 | gl->addMultiCellWidget( txtAddress2, 2, 2, 1, 2 ); |
346 | 365 | ||
347 | l = new QLabel( tr( "P.O. Box" ), container ); | 366 | l = new QLabel( tr( "P.O. Box" ), container ); |
348 | gl->addWidget( l, 3, 0 ); | 367 | gl->addWidget( l, 3, 0 ); |
349 | txtPOBox = new QLineEdit( container ); | 368 | txtPOBox = new QLineEdit( container ); |
350 | gl->addMultiCellWidget( txtPOBox, 3, 3, 1, 2 ); | 369 | gl->addMultiCellWidget( txtPOBox, 3, 3, 1, 2 ); |
351 | */ | 370 | */ |
352 | l = new QLabel( tr( "City" ), container ); | 371 | l = new QLabel( tr( "City" ), container ); |
353 | gl->addWidget( l, 2, 0 ); | 372 | gl->addWidget( l, 2, 0 ); |
354 | txtCity = new QLineEdit( container ); | 373 | txtCity = new QLineEdit( container ); |
355 | gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); | 374 | gl->addMultiCellWidget( txtCity, 2, 2, 1, 2 ); |
356 | 375 | ||
357 | l = new QLabel( tr( "State" ), container ); | 376 | l = new QLabel( tr( "State" ), container ); |
358 | gl->addWidget( l, 3, 0 ); | 377 | gl->addWidget( l, 3, 0 ); |
359 | txtState = new QLineEdit( container ); | 378 | txtState = new QLineEdit( container ); |
360 | gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); | 379 | gl->addMultiCellWidget( txtState, 3, 3, 1, 2 ); |
361 | 380 | ||
362 | l = new QLabel( tr( "Zip Code" ), container ); | 381 | l = new QLabel( tr( "Zip Code" ), container ); |
363 | gl->addWidget( l, 4, 0 ); | 382 | gl->addWidget( l, 4, 0 ); |
364 | txtZip = new QLineEdit( container ); | 383 | txtZip = new QLineEdit( container ); |
365 | gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); | 384 | gl->addMultiCellWidget( txtZip, 4, 4, 1, 2 ); |
366 | 385 | ||
367 | l = new QLabel( tr( "Country" ), container ); | 386 | l = new QLabel( tr( "Country" ), container ); |
368 | gl->addWidget( l, 5, 0 ); | 387 | gl->addWidget( l, 5, 0 ); |
369 | cmbCountry = new QComboBox( TRUE, container ); | 388 | cmbCountry = new QComboBox( TRUE, container ); |
370 | cmbCountry->insertItem( tr( "" ) ); | 389 | cmbCountry->insertItem( tr( "" ) ); |
371 | cmbCountry->insertItem( tr( "United States" ) ); | 390 | cmbCountry->insertItem( tr( "United States" ) ); |
372 | cmbCountry->insertItem( tr( "United Kingdom" ) ); | 391 | cmbCountry->insertItem( tr( "United Kingdom" ) ); |
373 | cmbCountry->insertItem( tr( "Japan" ) ); | 392 | cmbCountry->insertItem( tr( "Japan" ) ); |
374 | cmbCountry->insertItem( tr( "France" ) ); | 393 | cmbCountry->insertItem( tr( "France" ) ); |
375 | cmbCountry->insertItem( tr( "Germany" ) ); | 394 | cmbCountry->insertItem( tr( "Germany" ) ); |
376 | cmbCountry->insertItem( tr( "Norway" ) ); | 395 | cmbCountry->insertItem( tr( "Norway" ) ); |
377 | cmbCountry->insertItem( tr( "Canada" ) ); | 396 | cmbCountry->insertItem( tr( "Canada" ) ); |
378 | 397 | ||
379 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); | 398 | gl->addMultiCellWidget( cmbCountry, 5, 5, 1, 2 ); |
380 | 399 | ||
381 | tabMain->insertTab( tabViewport, tr( "Address" ) ); | 400 | tabMain->insertTab( tabViewport, tr( "Address" ) ); |
382 | 401 | ||
383 | tabViewport = new QWidget ( tabMain ); | 402 | tabViewport = new QWidget ( tabMain ); |
384 | 403 | ||
385 | vb = new QVBoxLayout( tabViewport ); | 404 | vb = new QVBoxLayout( tabViewport ); |
386 | 405 | ||
387 | svDetails = new QScrollView( tabViewport ); | 406 | svDetails = new QScrollView( tabViewport ); |
388 | vb->addWidget( svDetails, 0, 0 ); | 407 | vb->addWidget( svDetails, 0, 0 ); |
389 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); | 408 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); |
390 | svDetails->setFrameStyle( QFrame::NoFrame ); | 409 | svDetails->setFrameStyle( QFrame::NoFrame ); |
391 | 410 | ||
392 | container = new QWidget( svDetails->viewport() ); | 411 | container = new QWidget( svDetails->viewport() ); |
393 | svDetails->addChild( container ); | 412 | svDetails->addChild( container ); |
394 | 413 | ||
395 | gl = new QGridLayout( container, 1, 2, 2, 3 ); | 414 | gl = new QGridLayout( container, 1, 2, 2, 3 ); |
396 | 415 | ||
397 | QStringList::ConstIterator it = slDynamicEntries->begin(); | 416 | QStringList::ConstIterator it = slDynamicEntries->begin(); |
398 | for (i = 0; it != slDynamicEntries->end(); i++, ++it) { | 417 | for (i = 0; it != slDynamicEntries->end(); i++, ++it) { |
399 | l = new QLabel( *it, container ); | 418 | l = new QLabel( *it, container ); |
400 | listName.append( l ); | 419 | listName.append( l ); |
401 | gl->addWidget( l, i, 0 ); | 420 | gl->addWidget( l, i, 0 ); |
402 | QLineEdit *e = new QLineEdit( container ); | 421 | QLineEdit *e = new QLineEdit( container ); |
403 | listValue.append( e ); | 422 | listValue.append( e ); |
404 | gl->addWidget( e, i, 1); | 423 | gl->addWidget( e, i, 1); |
405 | } | 424 | } |
406 | 425 | ||
407 | l = new QLabel( tr("Gender"), container ); | 426 | l = new QLabel( tr("Gender"), container ); |
408 | gl->addWidget( l, slDynamicEntries->count(), 0 ); | 427 | gl->addWidget( l, slDynamicEntries->count(), 0 ); |
409 | cmbGender = new QComboBox( container ); | 428 | cmbGender = new QComboBox( container ); |
410 | cmbGender->insertItem( "", 0 ); | 429 | cmbGender->insertItem( "", 0 ); |
411 | cmbGender->insertItem( tr("Male"), 1); | 430 | cmbGender->insertItem( tr("Male"), 1); |
412 | cmbGender->insertItem( tr("Female"), 2); | 431 | cmbGender->insertItem( tr("Female"), 2); |
413 | gl->addWidget( cmbGender, slDynamicEntries->count(), 1 ); | 432 | gl->addWidget( cmbGender, slDynamicEntries->count(), 1 ); |
414 | 433 | ||
415 | tabMain->insertTab( tabViewport, tr( "Details" ) ); | 434 | tabMain->insertTab( tabViewport, tr( "Details" ) ); |
416 | 435 | ||
417 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 436 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
418 | dlgNote->setCaption( tr("Enter Note") ); | 437 | dlgNote->setCaption( tr("Enter Note") ); |
419 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 438 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
420 | txtNote = new QMultiLineEdit( dlgNote ); | 439 | txtNote = new QMultiLineEdit( dlgNote ); |
421 | vbNote->addWidget( txtNote ); | 440 | vbNote->addWidget( txtNote ); |
422 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 441 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
423 | 442 | ||
424 | dlgName = new QDialog( this, "Name Dialog", TRUE ); | 443 | dlgName = new QDialog( this, "Name Dialog", TRUE ); |
425 | dlgName->setCaption( tr("Edit Name") ); | 444 | dlgName->setCaption( tr("Edit Name") ); |
426 | gl = new QGridLayout( dlgName, 4, 2, 2, 3 ); | 445 | gl = new QGridLayout( dlgName, 4, 2, 2, 3 ); |
427 | 446 | ||
428 | l = new QLabel( tr("First Name"), dlgName ); | 447 | l = new QLabel( tr("First Name"), dlgName ); |
429 | gl->addWidget( l, 0, 0 ); | 448 | gl->addWidget( l, 0, 0 ); |
430 | txtFirstName = new QLineEdit( dlgName ); | 449 | txtFirstName = new QLineEdit( dlgName ); |
431 | gl->addWidget( txtFirstName, 0, 1 ); | 450 | gl->addWidget( txtFirstName, 0, 1 ); |
432 | 451 | ||
433 | l = new QLabel( tr("Middle Name"), dlgName ); | 452 | l = new QLabel( tr("Middle Name"), dlgName ); |
434 | gl->addWidget( l, 1, 0 ); | 453 | gl->addWidget( l, 1, 0 ); |
435 | txtMiddleName = new QLineEdit( dlgName ); | 454 | txtMiddleName = new QLineEdit( dlgName ); |
436 | gl->addWidget( txtMiddleName, 1, 1 ); | 455 | gl->addWidget( txtMiddleName, 1, 1 ); |
437 | 456 | ||
438 | l = new QLabel( tr("Last Name"), dlgName ); | 457 | l = new QLabel( tr("Last Name"), dlgName ); |
439 | gl->addWidget( l, 2, 0 ); | 458 | gl->addWidget( l, 2, 0 ); |
440 | txtLastName = new QLineEdit( dlgName ); | 459 | txtLastName = new QLineEdit( dlgName ); |
441 | gl->addWidget( txtLastName, 2, 1 ); | 460 | gl->addWidget( txtLastName, 2, 1 ); |
442 | 461 | ||
443 | l = new QLabel( tr("Suffix"), dlgName ); | 462 | l = new QLabel( tr("Suffix"), dlgName ); |
444 | gl->addWidget( l, 3, 0 ); | 463 | gl->addWidget( l, 3, 0 ); |
445 | txtSuffix = new QLineEdit( dlgName ); | 464 | txtSuffix = new QLineEdit( dlgName ); |
446 | gl->addWidget( txtSuffix, 3, 1 ); | 465 | gl->addWidget( txtSuffix, 3, 1 ); |
447 | 466 | ||
448 | cmbChooserField1->insertStringList( *slChooserNames ); | 467 | cmbChooserField1->insertStringList( *slChooserNames ); |
449 | cmbChooserField2->insertStringList( *slChooserNames ); | 468 | cmbChooserField2->insertStringList( *slChooserNames ); |
450 | cmbChooserField3->insertStringList( *slChooserNames ); | 469 | cmbChooserField3->insertStringList( *slChooserNames ); |
451 | 470 | ||
452 | cmbChooserField1->setCurrentItem( 0 ); | 471 | cmbChooserField1->setCurrentItem( 0 ); |
453 | cmbChooserField2->setCurrentItem( 1 ); | 472 | cmbChooserField2->setCurrentItem( 1 ); |
454 | cmbChooserField3->setCurrentItem( 2 ); | 473 | cmbChooserField3->setCurrentItem( 2 ); |
455 | 474 | ||
456 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); | 475 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); |
457 | 476 | ||
458 | connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); | 477 | connect( txtFullName, SIGNAL(textChanged(const QString &)), this, SLOT(slotFullNameChange(const QString &)) ); |
459 | 478 | ||
460 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser1Change(const QString &)) ); | 479 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser1Change(const QString &)) ); |
461 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser2Change(const QString &)) ); | 480 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser2Change(const QString &)) ); |
462 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser3Change(const QString &)) ); | 481 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), this, SLOT(slotChooser3Change(const QString &)) ); |
463 | connect( txtAddress, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddressChange(const QString &)) ); | 482 | connect( txtAddress, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddressChange(const QString &)) ); |
464 | //connect( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) ); | 483 | //connect( txtAddress2, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddress2Change(const QString &)) ); |
465 | //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(const QString &)) ); | 484 | //connect( txtPOBox, SIGNAL(textChanged(const QString &)), this, SLOT(slotPOBoxChange(const QString &)) ); |
466 | connect( txtCity, SIGNAL(textChanged(const QString &)), this, SLOT(slotCityChange(const QString &)) ); | 485 | connect( txtCity, SIGNAL(textChanged(const QString &)), this, SLOT(slotCityChange(const QString &)) ); |
467 | connect( txtState, SIGNAL(textChanged(const QString &)), this, SLOT(slotStateChange(const QString &)) ); | 486 | connect( txtState, SIGNAL(textChanged(const QString &)), this, SLOT(slotStateChange(const QString &)) ); |
468 | connect( txtZip, SIGNAL(textChanged(const QString &)), this, SLOT(slotZipChange(const QString &)) ); | 487 | connect( txtZip, SIGNAL(textChanged(const QString &)), this, SLOT(slotZipChange(const QString &)) ); |
469 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), this, SLOT(slotCountryChange(const QString &)) ); | 488 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), this, SLOT(slotCountryChange(const QString &)) ); |
470 | connect( cmbCountry, SIGNAL(activated(const QString &)), this, SLOT(slotCountryChange(const QString &)) ); | 489 | connect( cmbCountry, SIGNAL(activated(const QString &)), this, SLOT(slotCountryChange(const QString &)) ); |
471 | connect( cmbChooserField1, SIGNAL(activated(int)), this, SLOT(slotCmbChooser1Change(int)) ); | 490 | connect( cmbChooserField1, SIGNAL(activated(int)), this, SLOT(slotCmbChooser1Change(int)) ); |
472 | connect( cmbChooserField2, SIGNAL(activated(int)), this, SLOT(slotCmbChooser2Change(int)) ); | 491 | connect( cmbChooserField2, SIGNAL(activated(int)), this, SLOT(slotCmbChooser2Change(int)) ); |
473 | connect( cmbChooserField3, SIGNAL(activated(int)), this, SLOT(slotCmbChooser3Change(int)) ); | 492 | connect( cmbChooserField3, SIGNAL(activated(int)), this, SLOT(slotCmbChooser3Change(int)) ); |
474 | connect( cmbAddress, SIGNAL(activated(int)), this, SLOT(slotAddressTypeChange(int)) ); | 493 | connect( cmbAddress, SIGNAL(activated(int)), this, SLOT(slotAddressTypeChange(int)) ); |
475 | new QPEDialogListener(this); | 494 | new QPEDialogListener(this); |
476 | } | 495 | } |
477 | 496 | ||
478 | void ContactEditor::initMap() | 497 | void ContactEditor::initMap() |
479 | { | 498 | { |
480 | /* | 499 | /* |
481 | // since the fields and the XML fields exist, create a map | 500 | // since the fields and the XML fields exist, create a map |
482 | // between them... | 501 | // between them... |
483 | Config cfg1( "AddressBook" ); | 502 | Config cfg1( "AddressBook" ); |
484 | Config cfg2( "AddressBook" ); | 503 | Config cfg2( "AddressBook" ); |
485 | QString strCfg1, | 504 | QString strCfg1, |
486 | strCfg2; | 505 | strCfg2; |
487 | int i; | 506 | int i; |
488 | 507 | ||
489 | // This stuff better exist... | 508 | // This stuff better exist... |
490 | cfg1.setGroup( "AddressFields" ); | 509 | cfg1.setGroup( "AddressFields" ); |
491 | o cfg2.setGroup( "XMLFields" ); | 510 | o cfg2.setGroup( "XMLFields" ); |
492 | i = 0; | 511 | i = 0; |
493 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); | 512 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); |
494 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 513 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
495 | QString::null ); | 514 | QString::null ); |
496 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { | 515 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { |
497 | mapField.insert( strCfg1, strCfg2 ); | 516 | mapField.insert( strCfg1, strCfg2 ); |
498 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), | 517 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), |
499 | QString::null ); | 518 | QString::null ); |
500 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 519 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
501 | QString::null ); | 520 | QString::null ); |
502 | } | 521 | } |
503 | */ | 522 | */ |
504 | } | 523 | } |
505 | 524 | ||
506 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { | 525 | void ContactEditor::slotChooser1Change( const QString &textChanged ) { |
507 | 526 | ||
508 | int index = cmbChooserField1->currentItem(); | 527 | int index = cmbChooserField1->currentItem(); |
509 | 528 | ||
510 | (*slChooserValues)[index] = textChanged; | 529 | (*slChooserValues)[index] = textChanged; |
511 | 530 | ||
512 | } | 531 | } |
513 | 532 | ||
514 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { | 533 | void ContactEditor::slotChooser2Change( const QString &textChanged ) { |
515 | 534 | ||
516 | int index = cmbChooserField2->currentItem(); | 535 | int index = cmbChooserField2->currentItem(); |
517 | 536 | ||
518 | (*slChooserValues)[index] = textChanged; | 537 | (*slChooserValues)[index] = textChanged; |
519 | 538 | ||
520 | } | 539 | } |
521 | 540 | ||
522 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { | 541 | void ContactEditor::slotChooser3Change( const QString &textChanged ) { |
523 | 542 | ||
524 | int index = cmbChooserField3->currentItem(); | 543 | int index = cmbChooserField3->currentItem(); |
525 | 544 | ||
526 | (*slChooserValues)[index] = textChanged; | 545 | (*slChooserValues)[index] = textChanged; |
527 | 546 | ||
528 | } | 547 | } |
529 | 548 | ||
530 | void ContactEditor::slotAddressChange( const QString &textChanged ) { | 549 | void ContactEditor::slotAddressChange( const QString &textChanged ) { |
531 | 550 | ||
532 | if ( cmbAddress->currentItem() == 0 ) { | 551 | if ( cmbAddress->currentItem() == 0 ) { |
533 | (*slBusinessAddress)[0] = textChanged; | 552 | (*slBusinessAddress)[0] = textChanged; |
534 | } else { | 553 | } else { |
535 | (*slHomeAddress)[0] = textChanged; | 554 | (*slHomeAddress)[0] = textChanged; |
536 | } | 555 | } |
537 | } | 556 | } |
538 | 557 | ||
539 | void ContactEditor::slotAddress2Change( const QString &textChanged ) { | 558 | void ContactEditor::slotAddress2Change( const QString &textChanged ) { |
540 | 559 | ||
541 | if ( cmbAddress->currentItem() == 0 ) { | 560 | if ( cmbAddress->currentItem() == 0 ) { |
542 | (*slBusinessAddress)[1] = textChanged; | 561 | (*slBusinessAddress)[1] = textChanged; |
543 | } else { | 562 | } else { |
544 | (*slHomeAddress)[1] = textChanged; | 563 | (*slHomeAddress)[1] = textChanged; |
545 | } | 564 | } |
546 | } | 565 | } |
547 | 566 | ||
548 | void ContactEditor::slotPOBoxChange( const QString &textChanged ) { | 567 | void ContactEditor::slotPOBoxChange( const QString &textChanged ) { |
549 | 568 | ||
550 | if ( cmbAddress->currentItem() == 0 ) { | 569 | if ( cmbAddress->currentItem() == 0 ) { |
551 | (*slBusinessAddress)[2] = textChanged; | 570 | (*slBusinessAddress)[2] = textChanged; |
552 | } else { | 571 | } else { |
553 | (*slHomeAddress)[2] = textChanged; | 572 | (*slHomeAddress)[2] = textChanged; |
554 | } | 573 | } |
555 | } | 574 | } |
556 | 575 | ||
557 | void ContactEditor::slotCityChange( const QString &textChanged ) { | 576 | void ContactEditor::slotCityChange( const QString &textChanged ) { |
558 | 577 | ||
559 | if ( cmbAddress->currentItem() == 0 ) { | 578 | if ( cmbAddress->currentItem() == 0 ) { |
560 | (*slBusinessAddress)[3] = textChanged; | 579 | (*slBusinessAddress)[3] = textChanged; |
561 | } else { | 580 | } else { |
562 | (*slHomeAddress)[3] = textChanged; | 581 | (*slHomeAddress)[3] = textChanged; |
563 | } | 582 | } |
564 | } | 583 | } |
565 | 584 | ||
566 | void ContactEditor::slotStateChange( const QString &textChanged ) { | 585 | void ContactEditor::slotStateChange( const QString &textChanged ) { |
567 | 586 | ||
568 | 587 | ||
569 | if ( cmbAddress->currentItem() == 0 ) { | 588 | if ( cmbAddress->currentItem() == 0 ) { |
570 | (*slBusinessAddress)[4] = textChanged; | 589 | (*slBusinessAddress)[4] = textChanged; |
571 | } else { | 590 | } else { |
572 | (*slHomeAddress)[4] = textChanged; | 591 | (*slHomeAddress)[4] = textChanged; |
573 | } | 592 | } |
574 | } | 593 | } |
575 | 594 | ||
576 | void ContactEditor::slotZipChange( const QString &textChanged ) { | 595 | void ContactEditor::slotZipChange( const QString &textChanged ) { |
577 | 596 | ||
578 | if ( cmbAddress->currentItem() == 0 ) { | 597 | if ( cmbAddress->currentItem() == 0 ) { |
579 | (*slBusinessAddress)[5] = textChanged; | 598 | (*slBusinessAddress)[5] = textChanged; |
580 | } else { | 599 | } else { |
581 | (*slHomeAddress)[5] = textChanged; | 600 | (*slHomeAddress)[5] = textChanged; |
582 | } | 601 | } |
583 | } | 602 | } |
584 | 603 | ||
585 | void ContactEditor::slotCountryChange( const QString &textChanged ) { | 604 | void ContactEditor::slotCountryChange( const QString &textChanged ) { |
586 | 605 | ||
587 | if ( cmbAddress->currentItem() == 0 ) { | 606 | if ( cmbAddress->currentItem() == 0 ) { |
588 | (*slBusinessAddress)[6] = textChanged; | 607 | (*slBusinessAddress)[6] = textChanged; |
589 | } else { | 608 | } else { |
590 | (*slHomeAddress)[6] = textChanged; | 609 | (*slHomeAddress)[6] = textChanged; |
591 | } | 610 | } |
592 | } | 611 | } |
593 | 612 | ||
594 | void ContactEditor::slotCmbChooser1Change( int index ) { | 613 | void ContactEditor::slotCmbChooser1Change( int index ) { |
595 | 614 | ||
596 | txtChooserField1->setText( (*slChooserValues)[index] ); | 615 | txtChooserField1->setText( (*slChooserValues)[index] ); |
597 | 616 | ||
598 | } | 617 | } |
599 | 618 | ||
600 | void ContactEditor::slotCmbChooser2Change( int index ) { | 619 | void ContactEditor::slotCmbChooser2Change( int index ) { |
601 | 620 | ||
602 | txtChooserField2->setText( (*slChooserValues)[index] ); | 621 | txtChooserField2->setText( (*slChooserValues)[index] ); |
603 | 622 | ||
604 | } | 623 | } |
605 | 624 | ||
606 | void ContactEditor::slotCmbChooser3Change( int index ) { | 625 | void ContactEditor::slotCmbChooser3Change( int index ) { |
607 | 626 | ||
608 | txtChooserField3->setText( (*slChooserValues)[index] ); | 627 | txtChooserField3->setText( (*slChooserValues)[index] ); |
609 | 628 | ||
610 | } | 629 | } |
611 | 630 | ||
612 | void ContactEditor::slotAddressTypeChange( int index ) { | 631 | void ContactEditor::slotAddressTypeChange( int index ) { |
613 | 632 | ||
614 | if ( index == 0 ) { | 633 | if ( index == 0 ) { |
615 | 634 | ||
616 | txtAddress->setText( (*slBusinessAddress)[0] ); | 635 | txtAddress->setText( (*slBusinessAddress)[0] ); |
617 | //txtAddress2->setText( (*slBusinessAddress)[1] ); | 636 | //txtAddress2->setText( (*slBusinessAddress)[1] ); |
618 | //txtPOBox->setText( (*slBusinessAddress)[2] ); | 637 | //txtPOBox->setText( (*slBusinessAddress)[2] ); |
619 | txtCity->setText( (*slBusinessAddress)[3] ); | 638 | txtCity->setText( (*slBusinessAddress)[3] ); |
620 | txtState->setText( (*slBusinessAddress)[4] ); | 639 | txtState->setText( (*slBusinessAddress)[4] ); |
621 | txtZip->setText( (*slBusinessAddress)[5] ); | 640 | txtZip->setText( (*slBusinessAddress)[5] ); |
622 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 641 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
623 | txtTmp->setText( (*slBusinessAddress)[6] ); | 642 | txtTmp->setText( (*slBusinessAddress)[6] ); |
624 | 643 | ||
625 | } else { | 644 | } else { |
626 | 645 | ||
627 | txtAddress->setText( (*slHomeAddress)[0] ); | 646 | txtAddress->setText( (*slHomeAddress)[0] ); |
628 | //txtAddress2->setText( (*slHomeAddress)[1] ); | 647 | //txtAddress2->setText( (*slHomeAddress)[1] ); |
629 | //txtPOBox->setText( (*slHomeAddress)[2] ); | 648 | //txtPOBox->setText( (*slHomeAddress)[2] ); |
630 | txtCity->setText( (*slHomeAddress)[3] ); | 649 | txtCity->setText( (*slHomeAddress)[3] ); |
631 | txtState->setText( (*slHomeAddress)[4] ); | 650 | txtState->setText( (*slHomeAddress)[4] ); |
632 | txtZip->setText( (*slHomeAddress)[5] ); | 651 | txtZip->setText( (*slHomeAddress)[5] ); |
633 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 652 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
634 | txtTmp->setText( (*slHomeAddress)[6] ); | 653 | txtTmp->setText( (*slHomeAddress)[6] ); |
635 | 654 | ||
636 | } | 655 | } |
637 | 656 | ||
638 | } | 657 | } |
639 | 658 | ||
640 | void ContactEditor::slotFullNameChange( const QString &textChanged ) { | 659 | void ContactEditor::slotFullNameChange( const QString &textChanged ) { |
641 | 660 | ||
642 | int index = cmbFileAs->currentItem(); | 661 | int index = cmbFileAs->currentItem(); |
643 | 662 | ||
644 | cmbFileAs->clear(); | 663 | cmbFileAs->clear(); |
645 | 664 | ||
646 | cmbFileAs->insertItem( parseName( textChanged, 0 ) ); | 665 | cmbFileAs->insertItem( parseName( textChanged, 0 ) ); |
647 | cmbFileAs->insertItem( parseName( textChanged, 1 ) ); | 666 | cmbFileAs->insertItem( parseName( textChanged, 1 ) ); |
648 | cmbFileAs->insertItem( parseName( textChanged, 2 ) ); | 667 | cmbFileAs->insertItem( parseName( textChanged, 2 ) ); |
649 | cmbFileAs->insertItem( parseName( textChanged, 3 ) ); | 668 | cmbFileAs->insertItem( parseName( textChanged, 3 ) ); |
650 | 669 | ||
651 | cmbFileAs->setCurrentItem( index ); | 670 | cmbFileAs->setCurrentItem( index ); |
652 | 671 | ||
653 | useFullName = TRUE; | 672 | useFullName = TRUE; |
654 | 673 | ||
655 | } | 674 | } |
656 | 675 | ||
657 | void ContactEditor::loadFields() { | 676 | void ContactEditor::loadFields() { |
658 | 677 | ||
659 | QStringList::ConstIterator it; | 678 | QStringList::ConstIterator it; |
660 | QListIterator<QLabel> lit( listName ); | 679 | QListIterator<QLabel> lit( listName ); |
661 | for ( it = slDynamicEntries->begin(); *lit; ++lit, ++it) { | 680 | for ( it = slDynamicEntries->begin(); *lit; ++lit, ++it) { |
662 | (*lit)->setText( *it ); | 681 | (*lit)->setText( *it ); |
663 | } | 682 | } |
664 | } | 683 | } |
665 | 684 | ||
666 | void ContactEditor::accept() { | 685 | void ContactEditor::accept() { |
667 | 686 | ||
668 | if ( isEmpty() ) { | 687 | if ( isEmpty() ) { |
669 | cleanupFields(); | 688 | cleanupFields(); |
670 | reject(); | 689 | reject(); |
671 | } else { | 690 | } else { |
672 | saveEntry(); | 691 | saveEntry(); |
673 | cleanupFields(); | 692 | cleanupFields(); |
674 | QDialog::accept(); | 693 | QDialog::accept(); |
675 | } | 694 | } |
676 | 695 | ||
677 | } | 696 | } |
678 | 697 | ||
679 | void ContactEditor::slotNote() { | 698 | void ContactEditor::slotNote() { |
680 | 699 | ||
681 | dlgNote->showMaximized(); | 700 | dlgNote->showMaximized(); |
682 | if ( !dlgNote->exec() ) { | 701 | if ( !dlgNote->exec() ) { |
683 | txtNote->setText( ent.notes() ); | 702 | txtNote->setText( ent.notes() ); |
684 | } | 703 | } |
685 | } | 704 | } |
686 | 705 | ||
687 | void ContactEditor::slotName() { | 706 | void ContactEditor::slotName() { |
688 | 707 | ||
689 | if (useFullName = TRUE) { | 708 | if (useFullName = TRUE) { |
690 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); | 709 | txtFirstName->setText( parseName(txtFullName->text(), NAME_F) ); |
691 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); | 710 | txtMiddleName->setText( parseName(txtFullName->text(), NAME_M) ); |
692 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); | 711 | txtLastName->setText( parseName(txtFullName->text(), NAME_L) ); |
693 | txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); | 712 | txtSuffix->setText( parseName(txtFullName->text(), NAME_S) ); |
694 | } | 713 | } |
695 | 714 | ||
696 | dlgName->showMaximized(); | 715 | dlgName->showMaximized(); |
697 | if ( dlgName->exec() ) { | 716 | if ( dlgName->exec() ) { |
698 | txtFullName->setText( txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text() ); | 717 | txtFullName->setText( txtFirstName->text() + " " + txtMiddleName->text() + " " + txtLastName->text() + " " + txtSuffix->text() ); |
699 | slotFullNameChange( txtFullName->text() ); | 718 | slotFullNameChange( txtFullName->text() ); |
700 | useFullName = FALSE; | 719 | useFullName = FALSE; |
701 | } | 720 | } |
702 | 721 | ||
703 | } | 722 | } |
704 | 723 | ||
705 | void ContactEditor::setNameFocus() { | 724 | void ContactEditor::setNameFocus() { |
706 | 725 | ||
707 | txtFullName->setFocus(); | 726 | txtFullName->setFocus(); |
708 | 727 | ||
709 | } | 728 | } |
710 | 729 | ||
711 | bool ContactEditor::isEmpty() { | 730 | bool ContactEditor::isEmpty() { |
712 | // Test and see if the record should be saved. | 731 | // Test and see if the record should be saved. |
713 | // More strict than the original qtopia, needs name or fileas to save | 732 | // More strict than the original qtopia, needs name or fileas to save |
714 | 733 | ||
715 | QString t = txtFullName->text(); | 734 | QString t = txtFullName->text(); |
716 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 735 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
717 | return false; | 736 | return false; |
718 | 737 | ||
719 | t = cmbFileAs->currentText(); | 738 | t = cmbFileAs->currentText(); |
720 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 739 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
721 | return false; | 740 | return false; |
722 | 741 | ||
723 | return true; | 742 | return true; |
724 | 743 | ||
725 | } | 744 | } |
726 | 745 | ||
727 | QString ContactEditor::parseName( const QString fullName, int type ) { | 746 | QString ContactEditor::parseName( const QString fullName, int type ) { |
728 | 747 | ||
729 | QString simplifiedName( fullName.simplifyWhiteSpace() ); | 748 | QString simplifiedName( fullName.simplifyWhiteSpace() ); |
730 | QString strFirstName; | 749 | QString strFirstName; |
731 | QString strMiddleName; | 750 | QString strMiddleName; |
732 | QString strLastName; | 751 | QString strLastName; |
733 | QString strSuffix; | 752 | QString strSuffix; |
734 | QString strTitle; | 753 | QString strTitle; |
735 | int commapos; | 754 | int commapos; |
736 | int spCount; | 755 | int spCount; |
737 | int spPos; | 756 | int spPos; |
738 | int spPos2; | 757 | int spPos2; |
739 | 758 | ||
740 | 759 | ||
741 | commapos = simplifiedName.find( ',', 0, TRUE); | 760 | commapos = simplifiedName.find( ',', 0, TRUE); |
742 | spCount = simplifiedName.contains( ' ', TRUE ); | 761 | spCount = simplifiedName.contains( ' ', TRUE ); |
743 | 762 | ||
744 | if ( commapos == -1 ) { | 763 | if ( commapos == -1 ) { |
745 | 764 | ||
746 | switch (spCount) { | 765 | switch (spCount) { |
747 | case 0: | 766 | case 0: |
748 | return simplifiedName; | 767 | return simplifiedName; |
749 | 768 | ||
750 | case 1: | 769 | case 1: |
751 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 770 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
752 | strFirstName = simplifiedName.left( spPos ); | 771 | strFirstName = simplifiedName.left( spPos ); |
753 | strLastName = simplifiedName.mid( spPos + 1 ); | 772 | strLastName = simplifiedName.mid( spPos + 1 ); |
754 | break; | 773 | break; |
755 | 774 | ||
756 | case 2: | 775 | case 2: |
757 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 776 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
758 | strFirstName = simplifiedName.left( spPos ); | 777 | strFirstName = simplifiedName.left( spPos ); |
759 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 778 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
760 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 779 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
761 | strLastName = simplifiedName.mid( spPos2 + 1 ); | 780 | strLastName = simplifiedName.mid( spPos2 + 1 ); |
762 | break; | 781 | break; |
763 | 782 | ||
764 | case 3: | 783 | case 3: |
765 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 784 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
766 | strFirstName = simplifiedName.left( spPos ); | 785 | strFirstName = simplifiedName.left( spPos ); |
767 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 786 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
768 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 787 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
769 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 788 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
770 | strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); | 789 | strLastName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); |
771 | strSuffix = simplifiedName.mid( spPos + 1 ); | 790 | strSuffix = simplifiedName.mid( spPos + 1 ); |
772 | break; | 791 | break; |
773 | 792 | ||
774 | case 4: | 793 | case 4: |
775 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 794 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
776 | strTitle = simplifiedName.left( spPos ); | 795 | strTitle = simplifiedName.left( spPos ); |
777 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 796 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
778 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 797 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
779 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 798 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
780 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); | 799 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); |
781 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 800 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
782 | strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 801 | strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
783 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 802 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
784 | break; | 803 | break; |
785 | 804 | ||
786 | default: | 805 | default: |
787 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 806 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
788 | strTitle = simplifiedName.left( spPos ); | 807 | strTitle = simplifiedName.left( spPos ); |
789 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 808 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
790 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 809 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
791 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 810 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
792 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); | 811 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); |
793 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 812 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
794 | strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 813 | strLastName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
795 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 814 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
796 | break; | 815 | break; |
797 | } | 816 | } |
798 | } else { | 817 | } else { |
799 | simplifiedName.replace( commapos, 1, " " ); | 818 | simplifiedName.replace( commapos, 1, " " ); |
800 | simplifiedName = simplifiedName.simplifyWhiteSpace(); | 819 | simplifiedName = simplifiedName.simplifyWhiteSpace(); |
801 | 820 | ||
802 | switch (spCount) { | 821 | switch (spCount) { |
803 | case 0: | 822 | case 0: |
804 | return simplifiedName; | 823 | return simplifiedName; |
805 | 824 | ||
806 | case 1: | 825 | case 1: |
807 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 826 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
808 | strLastName = simplifiedName.left( spPos ); | 827 | strLastName = simplifiedName.left( spPos ); |
809 | strFirstName = simplifiedName.mid( spPos + 1 ); | 828 | strFirstName = simplifiedName.mid( spPos + 1 ); |
810 | break; | 829 | break; |
811 | 830 | ||
812 | case 2: | 831 | case 2: |
813 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 832 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
814 | strLastName = simplifiedName.left( spPos ); | 833 | strLastName = simplifiedName.left( spPos ); |
815 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 834 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
816 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 835 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
817 | strMiddleName = simplifiedName.mid( spPos2 + 1 ); | 836 | strMiddleName = simplifiedName.mid( spPos2 + 1 ); |
818 | break; | 837 | break; |
819 | 838 | ||
820 | case 3: | 839 | case 3: |
821 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 840 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
822 | strLastName = simplifiedName.left( spPos ); | 841 | strLastName = simplifiedName.left( spPos ); |
823 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 842 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
824 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 843 | strFirstName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
825 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 844 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
826 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); | 845 | strMiddleName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); |
827 | strSuffix = simplifiedName.mid( spPos + 1 ); | 846 | strSuffix = simplifiedName.mid( spPos + 1 ); |
828 | break; | 847 | break; |
829 | 848 | ||
830 | case 4: | 849 | case 4: |
831 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 850 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
832 | strLastName = simplifiedName.left( spPos ); | 851 | strLastName = simplifiedName.left( spPos ); |
833 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 852 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
834 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 853 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
835 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 854 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
836 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); | 855 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); |
837 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 856 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
838 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 857 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
839 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 858 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
840 | break; | 859 | break; |
841 | 860 | ||
842 | default: | 861 | default: |
843 | spPos = simplifiedName.find( ' ', 0, TRUE ); | 862 | spPos = simplifiedName.find( ' ', 0, TRUE ); |
844 | strLastName = simplifiedName.left( spPos ); | 863 | strLastName = simplifiedName.left( spPos ); |
845 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 864 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
846 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 865 | strTitle = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
847 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); | 866 | spPos = simplifiedName.find( ' ', spPos2 + 1, TRUE ); |
848 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); | 867 | strFirstName = simplifiedName.mid( spPos2 + 1, (spPos - 1) - spPos ); |
849 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); | 868 | spPos2 = simplifiedName.find( ' ', spPos + 1, TRUE ); |
850 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); | 869 | strMiddleName = simplifiedName.mid( spPos + 1, (spPos2 - 1) - spPos ); |
851 | strSuffix = simplifiedName.mid( spPos2 + 1 ); | 870 | strSuffix = simplifiedName.mid( spPos2 + 1 ); |
852 | break; | 871 | break; |
853 | } | 872 | } |
854 | } | 873 | } |
855 | 874 | ||
856 | switch (type) { | 875 | switch (type) { |
857 | case NAME_FL: | 876 | case NAME_FL: |
858 | return strFirstName + " " + strLastName; | 877 | return strFirstName + " " + strLastName; |
859 | 878 | ||
860 | case NAME_LF: | 879 | case NAME_LF: |
861 | return strLastName + ", " + strFirstName; | 880 | return strLastName + ", " + strFirstName; |
862 | 881 | ||
863 | case NAME_LFM: | 882 | case NAME_LFM: |
864 | return strLastName + ", " + strFirstName + " " + strMiddleName; | 883 | return strLastName + ", " + strFirstName + " " + strMiddleName; |
865 | 884 | ||
866 | case NAME_FMLS: | 885 | case NAME_FMLS: |
867 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; | 886 | return strFirstName + " " + strMiddleName + " " + strLastName + " " + strSuffix; |
868 | 887 | ||
869 | case NAME_F: | 888 | case NAME_F: |
870 | return strFirstName; | 889 | return strFirstName; |
871 | 890 | ||
872 | case NAME_M: | 891 | case NAME_M: |
873 | return strMiddleName; | 892 | return strMiddleName; |
874 | 893 | ||
875 | case NAME_L: | 894 | case NAME_L: |
876 | return strLastName; | 895 | return strLastName; |
877 | 896 | ||
878 | case NAME_S: | 897 | case NAME_S: |
879 | return strSuffix; | 898 | return strSuffix; |
880 | 899 | ||
881 | } | 900 | } |
882 | } | 901 | } |
883 | 902 | ||
884 | void ContactEditor::cleanupFields() { | 903 | void ContactEditor::cleanupFields() { |
885 | 904 | ||
886 | QStringList::Iterator it = slChooserValues->begin(); | 905 | QStringList::Iterator it = slChooserValues->begin(); |
887 | for ( int i = 0; it != slChooserValues->end(); i++, ++it ) { | 906 | for ( int i = 0; it != slChooserValues->end(); i++, ++it ) { |
888 | (*it) = ""; | 907 | (*it) = ""; |
889 | } | 908 | } |
890 | 909 | ||
891 | for ( int i = 0; i < 7; i++ ) { | 910 | for ( int i = 0; i < 7; i++ ) { |
892 | (*slHomeAddress)[i] = ""; | 911 | (*slHomeAddress)[i] = ""; |
893 | (*slBusinessAddress)[i] = ""; | 912 | (*slBusinessAddress)[i] = ""; |
894 | } | 913 | } |
895 | 914 | ||
896 | QStringList::ConstIterator cit; | 915 | QStringList::ConstIterator cit; |
897 | QListIterator<QLineEdit> itLE( listValue ); | 916 | QListIterator<QLineEdit> itLE( listValue ); |
898 | for ( cit = slDynamicEntries->begin(); cit != slDynamicEntries->end(); ++cit, ++itLE) { | 917 | for ( cit = slDynamicEntries->begin(); cit != slDynamicEntries->end(); ++cit, ++itLE) { |
899 | (*itLE)->setText( "" ); | 918 | (*itLE)->setText( "" ); |
900 | } | 919 | } |
901 | 920 | ||
902 | txtFirstName->setText(""); | 921 | txtFirstName->setText(""); |
903 | txtMiddleName->setText(""); | 922 | txtMiddleName->setText(""); |
904 | txtLastName->setText(""); | 923 | txtLastName->setText(""); |
905 | txtSuffix->setText(""); | 924 | txtSuffix->setText(""); |
906 | txtNote->setText(""); | 925 | txtNote->setText(""); |
907 | txtFullName->setText(""); | 926 | txtFullName->setText(""); |
908 | txtJobTitle->setText(""); | 927 | txtJobTitle->setText(""); |
909 | txtOrganization->setText(""); | 928 | txtOrganization->setText(""); |
910 | txtChooserField1->setText(""); | 929 | txtChooserField1->setText(""); |
911 | txtChooserField2->setText(""); | 930 | txtChooserField2->setText(""); |
912 | txtChooserField3->setText(""); | 931 | txtChooserField3->setText(""); |
913 | txtAddress->setText(""); | 932 | txtAddress->setText(""); |
914 | //txtAddress2->setText(""); | 933 | //txtAddress2->setText(""); |
915 | txtCity->setText(""); | 934 | txtCity->setText(""); |
916 | //txtPOBox->setText(""); | 935 | //txtPOBox->setText(""); |
917 | txtState->setText(""); | 936 | txtState->setText(""); |
918 | txtZip->setText(""); | 937 | txtZip->setText(""); |
919 | QLineEdit *txtTmp = cmbCountry->lineEdit(); | 938 | QLineEdit *txtTmp = cmbCountry->lineEdit(); |
920 | txtTmp->setText(""); | 939 | txtTmp->setText(""); |
921 | txtTmp = cmbFileAs->lineEdit(); | 940 | txtTmp = cmbFileAs->lineEdit(); |
922 | txtTmp->setText(""); | 941 | txtTmp->setText(""); |
923 | 942 | ||
924 | } | 943 | } |
925 | 944 | ||
926 | void ContactEditor::setEntry( const Contact &entry ) { | 945 | void ContactEditor::setEntry( const Contact &entry ) { |
927 | 946 | ||
928 | cleanupFields(); | 947 | cleanupFields(); |
929 | 948 | ||
930 | 949 | ||
931 | ent = entry; | 950 | ent = entry; |
932 | 951 | ||
933 | useFullName = FALSE; | 952 | useFullName = FALSE; |
934 | txtFirstName->setText( ent.firstName() ); | 953 | txtFirstName->setText( ent.firstName() ); |
935 | txtMiddleName->setText( ent.middleName() ); | 954 | txtMiddleName->setText( ent.middleName() ); |
936 | txtLastName->setText( ent.lastName() ); | 955 | txtLastName->setText( ent.lastName() ); |
937 | txtSuffix->setText( ent.suffix() ); | 956 | txtSuffix->setText( ent.suffix() ); |
938 | 957 | ||
939 | QString *tmpString = new QString; | 958 | QString *tmpString = new QString; |
940 | *tmpString = ent.firstName() + " " + ent.middleName() + | 959 | *tmpString = ent.firstName() + " " + ent.middleName() + |
941 | + " " + ent.lastName() + " " + ent.suffix(); | 960 | + " " + ent.lastName() + " " + ent.suffix(); |
942 | 961 | ||
943 | txtFullName->setText( tmpString->simplifyWhiteSpace() ); | 962 | txtFullName->setText( tmpString->simplifyWhiteSpace() ); |
944 | 963 | ||
945 | cmbFileAs->setEditText( ent.fileAs() ); | 964 | cmbFileAs->setEditText( ent.fileAs() ); |
946 | 965 | ||
947 | if (hasTitle) | 966 | if (hasTitle) |
948 | txtJobTitle->setText( ent.jobTitle() ); | 967 | txtJobTitle->setText( ent.jobTitle() ); |
949 | 968 | ||
950 | if (hasCompany) | 969 | if (hasCompany) |
951 | txtOrganization->setText( ent.company() ); | 970 | txtOrganization->setText( ent.company() ); |
952 | 971 | ||
953 | if (hasNotes) | 972 | if (hasNotes) |
954 | txtNote->setText( ent.notes() ); | 973 | txtNote->setText( ent.notes() ); |
955 | 974 | ||
956 | if (hasStreet) { | 975 | if (hasStreet) { |
957 | (*slHomeAddress)[0] = ent.homeStreet(); | 976 | (*slHomeAddress)[0] = ent.homeStreet(); |
958 | (*slBusinessAddress)[0] = ent.businessStreet(); | 977 | (*slBusinessAddress)[0] = ent.businessStreet(); |
959 | } | 978 | } |
960 | /* | 979 | /* |
961 | if (hasStreet2) { | 980 | if (hasStreet2) { |
962 | (*slHomeAddress)[1] = ent.homeStreet2(); | 981 | (*slHomeAddress)[1] = ent.homeStreet2(); |
963 | (*slBusinessAddress)[1] = ent.businessStreet2(); | 982 | (*slBusinessAddress)[1] = ent.businessStreet2(); |
964 | } | 983 | } |
965 | 984 | ||
966 | if (hasPOBox) { | 985 | if (hasPOBox) { |
967 | (*slHomeAddress)[2] = ent.homePOBox(); | 986 | (*slHomeAddress)[2] = ent.homePOBox(); |
968 | (*slBusinessAddress)[2] = ent.businessPOBox(); | 987 | (*slBusinessAddress)[2] = ent.businessPOBox(); |
969 | } | 988 | } |
970 | */ | 989 | */ |
971 | if (hasCity) { | 990 | if (hasCity) { |
972 | (*slHomeAddress)[3] = ent.homeCity(); | 991 | (*slHomeAddress)[3] = ent.homeCity(); |
973 | (*slBusinessAddress)[3] = ent.businessCity(); | 992 | (*slBusinessAddress)[3] = ent.businessCity(); |
974 | } | 993 | } |
975 | 994 | ||
976 | if (hasState) { | 995 | if (hasState) { |
977 | (*slHomeAddress)[4] = ent.homeState(); | 996 | (*slHomeAddress)[4] = ent.homeState(); |
978 | (*slBusinessAddress)[4] = ent.businessState(); | 997 | (*slBusinessAddress)[4] = ent.businessState(); |
979 | } | 998 | } |
980 | 999 | ||
981 | if (hasZip) { | 1000 | if (hasZip) { |
982 | (*slHomeAddress)[5] = ent.homeZip(); | 1001 | (*slHomeAddress)[5] = ent.homeZip(); |
983 | (*slBusinessAddress)[5] = ent.businessZip(); | 1002 | (*slBusinessAddress)[5] = ent.businessZip(); |
984 | } | 1003 | } |
985 | 1004 | ||
986 | if (hasCountry) { | 1005 | if (hasCountry) { |
987 | (*slHomeAddress)[6] = ent.homeCountry(); | 1006 | (*slHomeAddress)[6] = ent.homeCountry(); |
988 | (*slBusinessAddress)[6] = ent.businessCountry(); | 1007 | (*slBusinessAddress)[6] = ent.businessCountry(); |
989 | } | 1008 | } |
990 | 1009 | ||
991 | QStringList::ConstIterator it; | 1010 | QStringList::ConstIterator it; |
992 | QListIterator<QLineEdit> itLE( listValue ); | 1011 | QListIterator<QLineEdit> itLE( listValue ); |
993 | for ( it = slDynamicEntries->begin(); it != slDynamicEntries->end(); ++it, ++itLE) { | 1012 | for ( it = slDynamicEntries->begin(); it != slDynamicEntries->end(); ++it, ++itLE) { |
994 | if ( *it == "Department" ) | 1013 | if ( *it == "Department" ) |
995 | (*itLE)->setText( ent.department() ); | 1014 | (*itLE)->setText( ent.department() ); |
996 | 1015 | ||
997 | if ( *it == "Company" ) | 1016 | if ( *it == "Company" ) |
998 | (*itLE)->setText( ent.company() ); | 1017 | (*itLE)->setText( ent.company() ); |
999 | 1018 | ||
1000 | if ( *it == "Office" ) | 1019 | if ( *it == "Office" ) |
1001 | (*itLE)->setText( ent.office() ); | 1020 | (*itLE)->setText( ent.office() ); |
1002 | 1021 | ||
1003 | if ( *it == "Profession" ) | 1022 | if ( *it == "Profession" ) |
1004 | (*itLE)->setText( ent.profession() ); | 1023 | (*itLE)->setText( ent.profession() ); |
1005 | 1024 | ||
1006 | if ( *it == "Assistant" ) | 1025 | if ( *it == "Assistant" ) |
1007 | (*itLE)->setText( ent.assistant() ); | 1026 | (*itLE)->setText( ent.assistant() ); |
1008 | 1027 | ||
1009 | if ( *it == "Manager" ) | 1028 | if ( *it == "Manager" ) |
1010 | (*itLE)->setText( ent.manager() ); | 1029 | (*itLE)->setText( ent.manager() ); |
1011 | 1030 | ||
1012 | if ( *it == "Spouse" ) | 1031 | if ( *it == "Spouse" ) |
1013 | (*itLE)->setText( ent.spouse() ); | 1032 | (*itLE)->setText( ent.spouse() ); |
1014 | 1033 | ||
1015 | if ( *it == "Birthday" ) | 1034 | if ( *it == "Birthday" ) |
1016 | (*itLE)->setText( ent.birthday() ); | 1035 | (*itLE)->setText( ent.birthday() ); |
1017 | 1036 | ||
1018 | if ( *it == "Anniversary" ) | 1037 | if ( *it == "Anniversary" ) |
1019 | (*itLE)->setText( ent.anniversary() ); | 1038 | (*itLE)->setText( ent.anniversary() ); |
1020 | 1039 | ||
1021 | if ( *it == "Nickname" ) | 1040 | if ( *it == "Nickname" ) |
1022 | (*itLE)->setText( ent.nickname() ); | 1041 | (*itLE)->setText( ent.nickname() ); |
1023 | 1042 | ||
1024 | if ( *it == "Children" ) | 1043 | if ( *it == "Children" ) |
1025 | (*itLE)->setText( ent.children() ); | 1044 | (*itLE)->setText( ent.children() ); |
1026 | 1045 | ||
1027 | } | 1046 | } |
1028 | 1047 | ||
1029 | QStringList::Iterator itV; | 1048 | QStringList::Iterator itV; |
1030 | for ( it = slChooserNames->begin(), itV = slChooserValues->begin(); it != slChooserNames->end(); ++it, ++itV ) { | 1049 | for ( it = slChooserNames->begin(), itV = slChooserValues->begin(); it != slChooserNames->end(); ++it, ++itV ) { |
1031 | 1050 | ||
1032 | if ( *it == "Business Phone" || *it == "Work Phone" ) | 1051 | if ( *it == "Business Phone" || *it == "Work Phone" ) |
1033 | *itV = ent.businessPhone(); | 1052 | *itV = ent.businessPhone(); |
1034 | /* | 1053 | /* |
1035 | if ( *it == "Business 2 Phone" ) | 1054 | if ( *it == "Business 2 Phone" ) |
1036 | *itV = ent.business2Phone(); | 1055 | *itV = ent.business2Phone(); |
1037 | */ | 1056 | */ |
1038 | if ( *it == "Business Fax" || *it == "Work Fax" ) | 1057 | if ( *it == "Business Fax" || *it == "Work Fax" ) |
1039 | *itV = ent.businessFax(); | 1058 | *itV = ent.businessFax(); |
1040 | 1059 | ||
1041 | if ( *it == "Business Mobile" || *it == "work Mobile" ) | 1060 | if ( *it == "Business Mobile" || *it == "work Mobile" ) |
1042 | *itV = ent.businessMobile(); | 1061 | *itV = ent.businessMobile(); |
1043 | /* | 1062 | /* |
1044 | if ( *it == "Company Phone" ) | 1063 | if ( *it == "Company Phone" ) |
1045 | *itV = ent.companyPhone(); | 1064 | *itV = ent.companyPhone(); |
1046 | */ | 1065 | */ |
1047 | if ( *it == "Default Email" ) | 1066 | if ( *it == "Default Email" ) |
1048 | *itV = ent.defaultEmail(); | 1067 | *itV = ent.defaultEmail(); |
1049 | 1068 | ||
1050 | if ( *it == "Emails" ) | 1069 | if ( *it == "Emails" ) |
1051 | *itV = ent.emails(); | 1070 | *itV = ent.emails(); |
1052 | 1071 | ||
1053 | if ( *it == "Home Phone" ) | 1072 | if ( *it == "Home Phone" ) |
1054 | *itV = ent.homePhone(); | 1073 | *itV = ent.homePhone(); |
1055 | /* | 1074 | /* |
1056 | if ( *it == "Home 2 Phone" ) | 1075 | if ( *it == "Home 2 Phone" ) |
1057 | *itV = ent.home2Phone(); | 1076 | *itV = ent.home2Phone(); |
1058 | */ | 1077 | */ |
1059 | if ( *it == "Home Fax" ) | 1078 | if ( *it == "Home Fax" ) |
1060 | *itV = ent.homeFax(); | 1079 | *itV = ent.homeFax(); |
1061 | 1080 | ||
1062 | if ( *it == "Home Mobile" ) | 1081 | if ( *it == "Home Mobile" ) |
1063 | *itV = ent.homeMobile(); | 1082 | *itV = ent.homeMobile(); |
1064 | /* | 1083 | /* |
1065 | if ( *it == "Car Phone" ) | 1084 | if ( *it == "Car Phone" ) |
1066 | *itV = ent.carPhone(); | 1085 | *itV = ent.carPhone(); |
1067 | 1086 | ||
1068 | if ( *it == "ISDN Phone" ) | 1087 | if ( *it == "ISDN Phone" ) |
1069 | *itV = ent.ISDNPhone(); | 1088 | *itV = ent.ISDNPhone(); |
1070 | 1089 | ||
1071 | if ( *it == "Other Phone" ) | 1090 | if ( *it == "Other Phone" ) |
1072 | *itV = ent.otherPhone(); | 1091 | *itV = ent.otherPhone(); |
1073 | */ | 1092 | */ |
1074 | if ( *it == "Business Pager" || *it == "Work Pager" ) | 1093 | if ( *it == "Business Pager" || *it == "Work Pager" ) |
1075 | *itV = ent.businessPager(); | 1094 | *itV = ent.businessPager(); |
1076 | /* | 1095 | /* |
1077 | if ( *it == "Home Pager") | 1096 | if ( *it == "Home Pager") |
1078 | *itV = ent.homePager(); | 1097 | *itV = ent.homePager(); |
1079 | 1098 | ||
1080 | if ( *it == "AIM IM" ) | 1099 | if ( *it == "AIM IM" ) |
1081 | *itV = ent.AIMIM(); | 1100 | *itV = ent.AIMIM(); |
1082 | 1101 | ||
1083 | if ( *it == "ICQ IM" ) | 1102 | if ( *it == "ICQ IM" ) |
1084 | *itV = ent.ICQIM(); | 1103 | *itV = ent.ICQIM(); |
1085 | 1104 | ||
1086 | if ( *it == "Jabber IM" ) | 1105 | if ( *it == "Jabber IM" ) |
1087 | *itV = ent.jabberIM(); | 1106 | *itV = ent.jabberIM(); |
1088 | 1107 | ||
1089 | if ( *it == "MSN IM" ) | 1108 | if ( *it == "MSN IM" ) |
1090 | *itV = ent.MSNIM(); | 1109 | *itV = ent.MSNIM(); |
1091 | 1110 | ||
1092 | if ( *it == "Yahoo IM" ) | 1111 | if ( *it == "Yahoo IM" ) |
1093 | *itV = ent.yahooIM(); | 1112 | *itV = ent.yahooIM(); |
1094 | */ | 1113 | */ |
1095 | if ( *it == "Home Web Page" ) | 1114 | if ( *it == "Home Web Page" ) |
1096 | *itV = ent.homeWebpage(); | 1115 | *itV = ent.homeWebpage(); |
1097 | if ( *it == "Business Web Page" || *it == "Work Web Page" ) | 1116 | if ( *it == "Business Web Page" || *it == "Work Web Page" ) |
1098 | *itV = ent.businessWebpage(); | 1117 | *itV = ent.businessWebpage(); |
1099 | 1118 | ||
1100 | 1119 | ||
1101 | } | 1120 | } |
1102 | 1121 | ||
1103 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); | 1122 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); |
1104 | 1123 | ||
1105 | QString gender = ent.gender(); | 1124 | QString gender = ent.gender(); |
1106 | cmbGender->setCurrentItem( gender.toInt() ); | 1125 | cmbGender->setCurrentItem( gender.toInt() ); |
1107 | 1126 | ||
1108 | txtNote->setText( ent.notes() ); | 1127 | txtNote->setText( ent.notes() ); |
1109 | 1128 | ||
1110 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); | 1129 | slotCmbChooser1Change( cmbChooserField1->currentItem() ); |
1111 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); | 1130 | slotCmbChooser2Change( cmbChooserField2->currentItem() ); |
1112 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); | 1131 | slotCmbChooser3Change( cmbChooserField3->currentItem() ); |
1113 | 1132 | ||
1114 | slotAddressTypeChange( cmbAddress->currentItem() ); | 1133 | slotAddressTypeChange( cmbAddress->currentItem() ); |
1115 | 1134 | ||
1116 | } | 1135 | } |
1117 | 1136 | ||
1118 | void ContactEditor::saveEntry() { | 1137 | void ContactEditor::saveEntry() { |
1119 | 1138 | ||
1120 | if ( useFullName == TRUE ) { | 1139 | if ( useFullName == TRUE ) { |
1121 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); | 1140 | txtFirstName->setText( parseName( txtFullName->text(), NAME_F ) ); |
1122 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); | 1141 | txtMiddleName->setText( parseName( txtFullName->text(), NAME_M ) ); |
1123 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); | 1142 | txtLastName->setText( parseName( txtFullName->text(), NAME_L ) ); |
1124 | txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); | 1143 | txtSuffix->setText( parseName( txtFullName->text(), NAME_S ) ); |
1125 | 1144 | ||
1126 | useFullName = FALSE; | 1145 | useFullName = FALSE; |
1127 | } | 1146 | } |
1128 | 1147 | ||
1129 | /*if ( ent.firstName() != txtFirstName->text() || | 1148 | /*if ( ent.firstName() != txtFirstName->text() || |
1130 | ent.lastName != txtLastName->text() || | 1149 | ent.lastName != txtLastName->text() || |
1131 | ent.middleName != txtMiddleName->text() ) { | 1150 | ent.middleName != txtMiddleName->text() ) { |
1132 | */ | 1151 | */ |
1133 | ent.setFirstName( txtFirstName->text() ); | 1152 | ent.setFirstName( txtFirstName->text() ); |
1134 | ent.setLastName( txtLastName->text() ); | 1153 | ent.setLastName( txtLastName->text() ); |
1135 | ent.setMiddleName( txtMiddleName->text() ); | 1154 | ent.setMiddleName( txtMiddleName->text() ); |
1136 | 1155 | ||
1137 | //} | 1156 | //} |
1138 | 1157 | ||
1139 | ent.setFileAs( cmbFileAs->currentText() ); | 1158 | ent.setFileAs( cmbFileAs->currentText() ); |
1140 | 1159 | ||
1141 | ent.setCategories( cmbCat->currentCategories() ); | 1160 | ent.setCategories( cmbCat->currentCategories() ); |
1142 | 1161 | ||
1143 | if (hasTitle) | 1162 | if (hasTitle) |
1144 | ent.setJobTitle( txtJobTitle->text() ); | 1163 | ent.setJobTitle( txtJobTitle->text() ); |
1145 | 1164 | ||
1146 | if (hasCompany) | 1165 | if (hasCompany) |
1147 | ent.setCompany( txtOrganization->text() ); | 1166 | ent.setCompany( txtOrganization->text() ); |
1148 | 1167 | ||
1149 | if (hasNotes) | 1168 | if (hasNotes) |
1150 | ent.setNotes( txtNote->text() ); | 1169 | ent.setNotes( txtNote->text() ); |
1151 | 1170 | ||
1152 | if (hasStreet) { | 1171 | if (hasStreet) { |
1153 | ent.setHomeStreet( (*slHomeAddress)[0] ); | 1172 | ent.setHomeStreet( (*slHomeAddress)[0] ); |
1154 | ent.setBusinessStreet( (*slBusinessAddress)[0] ); | 1173 | ent.setBusinessStreet( (*slBusinessAddress)[0] ); |
1155 | } | 1174 | } |
1156 | /* | 1175 | /* |
1157 | if (hasStreet2) { | 1176 | if (hasStreet2) { |
1158 | ent.setHomeStreet2( (*slHomeAddress)[1] ); | 1177 | ent.setHomeStreet2( (*slHomeAddress)[1] ); |
1159 | ent.setBusinessStreet2( (*slBusinessAddress)[1] ); | 1178 | ent.setBusinessStreet2( (*slBusinessAddress)[1] ); |
1160 | } | 1179 | } |
1161 | 1180 | ||
1162 | if (hasPOBox) { | 1181 | if (hasPOBox) { |
1163 | ent.setHomePOBox( (*slHomeAddress)[2] ); | 1182 | ent.setHomePOBox( (*slHomeAddress)[2] ); |
1164 | ent.setBusinessPOBox( (*slBusinessAddress)[2] ); | 1183 | ent.setBusinessPOBox( (*slBusinessAddress)[2] ); |
1165 | } | 1184 | } |
1166 | */ | 1185 | */ |
1167 | if (hasCity) { | 1186 | if (hasCity) { |
1168 | ent.setHomeCity( (*slHomeAddress)[3] ); | 1187 | ent.setHomeCity( (*slHomeAddress)[3] ); |
1169 | ent.setBusinessCity( (*slBusinessAddress)[3] ); | 1188 | ent.setBusinessCity( (*slBusinessAddress)[3] ); |
1170 | } | 1189 | } |
1171 | 1190 | ||
1172 | if (hasState) { | 1191 | if (hasState) { |
1173 | ent.setHomeState( (*slHomeAddress)[4] ); | 1192 | ent.setHomeState( (*slHomeAddress)[4] ); |
1174 | ent.setBusinessState( (*slBusinessAddress)[4] ); | 1193 | ent.setBusinessState( (*slBusinessAddress)[4] ); |
1175 | } | 1194 | } |
1176 | 1195 | ||
1177 | if (hasZip) { | 1196 | if (hasZip) { |
1178 | ent.setHomeZip( (*slHomeAddress)[5] ); | 1197 | ent.setHomeZip( (*slHomeAddress)[5] ); |
1179 | ent.setBusinessZip( (*slBusinessAddress)[5] ); | 1198 | ent.setBusinessZip( (*slBusinessAddress)[5] ); |
1180 | } | 1199 | } |
1181 | 1200 | ||
1182 | if (hasCountry) { | 1201 | if (hasCountry) { |
1183 | ent.setHomeCountry( (*slHomeAddress)[6] ); | 1202 | ent.setHomeCountry( (*slHomeAddress)[6] ); |
1184 | ent.setBusinessCountry( (*slBusinessAddress)[6] ); | 1203 | ent.setBusinessCountry( (*slBusinessAddress)[6] ); |
1185 | } | 1204 | } |
1186 | 1205 | ||
1187 | QStringList::ConstIterator it; | 1206 | QStringList::ConstIterator it; |
1188 | QListIterator<QLineEdit> itLE( listValue ); | 1207 | QListIterator<QLineEdit> itLE( listValue ); |
1189 | for ( it = slDynamicEntries->begin(); it != slDynamicEntries->end(); ++it, ++itLE) { | 1208 | for ( it = slDynamicEntries->begin(); it != slDynamicEntries->end(); ++it, ++itLE) { |
1190 | if ( *it == "Department" ) | 1209 | if ( *it == "Department" ) |
1191 | ent.setDepartment( (*itLE)->text() ); | 1210 | ent.setDepartment( (*itLE)->text() ); |
1192 | 1211 | ||
1193 | if ( *it == "Company" ) | 1212 | if ( *it == "Company" ) |
1194 | ent.setCompany( (*itLE)->text() ); | 1213 | ent.setCompany( (*itLE)->text() ); |
1195 | 1214 | ||
1196 | if ( *it == "Office" ) | 1215 | if ( *it == "Office" ) |
1197 | ent.setOffice( (*itLE)->text() ); | 1216 | ent.setOffice( (*itLE)->text() ); |
1198 | 1217 | ||
1199 | if ( *it == "Profession" ) | 1218 | if ( *it == "Profession" ) |
1200 | ent.setProfession( (*itLE)->text() ); | 1219 | ent.setProfession( (*itLE)->text() ); |
1201 | 1220 | ||
1202 | if ( *it == "Assistant" ) | 1221 | if ( *it == "Assistant" ) |
1203 | ent.setAssistant( (*itLE)->text() ); | 1222 | ent.setAssistant( (*itLE)->text() ); |
1204 | 1223 | ||
1205 | if ( *it == "Manager" ) | 1224 | if ( *it == "Manager" ) |
1206 | ent.setManager( (*itLE)->text() ); | 1225 | ent.setManager( (*itLE)->text() ); |
1207 | 1226 | ||
1208 | if ( *it == "Spouse" ) | 1227 | if ( *it == "Spouse" ) |
1209 | ent.setSpouse( (*itLE)->text() ); | 1228 | ent.setSpouse( (*itLE)->text() ); |
1210 | 1229 | ||
1211 | if ( *it == "Birthday" ) | 1230 | if ( *it == "Birthday" ) |
1212 | ent.setBirthday( (*itLE)->text() ); | 1231 | ent.setBirthday( (*itLE)->text() ); |
1213 | 1232 | ||
1214 | if ( *it == "Anniversary" ) | 1233 | if ( *it == "Anniversary" ) |
1215 | ent.setAnniversary( (*itLE)->text() ); | 1234 | ent.setAnniversary( (*itLE)->text() ); |
1216 | 1235 | ||
1217 | if ( *it == "Nickname" ) | 1236 | if ( *it == "Nickname" ) |
1218 | ent.setNickname( (*itLE)->text() ); | 1237 | ent.setNickname( (*itLE)->text() ); |
1219 | 1238 | ||
1220 | if ( *it == "Children" ) | 1239 | if ( *it == "Children" ) |
1221 | ent.setChildren( (*itLE)->text() ); | 1240 | ent.setChildren( (*itLE)->text() ); |
1222 | 1241 | ||
1223 | } | 1242 | } |
1224 | 1243 | ||
1225 | QStringList::ConstIterator itV; | 1244 | QStringList::ConstIterator itV; |
1226 | for ( it = slChooserNames->begin(), itV = slChooserValues->begin(); it != slChooserNames->end(); ++it, ++itV ) { | 1245 | for ( it = slChooserNames->begin(), itV = slChooserValues->begin(); it != slChooserNames->end(); ++it, ++itV ) { |
1227 | 1246 | ||
1228 | if ( *it == "Business Phone" || *it == "Work Phone" ) | 1247 | if ( *it == "Business Phone" || *it == "Work Phone" ) |
1229 | ent.setBusinessPhone( *itV ); | 1248 | ent.setBusinessPhone( *itV ); |
1230 | /* | 1249 | /* |
1231 | if ( *it == "Business 2 Phone" ) | 1250 | if ( *it == "Business 2 Phone" ) |
1232 | ent.setBusiness2Phone( *itV ); | 1251 | ent.setBusiness2Phone( *itV ); |
1233 | */ | 1252 | */ |
1234 | if ( *it == "Business Fax" || *it == "Work Fax" ) | 1253 | if ( *it == "Business Fax" || *it == "Work Fax" ) |
1235 | ent.setBusinessFax( *itV ); | 1254 | ent.setBusinessFax( *itV ); |
1236 | 1255 | ||
1237 | if ( *it == "Business Mobile" || *it == "Work Mobile" ) | 1256 | if ( *it == "Business Mobile" || *it == "Work Mobile" ) |
1238 | ent.setBusinessMobile( *itV ); | 1257 | ent.setBusinessMobile( *itV ); |
1239 | /* | 1258 | /* |
1240 | if ( *it == "Company Phone" ) | 1259 | if ( *it == "Company Phone" ) |
1241 | ent.setCompanyPhone( *itV ); | 1260 | ent.setCompanyPhone( *itV ); |
1242 | */ | 1261 | */ |
1243 | //if ( *it == "Default Email" ) | 1262 | //if ( *it == "Default Email" ) |
1244 | //ent.setDefaultEmail( *itV ); | 1263 | //ent.setDefaultEmail( *itV ); |
1245 | 1264 | ||
1246 | if ( *it == "Emails" ) { | 1265 | if ( *it == "Emails" ) { |
1247 | QString allemail; | 1266 | QString allemail; |
1248 | QString defaultmail; | 1267 | QString defaultmail; |
1249 | parseEmailFrom( *itV, defaultmail, allemail ); | 1268 | parseEmailFrom( *itV, defaultmail, allemail ); |
1250 | ent.setDefaultEmail( defaultmail ); | 1269 | ent.setDefaultEmail( defaultmail ); |
1251 | ent.setEmails( *itV ); | 1270 | ent.setEmails( *itV ); |
1252 | } | 1271 | } |
1253 | 1272 | ||
1254 | if ( *it == "Home Phone" ) | 1273 | if ( *it == "Home Phone" ) |
1255 | ent.setHomePhone( *itV ); | 1274 | ent.setHomePhone( *itV ); |
1256 | /* | 1275 | /* |
1257 | if ( *it == "Home 2 Phone" ) | 1276 | if ( *it == "Home 2 Phone" ) |
1258 | ent.setHome2Phone( *itV ); | 1277 | ent.setHome2Phone( *itV ); |
1259 | */ | 1278 | */ |
1260 | if ( *it == "Home Fax" ) | 1279 | if ( *it == "Home Fax" ) |
1261 | ent.setHomeFax( *itV ); | 1280 | ent.setHomeFax( *itV ); |
1262 | 1281 | ||
1263 | if ( *it == "Home Mobile" ) | 1282 | if ( *it == "Home Mobile" ) |
1264 | ent.setHomeMobile( *itV ); | 1283 | ent.setHomeMobile( *itV ); |
1265 | /* | 1284 | /* |
1266 | if ( *it == "Car Phone" ) | 1285 | if ( *it == "Car Phone" ) |
1267 | ent.setCarPhone( *itV ); | 1286 | ent.setCarPhone( *itV ); |
1268 | 1287 | ||
1269 | if ( *it == "ISDN Phone" ) | 1288 | if ( *it == "ISDN Phone" ) |
1270 | ent.setISDNPhone( *itV ); | 1289 | ent.setISDNPhone( *itV ); |
1271 | 1290 | ||
1272 | if ( *it == "Other Phone" ) | 1291 | if ( *it == "Other Phone" ) |
1273 | ent.setOtherPhone( *itV ); | 1292 | ent.setOtherPhone( *itV ); |
1274 | */ | 1293 | */ |
1275 | if ( *it == "Business Pager" || *it == "Work Pager" ) | 1294 | if ( *it == "Business Pager" || *it == "Work Pager" ) |
1276 | ent.setBusinessPager( *itV ); | 1295 | ent.setBusinessPager( *itV ); |
1277 | /* | 1296 | /* |
1278 | if ( *it == "Home Pager" ) | 1297 | if ( *it == "Home Pager" ) |
1279 | ent.setHomePager( *itV ); | 1298 | ent.setHomePager( *itV ); |
1280 | 1299 | ||
1281 | if ( *it == "AIM IM" ) | 1300 | if ( *it == "AIM IM" ) |
1282 | ent.setAIMIM( *itV ); | 1301 | ent.setAIMIM( *itV ); |
1283 | 1302 | ||
1284 | if ( *it == "ICQ IM" ) | 1303 | if ( *it == "ICQ IM" ) |
1285 | ent.setICQIM( *itV ); | 1304 | ent.setICQIM( *itV ); |
1286 | 1305 | ||
1287 | if ( *it == "Jabber IM" ) | 1306 | if ( *it == "Jabber IM" ) |
1288 | ent.setJabberIM( *itV ); | 1307 | ent.setJabberIM( *itV ); |
1289 | 1308 | ||
1290 | if ( *it == "MSN IM" ) | 1309 | if ( *it == "MSN IM" ) |
1291 | ent.setMSNIM( *itV ); | 1310 | ent.setMSNIM( *itV ); |
1292 | 1311 | ||
1293 | if ( *it == "Yahoo IM" ) | 1312 | if ( *it == "Yahoo IM" ) |
1294 | ent.setYahooIM( *itV ); | 1313 | ent.setYahooIM( *itV ); |
1295 | */ | 1314 | */ |
1296 | if ( *it == "Home Web Page" ) | 1315 | if ( *it == "Home Web Page" ) |
1297 | ent.setHomeWebpage( *itV ); | 1316 | ent.setHomeWebpage( *itV ); |
1298 | if ( *it == "Business Web Page" || *it == "Work Web Page" ) | 1317 | if ( *it == "Business Web Page" || *it == "Work Web Page" ) |
1299 | ent.setBusinessWebpage( *itV ); | 1318 | ent.setBusinessWebpage( *itV ); |
1300 | 1319 | ||
1301 | 1320 | ||
1302 | } | 1321 | } |
1303 | 1322 | ||
1304 | int gender = cmbGender->currentItem(); | 1323 | int gender = cmbGender->currentItem(); |
1305 | ent.setGender( QString::number( gender ) ); | 1324 | ent.setGender( QString::number( gender ) ); |
1306 | 1325 | ||
1307 | QString str = txtNote->text(); | 1326 | QString str = txtNote->text(); |
1308 | if ( !str.isNull() ) | 1327 | if ( !str.isNull() ) |
1309 | ent.setNotes( str ); | 1328 | ent.setNotes( str ); |
1310 | 1329 | ||
1311 | } | 1330 | } |
1312 | 1331 | ||
1313 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 1332 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
1314 | QString &strAll ) | 1333 | QString &strAll ) |
1315 | { | 1334 | { |
1316 | int where, | 1335 | int where, |
1317 | start; | 1336 | start; |
1318 | if ( txt.isEmpty() ) | 1337 | if ( txt.isEmpty() ) |
1319 | return; | 1338 | return; |
1320 | // find the first | 1339 | // find the first |
1321 | where = txt.find( ',' ); | 1340 | where = txt.find( ',' ); |
1322 | if ( where < 0 ) { | 1341 | if ( where < 0 ) { |
1323 | strDefaultEmail = txt; | 1342 | strDefaultEmail = txt; |
1324 | strAll = txt; | 1343 | strAll = txt; |
1325 | } else { | 1344 | } else { |
1326 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); | 1345 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); |
1327 | strAll = strDefaultEmail; | 1346 | strAll = strDefaultEmail; |
1328 | while ( where > -1 ) { | 1347 | while ( where > -1 ) { |
1329 | strAll.append(" "); | 1348 | strAll.append(" "); |
1330 | start = where; | 1349 | start = where; |
1331 | where = txt.find( ',', where + 1 ); | 1350 | where = txt.find( ',', where + 1 ); |
1332 | if ( where > - 1 ) | 1351 | if ( where > - 1 ) |
1333 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); | 1352 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); |
1334 | else // grab until the end... | 1353 | else // grab until the end... |
1335 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); | 1354 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); |
1336 | } | 1355 | } |
1337 | } | 1356 | } |
1338 | } | 1357 | } |
1339 | 1358 | ||
1340 | void parseEmailTo( const QString &strDefaultEmail, | 1359 | void parseEmailTo( const QString &strDefaultEmail, |
1341 | const QString &strOtherEmail, QString &strBack ) | 1360 | const QString &strOtherEmail, QString &strBack ) |
1342 | { | 1361 | { |
1343 | // create a comma dilimeted set of emails... | 1362 | // create a comma dilimeted set of emails... |
1344 | // use the power of short circuiting... | 1363 | // use the power of short circuiting... |
1345 | bool foundDefault = false; | 1364 | bool foundDefault = false; |
1346 | QString strTmp; | 1365 | QString strTmp; |
1347 | int start = 0; | 1366 | int start = 0; |
1348 | int where; | 1367 | int where; |
1349 | // start at the beginng. | 1368 | // start at the beginng. |
1350 | strBack = strDefaultEmail; | 1369 | strBack = strDefaultEmail; |
1351 | where = 0; | 1370 | where = 0; |
1352 | while ( where > -1 ) { | 1371 | while ( where > -1 ) { |
1353 | start = where; | 1372 | start = where; |
1354 | where = strOtherEmail.find( ' ', where + 1 ); | 1373 | where = strOtherEmail.find( ' ', where + 1 ); |
1355 | if ( where > 0 ) { | 1374 | if ( where > 0 ) { |
1356 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); | 1375 | strTmp = strOtherEmail.mid( start, where - start ).stripWhiteSpace(); |
1357 | } else | 1376 | } else |
1358 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); | 1377 | strTmp = strOtherEmail.right( strOtherEmail.length() - start ).stripWhiteSpace(); |
1359 | if ( foundDefault || strTmp != strDefaultEmail ) { | 1378 | if ( foundDefault || strTmp != strDefaultEmail ) { |
1360 | strBack.append( ", " ); | 1379 | strBack.append( ", " ); |
1361 | strBack.append( strTmp ); | 1380 | strBack.append( strTmp ); |
1362 | } else | 1381 | } else |
1363 | foundDefault = true; | 1382 | foundDefault = true; |
1364 | } | 1383 | } |
1365 | } | 1384 | } |
1366 | 1385 | ||
1367 | 1386 | ||
1368 | static inline bool containsAlphaNum( const QString &str ) | 1387 | static inline bool containsAlphaNum( const QString &str ) |
1369 | { | 1388 | { |
1370 | int i, | 1389 | int i, |
1371 | count = str.length(); | 1390 | count = str.length(); |
1372 | for ( i = 0; i < count; i++ ) | 1391 | for ( i = 0; i < count; i++ ) |
1373 | if ( !str[i].isSpace() ) | 1392 | if ( !str[i].isSpace() ) |
1374 | return TRUE; | 1393 | return TRUE; |
1375 | return FALSE; | 1394 | return FALSE; |
1376 | } | 1395 | } |
1377 | 1396 | ||
1378 | static inline bool constainsWhiteSpace( const QString &str ) | 1397 | static inline bool constainsWhiteSpace( const QString &str ) |
1379 | { | 1398 | { |
1380 | int i, | 1399 | int i, |
1381 | count = str.length(); | 1400 | count = str.length(); |
1382 | for (i = 0; i < count; i++ ) | 1401 | for (i = 0; i < count; i++ ) |
1383 | if ( str[i].isSpace() ) | 1402 | if ( str[i].isSpace() ) |
1384 | return TRUE; | 1403 | return TRUE; |
1385 | return FALSE; | 1404 | return FALSE; |
1386 | } | 1405 | } |
1387 | 1406 | ||