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
@@ -26,6 +26,9 @@
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>
@@ -73,20 +76,20 @@ static QString addressbookOldXMLFilename()
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),
@@ -114,21 +117,21 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 );
@@ -155,16 +158,24 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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() ) );
@@ -182,11 +193,11 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 );
@@ -197,18 +208,18 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 );
@@ -241,54 +252,62 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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}
@@ -305,9 +324,9 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e )
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()
@@ -328,10 +347,10 @@ void AddressbookWindow::showList()
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
@@ -339,13 +358,13 @@ void 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
@@ -359,25 +378,25 @@ void AddressbookWindow::slotListView()
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
@@ -389,16 +408,16 @@ void AddressbookWindow::slotViewBack()
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
@@ -423,16 +442,16 @@ void AddressbookWindow::slotBeam()
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 * ) ) );
@@ -448,28 +467,28 @@ void AddressbookWindow::beamDone( Ir *ir )
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}
@@ -478,35 +497,35 @@ static void parseName( const QString& name, QString *first, QString *middle,
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
@@ -548,14 +567,14 @@ void AddressbookWindow::editPersonal()
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();
@@ -563,12 +582,12 @@ void AddressbookWindow::editPersonal()
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}
@@ -576,16 +595,16 @@ void AddressbookWindow::editPersonal()
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.
@@ -600,7 +619,7 @@ void AddressbookWindow::slotPersonalView()
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();
@@ -614,11 +633,11 @@ void 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") );
@@ -629,17 +648,17 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
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();
@@ -648,7 +667,7 @@ void AddressbookWindow::editEntry( EntryMode entryMode )
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
@@ -669,30 +688,30 @@ void AddressbookWindow::flush()
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/*
@@ -703,31 +722,31 @@ bool 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}
@@ -740,13 +759,13 @@ void AddressbookWindow::slotSettings()
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
@@ -764,14 +783,14 @@ void AddressbookWindow::initFields()
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" );
@@ -781,58 +800,58 @@ void AddressbookWindow::initFields()
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") );
@@ -858,7 +877,7 @@ void 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)));
@@ -868,7 +887,7 @@ void AddressbookWindow::slotFind()
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
@@ -877,25 +896,25 @@ void AddressbookWindow::slotFind()
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
@@ -904,21 +923,21 @@ void AddressbookWindow::populateCategories()
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
@@ -59,6 +59,7 @@ public slots:
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();
@@ -76,7 +77,7 @@ private slots:
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
@@ -84,7 +85,7 @@ private:
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;
@@ -94,7 +95,7 @@ private:
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;
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
@@ -19,7 +19,7 @@ INTERFACES = addresssettingsbase.ui
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