summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abeditor.cpp2
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,312 +1,312 @@
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
39static inline bool containsAlphaNum( const QString &str ); 39static inline bool containsAlphaNum( const QString &str );
40static inline bool constainsWhiteSpace( const QString &str ); 40static 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...
45void parseEmailFrom( const QString &txt, QString &strDefaultEmail, 45void 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...
49void parseEmailTo( const QString &strDefaultEmail, 49void parseEmailTo( const QString &strDefaultEmail,
50 const QString &strOtherEmail, QString &strBack ); 50 const QString &strOtherEmail, QString &strBack );
51 51
52 52
53 53
54AbEditor::AbEditor( const Contact &entry, const QValueList<int> *newOrdered, 54AbEditor::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
66AbEditor::~AbEditor() 66AbEditor::~AbEditor()
67{ 67{
68} 68}
69 69
70void AbEditor::init() 70void 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
148void AbEditor::initMap() 148void 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
176void AbEditor::loadFields() 176void 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
185void AbEditor::setEntry( const Contact &entry ) 185void 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 // email 208 // email
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() );