-rw-r--r-- | core/pim/addressbook/abeditor.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/addressbook/abeditor.cpp b/core/pim/addressbook/abeditor.cpp index 6354db9..94baa71 100644 --- a/core/pim/addressbook/abeditor.cpp +++ b/core/pim/addressbook/abeditor.cpp | |||
@@ -1,568 +1,568 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "abeditor.h" | 21 | #include "abeditor.h" |
22 | #include "addresspicker.h" | 22 | #include "addresspicker.h" |
23 | 23 | ||
24 | #include <qpe/categoryselect.h> | 24 | #include <qpe/categoryselect.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qpedialog.h> | 26 | #include <qpe/qpedialog.h> |
27 | 27 | ||
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qmultilineedit.h> | 32 | #include <qmultilineedit.h> |
33 | #include <qscrollview.h> | 33 | #include <qscrollview.h> |
34 | #include <qtoolbutton.h> | 34 | #include <qtoolbutton.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qmainwindow.h> | 36 | #include <qmainwindow.h> |
37 | 37 | ||
38 | 38 | ||
39 | static inline bool containsAlphaNum( const QString &str ); | 39 | static inline bool containsAlphaNum( const QString &str ); |
40 | static inline bool constainsWhiteSpace( const QString &str ); | 40 | static inline bool constainsWhiteSpace( const QString &str ); |
41 | 41 | ||
42 | 42 | ||
43 | // helper functions, convert our comma delimited list to proper | 43 | // helper functions, convert our comma delimited list to proper |
44 | // file format... | 44 | // file format... |
45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 45 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
46 | QString &strAll ); | 46 | QString &strAll ); |
47 | 47 | ||
48 | // helper convert from file format to comma delimited... | 48 | // helper convert from file format to comma delimited... |
49 | void parseEmailTo( const QString &strDefaultEmail, | 49 | void parseEmailTo( const QString &strDefaultEmail, |
50 | const QString &strOtherEmail, QString &strBack ); | 50 | const QString &strOtherEmail, QString &strBack ); |
51 | 51 | ||
52 | 52 | ||
53 | 53 | ||
54 | AbEditor::AbEditor( const Contact &entry, const QValueList<int> *newOrdered, | 54 | AbEditor::AbEditor( const Contact &entry, const QValueList<int> *newOrdered, |
55 | QStringList *slNewOrdered, | 55 | QStringList *slNewOrdered, |
56 | QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ) | 56 | QWidget *parent, const char *name, WFlags fl ) |
57 | : QDialog( parent, name, TRUE, fl ), | 57 | : QDialog( parent, name, TRUE, fl ), |
58 | orderedValues( newOrdered ), | 58 | orderedValues( newOrdered ), |
59 | slOrdered( slNewOrdered ) | 59 | slOrdered( slNewOrdered ) |
60 | { | 60 | { |
61 | init(); | 61 | init(); |
62 | initMap(); | 62 | initMap(); |
63 | setEntry( entry ); | 63 | setEntry( entry ); |
64 | } | 64 | } |
65 | 65 | ||
66 | AbEditor::~AbEditor() | 66 | AbEditor::~AbEditor() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | void AbEditor::init() | 70 | void AbEditor::init() |
71 | { | 71 | { |
72 | middleEdit = 0; | 72 | middleEdit = 0; |
73 | QVBoxLayout *vb = new QVBoxLayout( this ); | 73 | QVBoxLayout *vb = new QVBoxLayout( this ); |
74 | svPage = new QScrollView( this ); | 74 | svPage = new QScrollView( this ); |
75 | svPage->setHScrollBarMode( QScrollView::AlwaysOff ); | 75 | svPage->setHScrollBarMode( QScrollView::AlwaysOff ); |
76 | vb->addWidget( svPage ); | 76 | vb->addWidget( svPage ); |
77 | svPage->setResizePolicy( QScrollView::AutoOneFit ); | 77 | svPage->setResizePolicy( QScrollView::AutoOneFit ); |
78 | svPage->setFrameStyle( QFrame::NoFrame ); | 78 | svPage->setFrameStyle( QFrame::NoFrame ); |
79 | 79 | ||
80 | QWidget *container = new QWidget( svPage->viewport() ); | 80 | QWidget *container = new QWidget( svPage->viewport() ); |
81 | svPage->addChild( container ); | 81 | svPage->addChild( container ); |
82 | 82 | ||
83 | QGridLayout *gl = new QGridLayout( container, 20, 2, 4, 2 ); | 83 | QGridLayout *gl = new QGridLayout( container, 20, 2, 4, 2 ); |
84 | 84 | ||
85 | QLabel *l = new QLabel( tr("First Name"), container ); | 85 | QLabel *l = new QLabel( tr("First Name"), container ); |
86 | gl->addWidget( l, 0, 0 ); | 86 | gl->addWidget( l, 0, 0 ); |
87 | firstEdit = new QLineEdit( container ); | 87 | firstEdit = new QLineEdit( container ); |
88 | gl->addWidget( firstEdit, 0, 1 ); | 88 | gl->addWidget( firstEdit, 0, 1 ); |
89 | 89 | ||
90 | l = new QLabel( tr("Last Name"), container ); | 90 | l = new QLabel( tr("Last Name"), container ); |
91 | gl->addWidget( l, 1, 0 ); | 91 | gl->addWidget( l, 1, 0 ); |
92 | lastEdit = new QLineEdit( container ); | 92 | lastEdit = new QLineEdit( container ); |
93 | gl->addWidget( lastEdit, 1, 1 ); | 93 | gl->addWidget( lastEdit, 1, 1 ); |
94 | 94 | ||
95 | l = new QLabel( tr("Categories"), container ); | 95 | l = new QLabel( tr("Categories"), container ); |
96 | gl->addWidget( l, 2, 0 ); | 96 | gl->addWidget( l, 2, 0 ); |
97 | 97 | ||
98 | cmbCat = new CategorySelect( container ); | 98 | cmbCat = new CategorySelect( container ); |
99 | gl->addWidget( cmbCat, 2, 1 ); | 99 | gl->addWidget( cmbCat, 2, 1 ); |
100 | 100 | ||
101 | int i; | 101 | int i; |
102 | bool foundGender, | 102 | bool foundGender, |
103 | foundNotes; | 103 | foundNotes; |
104 | foundGender = foundNotes = false; | 104 | foundGender = foundNotes = false; |
105 | QStringList::ConstIterator it = slOrdered->begin(); | 105 | QStringList::ConstIterator it = slOrdered->begin(); |
106 | for ( i = 0; it != slOrdered->end(); i++, ++it ) { | 106 | for ( i = 0; it != slOrdered->end(); i++, ++it ) { |
107 | if ( !foundGender && *it == tr("Gender") ) { | 107 | if ( !foundGender && *it == tr("Gender") ) { |
108 | foundGender = true; | 108 | foundGender = true; |
109 | } else if ( !foundNotes && *it == tr("Notes") ) { | 109 | } else if ( !foundNotes && *it == tr("Notes") ) { |
110 | foundNotes = true; | 110 | foundNotes = true; |
111 | } else { | 111 | } else { |
112 | l = new QLabel( *it, container ); | 112 | l = new QLabel( *it, container ); |
113 | listName.append( l ); | 113 | listName.append( l ); |
114 | gl->addWidget( l, i + 3, 0 ); | 114 | gl->addWidget( l, i + 3, 0 ); |
115 | QLineEdit *e = new QLineEdit( container ); | 115 | QLineEdit *e = new QLineEdit( container ); |
116 | listValue.append( e ); | 116 | listValue.append( e ); |
117 | gl->addWidget( e, i + 3, 1 ); | 117 | gl->addWidget( e, i + 3, 1 ); |
118 | if ( *it == tr( "Middle Name" ) ) | 118 | if ( *it == tr( "Middle Name" ) ) |
119 | middleEdit = e; | 119 | middleEdit = e; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | l = new QLabel( tr("Gender"), container ); | 122 | l = new QLabel( tr("Gender"), container ); |
123 | gl->addWidget( l, slOrdered->count() + 3, 0 ); | 123 | gl->addWidget( l, slOrdered->count() + 3, 0 ); |
124 | genderCombo = new QComboBox( container ); | 124 | genderCombo = new QComboBox( container ); |
125 | genderCombo->insertItem( "", 0 ); | 125 | genderCombo->insertItem( "", 0 ); |
126 | genderCombo->insertItem( tr( "Male" ), 1 ); | 126 | genderCombo->insertItem( tr( "Male" ), 1 ); |
127 | genderCombo->insertItem( tr( "Female" ), 2 ); | 127 | genderCombo->insertItem( tr( "Female" ), 2 ); |
128 | gl->addWidget( genderCombo, slOrdered->count() + 3, 1 ); | 128 | gl->addWidget( genderCombo, slOrdered->count() + 3, 1 ); |
129 | 129 | ||
130 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 130 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
131 | dlgNote->setCaption( tr("Enter Note") ); | 131 | dlgNote->setCaption( tr("Enter Note") ); |
132 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 132 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
133 | // lblNote = new QLabel( dlgNote ); | 133 | // lblNote = new QLabel( dlgNote ); |
134 | // lblNote->setMinimumSize( lblNote->sizeHint() + QSize( 0, 4 ) ); | 134 | // lblNote->setMinimumSize( lblNote->sizeHint() + QSize( 0, 4 ) ); |
135 | // vbNote->addWidget( lblNote ); | 135 | // vbNote->addWidget( lblNote ); |
136 | txtNote = new QMultiLineEdit( dlgNote ); | 136 | txtNote = new QMultiLineEdit( dlgNote ); |
137 | vbNote->addWidget( txtNote ); | 137 | vbNote->addWidget( txtNote ); |
138 | 138 | ||
139 | QHBoxLayout *hb = new QHBoxLayout( vb ); | 139 | QHBoxLayout *hb = new QHBoxLayout( vb ); |
140 | hb->addStretch( 2 ); | 140 | hb->addStretch( 2 ); |
141 | QPushButton *pb = new QPushButton( tr("Notes..."), this ); | 141 | QPushButton *pb = new QPushButton( tr("Notes..."), this ); |
142 | hb->addWidget( pb ); | 142 | hb->addWidget( pb ); |
143 | connect( pb, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 143 | connect( pb, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
144 | 144 | ||
145 | new QPEDialogListener(this); | 145 | new QPEDialogListener(this); |
146 | } | 146 | } |
147 | 147 | ||
148 | void AbEditor::initMap() | 148 | void AbEditor::initMap() |
149 | { | 149 | { |
150 | /* | 150 | /* |
151 | // since the fields and the XML fields exist, create a map | 151 | // since the fields and the XML fields exist, create a map |
152 | // between them... | 152 | // between them... |
153 | Config cfg1( "AddressBook" ); | 153 | Config cfg1( "AddressBook" ); |
154 | Config cfg2( "AddressBook" ); | 154 | Config cfg2( "AddressBook" ); |
155 | QString strCfg1, | 155 | QString strCfg1, |
156 | strCfg2; | 156 | strCfg2; |
157 | int i; | 157 | int i; |
158 | 158 | ||
159 | // This stuff better exist... | 159 | // This stuff better exist... |
160 | cfg1.setGroup( "AddressFields" ); | 160 | cfg1.setGroup( "AddressFields" ); |
161 | cfg2.setGroup( "XMLFields" ); | 161 | cfg2.setGroup( "XMLFields" ); |
162 | i = 0; | 162 | i = 0; |
163 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); | 163 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), QString::null ); |
164 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 164 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
165 | QString::null ); | 165 | QString::null ); |
166 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { | 166 | while ( !strCfg1.isNull() && !strCfg2.isNull() ) { |
167 | mapField.insert( strCfg1, strCfg2 ); | 167 | mapField.insert( strCfg1, strCfg2 ); |
168 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), | 168 | strCfg1 = cfg1.readEntry( "Field" + QString::number(i), |
169 | QString::null ); | 169 | QString::null ); |
170 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), | 170 | strCfg2 = cfg2.readEntry( "XMLField" + QString::number(i++), |
171 | QString::null ); | 171 | QString::null ); |
172 | } | 172 | } |
173 | */ | 173 | */ |
174 | } | 174 | } |
175 | 175 | ||
176 | void AbEditor::loadFields() | 176 | void AbEditor::loadFields() |
177 | { | 177 | { |
178 | QStringList::ConstIterator it; | 178 | QStringList::ConstIterator it; |
179 | QListIterator<QLabel> lit( listName ); | 179 | QListIterator<QLabel> lit( listName ); |
180 | for ( it = slOrdered->begin(); *lit; ++lit, ++it ) { | 180 | for ( it = slOrdered->begin(); *lit; ++lit, ++it ) { |
181 | (*lit)->setText( *it ); | 181 | (*lit)->setText( *it ); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | void AbEditor::setEntry( const Contact &entry ) | 185 | void AbEditor::setEntry( const Contact &entry ) |
186 | { | 186 | { |
187 | ent = entry; | 187 | ent = entry; |
188 | QListIterator<QLineEdit> it( listValue ); | 188 | QListIterator<QLineEdit> it( listValue ); |
189 | firstEdit->setText( ent.firstName() ); | 189 | firstEdit->setText( ent.firstName() ); |
190 | lastEdit->setText( ent.lastName() ); | 190 | lastEdit->setText( ent.lastName() ); |
191 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); | 191 | cmbCat->setCategories( ent.categories(), "Contacts", tr("Contacts") ); |
192 | 192 | ||
193 | // ### Fix... | 193 | // ### Fix... |
194 | QValueList<int>::ConstIterator itVl; | 194 | QValueList<int>::ConstIterator itVl; |
195 | for ( itVl = orderedValues->begin(); *it && itVl != orderedValues->end(); | 195 | for ( itVl = orderedValues->begin(); *it && itVl != orderedValues->end(); |
196 | ++itVl, ++it ) { | 196 | ++itVl, ++it ) { |
197 | switch( *itVl ) { | 197 | switch( *itVl ) { |
198 | case Qtopia::Title: | 198 | case Qtopia::Title: |
199 | (*it)->setText(ent.title()); | 199 | (*it)->setText(ent.title()); |
200 | break; | 200 | break; |
201 | case Qtopia::MiddleName: | 201 | case Qtopia::MiddleName: |
202 | (*it)->setText( ent.middleName() ); | 202 | (*it)->setText( ent.middleName() ); |
203 | break; | 203 | break; |
204 | case Qtopia::Suffix: | 204 | case Qtopia::Suffix: |
205 | (*it)->setText( ent.suffix() ); | 205 | (*it)->setText( ent.suffix() ); |
206 | break; | 206 | break; |
207 | 207 | ||
208 | 208 | ||
209 | case Qtopia::DefaultEmail: | 209 | case Qtopia::DefaultEmail: |
210 | case Qtopia::Emails: | 210 | case Qtopia::Emails: |
211 | { | 211 | { |
212 | QString strDefEmail = ent.defaultEmail(); | 212 | QString strDefEmail = ent.defaultEmail(); |
213 | QString strAllEmail = ent.emails(); | 213 | QString strAllEmail = ent.emails(); |
214 | QString strFinal; | 214 | QString strFinal; |
215 | parseEmailTo( strDefEmail, strAllEmail, strFinal ); | 215 | parseEmailTo( strDefEmail, strAllEmail, strFinal ); |
216 | (*it)->setText( strFinal ); | 216 | (*it)->setText( strFinal ); |
217 | // make sure we see the "default" | 217 | // make sure we see the "default" |
218 | (*it)->home( false ); | 218 | (*it)->home( false ); |
219 | break; | 219 | break; |
220 | } | 220 | } |
221 | 221 | ||
222 | // home | 222 | // home |
223 | case Qtopia::HomeStreet: | 223 | case Qtopia::HomeStreet: |
224 | (*it)->setText(ent.homeStreet() ); | 224 | (*it)->setText(ent.homeStreet() ); |
225 | break; | 225 | break; |
226 | case Qtopia::HomeCity: | 226 | case Qtopia::HomeCity: |
227 | (*it)->setText( ent.homeCity() ); | 227 | (*it)->setText( ent.homeCity() ); |
228 | break; | 228 | break; |
229 | case Qtopia::HomeState: | 229 | case Qtopia::HomeState: |
230 | (*it)->setText( ent.homeState() ); | 230 | (*it)->setText( ent.homeState() ); |
231 | break; | 231 | break; |
232 | case Qtopia::HomeZip: | 232 | case Qtopia::HomeZip: |
233 | (*it)->setText( ent.homeZip() ); | 233 | (*it)->setText( ent.homeZip() ); |
234 | break; | 234 | break; |
235 | case Qtopia::HomeCountry: | 235 | case Qtopia::HomeCountry: |
236 | (*it)->setText( ent.homeCountry() ); | 236 | (*it)->setText( ent.homeCountry() ); |
237 | break; | 237 | break; |
238 | case Qtopia::HomePhone: | 238 | case Qtopia::HomePhone: |
239 | (*it)->setText( ent.homePhone() ); | 239 | (*it)->setText( ent.homePhone() ); |
240 | break; | 240 | break; |
241 | case Qtopia::HomeFax: | 241 | case Qtopia::HomeFax: |
242 | (*it)->setText( ent.homeFax() ); | 242 | (*it)->setText( ent.homeFax() ); |
243 | break; | 243 | break; |
244 | case Qtopia::HomeMobile: | 244 | case Qtopia::HomeMobile: |
245 | (*it)->setText( ent.homeMobile() ); | 245 | (*it)->setText( ent.homeMobile() ); |
246 | break; | 246 | break; |
247 | case Qtopia::HomeWebPage: | 247 | case Qtopia::HomeWebPage: |
248 | (*it)->setText( ent.homeWebpage() ); | 248 | (*it)->setText( ent.homeWebpage() ); |
249 | break; | 249 | break; |
250 | 250 | ||
251 | // business | 251 | // business |
252 | case Qtopia::Company: | 252 | case Qtopia::Company: |
253 | (*it)->setText( ent.company() ); | 253 | (*it)->setText( ent.company() ); |
254 | break; | 254 | break; |
255 | case Qtopia::BusinessStreet: | 255 | case Qtopia::BusinessStreet: |
256 | (*it)->setText( ent.businessStreet() ); | 256 | (*it)->setText( ent.businessStreet() ); |
257 | break; | 257 | break; |
258 | case Qtopia::BusinessCity: | 258 | case Qtopia::BusinessCity: |
259 | (*it)->setText( ent.businessCity() ); | 259 | (*it)->setText( ent.businessCity() ); |
260 | break; | 260 | break; |
261 | case Qtopia::BusinessState: | 261 | case Qtopia::BusinessState: |
262 | (*it)->setText( ent.businessState() ); | 262 | (*it)->setText( ent.businessState() ); |
263 | break; | 263 | break; |
264 | case Qtopia::BusinessZip: | 264 | case Qtopia::BusinessZip: |
265 | (*it)->setText( ent.businessZip() ); | 265 | (*it)->setText( ent.businessZip() ); |
266 | break; | 266 | break; |
267 | case Qtopia::BusinessCountry: | 267 | case Qtopia::BusinessCountry: |
268 | (*it)->setText( ent.businessCountry() ); | 268 | (*it)->setText( ent.businessCountry() ); |
269 | break; | 269 | break; |
270 | case Qtopia::BusinessWebPage: | 270 | case Qtopia::BusinessWebPage: |
271 | (*it)->setText( ent.businessWebpage() ); | 271 | (*it)->setText( ent.businessWebpage() ); |
272 | break; | 272 | break; |
273 | case Qtopia::JobTitle: | 273 | case Qtopia::JobTitle: |
274 | (*it)->setText( ent.jobTitle() ); | 274 | (*it)->setText( ent.jobTitle() ); |
275 | break; | 275 | break; |
276 | case Qtopia::Department: | 276 | case Qtopia::Department: |
277 | (*it)->setText( ent.department() ); | 277 | (*it)->setText( ent.department() ); |
278 | break; | 278 | break; |
279 | case Qtopia::Office: | 279 | case Qtopia::Office: |
280 | (*it)->setText( ent.office() ); | 280 | (*it)->setText( ent.office() ); |
281 | break; | 281 | break; |
282 | case Qtopia::BusinessPhone: | 282 | case Qtopia::BusinessPhone: |
283 | (*it)->setText( ent.businessPhone() ); | 283 | (*it)->setText( ent.businessPhone() ); |
284 | break; | 284 | break; |
285 | case Qtopia::BusinessFax: | 285 | case Qtopia::BusinessFax: |
286 | (*it)->setText( ent.businessFax() ); | 286 | (*it)->setText( ent.businessFax() ); |
287 | break; | 287 | break; |
288 | case Qtopia::BusinessMobile: | 288 | case Qtopia::BusinessMobile: |
289 | (*it)->setText( ent.businessMobile() ); | 289 | (*it)->setText( ent.businessMobile() ); |
290 | break; | 290 | break; |
291 | case Qtopia::BusinessPager: | 291 | case Qtopia::BusinessPager: |
292 | (*it)->setText( ent.businessPager() ); | 292 | (*it)->setText( ent.businessPager() ); |
293 | break; | 293 | break; |
294 | case Qtopia::Profession: | 294 | case Qtopia::Profession: |
295 | (*it)->setText( ent.profession() ); | 295 | (*it)->setText( ent.profession() ); |
296 | break; | 296 | break; |
297 | case Qtopia::Assistant: | 297 | case Qtopia::Assistant: |
298 | (*it)->setText( ent.assistant() ); | 298 | (*it)->setText( ent.assistant() ); |
299 | break; | 299 | break; |
300 | case Qtopia::Manager: | 300 | case Qtopia::Manager: |
301 | (*it)->setText( ent.manager() ); | 301 | (*it)->setText( ent.manager() ); |
302 | break; | 302 | break; |
303 | 303 | ||
304 | // personal | 304 | // personal |
305 | case Qtopia::Spouse: | 305 | case Qtopia::Spouse: |
306 | (*it)->setText( ent.spouse() ); | 306 | (*it)->setText( ent.spouse() ); |
307 | break; | 307 | break; |
308 | case Qtopia::Children: | 308 | case Qtopia::Children: |
309 | (*it)->setText( ent.children() ); | 309 | (*it)->setText( ent.children() ); |
310 | break; | 310 | break; |
311 | case Qtopia::Birthday: | 311 | case Qtopia::Birthday: |
312 | (*it)->setText( ent.birthday() ); | 312 | (*it)->setText( ent.birthday() ); |
313 | break; | 313 | break; |
314 | case Qtopia::Anniversary: | 314 | case Qtopia::Anniversary: |
315 | (*it)->setText( ent.anniversary() ); | 315 | (*it)->setText( ent.anniversary() ); |
316 | break; | 316 | break; |
317 | case Qtopia::Nickname: | 317 | case Qtopia::Nickname: |
318 | (*it)->setText( ent.nickname() ); | 318 | (*it)->setText( ent.nickname() ); |
319 | break; | 319 | break; |
320 | 320 | ||
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | QString gender = ent.gender(); | 324 | QString gender = ent.gender(); |
325 | genderCombo->setCurrentItem( gender.toInt() ); | 325 | genderCombo->setCurrentItem( gender.toInt() ); |
326 | 326 | ||
327 | txtNote->setText( ent.notes() ); | 327 | txtNote->setText( ent.notes() ); |
328 | } | 328 | } |
329 | 329 | ||
330 | void AbEditor::accept() | 330 | void AbEditor::accept() |
331 | { | 331 | { |
332 | if ( isEmpty() ) | 332 | if ( isEmpty() ) |
333 | reject(); | 333 | reject(); |
334 | else { | 334 | else { |
335 | saveEntry(); | 335 | saveEntry(); |
336 | QDialog::accept(); | 336 | QDialog::accept(); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | bool AbEditor::isEmpty() | 340 | bool AbEditor::isEmpty() |
341 | { | 341 | { |
342 | // analyze all the fields and make sure there is _something_ there | 342 | // analyze all the fields and make sure there is _something_ there |
343 | // that warrants saving... | 343 | // that warrants saving... |
344 | QString t = firstEdit->text(); | 344 | QString t = firstEdit->text(); |
345 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 345 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
346 | return false; | 346 | return false; |
347 | 347 | ||
348 | t = lastEdit->text(); | 348 | t = lastEdit->text(); |
349 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 349 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
350 | return false; | 350 | return false; |
351 | 351 | ||
352 | QListIterator<QLineEdit> it( listValue ); | 352 | QListIterator<QLineEdit> it( listValue ); |
353 | for ( ; it.current(); ++it ) { | 353 | for ( ; it.current(); ++it ) { |
354 | t = it.current()->text(); | 354 | t = it.current()->text(); |
355 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 355 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
356 | return false; | 356 | return false; |
357 | } | 357 | } |
358 | 358 | ||
359 | t = txtNote->text(); | 359 | t = txtNote->text(); |
360 | if ( !t.isEmpty() && containsAlphaNum( t ) ) | 360 | if ( !t.isEmpty() && containsAlphaNum( t ) ) |
361 | return false; | 361 | return false; |
362 | 362 | ||
363 | return true; | 363 | return true; |
364 | } | 364 | } |
365 | 365 | ||
366 | void AbEditor::saveEntry() | 366 | void AbEditor::saveEntry() |
367 | { | 367 | { |
368 | QString strDefaultEmail, strOtherEmail; | 368 | QString strDefaultEmail, strOtherEmail; |
369 | 369 | ||
370 | // determine if there has been a change in names | 370 | // determine if there has been a change in names |
371 | if ( ent.firstName() != firstEdit->text() || | 371 | if ( ent.firstName() != firstEdit->text() || |
372 | ent.lastName() != lastEdit->text() | 372 | ent.lastName() != lastEdit->text() |
373 | || (middleEdit && ent.middleName() != middleEdit->text()) ) { | 373 | || (middleEdit && ent.middleName() != middleEdit->text()) ) { |
374 | // set the names | 374 | // set the names |
375 | ent.setFirstName( firstEdit->text() ); | 375 | ent.setFirstName( firstEdit->text() ); |
376 | ent.setLastName( lastEdit->text() ); | 376 | ent.setLastName( lastEdit->text() ); |
377 | if ( middleEdit ) | 377 | if ( middleEdit ) |
378 | ent.setMiddleName( middleEdit->text() ); | 378 | ent.setMiddleName( middleEdit->text() ); |
379 | ent.setFileAs(); | 379 | ent.setFileAs(); |
380 | } | 380 | } |
381 | 381 | ||
382 | ent.setCategories( cmbCat->currentCategories() ); | 382 | ent.setCategories( cmbCat->currentCategories() ); |
383 | 383 | ||
384 | QListIterator<QLineEdit> it( listValue ); | 384 | QListIterator<QLineEdit> it( listValue ); |
385 | int i; | 385 | int i; |
386 | QValueList<int>::ConstIterator<int> vlIt; | 386 | QValueList<int>::ConstIterator<int> vlIt; |
387 | for ( i = 0, vlIt = orderedValues->begin(); | 387 | for ( i = 0, vlIt = orderedValues->begin(); |
388 | it.current(); ++it, ++vlIt, i++ ) { | 388 | it.current(); ++it, ++vlIt, i++ ) { |
389 | switch( *vlIt ) { | 389 | switch( *vlIt ) { |
390 | case Qtopia::Title: | 390 | case Qtopia::Title: |
391 | ent.setTitle( it.current()->text() ); | 391 | ent.setTitle( it.current()->text() ); |
392 | break; | 392 | break; |
393 | case Qtopia::MiddleName: | 393 | case Qtopia::MiddleName: |
394 | ent.setMiddleName( it.current()->text() ); | 394 | ent.setMiddleName( it.current()->text() ); |
395 | break; | 395 | break; |
396 | case Qtopia::Suffix: | 396 | case Qtopia::Suffix: |
397 | ent.setSuffix( it.current()->text() ); | 397 | ent.setSuffix( it.current()->text() ); |
398 | break; | 398 | break; |
399 | // case Qtopia::Category: | 399 | // case Qtopia::Category: |
400 | // { | 400 | // { |
401 | // // QStringList slCat = QStringList::split( ";", value ); | 401 | // // QStringList slCat = QStringList::split( ";", value ); |
402 | // // QValueList<int> cat; | 402 | // // QValueList<int> cat; |
403 | // // for ( QStringList::ConstIterator it = slCat.begin(); | 403 | // // for ( QStringList::ConstIterator it = slCat.begin(); |
404 | // // it != slCat.end(); ++it ) | 404 | // // it != slCat.end(); ++it ) |
405 | // // cat.append( (*it).toInt() ); | 405 | // // cat.append( (*it).toInt() ); |
406 | // // ent.setCategories( cat ); | 406 | // // ent.setCategories( cat ); |
407 | // } | 407 | // } |
408 | // break; | 408 | // break; |
409 | 409 | ||
410 | 410 | ||
411 | case Qtopia::DefaultEmail: | 411 | case Qtopia::DefaultEmail: |
412 | case Qtopia::Emails: | 412 | case Qtopia::Emails: |
413 | parseEmailFrom( it.current()->text(), strDefaultEmail, | 413 | parseEmailFrom( it.current()->text(), strDefaultEmail, |
414 | strOtherEmail ); | 414 | strOtherEmail ); |
415 | ent.setDefaultEmail( strDefaultEmail ); | 415 | ent.setDefaultEmail( strDefaultEmail ); |
416 | ent.setEmails( strOtherEmail ); | 416 | ent.setEmails( strOtherEmail ); |
417 | break; | 417 | break; |
418 | 418 | ||
419 | // home | 419 | // home |
420 | case Qtopia::HomeStreet: | 420 | case Qtopia::HomeStreet: |
421 | ent.setHomeStreet( it.current()->text() ); | 421 | ent.setHomeStreet( it.current()->text() ); |
422 | break; | 422 | break; |
423 | case Qtopia::HomeCity: | 423 | case Qtopia::HomeCity: |
424 | ent.setHomeCity( it.current()->text() ); | 424 | ent.setHomeCity( it.current()->text() ); |
425 | break; | 425 | break; |
426 | case Qtopia::HomeState: | 426 | case Qtopia::HomeState: |
427 | ent.setHomeState( it.current()->text() ); | 427 | ent.setHomeState( it.current()->text() ); |
428 | break; | 428 | break; |
429 | case Qtopia::HomeZip: | 429 | case Qtopia::HomeZip: |
430 | ent.setHomeZip( it.current()->text() ); | 430 | ent.setHomeZip( it.current()->text() ); |
431 | break; | 431 | break; |
432 | case Qtopia::HomeCountry: | 432 | case Qtopia::HomeCountry: |
433 | ent.setHomeCountry( it.current()->text() ); | 433 | ent.setHomeCountry( it.current()->text() ); |
434 | break; | 434 | break; |
435 | case Qtopia::HomePhone: | 435 | case Qtopia::HomePhone: |
436 | ent.setHomePhone( it.current()->text() ); | 436 | ent.setHomePhone( it.current()->text() ); |
437 | break; | 437 | break; |
438 | case Qtopia::HomeFax: | 438 | case Qtopia::HomeFax: |
439 | ent.setHomeFax( it.current()->text() ); | 439 | ent.setHomeFax( it.current()->text() ); |
440 | break; | 440 | break; |
441 | case Qtopia::HomeMobile: | 441 | case Qtopia::HomeMobile: |
442 | ent.setHomeMobile( it.current()->text() ); | 442 | ent.setHomeMobile( it.current()->text() ); |
443 | break; | 443 | break; |
444 | case Qtopia::HomeWebPage: | 444 | case Qtopia::HomeWebPage: |
445 | ent.setHomeWebpage( it.current()->text() ); | 445 | ent.setHomeWebpage( it.current()->text() ); |
446 | break; | 446 | break; |
447 | 447 | ||
448 | // business | 448 | // business |
449 | case Qtopia::Company: | 449 | case Qtopia::Company: |
450 | ent.setCompany( it.current()->text() ); | 450 | ent.setCompany( it.current()->text() ); |
451 | break; | 451 | break; |
452 | case Qtopia::BusinessStreet: | 452 | case Qtopia::BusinessStreet: |
453 | ent.setBusinessStreet( it.current()->text() ); | 453 | ent.setBusinessStreet( it.current()->text() ); |
454 | break; | 454 | break; |
455 | case Qtopia::BusinessCity: | 455 | case Qtopia::BusinessCity: |
456 | ent.setBusinessCity( it.current()->text() ); | 456 | ent.setBusinessCity( it.current()->text() ); |
457 | break; | 457 | break; |
458 | case Qtopia::BusinessState: | 458 | case Qtopia::BusinessState: |
459 | ent.setBusinessState( it.current()->text() ); | 459 | ent.setBusinessState( it.current()->text() ); |
460 | break; | 460 | break; |
461 | case Qtopia::BusinessZip: | 461 | case Qtopia::BusinessZip: |
462 | ent.setBusinessZip( it.current()->text() ); | 462 | ent.setBusinessZip( it.current()->text() ); |
463 | break; | 463 | break; |
464 | case Qtopia::BusinessCountry: | 464 | case Qtopia::BusinessCountry: |
465 | ent.setBusinessCountry( it.current()->text() ); | 465 | ent.setBusinessCountry( it.current()->text() ); |
466 | break; | 466 | break; |
467 | case Qtopia::BusinessWebPage: | 467 | case Qtopia::BusinessWebPage: |
468 | ent.setBusinessWebpage( it.current()->text() ); | 468 | ent.setBusinessWebpage( it.current()->text() ); |
469 | break; | 469 | break; |
470 | case Qtopia::JobTitle: | 470 | case Qtopia::JobTitle: |
471 | ent.setJobTitle( it.current()->text() ); | 471 | ent.setJobTitle( it.current()->text() ); |
472 | break; | 472 | break; |
473 | case Qtopia::Department: | 473 | case Qtopia::Department: |
474 | ent.setDepartment( it.current()->text() ); | 474 | ent.setDepartment( it.current()->text() ); |
475 | break; | 475 | break; |
476 | case Qtopia::Office: | 476 | case Qtopia::Office: |
477 | ent.setOffice( it.current()->text() ); | 477 | ent.setOffice( it.current()->text() ); |
478 | break; | 478 | break; |
479 | case Qtopia::BusinessPhone: | 479 | case Qtopia::BusinessPhone: |
480 | ent.setBusinessPhone( it.current()->text() ); | 480 | ent.setBusinessPhone( it.current()->text() ); |
481 | break; | 481 | break; |
482 | case Qtopia::BusinessFax: | 482 | case Qtopia::BusinessFax: |
483 | ent.setBusinessFax( it.current()->text() ); | 483 | ent.setBusinessFax( it.current()->text() ); |
484 | break; | 484 | break; |
485 | case Qtopia::BusinessMobile: | 485 | case Qtopia::BusinessMobile: |
486 | ent.setBusinessMobile( it.current()->text() ); | 486 | ent.setBusinessMobile( it.current()->text() ); |
487 | break; | 487 | break; |
488 | case Qtopia::BusinessPager: | 488 | case Qtopia::BusinessPager: |
489 | ent.setBusinessPager( it.current()->text() ); | 489 | ent.setBusinessPager( it.current()->text() ); |
490 | break; | 490 | break; |
491 | case Qtopia::Profession: | 491 | case Qtopia::Profession: |
492 | ent.setProfession( it.current()->text() ); | 492 | ent.setProfession( it.current()->text() ); |
493 | break; | 493 | break; |
494 | case Qtopia::Assistant: | 494 | case Qtopia::Assistant: |
495 | ent.setAssistant( it.current()->text() ); | 495 | ent.setAssistant( it.current()->text() ); |
496 | break; | 496 | break; |
497 | case Qtopia::Manager: | 497 | case Qtopia::Manager: |
498 | ent.setManager( it.current()->text() ); | 498 | ent.setManager( it.current()->text() ); |
499 | break; | 499 | break; |
500 | 500 | ||
501 | // personal | 501 | // personal |
502 | case Qtopia::Spouse: | 502 | case Qtopia::Spouse: |
503 | ent.setSpouse( it.current()->text() ); | 503 | ent.setSpouse( it.current()->text() ); |
504 | break; | 504 | break; |
505 | case Qtopia::Children: | 505 | case Qtopia::Children: |
506 | ent.setChildren( it.current()->text() ); | 506 | ent.setChildren( it.current()->text() ); |
507 | break; | 507 | break; |
508 | case Qtopia::Birthday: | 508 | case Qtopia::Birthday: |
509 | ent.setBirthday( it.current()->text() ); | 509 | ent.setBirthday( it.current()->text() ); |
510 | break; | 510 | break; |
511 | case Qtopia::Anniversary: | 511 | case Qtopia::Anniversary: |
512 | ent.setAnniversary( it.current()->text() ); | 512 | ent.setAnniversary( it.current()->text() ); |
513 | break; | 513 | break; |
514 | case Qtopia::Nickname: | 514 | case Qtopia::Nickname: |
515 | ent.setNickname( it.current()->text() ); | 515 | ent.setNickname( it.current()->text() ); |
516 | break; | 516 | break; |
517 | default: | 517 | default: |
518 | break; | 518 | break; |
519 | 519 | ||
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | int gender = genderCombo->currentItem(); | 523 | int gender = genderCombo->currentItem(); |
524 | ent.setGender( QString::number( gender ) ); | 524 | ent.setGender( QString::number( gender ) ); |
525 | 525 | ||
526 | QString str = txtNote->text(); | 526 | QString str = txtNote->text(); |
527 | if ( !str.isNull() ) | 527 | if ( !str.isNull() ) |
528 | ent.setNotes( str ); | 528 | ent.setNotes( str ); |
529 | } | 529 | } |
530 | 530 | ||
531 | void AbEditor::slotNote() | 531 | void AbEditor::slotNote() |
532 | { | 532 | { |
533 | dlgNote->showMaximized(); | 533 | dlgNote->showMaximized(); |
534 | if ( !dlgNote->exec() ) { | 534 | if ( !dlgNote->exec() ) { |
535 | // reset the note... | 535 | // reset the note... |
536 | txtNote->setText( ent.notes() ); | 536 | txtNote->setText( ent.notes() ); |
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | void AbEditor::setNameFocus() | 540 | void AbEditor::setNameFocus() |
541 | { | 541 | { |
542 | firstEdit->setFocus(); | 542 | firstEdit->setFocus(); |
543 | } | 543 | } |
544 | 544 | ||
545 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | 545 | void parseEmailFrom( const QString &txt, QString &strDefaultEmail, |
546 | QString &strAll ) | 546 | QString &strAll ) |
547 | { | 547 | { |
548 | int where, | 548 | int where, |
549 | start; | 549 | start; |
550 | if ( txt.isEmpty() ) | 550 | if ( txt.isEmpty() ) |
551 | return; | 551 | return; |
552 | // find the first | 552 | // find the first |
553 | where = txt.find( ',' ); | 553 | where = txt.find( ',' ); |
554 | if ( where < 0 ) { | 554 | if ( where < 0 ) { |
555 | strDefaultEmail = txt; | 555 | strDefaultEmail = txt; |
556 | strAll = txt; | 556 | strAll = txt; |
557 | } else { | 557 | } else { |
558 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); | 558 | strDefaultEmail = txt.left( where ).stripWhiteSpace(); |
559 | strAll = strDefaultEmail; | 559 | strAll = strDefaultEmail; |
560 | while ( where > -1 ) { | 560 | while ( where > -1 ) { |
561 | strAll.append(" "); | 561 | strAll.append(" "); |
562 | start = where; | 562 | start = where; |
563 | where = txt.find( ',', where + 1 ); | 563 | where = txt.find( ',', where + 1 ); |
564 | if ( where > - 1 ) | 564 | if ( where > - 1 ) |
565 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); | 565 | strAll.append( txt.mid(start + 1, where - start - 1).stripWhiteSpace() ); |
566 | else // grab until the end... | 566 | else // grab until the end... |
567 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); | 567 | strAll.append( txt.right(txt.length() - start - 1).stripWhiteSpace() ); |
568 | } | 568 | } |