-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 617 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 7 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.pro | 2 |
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 | |||
@@ -28,2 +28,5 @@ | |||
28 | 28 | ||
29 | |||
30 | #include <opie/ofileselector.h> | ||
31 | #include <opie/ofiledialog.h> | ||
29 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
@@ -75,3 +78,3 @@ static QString addressbookXMLFilename() | |||
75 | QString filename = Global::applicationFileName("addressbook", | 78 | QString filename = Global::applicationFileName("addressbook", |
76 | "addressbook.xml"); | 79 | "addressbook.xml"); |
77 | return filename; | 80 | return filename; |
@@ -82,3 +85,3 @@ static QString addressbookPersonalVCardName() | |||
82 | QString filename = Global::applicationFileName("addressbook", | 85 | QString filename = Global::applicationFileName("addressbook", |
83 | "businesscard.vcf"); | 86 | "businesscard.vcf"); |
84 | return filename; | 87 | return filename; |
@@ -88,3 +91,3 @@ static QString addressbookPersonalVCardName() | |||
88 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 91 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
89 | WFlags f ) | 92 | WFlags f ) |
90 | : QMainWindow( parent, name, f ), | 93 | : QMainWindow( parent, name, f ), |
@@ -116,3 +119,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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; |
@@ -123,3 +126,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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; |
@@ -130,3 +133,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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; |
@@ -157,8 +160,8 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 | } |
@@ -167,2 +170,10 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 ); |
@@ -184,7 +195,7 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 | } |
@@ -199,7 +210,7 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 | ||
@@ -209,4 +220,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
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 | } |
@@ -243,38 +254,46 @@ void 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 | |||
292 | void AddressbookWindow::importvCard() { | ||
293 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | ||
294 | if(!str.isEmpty() ) | ||
295 | setDocument((const QString&) str ); | ||
296 | |||
277 | } | 297 | } |
278 | 298 | ||
279 | |||
280 | void AddressbookWindow::setDocument( const QString &filename ) | 299 | void AddressbookWindow::setDocument( const QString &filename ) |
@@ -285,8 +304,8 @@ void AddressbookWindow::setDocument( const QString &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 | } |
@@ -307,5 +326,5 @@ AddressbookWindow::~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 | } |
@@ -330,6 +349,6 @@ void AddressbookWindow::showView() | |||
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 | } |
@@ -341,9 +360,9 @@ void AddressbookWindow::slotListNew() | |||
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 | } |
@@ -361,21 +380,21 @@ void AddressbookWindow::slotListDelete() | |||
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 | } |
@@ -391,12 +410,12 @@ void AddressbookWindow::slotViewEdit() | |||
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 | } |
@@ -425,12 +444,12 @@ void AddressbookWindow::slotBeam() | |||
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 | } |
@@ -450,3 +469,3 @@ void AddressbookWindow::beamDone( Ir *ir ) | |||
450 | static void parseName( const QString& name, QString *first, QString *middle, | 469 | static void parseName( const QString& name, QString *first, QString *middle, |
451 | QString * last ) | 470 | QString * last ) |
452 | { | 471 | { |
@@ -456,11 +475,11 @@ static void parseName( const QString& name, QString *first, QString *middle, | |||
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 | } |
@@ -468,6 +487,6 @@ static void parseName( const QString& name, QString *first, QString *middle, | |||
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 | } |
@@ -480,6 +499,6 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
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)" ) { |
@@ -489,22 +508,22 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
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 | ||
@@ -550,10 +569,10 @@ void AddressbookWindow::editPersonal() | |||
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 | ||
@@ -565,8 +584,8 @@ void AddressbookWindow::editPersonal() | |||
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 | } |
@@ -578,12 +597,12 @@ void AddressbookWindow::slotPersonalView() | |||
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 | } |
@@ -602,3 +621,3 @@ void AddressbookWindow::slotPersonalView() | |||
602 | if (QFile::exists(filename)) | 621 | if (QFile::exists(filename)) |
603 | me = Contact::readVCard( filename )[0]; | 622 | me = Contact::readVCard( filename )[0]; |
604 | 623 | ||
@@ -616,7 +635,7 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) | |||
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 | } |
@@ -631,13 +650,13 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) | |||
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 | } |
@@ -650,3 +669,3 @@ void AddressbookWindow::listIsEmpty( bool empty ) | |||
650 | if ( !empty ) { | 669 | if ( !empty ) { |
651 | deleteButton->setEnabled( TRUE ); | 670 | deleteButton->setEnabled( TRUE ); |
652 | } | 671 | } |
@@ -671,11 +690,11 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) | |||
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 | } |
@@ -683,8 +702,8 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) | |||
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 | } |
@@ -692,5 +711,5 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) | |||
692 | if ( save() ) | 711 | if ( save() ) |
693 | e->accept(); | 712 | e->accept(); |
694 | else | 713 | else |
695 | e->ignore(); | 714 | e->ignore(); |
696 | } | 715 | } |
@@ -705,27 +724,27 @@ bool AddressbookWindow::save() | |||
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 | } |
@@ -742,9 +761,9 @@ void AddressbookWindow::slotSettings() | |||
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 | } |
@@ -766,3 +785,3 @@ void AddressbookWindow::initFields() | |||
766 | int i, | 785 | int i, |
767 | version; | 786 | version; |
768 | Config cfg( "AddressBook" ); | 787 | Config cfg( "AddressBook" ); |
@@ -773,3 +792,3 @@ void AddressbookWindow::initFields() | |||
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 | } |
@@ -783,15 +802,15 @@ void AddressbookWindow::initFields() | |||
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 | ||
@@ -799,38 +818,38 @@ void AddressbookWindow::initFields() | |||
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") ); |
@@ -860,3 +879,3 @@ void AddressbookWindow::slotFind() | |||
860 | if ( centralWidget() == abView() ) | 879 | if ( centralWidget() == abView() ) |
861 | showList(); | 880 | showList(); |
862 | 881 | ||
@@ -870,3 +889,3 @@ void AddressbookWindow::slotFind() | |||
870 | if ( abList->numSelections() ) | 889 | if ( abList->numSelections() ) |
871 | abList->clearSelection(); | 890 | abList->clearSelection(); |
872 | 891 | ||
@@ -879,15 +898,15 @@ void AddressbookWindow::slotSetCategory( int c ) | |||
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 | } |
@@ -897,3 +916,3 @@ void AddressbookWindow::slotSetLetter( char c ) { | |||
897 | 916 | ||
898 | abList->setShowByLetter( c ); | 917 | abList->setShowByLetter( c ); |
899 | 918 | ||
@@ -906,3 +925,3 @@ void AddressbookWindow::populateCategories() | |||
906 | int id, | 925 | int id, |
907 | rememberId; | 926 | rememberId; |
908 | id = 1; | 927 | id = 1; |
@@ -913,12 +932,12 @@ void AddressbookWindow::populateCategories() | |||
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 | |||
@@ -61,2 +61,3 @@ public slots: | |||
61 | private slots: | 61 | private slots: |
62 | void importvCard(); | ||
62 | void slotListNew(); | 63 | void slotListNew(); |
@@ -78,3 +79,3 @@ private slots: | |||
78 | private: | 79 | private: |
79 | void initFields();// inititialize our fields... | 80 | void initFields(); // inititialize our fields... |
80 | AbLabel *abView(); | 81 | AbLabel *abView(); |
@@ -86,3 +87,3 @@ private: | |||
86 | QValueList<int> allFields, | 87 | QValueList<int> allFields, |
87 | orderedFields; | 88 | orderedFields; |
88 | QStringList slOrderedFields; | 89 | QStringList slOrderedFields; |
@@ -96,3 +97,3 @@ private: | |||
96 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, | 97 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, |
97 | *actionPersonal, *actionMail; | 98 | *actionPersonal, *actionMail; |
98 | 99 | ||
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 | |||
@@ -21,3 +21,3 @@ INCLUDEPATH += $(OPIEDIR)/include | |||
21 | DEPENDPATH+= $(OPIEDIR)/include | 21 | DEPENDPATH+= $(OPIEDIR)/include |
22 | LIBS += -lqpe | 22 | LIBS += -lqpe -lopie |
23 | 23 | ||