summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-05 18:33:09 (UTC)
committer llornkcor <llornkcor>2002-06-05 18:33:09 (UTC)
commit91398d550495cb82445457b59e472a58ad0a296a (patch) (unidiff)
tree946605431ce9f600ae496c807126c281848a83b4
parent9bd38805d22b6687ec8918ab1f581b2a28ba637a (diff)
downloadopie-91398d550495cb82445457b59e472a58ad0a296a.zip
opie-91398d550495cb82445457b59e472a58ad0a296a.tar.gz
opie-91398d550495cb82445457b59e472a58ad0a296a.tar.bz2
added import vcard menu entry
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp617
-rw-r--r--core/pim/addressbook/addressbook.h7
-rw-r--r--core/pim/addressbook/addressbook.pro2
3 files changed, 323 insertions, 303 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 8229212..86d1760 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -21,16 +21,19 @@
21#define QTOPIA_INTERNAL_FD 21#define QTOPIA_INTERNAL_FD
22 22
23#include "contacteditor.h" 23#include "contacteditor.h"
24#include "ablabel.h" 24#include "ablabel.h"
25#include "abtable.h" 25#include "abtable.h"
26#include "addresssettings.h" 26#include "addresssettings.h"
27#include "addressbook.h" 27#include "addressbook.h"
28 28
29
30#include <opie/ofileselector.h>
31#include <opie/ofiledialog.h>
29#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
30#include <qpe/config.h> 33#include <qpe/config.h>
31#include <qpe/contact.h> 34#include <qpe/contact.h>
32 35
33#ifndef MAKE_FOR_SHARP_ROM 36#ifndef MAKE_FOR_SHARP_ROM
34#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
35#endif 38#endif
36 39
@@ -68,30 +71,30 @@ static QString addressbookOldXMLFilename()
68{ 71{
69 QString filename = QPEApplication::documentDir() + "addressbook.xml"; 72 QString filename = QPEApplication::documentDir() + "addressbook.xml";
70 return filename; 73 return filename;
71} 74}
72 75
73static QString addressbookXMLFilename() 76static QString addressbookXMLFilename()
74{ 77{
75 QString filename = Global::applicationFileName("addressbook", 78 QString filename = Global::applicationFileName("addressbook",
76 "addressbook.xml"); 79 "addressbook.xml");
77 return filename; 80 return filename;
78} 81}
79 82
80static QString addressbookPersonalVCardName() 83static QString addressbookPersonalVCardName()
81{ 84{
82 QString filename = Global::applicationFileName("addressbook", 85 QString filename = Global::applicationFileName("addressbook",
83 "businesscard.vcf"); 86 "businesscard.vcf");
84 return filename; 87 return filename;
85} 88}
86 89
87 90
88AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 91AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
89 WFlags f ) 92 WFlags f )
90 : QMainWindow( parent, name, f ), 93 : QMainWindow( parent, name, f ),
91 abEditor(0), 94 abEditor(0),
92 bAbEditFirstTime(TRUE), 95 bAbEditFirstTime(TRUE),
93 syncing(FALSE) 96 syncing(FALSE)
94{ 97{
95 initFields(); 98 initFields();
96 99
97 setCaption( tr("Contacts") ); 100 setCaption( tr("Contacts") );
@@ -109,31 +112,31 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
109 112
110 QPopupMenu *edit = new QPopupMenu( this ); 113 QPopupMenu *edit = new QPopupMenu( this );
111 mbList->insertItem( tr( "Contact" ), edit ); 114 mbList->insertItem( tr( "Contact" ), edit );
112 115
113 listTools = new QPEToolBar( this, "list operations" ); 116 listTools = new QPEToolBar( this, "list operations" );
114 117
115 118
116 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 119 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
117 0, this, 0 ); 120 0, this, 0 );
118 actionNew = a; 121 actionNew = a;
119 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 122 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
120 a->addTo( edit ); 123 a->addTo( edit );
121 a->addTo( listTools ); 124 a->addTo( listTools );
122 125
123 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 126 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
124 0, this, 0 ); 127 0, this, 0 );
125 actionEdit = a; 128 actionEdit = a;
126 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 129 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
127 a->addTo( edit ); 130 a->addTo( edit );
128 a->addTo( listTools ); 131 a->addTo( listTools );
129 132
130 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 133 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
131 0, this, 0 ); 134 0, this, 0 );
132 actionTrash = a; 135 actionTrash = a;
133 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 136 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
134 a->addTo( edit ); 137 a->addTo( edit );
135 a->addTo( listTools ); 138 a->addTo( listTools );
136 139
137#ifndef MAKE_FOR_SHARP_ROM 140#ifndef MAKE_FOR_SHARP_ROM
138 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 141 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
139 QString::null, 0, this, 0 ); 142 QString::null, 0, this, 0 );
@@ -150,26 +153,34 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
150 actionMail = a; 153 actionMail = a;
151 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 154 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
152 a->addTo( edit ); 155 a->addTo( edit );
153 a->addTo( listTools ); 156 a->addTo( listTools );
154 157
155 158
156 159
157 if ( Ir::supported() ) { 160 if ( Ir::supported() ) {
158 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 161 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
159 0, this, 0 ); 162 0, this, 0 );
160 actionBeam = a; 163 actionBeam = a;
161 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
162 a->addTo( edit ); 165 a->addTo( edit );
163 a->addTo( listTools ); 166 a->addTo( listTools );
164 } 167 }
165 168
166 edit->insertSeparator(); 169 edit->insertSeparator();
167 170
171 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE );
172 actionPersonal = a;
173 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
174 a->addTo( edit );
175
176
177 edit->insertSeparator();
178
168 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 179 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
169 actionPersonal = a; 180 actionPersonal = a;
170 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 181 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
171 a->addTo( edit ); 182 a->addTo( edit );
172 183
173 184
174 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 185 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
175 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 186 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
@@ -177,43 +188,43 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
177 188
178 // Create Views 189 // Create Views
179 190
180 // This is safe to call without checking to see if it exists... 191 // This is safe to call without checking to see if it exists...
181 // not to mention it also does the necessary stuff for the 192 // not to mention it also does the necessary stuff for the
182 // journaling... 193 // journaling...
183 QString str = addressbookXMLFilename(); 194 QString str = addressbookXMLFilename();
184 if ( str.isNull() ) { 195 if ( str.isNull() ) {
185 QMessageBox::warning( this, tr("Out of Space"), 196 QMessageBox::warning( this, tr("Out of Space"),
186 tr("There is not enough space to create\n" 197 tr("There is not enough space to create\n"
187 "neccessary startup files.\n" 198 "neccessary startup files.\n"
188 "\nFree up some space before\nentering data!") 199 "\nFree up some space before\nentering data!")
189 ); 200 );
190 } 201 }
191 202
192 listContainer = new QWidget( this ); 203 listContainer = new QWidget( this );
193 204
194 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 205 QVBoxLayout *vb = new QVBoxLayout( listContainer );
195 206
196 abList = new AbTable( &orderedFields, listContainer, "table" ); 207 abList = new AbTable( &orderedFields, listContainer, "table" );
197 vb->addWidget(abList); 208 vb->addWidget(abList);
198 abList->setHScrollBarMode( QScrollView::AlwaysOff ); 209 abList->setHScrollBarMode( QScrollView::AlwaysOff );
199 connect( abList, SIGNAL( empty( bool ) ), 210 connect( abList, SIGNAL( empty( bool ) ),
200 this, SLOT( listIsEmpty( bool ) ) ); 211 this, SLOT( listIsEmpty( bool ) ) );
201 connect( abList, SIGNAL( details() ), 212 connect( abList, SIGNAL( details() ),
202 this, SLOT( slotListView() ) ); 213 this, SLOT( slotListView() ) );
203 connect( abList, SIGNAL(currentChanged(int,int)), 214 connect( abList, SIGNAL(currentChanged(int,int)),
204 this, SLOT(slotUpdateToolbar()) ); 215 this, SLOT(slotUpdateToolbar()) );
205 216
206 mView = 0; 217 mView = 0;
207 218
208 abList->load( addressbookXMLFilename() ); 219 abList->load( addressbookXMLFilename() );
209 if ( QFile::exists(addressbookOldXMLFilename()) ) { 220 if ( QFile::exists(addressbookOldXMLFilename()) ) {
210 abList->load( addressbookOldXMLFilename() ); 221 abList->load( addressbookOldXMLFilename() );
211 QFile::remove(addressbookOldXMLFilename()); 222 QFile::remove(addressbookOldXMLFilename());
212 } 223 }
213 224
214 pLabel = new LetterPicker( listContainer ); 225 pLabel = new LetterPicker( listContainer );
215 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 226 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
216 vb->addWidget(pLabel); 227 vb->addWidget(pLabel);
217 catMenu = new QPopupMenu( this ); 228 catMenu = new QPopupMenu( this );
218 catMenu->setCheckable( TRUE ); 229 catMenu->setCheckable( TRUE );
219 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 230 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
@@ -236,83 +247,91 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
236 247
237 mbList->insertItem( tr("Font"), fontMenu); 248 mbList->insertItem( tr("Font"), fontMenu);
238 setCentralWidget(listContainer); 249 setCentralWidget(listContainer);
239 250
240 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 251 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
241} 252}
242void AddressbookWindow::slotSetFont( int size ) { 253void AddressbookWindow::slotSetFont( int size ) {
243 254
244 if (size > 2 || size < 0) 255 if (size > 2 || size < 0)
245 size = 1; 256 size = 1;
246 257
247 startFontSize = size; 258 startFontSize = size;
248 259
249 QFont *currentFont; 260 QFont *currentFont;
250 261
251 switch (size) { 262 switch (size) {
252 case 0: 263 case 0:
253 fontMenu->setItemChecked(0, true); 264 fontMenu->setItemChecked(0, true);
254 fontMenu->setItemChecked(1, false); 265 fontMenu->setItemChecked(1, false);
255 fontMenu->setItemChecked(2, false); 266 fontMenu->setItemChecked(2, false);
256 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 267 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
257 currentFont = new QFont (abList->font()); 268 currentFont = new QFont (abList->font());
258 abList->resizeRows(currentFont->pixelSize() + 7); 269 abList->resizeRows(currentFont->pixelSize() + 7);
259 break; 270 break;
260 case 1: 271 case 1:
261 fontMenu->setItemChecked(0, false); 272 fontMenu->setItemChecked(0, false);
262 fontMenu->setItemChecked(1, true); 273 fontMenu->setItemChecked(1, true);
263 fontMenu->setItemChecked(2, false); 274 fontMenu->setItemChecked(2, false);
264 abList->setFont( *defaultFont ); 275 abList->setFont( *defaultFont );
265 currentFont = new QFont (abList->font()); 276 currentFont = new QFont (abList->font());
266 abList->resizeRows(currentFont->pixelSize() + 7); 277 abList->resizeRows(currentFont->pixelSize() + 7);
267 break; 278 break;
268 case 2: 279 case 2:
269 fontMenu->setItemChecked(0, false); 280 fontMenu->setItemChecked(0, false);
270 fontMenu->setItemChecked(1, false); 281 fontMenu->setItemChecked(1, false);
271 fontMenu->setItemChecked(2, true); 282 fontMenu->setItemChecked(2, true);
272 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 283 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
273 currentFont = new QFont (abList->font()); 284 currentFont = new QFont (abList->font());
274 abList->resizeRows(currentFont->pixelSize() + 7); 285 abList->resizeRows(currentFont->pixelSize() + 7);
275 break; 286 break;
276 } 287 }
288}
289
290
291
292void AddressbookWindow::importvCard() {
293 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
294 if(!str.isEmpty() )
295 setDocument((const QString&) str );
296
277} 297}
278 298
279
280void AddressbookWindow::setDocument( const QString &filename ) 299void AddressbookWindow::setDocument( const QString &filename )
281{ 300{
282 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; 301 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return;
283 302
284 QValueList<Contact> cl = Contact::readVCard( filename ); 303 QValueList<Contact> cl = Contact::readVCard( filename );
285 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { 304 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
286 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") 305// QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?")
287 // .arg( (*it).fullName() ); 306// .arg( (*it).fullName() );
288 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == 307// if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) ==
289 // QMessageBox::Ok ) { 308// QMessageBox::Ok ) {
290 abList->addEntry( *it ); 309 abList->addEntry( *it );
291 // } 310// }
292 } 311 }
293 312
294} 313}
295 314
296void AddressbookWindow::resizeEvent( QResizeEvent *e ) 315void AddressbookWindow::resizeEvent( QResizeEvent *e )
297{ 316{
298 QMainWindow::resizeEvent( e ); 317 QMainWindow::resizeEvent( e );
299 318
300 if ( centralWidget() == listContainer ) 319 if ( centralWidget() == listContainer )
301 showList(); 320 showList();
302 else if ( centralWidget() == mView ) 321 else if ( centralWidget() == mView )
303 showView(); 322 showView();
304} 323}
305 324
306AddressbookWindow::~AddressbookWindow() 325AddressbookWindow::~AddressbookWindow()
307{ 326{
308 Config cfg("AddressBook"); 327 Config cfg("AddressBook");
309 cfg.setGroup("Font"); 328 cfg.setGroup("Font");
310 cfg.writeEntry("fontSize", startFontSize); 329 cfg.writeEntry("fontSize", startFontSize);
311} 330}
312 331
313void AddressbookWindow::slotUpdateToolbar() 332void AddressbookWindow::slotUpdateToolbar()
314{ 333{
315 Contact ce = abList->currentEntry(); 334 Contact ce = abList->currentEntry();
316 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 335 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
317} 336}
318 337
@@ -323,87 +342,87 @@ void AddressbookWindow::showList()
323 listContainer->show(); 342 listContainer->show();
324 // update our focues... (or use a stack widget!); 343 // update our focues... (or use a stack widget!);
325 abList->setFocus(); 344 abList->setFocus();
326} 345}
327 346
328void AddressbookWindow::showView() 347void AddressbookWindow::showView()
329{ 348{
330 if ( abList->numRows() > 0 ) { 349 if ( abList->numRows() > 0 ) {
331 listContainer->hide(); 350 listContainer->hide();
332 setCentralWidget( abView() ); 351 setCentralWidget( abView() );
333 mView->show(); 352 mView->show();
334 mView->setFocus(); 353 mView->setFocus();
335 } 354 }
336} 355}
337 356
338void AddressbookWindow::slotListNew() 357void AddressbookWindow::slotListNew()
339{ 358{
340 Contact cnt; 359 Contact cnt;
341 if( !syncing ) { 360 if( !syncing ) {
342 if ( abEditor ) 361 if ( abEditor )
343 abEditor->setEntry( cnt ); 362 abEditor->setEntry( cnt );
344 abView()->init( cnt ); 363 abView()->init( cnt );
345 editEntry( NewEntry ); 364 editEntry( NewEntry );
346 } else { 365 } else {
347 QMessageBox::warning(this, tr("Contacts"), 366 QMessageBox::warning(this, tr("Contacts"),
348 tr("Can not edit data, currently syncing")); 367 tr("Can not edit data, currently syncing"));
349 } 368 }
350} 369}
351 370
352void AddressbookWindow::slotListView() 371void AddressbookWindow::slotListView()
353{ 372{
354 abView()->init( abList->currentEntry() ); 373 abView()->init( abList->currentEntry() );
355 mView->sync(); 374 mView->sync();
356 showView(); 375 showView();
357} 376}
358 377
359void AddressbookWindow::slotListDelete() 378void AddressbookWindow::slotListDelete()
360{ 379{
361 if(!syncing) { 380 if(!syncing) {
362 Contact tmpEntry = abList->currentEntry(); 381 Contact tmpEntry = abList->currentEntry();
363 382
364 // get a name, do the best we can... 383 // get a name, do the best we can...
365 QString strName = tmpEntry.fullName(); 384 QString strName = tmpEntry.fullName();
366 if ( strName.isEmpty() ) { 385 if ( strName.isEmpty() ) {
367 strName = tmpEntry.company(); 386 strName = tmpEntry.company();
368 if ( strName.isEmpty() ) 387 if ( strName.isEmpty() )
369 strName = "No Name"; 388 strName = "No Name";
370 } 389 }
371 390
372 391
373 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 392 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
374 strName ) ) { 393 strName ) ) {
375 abList->deleteCurrentEntry(); 394 abList->deleteCurrentEntry();
376 showList(); 395 showList();
377 } 396 }
378 } else { 397 } else {
379 QMessageBox::warning( this, tr("Contacts"), 398 QMessageBox::warning( this, tr("Contacts"),
380 tr("Can not edit data, currently syncing") ); 399 tr("Can not edit data, currently syncing") );
381 } 400 }
382} 401}
383 402
384void AddressbookWindow::slotViewBack() 403void AddressbookWindow::slotViewBack()
385{ 404{
386 showList(); 405 showList();
387} 406}
388 407
389void AddressbookWindow::slotViewEdit() 408void AddressbookWindow::slotViewEdit()
390{ 409{
391 if(!syncing) { 410 if(!syncing) {
392 if (actionPersonal->isOn()) { 411 if (actionPersonal->isOn()) {
393 editPersonal(); 412 editPersonal();
394 } else { 413 } else {
395 if ( !bAbEditFirstTime ) 414 if ( !bAbEditFirstTime )
396 abEditor->setEntry( abList->currentEntry() ); 415 abEditor->setEntry( abList->currentEntry() );
397 editEntry( EditEntry ); 416 editEntry( EditEntry );
398 } 417 }
399 } else { 418 } else {
400 QMessageBox::warning( this, tr("Contacts"), 419 QMessageBox::warning( this, tr("Contacts"),
401 tr("Can not edit data, currently syncing") ); 420 tr("Can not edit data, currently syncing") );
402 } 421 }
403} 422}
404 423
405 424
406 425
407void AddressbookWindow::writeMail() 426void AddressbookWindow::writeMail()
408{ 427{
409 Contact c = abList->currentEntry(); 428 Contact c = abList->currentEntry();
@@ -418,100 +437,100 @@ void AddressbookWindow::writeMail()
418 437
419static const char * beamfile = "/tmp/obex/contact.vcf"; 438static const char * beamfile = "/tmp/obex/contact.vcf";
420 439
421void AddressbookWindow::slotBeam() 440void AddressbookWindow::slotBeam()
422{ 441{
423 QString filename; 442 QString filename;
424 Contact c; 443 Contact c;
425 if ( actionPersonal->isOn() ) { 444 if ( actionPersonal->isOn() ) {
426 filename = addressbookPersonalVCardName(); 445 filename = addressbookPersonalVCardName();
427 if (!QFile::exists(filename)) 446 if (!QFile::exists(filename))
428 return; // can't beam a non-existent file 447 return; // can't beam a non-existent file
429 c = Contact::readVCard( filename )[0]; 448 c = Contact::readVCard( filename )[0];
430 } else { 449 } else {
431 unlink( beamfile ); // delete if exists 450 unlink( beamfile ); // delete if exists
432 c = abList->currentEntry(); 451 c = abList->currentEntry();
433 mkdir("/tmp/obex/", 0755); 452 mkdir("/tmp/obex/", 0755);
434 Contact::writeVCard( beamfile, c ); 453 Contact::writeVCard( beamfile, c );
435 filename = beamfile; 454 filename = beamfile;
436 } 455 }
437 Ir *ir = new Ir( this ); 456 Ir *ir = new Ir( this );
438 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 457 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
439 QString description = c.fullName(); 458 QString description = c.fullName();
440 ir->send( filename, description, "text/x-vCard" ); 459 ir->send( filename, description, "text/x-vCard" );
441} 460}
442 461
443void AddressbookWindow::beamDone( Ir *ir ) 462void AddressbookWindow::beamDone( Ir *ir )
444{ 463{
445 delete ir; 464 delete ir;
446 unlink( beamfile ); 465 unlink( beamfile );
447} 466}
448 467
449 468
450static void parseName( const QString& name, QString *first, QString *middle, 469static void parseName( const QString& name, QString *first, QString *middle,
451 QString * last ) 470 QString * last )
452{ 471{
453 472
454 int comma = name.find ( "," ); 473 int comma = name.find ( "," );
455 QString rest; 474 QString rest;
456 if ( comma > 0 ) { 475 if ( comma > 0 ) {
457 *last = name.left( comma ); 476 *last = name.left( comma );
458 comma++; 477 comma++;
459 while ( comma < int(name.length()) && name[comma] == ' ' ) 478 while ( comma < int(name.length()) && name[comma] == ' ' )
460 comma++; 479 comma++;
461 rest = name.mid( comma ); 480 rest = name.mid( comma );
462 } else { 481 } else {
463 int space = name.findRev( ' ' ); 482 int space = name.findRev( ' ' );
464 *last = name.mid( space+1 ); 483 *last = name.mid( space+1 );
465 rest = name.left( space ); 484 rest = name.left( space );
466 } 485 }
467 int space = rest.find( ' ' ); 486 int space = rest.find( ' ' );
468 if ( space <= 0 ) { 487 if ( space <= 0 ) {
469 *first = rest; 488 *first = rest;
470 } else { 489 } else {
471 *first = rest.left( space ); 490 *first = rest.left( space );
472 *middle = rest.mid( space+1 ); 491 *middle = rest.mid( space+1 );
473 } 492 }
474 493
475} 494}
476 495
477 496
478void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 497void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
479{ 498{
480 if (msg == "editPersonal()") { 499 if (msg == "editPersonal()") {
481 editPersonal(); 500 editPersonal();
482 } else if (msg == "editPersonalAndClose()") { 501 } else if (msg == "editPersonalAndClose()") {
483 editPersonal(); 502 editPersonal();
484 close(); 503 close();
485 } else if ( msg == "addContact(QString,QString)" ) { 504 } else if ( msg == "addContact(QString,QString)" ) {
486 QDataStream stream(data,IO_ReadOnly); 505 QDataStream stream(data,IO_ReadOnly);
487 QString name, email; 506 QString name, email;
488 stream >> name >> email; 507 stream >> name >> email;
489 508
490 Contact cnt; 509 Contact cnt;
491 QString fn, mn, ln; 510 QString fn, mn, ln;
492 parseName( name, &fn, &mn, &ln ); 511 parseName( name, &fn, &mn, &ln );
493 //qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 512 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
494 cnt.setFirstName( fn ); 513 cnt.setFirstName( fn );
495 cnt.setMiddleName( mn ); 514 cnt.setMiddleName( mn );
496 cnt.setLastName( ln ); 515 cnt.setLastName( ln );
497 cnt.setEmails( email ); 516 cnt.setEmails( email );
498 cnt.setDefaultEmail( email ); 517 cnt.setDefaultEmail( email );
499 cnt.setFileAs(); 518 cnt.setFileAs();
500 519
501 if ( bAbEditFirstTime ) { 520 if ( bAbEditFirstTime ) {
502 abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, 521 abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields,
503 this, "editor" ); 522 this, "editor" );
504 bAbEditFirstTime = FALSE; 523 bAbEditFirstTime = FALSE;
505 } else { 524 } else {
506 abEditor->setEntry( cnt ); 525 abEditor->setEntry( cnt );
507 } 526 }
508 abView()->init( cnt ); 527 abView()->init( cnt );
509 editEntry( NewEntry ); 528 editEntry( NewEntry );
510 529
511 530
512 531
513 } 532 }
514#if 0 533#if 0
515 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { 534 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
516 QDataStream stream(data,IO_ReadOnly); 535 QDataStream stream(data,IO_ReadOnly);
517 QCString ch,m; 536 QCString ch,m;
@@ -543,117 +562,117 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
543 562
544} 563}
545 564
546void AddressbookWindow::editPersonal() 565void AddressbookWindow::editPersonal()
547{ 566{
548 QString filename = addressbookPersonalVCardName(); 567 QString filename = addressbookPersonalVCardName();
549 Contact me; 568 Contact me;
550 if (QFile::exists(filename)) 569 if (QFile::exists(filename))
551 me = Contact::readVCard( filename )[0]; 570 me = Contact::readVCard( filename )[0];
552 if (bAbEditFirstTime) { 571 if (bAbEditFirstTime) {
553 abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, 572 abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields,
554 this, "editor" ); 573 this, "editor" );
555 // don't create a new editor every time 574 // don't create a new editor every time
556 bAbEditFirstTime = FALSE; 575 bAbEditFirstTime = FALSE;
557 } else 576 } else
558 abEditor->setEntry( me ); 577 abEditor->setEntry( me );
559 578
560 abEditor->setCaption(tr("Edit My Personal Details")); 579 abEditor->setCaption(tr("Edit My Personal Details"));
561 abEditor->showMaximized(); 580 abEditor->showMaximized();
562 581
563 // fix the foxus... 582 // fix the foxus...
564 abEditor->setNameFocus(); 583 abEditor->setNameFocus();
565 if ( abEditor->exec() ) { 584 if ( abEditor->exec() ) {
566 setFocus(); 585 setFocus();
567 Contact new_personal = abEditor->entry(); 586 Contact new_personal = abEditor->entry();
568 QString fname = addressbookPersonalVCardName(); 587 QString fname = addressbookPersonalVCardName();
569 Contact::writeVCard( fname, new_personal ); 588 Contact::writeVCard( fname, new_personal );
570 abView()->init(new_personal); 589 abView()->init(new_personal);
571 abView()->sync(); 590 abView()->sync();
572 } 591 }
573 abEditor->setCaption( tr("Edit Address") ); 592 abEditor->setCaption( tr("Edit Address") );
574} 593}
575 594
576void AddressbookWindow::slotPersonalView() 595void AddressbookWindow::slotPersonalView()
577{ 596{
578 if (!actionPersonal->isOn()) { 597 if (!actionPersonal->isOn()) {
579 // we just turned it off 598 // we just turned it off
580 setCaption( tr("Contacts") ); 599 setCaption( tr("Contacts") );
581 actionNew->setEnabled(TRUE); 600 actionNew->setEnabled(TRUE);
582 actionTrash->setEnabled(TRUE); 601 actionTrash->setEnabled(TRUE);
583#ifndef MAKE_FOR_SHARP_ROM 602#ifndef MAKE_FOR_SHARP_ROM
584 actionFind->setEnabled(TRUE); 603 actionFind->setEnabled(TRUE);
585#endif 604#endif
586 slotUpdateToolbar(); // maybe some of the above could be moved there 605 slotUpdateToolbar(); // maybe some of the above could be moved there
587 showList(); 606 showList();
588 return; 607 return;
589 } 608 }
590 609
591 // XXX need to disable some QActions. 610 // XXX need to disable some QActions.
592 actionNew->setEnabled(FALSE); 611 actionNew->setEnabled(FALSE);
593 actionTrash->setEnabled(FALSE); 612 actionTrash->setEnabled(FALSE);
594#ifndef MAKE_FOR_SHARP_ROM 613#ifndef MAKE_FOR_SHARP_ROM
595 actionFind->setEnabled(FALSE); 614 actionFind->setEnabled(FALSE);
596#endif 615#endif
597 actionMail->setEnabled(FALSE); 616 actionMail->setEnabled(FALSE);
598 617
599 setCaption( tr("Contacts - My Personal Details") ); 618 setCaption( tr("Contacts - My Personal Details") );
600 QString filename = addressbookPersonalVCardName(); 619 QString filename = addressbookPersonalVCardName();
601 Contact me; 620 Contact me;
602 if (QFile::exists(filename)) 621 if (QFile::exists(filename))
603 me = Contact::readVCard( filename )[0]; 622 me = Contact::readVCard( filename )[0];
604 623
605 abView()->init( me ); 624 abView()->init( me );
606 abView()->sync(); 625 abView()->sync();
607 listContainer->hide(); 626 listContainer->hide();
608 setCentralWidget( abView() ); 627 setCentralWidget( abView() );
609 mView->show(); 628 mView->show();
610 mView->setFocus(); 629 mView->setFocus();
611} 630}
612 631
613void AddressbookWindow::editEntry( EntryMode entryMode ) 632void AddressbookWindow::editEntry( EntryMode entryMode )
614{ 633{
615 Contact entry; 634 Contact entry;
616 if ( bAbEditFirstTime ) { 635 if ( bAbEditFirstTime ) {
617 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, 636 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields,
618 this, "editor" ); 637 this, "editor" );
619 bAbEditFirstTime = FALSE; 638 bAbEditFirstTime = FALSE;
620 if ( entryMode == EditEntry ) 639 if ( entryMode == EditEntry )
621 abEditor->setEntry( abList->currentEntry() ); 640 abEditor->setEntry( abList->currentEntry() );
622 } 641 }
623 // other things may chane the caption. 642 // other things may chane the caption.
624 abEditor->setCaption( tr("Edit Address") ); 643 abEditor->setCaption( tr("Edit Address") );
625 644
626#if defined(Q_WS_QWS) || defined(_WS_QWS_) 645#if defined(Q_WS_QWS) || defined(_WS_QWS_)
627 abEditor->showMaximized(); 646 abEditor->showMaximized();
628#endif 647#endif
629 // fix the foxus... 648 // fix the foxus...
630 abEditor->setNameFocus(); 649 abEditor->setNameFocus();
631 if ( abEditor->exec() ) { 650 if ( abEditor->exec() ) {
632 setFocus(); 651 setFocus();
633 if ( entryMode == NewEntry ) { 652 if ( entryMode == NewEntry ) {
634 Contact insertEntry = abEditor->entry(); 653 Contact insertEntry = abEditor->entry();
635 insertEntry.assignUid(); 654 insertEntry.assignUid();
636 abList->addEntry( insertEntry ); 655 abList->addEntry( insertEntry );
637 } else { 656 } else {
638 Contact replaceEntry = abEditor->entry(); 657 Contact replaceEntry = abEditor->entry();
639 if ( !replaceEntry.isValidUid() ) 658 if ( !replaceEntry.isValidUid() )
640 replaceEntry.assignUid(); 659 replaceEntry.assignUid();
641 abList->replaceCurrentEntry( replaceEntry ); 660 abList->replaceCurrentEntry( replaceEntry );
642 } 661 }
643 } 662 }
644 populateCategories(); 663 populateCategories();
645 showList(); 664 showList();
646} 665}
647 666
648void AddressbookWindow::listIsEmpty( bool empty ) 667void AddressbookWindow::listIsEmpty( bool empty )
649{ 668{
650 if ( !empty ) { 669 if ( !empty ) {
651 deleteButton->setEnabled( TRUE ); 670 deleteButton->setEnabled( TRUE );
652 } 671 }
653} 672}
654 673
655void AddressbookWindow::reload() 674void AddressbookWindow::reload()
656{ 675{
657 syncing = FALSE; 676 syncing = FALSE;
658 abList->clear(); 677 abList->clear();
659 abList->load( addressbookXMLFilename() ); 678 abList->load( addressbookXMLFilename() );
@@ -664,94 +683,94 @@ void AddressbookWindow::flush()
664 syncing = TRUE; 683 syncing = TRUE;
665 abList->save( addressbookXMLFilename() ); 684 abList->save( addressbookXMLFilename() );
666} 685}
667 686
668 687
669void AddressbookWindow::closeEvent( QCloseEvent *e ) 688void AddressbookWindow::closeEvent( QCloseEvent *e )
670{ 689{
671 if ( centralWidget() == mView ) { 690 if ( centralWidget() == mView ) {
672 if (actionPersonal->isOn()) { 691 if (actionPersonal->isOn()) {
673 // pretend we clicked it off 692 // pretend we clicked it off
674 actionPersonal->setOn(FALSE); 693 actionPersonal->setOn(FALSE);
675 slotPersonalView(); 694 slotPersonalView();
676 } else { 695 } else {
677 showList(); 696 showList();
678 } 697 }
679 e->ignore(); 698 e->ignore();
680 return; 699 return;
681 } 700 }
682 701
683 if(syncing) { 702 if(syncing) {
684 /* shouldn't we save, I hear you say? well its already been set 703 /* shouldn't we save, I hear you say? well its already been set
685 so that an edit can not occur during a sync, and we flushed 704 so that an edit can not occur during a sync, and we flushed
686 at the start of the sync, so there is no need to save 705 at the start of the sync, so there is no need to save
687 Saving however itself would cause problems. */ 706 Saving however itself would cause problems. */
688 e->accept(); 707 e->accept();
689 return; 708 return;
690 } 709 }
691//################## shouldn't always save 710//################## shouldn't always save
692 if ( save() ) 711 if ( save() )
693 e->accept(); 712 e->accept();
694 else 713 else
695 e->ignore(); 714 e->ignore();
696} 715}
697 716
698/* 717/*
699 Returns TRUE if it is OK to exit 718 Returns TRUE if it is OK to exit
700 */ 719 */
701 720
702bool AddressbookWindow::save() 721bool AddressbookWindow::save()
703{ 722{
704 QString str = addressbookXMLFilename(); 723 QString str = addressbookXMLFilename();
705 if ( str.isNull() ) { 724 if ( str.isNull() ) {
706 if ( QMessageBox::critical( 0, tr("Out of space"), 725 if ( QMessageBox::critical( 0, tr("Out of space"),
707 tr("Unable to save information.\n" 726 tr("Unable to save information.\n"
708 "Free up some space\n" 727 "Free up some space\n"
709 "and try again.\n" 728 "and try again.\n"
710 "\nQuit anyway?"), 729 "\nQuit anyway?"),
711 QMessageBox::Yes|QMessageBox::Escape, 730 QMessageBox::Yes|QMessageBox::Escape,
712 QMessageBox::No|QMessageBox::Default ) 731 QMessageBox::No|QMessageBox::Default )
713 != QMessageBox::No ) 732 != QMessageBox::No )
714 return TRUE; 733 return TRUE;
715 else 734 else
716 return FALSE; 735 return FALSE;
717 } else { 736 } else {
718 if ( !abList->save( str ) ) { 737 if ( !abList->save( str ) ) {
719 if ( QMessageBox::critical( 0, tr( "Out of space" ), 738 if ( QMessageBox::critical( 0, tr( "Out of space" ),
720 tr("Unable to save information.\n" 739 tr("Unable to save information.\n"
721 "Free up some space\n" 740 "Free up some space\n"
722 "and try again.\n" 741 "and try again.\n"
723 "\nQuit anyway?"), 742 "\nQuit anyway?"),
724 QMessageBox::Yes|QMessageBox::Escape, 743 QMessageBox::Yes|QMessageBox::Escape,
725 QMessageBox::No|QMessageBox::Default ) 744 QMessageBox::No|QMessageBox::Default )
726 != QMessageBox::No ) 745 != QMessageBox::No )
727 return TRUE; 746 return TRUE;
728 else 747 else
729 return FALSE; 748 return FALSE;
730 } 749 }
731 } 750 }
732 return TRUE; 751 return TRUE;
733} 752}
734 753
735void AddressbookWindow::slotSettings() 754void AddressbookWindow::slotSettings()
736{ 755{
737 AddressSettings frmSettings( this ); 756 AddressSettings frmSettings( this );
738#if defined(Q_WS_QWS) || defined(_WS_QWS_) 757#if defined(Q_WS_QWS) || defined(_WS_QWS_)
739 frmSettings.showMaximized(); 758 frmSettings.showMaximized();
740#endif 759#endif
741 760
742 if ( frmSettings.exec() ) { 761 if ( frmSettings.exec() ) {
743 allFields.clear(); 762 allFields.clear();
744 orderedFields.clear(); 763 orderedFields.clear();
745 slOrderedFields.clear(); 764 slOrderedFields.clear();
746 initFields(); 765 initFields();
747 if ( abEditor ) 766 if ( abEditor )
748 abEditor->loadFields(); 767 abEditor->loadFields();
749 abList->refresh(); 768 abList->refresh();
750 } 769 }
751} 770}
752 771
753 772
754void AddressbookWindow::initFields() 773void AddressbookWindow::initFields()
755{ 774{
756 // we really don't need the things from the configuration, anymore 775 // we really don't need the things from the configuration, anymore
757 // only thing that is important are the important categories. So, 776 // only thing that is important are the important categories. So,
@@ -759,85 +778,85 @@ void AddressbookWindow::initFields()
759 778
760 QStringList xmlFields = Contact::fields(); 779 QStringList xmlFields = Contact::fields();
761 QStringList visibleFields = Contact::trfields(); 780 QStringList visibleFields = Contact::trfields();
762 xmlFields.remove( "Title" ); 781 xmlFields.remove( "Title" );
763 visibleFields.remove( tr("Name Title") ); 782 visibleFields.remove( tr("Name Title") );
764 visibleFields.remove( tr("Notes") ); 783 visibleFields.remove( tr("Notes") );
765 784
766 int i, 785 int i,
767 version; 786 version;
768 Config cfg( "AddressBook" ); 787 Config cfg( "AddressBook" );
769 QString zn; 788 QString zn;
770 789
771 // ### Write a function to keep this from happening again... 790 // ### Write a function to keep this from happening again...
772 QStringList::ConstIterator it; 791 QStringList::ConstIterator it;
773 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { 792 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) {
774 allFields.append( i + 3 ); 793 allFields.append( i + 3 );
775 } 794 }
776 795
777 cfg.setGroup( "Version" ); 796 cfg.setGroup( "Version" );
778 version = cfg.readNumEntry( "version" ); 797 version = cfg.readNumEntry( "version" );
779 i = 0; 798 i = 0;
780 startFontSize = 1; 799 startFontSize = 1;
781 800
782 if ( version >= ADDRESSVERSION ) { 801 if ( version >= ADDRESSVERSION ) {
783 802
784 cfg.setGroup( "ImportantCategory" ); 803 cfg.setGroup( "ImportantCategory" );
785 804
786 zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); 805 zn = cfg.readEntry( "Category" + QString::number(i), QString::null );
787 while ( !zn.isNull() ) { 806 while ( !zn.isNull() ) {
788 if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) { 807 if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) {
789 slOrderedFields.clear(); 808 slOrderedFields.clear();
790 break; 809 break;
791 } 810 }
792 slOrderedFields.append( zn ); 811 slOrderedFields.append( zn );
793 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); 812 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null );
794 } 813 }
795 cfg.setGroup( "Font" ); 814 cfg.setGroup( "Font" );
796 startFontSize = cfg.readNumEntry( "fontSize", 1 ); 815 startFontSize = cfg.readNumEntry( "fontSize", 1 );
797 816
798 817
799 } else { 818 } else {
800 QString str; 819 QString str;
801 str = getenv("HOME"); 820 str = getenv("HOME");
802 str += "/Settings/AddressBook.conf"; 821 str += "/Settings/AddressBook.conf";
803 QFile::remove( str ); 822 QFile::remove( str );
804 } 823 }
805 if ( slOrderedFields.count() > 0 ) { 824 if ( slOrderedFields.count() > 0 ) {
806 for( QStringList::ConstIterator it = slOrderedFields.begin(); 825 for( QStringList::ConstIterator it = slOrderedFields.begin();
807 it != slOrderedFields.end(); ++it ) { 826 it != slOrderedFields.end(); ++it ) {
808 QValueList<int>::ConstIterator itVl; 827 QValueList<int>::ConstIterator itVl;
809 QStringList::ConstIterator itVis; 828 QStringList::ConstIterator itVis;
810 itVl = allFields.begin(); 829 itVl = allFields.begin();
811 for ( itVis = visibleFields.begin(); 830 for ( itVis = visibleFields.begin();
812 itVis != visibleFields.end() && itVl != allFields.end(); 831 itVis != visibleFields.end() && itVl != allFields.end();
813 ++itVis, ++itVl ) { 832 ++itVis, ++itVl ) {
814 if ( *it == *itVis && itVl != allFields.end() ) { 833 if ( *it == *itVis && itVl != allFields.end() ) {
815 orderedFields.append( *itVl ); 834 orderedFields.append( *itVl );
816 } 835 }
817 } 836 }
818 } 837 }
819 } else { 838 } else {
820 QValueList<int>::ConstIterator it; 839 QValueList<int>::ConstIterator it;
821 for ( it = allFields.begin(); it != allFields.end(); ++it ) 840 for ( it = allFields.begin(); it != allFields.end(); ++it )
822 orderedFields.append( *it ); 841 orderedFields.append( *it );
823 842
824 slOrderedFields = visibleFields; 843 slOrderedFields = visibleFields;
825 orderedFields.remove( Qtopia::AddressUid ); 844 orderedFields.remove( Qtopia::AddressUid );
826 orderedFields.remove( Qtopia::Title ); 845 orderedFields.remove( Qtopia::Title );
827 orderedFields.remove( Qtopia::Groups ); 846 orderedFields.remove( Qtopia::Groups );
828 orderedFields.remove( Qtopia::AddressCategory ); 847 orderedFields.remove( Qtopia::AddressCategory );
829 orderedFields.remove( Qtopia::FirstName ); 848 orderedFields.remove( Qtopia::FirstName );
830 orderedFields.remove( Qtopia::LastName ); 849 orderedFields.remove( Qtopia::LastName );
831 orderedFields.remove( Qtopia::DefaultEmail ); 850 orderedFields.remove( Qtopia::DefaultEmail );
832 orderedFields.remove( Qtopia::FileAs ); 851 orderedFields.remove( Qtopia::FileAs );
833 orderedFields.remove( Qtopia::Notes ); 852 orderedFields.remove( Qtopia::Notes );
834 orderedFields.remove( Qtopia::Gender ); 853 orderedFields.remove( Qtopia::Gender );
835 slOrderedFields.remove( tr("Name Title") ); 854 slOrderedFields.remove( tr("Name Title") );
836 slOrderedFields.remove( tr("First Name") ); 855 slOrderedFields.remove( tr("First Name") );
837 slOrderedFields.remove( tr("Last Name") ); 856 slOrderedFields.remove( tr("Last Name") );
838 slOrderedFields.remove( tr("File As") ); 857 slOrderedFields.remove( tr("File As") );
839 slOrderedFields.remove( tr("Default Email") ); 858 slOrderedFields.remove( tr("Default Email") );
840 slOrderedFields.remove( tr("Notes") ); 859 slOrderedFields.remove( tr("Notes") );
841 slOrderedFields.remove( tr("Gender") ); 860 slOrderedFields.remove( tr("Gender") );
842 861
843 } 862 }
@@ -853,72 +872,72 @@ AbLabel *AddressbookWindow::abView()
853 } 872 }
854 return mView; 873 return mView;
855} 874}
856 875
857void AddressbookWindow::slotFind() 876void AddressbookWindow::slotFind()
858{ 877{
859#ifndef MAKE_FOR_SHARP_ROM 878#ifndef MAKE_FOR_SHARP_ROM
860 if ( centralWidget() == abView() ) 879 if ( centralWidget() == abView() )
861 showList(); 880 showList();
862 881
863 FindDialog frmFind( "Contacts", this ); 882 FindDialog frmFind( "Contacts", this );
864 QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int))); 883 QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int)));
865 QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); 884 QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
866 QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); 885 QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
867 886
868 frmFind.exec(); 887 frmFind.exec();
869 888
870 if ( abList->numSelections() ) 889 if ( abList->numSelections() )
871 abList->clearSelection(); 890 abList->clearSelection();
872 891
873 abList->clearFindRow(); 892 abList->clearFindRow();
874#endif 893#endif
875} 894}
876 895
877void AddressbookWindow::slotSetCategory( int c ) 896void AddressbookWindow::slotSetCategory( int c )
878{ 897{
879 if ( c <= 0 ) 898 if ( c <= 0 )
880 return; 899 return;
881 for ( unsigned int i = 1; i < catMenu->count(); i++ ) 900 for ( unsigned int i = 1; i < catMenu->count(); i++ )
882 catMenu->setItemChecked( i, c == (int)i ); 901 catMenu->setItemChecked( i, c == (int)i );
883 if ( c == 1 ) { 902 if ( c == 1 ) {
884 abList->setShowCategory( QString::null ); 903 abList->setShowCategory( QString::null );
885 setCaption( tr("Contacts") + " - " + tr ( "All" ) ); 904 setCaption( tr("Contacts") + " - " + tr ( "All" ) );
886 } else if ( c == (int)catMenu->count() ) { 905 } else if ( c == (int)catMenu->count() ) {
887 abList->setShowCategory( tr( "Unfiled" ) ); 906 abList->setShowCategory( tr( "Unfiled" ) );
888 setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); 907 setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) );
889 } else { 908 } else {
890 QString cat = abList->categories()[c - 2]; 909 QString cat = abList->categories()[c - 2];
891 abList->setShowCategory( cat ); 910 abList->setShowCategory( cat );
892 setCaption( tr("Contacts") + " - " + cat ); 911 setCaption( tr("Contacts") + " - " + cat );
893 } 912 }
894} 913}
895 914
896void AddressbookWindow::slotSetLetter( char c ) { 915void AddressbookWindow::slotSetLetter( char c ) {
897 916
898 abList->setShowByLetter( c ); 917 abList->setShowByLetter( c );
899 918
900} 919}
901 920
902void AddressbookWindow::populateCategories() 921void AddressbookWindow::populateCategories()
903{ 922{
904 catMenu->clear(); 923 catMenu->clear();
905 924
906 int id, 925 int id,
907 rememberId; 926 rememberId;
908 id = 1; 927 id = 1;
909 rememberId = 0; 928 rememberId = 0;
910 catMenu->insertItem( tr( "All" ), id++ ); 929 catMenu->insertItem( tr( "All" ), id++ );
911 QStringList categories = abList->categories(); 930 QStringList categories = abList->categories();
912 categories.append( tr( "Unfiled" ) ); 931 categories.append( tr( "Unfiled" ) );
913 for ( QStringList::Iterator it = categories.begin(); 932 for ( QStringList::Iterator it = categories.begin();
914 it != categories.end(); ++it ) { 933 it != categories.end(); ++it ) {
915 catMenu->insertItem( *it, id ); 934 catMenu->insertItem( *it, id );
916 if ( *it == abList->showCategory() ) 935 if ( *it == abList->showCategory() )
917 rememberId = id; 936 rememberId = id;
918 ++id; 937 ++id;
919 } 938 }
920 if ( abList->showCategory().isEmpty() ) 939 if ( abList->showCategory().isEmpty() )
921 slotSetCategory( 1 ); 940 slotSetCategory( 1 );
922 else 941 else
923 slotSetCategory( rememberId ); 942 slotSetCategory( rememberId );
924} 943}
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 476c971..da43731 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -54,16 +54,17 @@ protected:
54 54
55public slots: 55public slots:
56 void flush(); 56 void flush();
57 void reload(); 57 void reload();
58 void appMessage(const QCString &, const QByteArray &); 58 void appMessage(const QCString &, const QByteArray &);
59 void setDocument( const QString & ); 59 void setDocument( const QString & );
60 60
61private slots: 61private slots:
62 void importvCard();
62 void slotListNew(); 63 void slotListNew();
63 void slotListView(); 64 void slotListView();
64 void slotListDelete(); 65 void slotListDelete();
65 void slotViewBack(); 66 void slotViewBack();
66 void slotViewEdit(); 67 void slotViewEdit();
67 void slotPersonalView(); 68 void slotPersonalView();
68 void listIsEmpty( bool ); 69 void listIsEmpty( bool );
69 void slotSettings(); 70 void slotSettings();
@@ -71,35 +72,35 @@ private slots:
71 void slotBeam(); 72 void slotBeam();
72 void beamDone( Ir * ); 73 void beamDone( Ir * );
73 void slotFind(); 74 void slotFind();
74 void slotSetCategory( int ); 75 void slotSetCategory( int );
75 void slotSetLetter( char ); 76 void slotSetLetter( char );
76 void slotUpdateToolbar(); 77 void slotUpdateToolbar();
77 void slotSetFont(int); 78 void slotSetFont(int);
78private: 79private:
79 void initFields();// inititialize our fields... 80 void initFields(); // inititialize our fields...
80 AbLabel *abView(); 81 AbLabel *abView();
81 void populateCategories(); 82 void populateCategories();
82 83
83 QPopupMenu *catMenu, *fontMenu; 84 QPopupMenu *catMenu, *fontMenu;
84 QPEToolBar *listTools; 85 QPEToolBar *listTools;
85 QToolButton *deleteButton; 86 QToolButton *deleteButton;
86 QValueList<int> allFields, 87 QValueList<int> allFields,
87 orderedFields; 88 orderedFields;
88 QStringList slOrderedFields; 89 QStringList slOrderedFields;
89 enum Panes { paneList=0, paneView, paneEdit }; 90 enum Panes { paneList=0, paneView, paneEdit };
90 ContactEditor *abEditor; 91 ContactEditor *abEditor;
91 AbLabel *mView; 92 AbLabel *mView;
92 LetterPicker *pLabel; 93 LetterPicker *pLabel;
93 AbTable *abList; 94 AbTable *abList;
94 QWidget *listContainer; 95 QWidget *listContainer;
95 96
96 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, 97 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
97 *actionPersonal, *actionMail; 98 *actionPersonal, *actionMail;
98 99
99 bool bAbEditFirstTime; 100 bool bAbEditFirstTime;
100 int viewMargin; 101 int viewMargin;
101 102
102 bool syncing; 103 bool syncing;
103 QFont *defaultFont; 104 QFont *defaultFont;
104 int startFontSize; 105 int startFontSize;
105}; 106};
diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro
index 0d65c74..428af2b 100644
--- a/core/pim/addressbook/addressbook.pro
+++ b/core/pim/addressbook/addressbook.pro
@@ -14,17 +14,17 @@ SOURCES = main.cpp \
14 abtable.cpp \ 14 abtable.cpp \
15 addresssettings.cpp \ 15 addresssettings.cpp \
16 picker.cpp 16 picker.cpp
17 INTERFACES= addresssettingsbase.ui 17 INTERFACES= addresssettingsbase.ui
18 18
19 TARGET = addressbook 19 TARGET = addressbook
20INCLUDEPATH += $(OPIEDIR)/include 20INCLUDEPATH += $(OPIEDIR)/include
21 DEPENDPATH+= $(OPIEDIR)/include 21 DEPENDPATH+= $(OPIEDIR)/include
22LIBS += -lqpe 22LIBS += -lqpe -lopie
23 23
24TRANSLATIONS = ../../i18n/pt_BR/addressbook.ts 24TRANSLATIONS = ../../i18n/pt_BR/addressbook.ts
25TRANSLATIONS += ../../i18n/de/addressbook.ts 25TRANSLATIONS += ../../i18n/de/addressbook.ts
26TRANSLATIONS += ../../i18n/en/addressbook.ts 26TRANSLATIONS += ../../i18n/en/addressbook.ts
27TRANSLATIONS += ../../i18n/hu/addressbook.ts 27TRANSLATIONS += ../../i18n/hu/addressbook.ts
28TRANSLATIONS += ../../i18n/sl/addressbook.ts 28TRANSLATIONS += ../../i18n/sl/addressbook.ts
29TRANSLATIONS += ../../i18n/ja/addressbook.ts 29TRANSLATIONS += ../../i18n/ja/addressbook.ts
30TRANSLATIONS += ../../i18n/ko/addressbook.ts 30TRANSLATIONS += ../../i18n/ko/addressbook.ts