author | eilers <eilers> | 2002-10-08 12:33:52 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-08 12:33:52 (UTC) |
commit | a194611bf645fe7e2e9e83733ababc587fd42f1d (patch) (unidiff) | |
tree | 2c21a5576bce48dba2fe83f6c849c0d16025a848 /core | |
parent | 333fec32d47ea32de9fb4c8cd378a519785a1ff8 (diff) | |
download | opie-a194611bf645fe7e2e9e83733ababc587fd42f1d.zip opie-a194611bf645fe7e2e9e83733ababc587fd42f1d.tar.gz opie-a194611bf645fe7e2e9e83733ababc587fd42f1d.tar.bz2 |
Joined development branch: It uses the new PIM API
Some features in "View" added by Darwin Zins, but they are
not finished..
-rw-r--r-- | core/pim/addressbook/abeditor.cpp | 5 | ||||
-rw-r--r-- | core/pim/addressbook/abeditor.h | 8 | ||||
-rw-r--r-- | core/pim/addressbook/ablabel.cpp | 2 | ||||
-rw-r--r-- | core/pim/addressbook/ablabel.h | 6 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 444 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 36 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 191 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 9 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.cpp | 4 | ||||
-rw-r--r-- | core/pim/addressbook/contacteditor.h | 10 |
10 files changed, 295 insertions, 420 deletions
diff --git a/core/pim/addressbook/abeditor.cpp b/core/pim/addressbook/abeditor.cpp index 6354db9..91e8722 100644 --- a/core/pim/addressbook/abeditor.cpp +++ b/core/pim/addressbook/abeditor.cpp | |||
@@ -53,3 +53,3 @@ void parseEmailTo( const QString &strDefaultEmail, | |||
53 | 53 | ||
54 | AbEditor::AbEditor( const Contact &entry, const QValueList<int> *newOrdered, | 54 | AbEditor::AbEditor( const OContact &entry, const QValueList<int> *newOrdered, |
55 | QStringList *slNewOrdered, | 55 | QStringList *slNewOrdered, |
@@ -184,3 +184,3 @@ void AbEditor::loadFields() | |||
184 | 184 | ||
185 | void AbEditor::setEntry( const Contact &entry ) | 185 | void AbEditor::setEntry( const OContact &entry ) |
186 | { | 186 | { |
@@ -551,2 +551,3 @@ void parseEmailFrom( const QString &txt, QString &strDefaultEmail, | |||
551 | return; | 551 | return; |
552 | |||
552 | // find the first | 553 | // find the first |
diff --git a/core/pim/addressbook/abeditor.h b/core/pim/addressbook/abeditor.h index 9ce6704..a9c1c5f 100644 --- a/core/pim/addressbook/abeditor.h +++ b/core/pim/addressbook/abeditor.h | |||
@@ -40,3 +40,3 @@ class AbEditor : public QDialog | |||
40 | public: | 40 | public: |
41 | AbEditor( const Contact &entry, const QValueList<int> *newOrdedValues, | 41 | AbEditor( const OContact &entry, const QValueList<int> *newOrdedValues, |
42 | QStringList *slNewOrdered, | 42 | QStringList *slNewOrdered, |
@@ -46,3 +46,3 @@ public: | |||
46 | void setNameFocus(); | 46 | void setNameFocus(); |
47 | Contact entry() const { return ent; } | 47 | OContact entry() const { return ent; } |
48 | 48 | ||
@@ -50,3 +50,3 @@ public slots: | |||
50 | void slotNote(); | 50 | void slotNote(); |
51 | void setEntry( const Contact &entry ); | 51 | void setEntry( const OContact &entry ); |
52 | 52 | ||
@@ -65,3 +65,3 @@ private: | |||
65 | QMultiLineEdit *txtNote; | 65 | QMultiLineEdit *txtNote; |
66 | Contact ent; | 66 | OContact ent; |
67 | QScrollView *svPage; | 67 | QScrollView *svPage; |
diff --git a/core/pim/addressbook/ablabel.cpp b/core/pim/addressbook/ablabel.cpp index 3bf3e12..cf1e39f 100644 --- a/core/pim/addressbook/ablabel.cpp +++ b/core/pim/addressbook/ablabel.cpp | |||
@@ -36,3 +36,3 @@ AbLabel::~AbLabel() | |||
36 | 36 | ||
37 | void AbLabel::init( const Contact &entry ) | 37 | void AbLabel::init( const OContact &entry ) |
38 | { | 38 | { |
diff --git a/core/pim/addressbook/ablabel.h b/core/pim/addressbook/ablabel.h index cfbd999..9086c4a 100644 --- a/core/pim/addressbook/ablabel.h +++ b/core/pim/addressbook/ablabel.h | |||
@@ -22,3 +22,3 @@ | |||
22 | 22 | ||
23 | #include <qpe/contact.h> | 23 | #include <opie/ocontact.h> |
24 | #include <qtextview.h> | 24 | #include <qtextview.h> |
@@ -34,3 +34,3 @@ public: | |||
34 | public slots: | 34 | public slots: |
35 | void init( const Contact &entry ); | 35 | void init( const OContact &entry ); |
36 | void sync(); | 36 | void sync(); |
@@ -44,3 +44,3 @@ protected: | |||
44 | private: | 44 | private: |
45 | Contact ent; | 45 | OContact ent; |
46 | 46 | ||
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 3fa1a7c..08c6d0a 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -27,2 +27,4 @@ | |||
27 | 27 | ||
28 | #include <opie/orecordlist.h> | ||
29 | |||
28 | #include <qasciidict.h> | 30 | #include <qasciidict.h> |
@@ -31,2 +33,3 @@ | |||
31 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qmessagebox.h> | ||
32 | 35 | ||
@@ -41,12 +44,3 @@ | |||
41 | 44 | ||
42 | static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ); | 45 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); |
43 | |||
44 | //### qtmail/addresslist.cpp hardcodes this filename as well | ||
45 | static QString journalFileName() | ||
46 | { | ||
47 | QString str = getenv("HOME"); | ||
48 | str +="/.abjournal"; | ||
49 | return str; | ||
50 | } | ||
51 | |||
52 | 46 | ||
@@ -137,3 +131,4 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam | |||
137 | currFindRow( -2 ), | 131 | currFindRow( -2 ), |
138 | mCat( 0 ) | 132 | mCat( 0 ), |
133 | m_contactdb ("addressbook") | ||
139 | { | 134 | { |
@@ -161,2 +156,3 @@ void AbTable::init() | |||
161 | verticalHeader()->hide(); | 156 | verticalHeader()->hide(); |
157 | columnVisible = true; | ||
162 | } | 158 | } |
@@ -177,2 +173,3 @@ void AbTable::columnClicked( int col ) | |||
177 | } | 173 | } |
174 | //QMessageBox::information( this, "resort", "columnClicked" ); | ||
178 | resort(); | 175 | resort(); |
@@ -186,2 +183,3 @@ void AbTable::resort() | |||
186 | sortColumn( lastSortCol, asc, TRUE ); | 183 | sortColumn( lastSortCol, asc, TRUE ); |
184 | //QMessageBox::information( this, "resort", "resort" ); | ||
187 | updateVisible(); | 185 | updateVisible(); |
@@ -190,5 +188,5 @@ void AbTable::resort() | |||
190 | 188 | ||
191 | Contact AbTable::currentEntry() | 189 | OContact AbTable::currentEntry() |
192 | { | 190 | { |
193 | Contact cnt; | 191 | OContact cnt; |
194 | AbTableItem *abItem; | 192 | AbTableItem *abItem; |
@@ -197,2 +195,3 @@ Contact AbTable::currentEntry() | |||
197 | cnt = contactList[abItem]; | 195 | cnt = contactList[abItem]; |
196 | //cnt = contactList[currentRow()]; | ||
198 | } | 197 | } |
@@ -201,6 +200,5 @@ Contact AbTable::currentEntry() | |||
201 | 200 | ||
202 | void AbTable::replaceCurrentEntry( const Contact &newContact ) | 201 | void AbTable::replaceCurrentEntry( const OContact &newContact ) |
203 | { | 202 | { |
204 | int row = currentRow(); | 203 | int row = currentRow(); |
205 | updateJournal( newContact, Contact::ACTION_REPLACE, row ); | ||
206 | updateVisible(); | 204 | updateVisible(); |
@@ -208,2 +206,3 @@ void AbTable::replaceCurrentEntry( const Contact &newContact ) | |||
208 | journalFreeReplace( newContact, row ); | 206 | journalFreeReplace( newContact, row ); |
207 | |||
209 | } | 208 | } |
@@ -213,7 +212,2 @@ void AbTable::deleteCurrentEntry() | |||
213 | int row = currentRow(); | 212 | int row = currentRow(); |
214 | AbTableItem *abItem; | ||
215 | abItem = static_cast<AbTableItem*>(item( row, 0 )); | ||
216 | Contact oldContact; | ||
217 | oldContact = contactList[abItem]; | ||
218 | updateJournal( oldContact, Contact::ACTION_REMOVE, row ); | ||
219 | 213 | ||
@@ -226,2 +220,3 @@ void AbTable::deleteCurrentEntry() | |||
226 | emit empty( TRUE ); | 220 | emit empty( TRUE ); |
221 | |||
227 | } | 222 | } |
@@ -246,5 +241,11 @@ void AbTable::refresh() | |||
246 | AbTableItem *abi; | 241 | AbTableItem *abi; |
242 | |||
243 | // hide columns so no flashing ? | ||
244 | if ( showBk == "Cards" ) { | ||
245 | hideColumn(0); | ||
246 | hideColumn(1); | ||
247 | } | ||
247 | for ( int r = 0; r < rows; ++r ) { | 248 | for ( int r = 0; r < rows; ++r ) { |
248 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 249 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
249 | value = findContactContact( contactList[abi] ); | 250 | value = findContactContact( contactList[abi], r ); |
250 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); | 251 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); |
@@ -305,3 +306,3 @@ void AbTable::moveTo( char c ) | |||
305 | 306 | ||
306 | QString AbTable::findContactName( const Contact &entry ) | 307 | QString AbTable::findContactName( const OContact &entry ) |
307 | { | 308 | { |
@@ -319,3 +320,3 @@ QString AbTable::findContactName( const Contact &entry ) | |||
319 | 320 | ||
320 | QString AbTable::findContactContact( const Contact &entry ) | 321 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) |
321 | { | 322 | { |
@@ -445,13 +446,17 @@ QString AbTable::findContactContact( const Contact &entry ) | |||
445 | 446 | ||
446 | void AbTable::addEntry( const Contact &newCnt ) | 447 | void AbTable::addEntry( const OContact &newCnt ) |
447 | { | 448 | { |
448 | int row = numRows(); | 449 | int row = numRows(); |
450 | |||
449 | setNumRows( row + 1 ); | 451 | setNumRows( row + 1 ); |
450 | updateJournal( newCnt, Contact::ACTION_ADD ); | ||
451 | insertIntoTable( newCnt, row ); | 452 | insertIntoTable( newCnt, row ); |
453 | |||
454 | qWarning("abtable:AddContact"); | ||
455 | m_contactdb.add ( newCnt ); | ||
456 | |||
452 | setCurrentCell( row, 0 ); | 457 | setCurrentCell( row, 0 ); |
453 | updateVisible(); | 458 | // updateVisible(); |
454 | } | 459 | } |
455 | 460 | ||
456 | void AbTable::resizeRows( int size ) { | 461 | void AbTable::resizeRows() { |
457 | /* | 462 | /* |
@@ -461,26 +466,9 @@ void AbTable::resizeRows( int size ) { | |||
461 | } | 466 | } |
462 | }*/ | 467 | } |
463 | updateVisible(); | 468 | updateVisible(); |
469 | */ | ||
464 | } | 470 | } |
465 | 471 | ||
466 | void AbTable::updateJournal( const Contact &cnt, | 472 | |
467 | Contact::journal_action action, int row ) | 473 | bool AbTable::save( const QString& /* fn */ ) |
468 | { | ||
469 | QFile f( journalFileName() ); | ||
470 | if ( !f.open(IO_WriteOnly|IO_Append) ) | ||
471 | return; | ||
472 | QString buf; | ||
473 | QCString str; | ||
474 | buf = "<Contact "; | ||
475 | cnt.save( buf ); | ||
476 | buf += " action=\"" + QString::number( (int)action ) + "\" "; | ||
477 | if ( action == Contact::ACTION_REMOVE || action == Contact::ACTION_REPLACE) | ||
478 | buf += " actionrow=\"" + QString::number(row) + "\" "; | ||
479 | buf += "/>\n"; | ||
480 | QCString cstr = buf.utf8(); | ||
481 | f.writeBlock( cstr.data(), cstr.length() ); | ||
482 | QCopEnvelope( "QPE/PIM", "addressbookUpdated()" ); | ||
483 | } | ||
484 | |||
485 | bool AbTable::save( const QString &fn ) | ||
486 | { | 474 | { |
@@ -488,51 +476,5 @@ bool AbTable::save( const QString &fn ) | |||
488 | // t.start(); | 476 | // t.start(); |
477 | qWarning("abtable:Save data"); | ||
478 | m_contactdb.save(); | ||
489 | 479 | ||
490 | QString strNewFile = fn + ".new"; | ||
491 | QFile f( strNewFile ); | ||
492 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) | ||
493 | return false; | ||
494 | |||
495 | int total_written; | ||
496 | QString out; | ||
497 | out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" | ||
498 | " <Groups>\n" | ||
499 | " </Groups>\n" | ||
500 | " <Contacts>\n"; | ||
501 | QMapIterator<AbTableItem*, Contact> it; | ||
502 | for ( it = contactList.begin(); it != contactList.end(); ++it ) { | ||
503 | out += "<Contact "; | ||
504 | it.data().save( out ); | ||
505 | out += "/>\n"; | ||
506 | QCString cstr = out.utf8(); | ||
507 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | ||
508 | if ( total_written != int(cstr.length()) ) { | ||
509 | f.close(); | ||
510 | QFile::remove( strNewFile ); | ||
511 | return false; | ||
512 | } | ||
513 | out = ""; | ||
514 | } | ||
515 | out += " </Contacts>\n</AddressBook>\n"; | ||
516 | |||
517 | QCString cstr = out.utf8(); | ||
518 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | ||
519 | if ( total_written != int(cstr.length()) ) { | ||
520 | f.close(); | ||
521 | QFile::remove( strNewFile ); | ||
522 | return false; | ||
523 | } | ||
524 | f.close(); | ||
525 | |||
526 | // qDebug("saving: %d", t.elapsed() ); | ||
527 | |||
528 | // move the file over, I'm just going to use the system call | ||
529 | // because, I don't feel like using QDir. | ||
530 | if ( ::rename( strNewFile.latin1(), fn.latin1() ) < 0 ) { | ||
531 | qWarning( "problem renaming file %s to %s, errno: %d", | ||
532 | strNewFile.latin1(), fn.latin1(), errno ); | ||
533 | // remove the tmp file... | ||
534 | QFile::remove( strNewFile ); | ||
535 | } | ||
536 | // remove the journal... | ||
537 | QFile::remove( journalFileName() ); | ||
538 | return true; | 480 | return true; |
@@ -540,206 +482,25 @@ bool AbTable::save( const QString &fn ) | |||
540 | 482 | ||
541 | void AbTable::load( const QString &fn ) | 483 | void AbTable::load( const QString& /* fn */ ) |
542 | { | 484 | { |
543 | setSorting( false ); | 485 | setSorting( false ); |
544 | loadFile( fn, false ); | 486 | setUpdatesEnabled( FALSE ); |
545 | // merge in the journal | ||
546 | if ( QFile::exists( journalFileName() ) ) { | ||
547 | loadFile( journalFileName(), true ); | ||
548 | save( fn ); | ||
549 | } | ||
550 | setSorting( true ); | ||
551 | resort(); | ||
552 | } | ||
553 | 487 | ||
554 | void AbTable::loadFile( const QString &strFile, bool journalFile ) | 488 | qWarning("abtable:Load data"); |
555 | { | ||
556 | // QTime t; | ||
557 | // t.start(); | ||
558 | QFile f( strFile ); | ||
559 | if ( !f.open(IO_ReadOnly) ) | ||
560 | return; | ||
561 | QList<Contact> list; | ||
562 | list.setAutoDelete( TRUE ); | ||
563 | QByteArray ba = f.readAll(); | ||
564 | f.close(); | ||
565 | if (ba.isEmpty() ) | ||
566 | return; | ||
567 | char *uc = ba.data();//(QChar *)data.unicode(); | ||
568 | int len = ba.size();//data.length(); | ||
569 | bool foundAction = false; | ||
570 | Contact::journal_action action; | ||
571 | bool foundKey = false; | ||
572 | int journalKey = 0; | ||
573 | |||
574 | const int JOURNALACTION = Qtopia::Notes + 1; | ||
575 | const int JOURNALROW = JOURNALACTION + 1; | ||
576 | |||
577 | // ********************************** | ||
578 | // CHANGE THE SIZE OF THE DICT IF YOU ADD ANY MORE FIELDS!!!! | ||
579 | // ********************************** | ||
580 | QAsciiDict<int> dict( 47 ); | ||
581 | dict.setAutoDelete( TRUE ); | ||
582 | dict.insert( "Uid", new int(Qtopia::AddressUid) ); | ||
583 | dict.insert( "Title", new int(Qtopia::Title) ); | ||
584 | dict.insert( "FirstName", new int(Qtopia::FirstName) ); | ||
585 | dict.insert( "MiddleName", new int(Qtopia::MiddleName) ); | ||
586 | dict.insert( "LastName", new int(Qtopia::LastName) ); | ||
587 | dict.insert( "Suffix", new int(Qtopia::Suffix) ); | ||
588 | dict.insert( "FileAs", new int(Qtopia::FileAs) ); | ||
589 | dict.insert( "Categories", new int(Qtopia::AddressCategory) ); | ||
590 | dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) ); | ||
591 | dict.insert( "Emails", new int(Qtopia::Emails) ); | ||
592 | dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) ); | ||
593 | dict.insert( "HomeCity", new int(Qtopia::HomeCity) ); | ||
594 | dict.insert( "HomeState", new int(Qtopia::HomeState) ); | ||
595 | dict.insert( "HomeZip", new int(Qtopia::HomeZip) ); | ||
596 | dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) ); | ||
597 | dict.insert( "HomePhone", new int(Qtopia::HomePhone) ); | ||
598 | dict.insert( "HomeFax", new int(Qtopia::HomeFax) ); | ||
599 | dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) ); | ||
600 | dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) ); | ||
601 | dict.insert( "Company", new int(Qtopia::Company) ); | ||
602 | dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) ); | ||
603 | dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) ); | ||
604 | dict.insert( "BusinessState", new int(Qtopia::BusinessState) ); | ||
605 | dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) ); | ||
606 | dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) ); | ||
607 | dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) ); | ||
608 | dict.insert( "JobTitle", new int(Qtopia::JobTitle) ); | ||
609 | dict.insert( "Department", new int(Qtopia::Department) ); | ||
610 | dict.insert( "Office", new int(Qtopia::Office) ); | ||
611 | dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) ); | ||
612 | dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) ); | ||
613 | dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) ); | ||
614 | dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) ); | ||
615 | dict.insert( "Profession", new int(Qtopia::Profession) ); | ||
616 | dict.insert( "Assistant", new int(Qtopia::Assistant) ); | ||
617 | dict.insert( "Manager", new int(Qtopia::Manager) ); | ||
618 | dict.insert( "Spouse", new int(Qtopia::Spouse) ); | ||
619 | dict.insert( "Children", new int(Qtopia::Children) ); | ||
620 | dict.insert( "Gender", new int(Qtopia::Gender) ); | ||
621 | dict.insert( "Birthday", new int(Qtopia::Birthday) ); | ||
622 | dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); | ||
623 | dict.insert( "Nickname", new int(Qtopia::Nickname) ); | ||
624 | dict.insert( "Notes", new int(Qtopia::Notes) ); | ||
625 | dict.insert( "action", new int(JOURNALACTION) ); | ||
626 | dict.insert( "actionrow", new int(JOURNALROW) ); | ||
627 | |||
628 | int i = 0; | ||
629 | int num = 0; | ||
630 | char *point; | ||
631 | while ( (point = strstr( uc+i, "<Contact " ) ) != NULL ) { | ||
632 | i = point - uc; | ||
633 | // if we are reading the standard file, we just need to | ||
634 | // insert info, so just say we'll do an insert... | ||
635 | action = Contact::ACTION_ADD; | ||
636 | // new Contact | ||
637 | Contact *cnt = new Contact; | ||
638 | i += 9; | ||
639 | while ( 1 ) { | ||
640 | while ( i < len && (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) | ||
641 | i++; | ||
642 | if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) | ||
643 | break; | ||
644 | // we have another attribute read it. | ||
645 | int j = i; | ||
646 | while ( j < len && uc[j] != '=' ) | ||
647 | j++; | ||
648 | char *attr = uc+i; | ||
649 | uc[j] = '\0'; | ||
650 | //qDebug("attr=%s", attr.latin1() ); | ||
651 | i = ++j; // skip = | ||
652 | while ( i < len && uc[i] != '"' ) | ||
653 | i++; | ||
654 | j = ++i; | ||
655 | bool haveEnt = FALSE; | ||
656 | bool haveUtf = FALSE; | ||
657 | while ( j < len && uc[j] != '"' ) { | ||
658 | if ( uc[j] == '&' ) | ||
659 | haveEnt = TRUE; | ||
660 | if ( ((unsigned char)uc[j]) > 0x7f ) | ||
661 | haveUtf = TRUE; | ||
662 | j++; | ||
663 | } | ||
664 | |||
665 | if ( j == i ) { | ||
666 | // empty value | ||
667 | i = j + 1; | ||
668 | continue; | ||
669 | } | ||
670 | |||
671 | QString value = haveUtf ? QString::fromUtf8( uc+i, j-i ) | ||
672 | : QString::fromLatin1( uc+i, j-i ); | ||
673 | if ( haveEnt ) | ||
674 | value = Qtopia::plainString( value ); | ||
675 | i = j + 1; | ||
676 | |||
677 | int *find = dict[ attr ]; | ||
678 | if ( !find ) { | ||
679 | cnt->setCustomField(attr, value); | ||
680 | continue; | ||
681 | } | ||
682 | #if 1 | ||
683 | switch( *find ) { | ||
684 | case Qtopia::AddressUid: | ||
685 | cnt->setUid( value.toInt() ); | ||
686 | break; | ||
687 | case Qtopia::AddressCategory: | ||
688 | cnt->setCategories( Qtopia::Record::idsFromString( value )); | ||
689 | break; | ||
690 | case JOURNALACTION: | ||
691 | action = Contact::journal_action(value.toInt()); | ||
692 | break; | ||
693 | case JOURNALROW: | ||
694 | journalKey = value.toInt(); | ||
695 | break; | ||
696 | 489 | ||
697 | default: | 490 | OContactAccess::List list = m_contactdb.allRecords(); |
698 | cnt->insert( *find, value ); | 491 | OContactAccess::List::Iterator it; |
699 | break; | 492 | setNumRows( list.count() ); |
700 | } | 493 | int row = 0; |
701 | #endif | 494 | for ( it = list.begin(); it != list.end(); ++it ) |
702 | } | 495 | insertIntoTable( *it, row++ ); |
703 | 496 | ||
704 | // sadly we can't delay adding of items from the journal to get | 497 | resort(); |
705 | // the proper effect, but then, the journal should _never_ be | 498 | |
706 | // that huge, and recovering from a crash is not necessarily | 499 | setUpdatesEnabled( TRUE ); |
707 | // a *fast* thing. | ||
708 | switch ( action ) { | ||
709 | case Contact::ACTION_ADD: | ||
710 | if ( journalFile ) { | ||
711 | int myrows = numRows(); | ||
712 | setNumRows( myrows + 1 ); | ||
713 | insertIntoTable( *cnt, myrows ); | ||
714 | delete cnt; | ||
715 | } | ||
716 | else | ||
717 | list.append( cnt ); | ||
718 | break; | ||
719 | case Contact::ACTION_REMOVE: | ||
720 | // yup, we don't use the entry to remove the object... | ||
721 | journalFreeRemove( journalKey ); | ||
722 | delete cnt; | ||
723 | break; | ||
724 | case Contact::ACTION_REPLACE: | ||
725 | journalFreeReplace( *cnt, journalKey ); | ||
726 | delete cnt; | ||
727 | break; | ||
728 | default: | ||
729 | break; | ||
730 | } | ||
731 | num++; | ||
732 | foundAction = false; | ||
733 | foundKey = false; | ||
734 | // if ( num % 100 == 0 ) { | ||
735 | // qDebug("loading file, num=%d, t=%d", num, t.elapsed() ); | ||
736 | // } | ||
737 | } | ||
738 | if ( list.count() > 0 ) { | ||
739 | internalAddEntries( list ); | ||
740 | } | ||
741 | // qDebug("done loading %d, t=%d", num, t.elapsed() ); | ||
742 | 500 | ||
501 | setSorting( true ); | ||
502 | //resort(); | ||
743 | } | 503 | } |
744 | 504 | ||
505 | |||
745 | void AbTable::realignTable( int row ) | 506 | void AbTable::realignTable( int row ) |
@@ -763,3 +524,4 @@ void AbTable::realignTable( int row ) | |||
763 | 524 | ||
764 | void AbTable::insertIntoTable( const Contact &cnt, int row ) | 525 | // Add contact into table. |
526 | void AbTable::insertIntoTable( const OContact &cnt, int row ) | ||
765 | { | 527 | { |
@@ -769,3 +531,3 @@ void AbTable::insertIntoTable( const Contact &cnt, int row ) | |||
769 | strName = findContactName( cnt ); | 531 | strName = findContactName( cnt ); |
770 | strContact = findContactContact( cnt ); | 532 | strContact = findContactContact( cnt, row ); |
771 | 533 | ||
@@ -784,16 +546,5 @@ void AbTable::insertIntoTable( const Contact &cnt, int row ) | |||
784 | 546 | ||
785 | void AbTable::internalAddEntries( QList<Contact> &list ) | ||
786 | { | ||
787 | setUpdatesEnabled( FALSE ); | ||
788 | setNumRows( list.count() ); | ||
789 | int row = 0; | ||
790 | Contact *it; | ||
791 | for ( it = list.first(); it; it = list.next() ) | ||
792 | insertIntoTable( *it, row++ ); | ||
793 | resort(); | ||
794 | setUpdatesEnabled( TRUE ); | ||
795 | } | ||
796 | |||
797 | 547 | ||
798 | void AbTable::journalFreeReplace( const Contact &cnt, int row ) | 548 | // Replace or add an entry |
549 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) | ||
799 | { | 550 | { |
@@ -804,5 +555,12 @@ void AbTable::journalFreeReplace( const Contact &cnt, int row ) | |||
804 | strName = findContactName( cnt ); | 555 | strName = findContactName( cnt ); |
805 | strContact = findContactContact( cnt ); | 556 | strContact = findContactContact( cnt, row ); |
806 | ati = static_cast<AbTableItem*>(item(row, 0)); | 557 | ati = static_cast<AbTableItem*>(item(row, 0)); |
807 | if ( ati != 0 ) { | 558 | |
559 | // Replace element if found in row "row" | ||
560 | // or add this element if not. | ||
561 | if ( ati != 0 ) { // replace | ||
562 | // :SX db access -> replace | ||
563 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); | ||
564 | m_contactdb.replace ( cnt ); | ||
565 | |||
808 | contactList.remove( ati ); | 566 | contactList.remove( ati ); |
@@ -813,3 +571,4 @@ void AbTable::journalFreeReplace( const Contact &cnt, int row ) | |||
813 | ati->setItem( strContact, strName ); | 571 | ati->setItem( strContact, strName ); |
814 | }else{ | 572 | |
573 | }else{ // add | ||
815 | int myrows = numRows(); | 574 | int myrows = numRows(); |
@@ -817,3 +576,6 @@ void AbTable::journalFreeReplace( const Contact &cnt, int row ) | |||
817 | insertIntoTable( cnt, myrows ); | 576 | insertIntoTable( cnt, myrows ); |
818 | // gets deleted when returning | 577 | // gets deleted when returning -- Why ? (se) |
578 | // :SX db access -> add | ||
579 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); | ||
580 | // m_contactdb.add( cnt ); | ||
819 | } | 581 | } |
@@ -821,2 +583,3 @@ void AbTable::journalFreeReplace( const Contact &cnt, int row ) | |||
821 | 583 | ||
584 | // Remove entry | ||
822 | void AbTable::journalFreeRemove( int row ) | 585 | void AbTable::journalFreeRemove( int row ) |
@@ -827,4 +590,11 @@ void AbTable::journalFreeRemove( int row ) | |||
827 | return; | 590 | return; |
591 | |||
592 | // :SX db access -> remove | ||
593 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); | ||
594 | m_contactdb.remove( contactList[ati].uid() ); | ||
595 | |||
828 | contactList.remove( ati ); | 596 | contactList.remove( ati ); |
597 | |||
829 | realignTable( row ); | 598 | realignTable( row ); |
599 | |||
830 | } | 600 | } |
@@ -869,4 +639,3 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, | |||
869 | clearSelection( TRUE ); | 639 | clearSelection( TRUE ); |
870 | int rows, | 640 | int rows, row; |
871 | row; | ||
872 | AbTableItem *ati; | 641 | AbTableItem *ati; |
@@ -881,4 +650,4 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, | |||
881 | if ( contactCompare( contactList[ati], r, category ) ) | 650 | if ( contactCompare( contactList[ati], r, category ) ) |
651 | //if ( contactCompare( contactList[row], r, category ) ) | ||
882 | break; | 652 | break; |
883 | |||
884 | } | 653 | } |
@@ -888,2 +657,3 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, | |||
888 | if ( contactCompare( contactList[ati], r, category ) ) | 657 | if ( contactCompare( contactList[ati], r, category ) ) |
658 | //if ( contactCompare( contactList[row], r, category ) ) | ||
889 | break; | 659 | break; |
@@ -914,3 +684,3 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, | |||
914 | 684 | ||
915 | static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ) | 685 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) |
916 | { | 686 | { |
@@ -932,2 +702,3 @@ static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ) | |||
932 | } | 702 | } |
703 | |||
933 | return returnMe; | 704 | return returnMe; |
@@ -937,7 +708,19 @@ void AbTable::fitColumns() | |||
937 | { | 708 | { |
938 | int contentsWidth = visibleWidth(); | 709 | int contentsWidth = visibleWidth() / 2; |
939 | int n = numCols(); | 710 | |
940 | int pw = n == 3 ? columnWidth(2) : 0; | 711 | if ( showBk == "Cards" ) { |
941 | setColumnWidth( 0, contentsWidth - contentsWidth / 2 ); | 712 | showColumn(1); |
942 | setColumnWidth( 1, contentsWidth / 2 - pw ); | 713 | //adjustColumn(1); |
714 | setColumnWidth( 1, visibleWidth() ); | ||
715 | columnVisible = false; | ||
716 | } else { | ||
717 | if ( columnVisible == false ){ | ||
718 | showColumn(0); | ||
719 | columnVisible = true; | ||
720 | } | ||
721 | setColumnWidth( 0, contentsWidth ); | ||
722 | adjustColumn(1); | ||
723 | if ( columnWidth(1) < contentsWidth ) | ||
724 | setColumnWidth( 1, contentsWidth ); | ||
725 | } | ||
943 | } | 726 | } |
@@ -985,3 +768,3 @@ void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) | |||
985 | for (each row) { | 768 | for (each row) { |
986 | Contact *c = contactForRow(row); | 769 | OContact *c = contactForRow(row); |
987 | if ( list.contains(c->email) ) { | 770 | if ( list.contains(c->email) ) { |
@@ -992,3 +775,3 @@ void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) | |||
992 | for (remaining list items) { | 775 | for (remaining list items) { |
993 | Contact *c = new contact(item); | 776 | OContact *c = new contact(item); |
994 | setText(newrow, 2, selname); | 777 | setText(newrow, 2, selname); |
@@ -1006,3 +789,3 @@ QStringList AbTable::choiceSelection(int /*index*/) const | |||
1006 | for (each row) { | 789 | for (each row) { |
1007 | Contact *c = contactForRow(row); | 790 | OContact *c = contactForRow(row); |
1008 | if ( text(row,2) == selname ) { | 791 | if ( text(row,2) == selname ) { |
@@ -1016,6 +799,11 @@ QStringList AbTable::choiceSelection(int /*index*/) const | |||
1016 | 799 | ||
1017 | void AbTable::setShowCategory( const QString &c ) | 800 | void AbTable::setShowCategory( const QString &b, const QString &c ) |
1018 | { | 801 | { |
802 | showBk = b; | ||
1019 | showCat = c; | 803 | showCat = c; |
1020 | updateVisible(); | 804 | //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); |
805 | //updateVisible(); | ||
806 | refresh(); | ||
807 | ensureCellVisible( currentRow(), 0 ); | ||
808 | updateVisible(); // :SX | ||
1021 | } | 809 | } |
@@ -1033,2 +821,6 @@ QString AbTable::showCategory() const | |||
1033 | 821 | ||
822 | QString AbTable::showBook() const | ||
823 | { | ||
824 | return showBk; | ||
825 | } | ||
1034 | 826 | ||
@@ -1051,3 +843,3 @@ void AbTable::updateVisible() | |||
1051 | AbTableItem *ati; | 843 | AbTableItem *ati; |
1052 | Contact *cnt; | 844 | OContact *cnt; |
1053 | QString fileAsName; | 845 | QString fileAsName; |
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index d5ff279..84aef1e 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h | |||
@@ -24,3 +24,3 @@ | |||
24 | #include <qpe/categories.h> | 24 | #include <qpe/categories.h> |
25 | #include <qpe/contact.h> | 25 | #include <opie/ocontact.h> |
26 | 26 | ||
@@ -31,2 +31,4 @@ | |||
31 | 31 | ||
32 | #include <opie/ocontactaccess.h> | ||
33 | |||
32 | class AbTableItem : public QTableItem | 34 | class AbTableItem : public QTableItem |
@@ -66,5 +68,5 @@ public: | |||
66 | // NEW | 68 | // NEW |
67 | void addEntry( const Contact &newContact ); | 69 | void addEntry( const OContact &newContact ); |
68 | Contact currentEntry(); | 70 | OContact currentEntry(); |
69 | void replaceCurrentEntry( const Contact &newContact ); | 71 | void replaceCurrentEntry( const OContact &newContact ); |
70 | 72 | ||
@@ -85,3 +87,3 @@ public: | |||
85 | QStringList choiceSelection(int index) const; | 87 | QStringList choiceSelection(int index) const; |
86 | void setShowCategory( const QString &c ); | 88 | void setShowCategory( const QString &b, const QString &c ); |
87 | void setShowByLetter( char c ); | 89 | void setShowByLetter( char c ); |
@@ -89,3 +91,4 @@ public: | |||
89 | QStringList categories(); | 91 | QStringList categories(); |
90 | void resizeRows( int size ); | 92 | |
93 | void resizeRows(); | ||
91 | 94 | ||
@@ -94,2 +97,4 @@ public: | |||
94 | 97 | ||
98 | QString showBook() const; | ||
99 | |||
95 | public slots: | 100 | public slots: |
@@ -121,9 +126,8 @@ private: | |||
121 | void resort(); | 126 | void resort(); |
122 | void updateJournal( const Contact &contact, Contact::journal_action action, | 127 | void updateJournal( const OContact &contact, OContact::journal_action action, |
123 | int row = -1 ); | 128 | int row = -1 ); |
124 | void insertIntoTable( const Contact &contact, int row ); | 129 | void insertIntoTable( const OContact &contact, int row ); |
125 | void internalAddEntries( QList<Contact> &list ); | 130 | QString findContactName( const OContact &entry ); |
126 | QString findContactName( const Contact &entry ); | 131 | QString findContactContact( const OContact &entry, int row ); |
127 | QString findContactContact( const Contact &entry ); | 132 | void journalFreeReplace( const OContact &cnt, int row ); |
128 | void journalFreeReplace( const Contact &cnt, int row ); | ||
129 | void journalFreeRemove( int row ); | 133 | void journalFreeRemove( int row ); |
@@ -134,3 +138,3 @@ private: | |||
134 | char showChar; | 138 | char showChar; |
135 | QMap<AbTableItem*, Contact> contactList; | 139 | QMap<AbTableItem*, OContact> contactList; |
136 | const QValueList<int> *intFields; | 140 | const QValueList<int> *intFields; |
@@ -141,2 +145,8 @@ private: | |||
141 | Categories mCat; | 145 | Categories mCat; |
146 | |||
147 | QString showBk; | ||
148 | bool columnVisible; | ||
149 | |||
150 | OContactAccess m_contactdb; | ||
151 | |||
142 | }; | 152 | }; |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 3255269..cf2eddf 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -15,3 +15,3 @@ | |||
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** OContact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
@@ -97,2 +97,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
97 | { | 97 | { |
98 | isLoading = true; | ||
99 | |||
98 | initFields(); | 100 | initFields(); |
@@ -189,3 +191,2 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
189 | 191 | ||
190 | |||
191 | edit->insertSeparator(); | 192 | edit->insertSeparator(); |
@@ -209,3 +210,5 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
209 | if ( str.isNull() ) { | 210 | if ( str.isNull() ) { |
210 | QMessageBox::warning( this, tr("Out of Space"), | 211 | QMessageBox::warning( |
212 | this, | ||
213 | tr("Out of Space"), | ||
211 | tr("There is not enough space to create\n" | 214 | tr("There is not enough space to create\n" |
@@ -222,9 +225,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
222 | vb->addWidget(abList); | 225 | vb->addWidget(abList); |
223 | abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 226 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
224 | connect( abList, SIGNAL( empty( bool ) ), | 227 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); |
225 | this, SLOT( listIsEmpty( bool ) ) ); | 228 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); |
226 | connect( abList, SIGNAL( details() ), | 229 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); |
227 | this, SLOT( slotListView() ) ); | ||
228 | connect( abList, SIGNAL(currentChanged(int,int)), | ||
229 | this, SLOT(slotUpdateToolbar()) ); | ||
230 | 230 | ||
@@ -247,3 +247,3 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
247 | mbList->insertItem( tr("View"), catMenu ); | 247 | mbList->insertItem( tr("View"), catMenu ); |
248 | setCentralWidget( listContainer ); | 248 | // setCentralWidget( listContainer ); |
249 | 249 | ||
@@ -265,2 +265,6 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
265 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 265 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
266 | |||
267 | abList->setCurrentCell( 0, 0 ); | ||
268 | |||
269 | isLoading = false; | ||
266 | } | 270 | } |
@@ -284,3 +288,4 @@ void AddressbookWindow::slotSetFont( int size ) { | |||
284 | currentFont = new QFont (abList->font()); | 288 | currentFont = new QFont (abList->font()); |
285 | abList->resizeRows(currentFont->pixelSize() + 7); | 289 | // abList->resizeRows(currentFont->pixelSize() + 7); |
290 | abList->resizeRows(); | ||
286 | break; | 291 | break; |
@@ -292,3 +297,4 @@ void AddressbookWindow::slotSetFont( int size ) { | |||
292 | currentFont = new QFont (abList->font()); | 297 | currentFont = new QFont (abList->font()); |
293 | abList->resizeRows(currentFont->pixelSize() + 7); | 298 | // abList->resizeRows(currentFont->pixelSize() + 7); |
299 | abList->resizeRows(); | ||
294 | break; | 300 | break; |
@@ -300,3 +306,4 @@ void AddressbookWindow::slotSetFont( int size ) { | |||
300 | currentFont = new QFont (abList->font()); | 306 | currentFont = new QFont (abList->font()); |
301 | abList->resizeRows(currentFont->pixelSize() + 7); | 307 | //abList->resizeRows(currentFont->pixelSize() + 7); |
308 | abList->resizeRows(); | ||
302 | break; | 309 | break; |
@@ -316,6 +323,7 @@ void AddressbookWindow::setDocument( const QString &filename ) | |||
316 | { | 323 | { |
317 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; | 324 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) |
325 | return; | ||
318 | 326 | ||
319 | QValueList<Contact> cl = Contact::readVCard( filename ); | 327 | QValueList<OContact> cl = OContact::readVCard( filename ); |
320 | for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { | 328 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { |
321 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") | 329 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") |
@@ -349,3 +357,3 @@ void AddressbookWindow::slotUpdateToolbar() | |||
349 | { | 357 | { |
350 | Contact ce = abList->currentEntry(); | 358 | OContact ce = abList->currentEntry(); |
351 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 359 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
@@ -355,3 +363,9 @@ void AddressbookWindow::showList() | |||
355 | { | 363 | { |
356 | if ( mView ) mView->hide(); | 364 | bool visiblemView; |
365 | |||
366 | visiblemView = false; | ||
367 | if ( mView ) { | ||
368 | mView->hide(); | ||
369 | visiblemView = true; | ||
370 | } | ||
357 | setCentralWidget( listContainer ); | 371 | setCentralWidget( listContainer ); |
@@ -360,2 +374,9 @@ void AddressbookWindow::showList() | |||
360 | abList->setFocus(); | 374 | abList->setFocus(); |
375 | |||
376 | // This makes sure we are scrolled all the way to the left | ||
377 | abList->setContentsPos( 0, abList->contentsY() ); | ||
378 | |||
379 | //if ( visiblemView && abList->showBook() == "Cards" ) | ||
380 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); | ||
381 | |||
361 | } | 382 | } |
@@ -374,3 +395,3 @@ void AddressbookWindow::slotListNew() | |||
374 | { | 395 | { |
375 | Contact cnt; | 396 | OContact cnt; |
376 | if( !syncing ) { | 397 | if( !syncing ) { |
@@ -381,3 +402,3 @@ void AddressbookWindow::slotListNew() | |||
381 | } else { | 402 | } else { |
382 | QMessageBox::warning(this, tr("Contacts"), | 403 | QMessageBox::warning(this, tr("OContacts"), |
383 | tr("Can not edit data, currently syncing")); | 404 | tr("Can not edit data, currently syncing")); |
@@ -396,3 +417,3 @@ void AddressbookWindow::slotListDelete() | |||
396 | if(!syncing) { | 417 | if(!syncing) { |
397 | Contact tmpEntry = abList->currentEntry(); | 418 | OContact tmpEntry = abList->currentEntry(); |
398 | 419 | ||
@@ -443,3 +464,3 @@ void AddressbookWindow::writeMail() | |||
443 | { | 464 | { |
444 | Contact c = abList->currentEntry(); | 465 | OContact c = abList->currentEntry(); |
445 | QString name = c.fileAs(); | 466 | QString name = c.fileAs(); |
@@ -450,5 +471,2 @@ void AddressbookWindow::writeMail() | |||
450 | 471 | ||
451 | |||
452 | |||
453 | |||
454 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 472 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
@@ -458,3 +476,3 @@ void AddressbookWindow::slotBeam() | |||
458 | QString filename; | 476 | QString filename; |
459 | Contact c; | 477 | OContact c; |
460 | if ( actionPersonal->isOn() ) { | 478 | if ( actionPersonal->isOn() ) { |
@@ -463,3 +481,3 @@ void AddressbookWindow::slotBeam() | |||
463 | return; // can't beam a non-existent file | 481 | return; // can't beam a non-existent file |
464 | c = Contact::readVCard( filename )[0]; | 482 | c = OContact::readVCard( filename )[0]; |
465 | } else { | 483 | } else { |
@@ -468,3 +486,3 @@ void AddressbookWindow::slotBeam() | |||
468 | mkdir("/tmp/obex/", 0755); | 486 | mkdir("/tmp/obex/", 0755); |
469 | Contact::writeVCard( beamfile, c ); | 487 | OContact::writeVCard( beamfile, c ); |
470 | filename = beamfile; | 488 | filename = beamfile; |
@@ -524,3 +542,3 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | |||
524 | 542 | ||
525 | Contact cnt; | 543 | OContact cnt; |
526 | QString fn, mn, ln; | 544 | QString fn, mn, ln; |
@@ -583,5 +601,5 @@ void AddressbookWindow::editPersonal() | |||
583 | QString filename = addressbookPersonalVCardName(); | 601 | QString filename = addressbookPersonalVCardName(); |
584 | Contact me; | 602 | OContact me; |
585 | if (QFile::exists(filename)) | 603 | if (QFile::exists(filename)) |
586 | me = Contact::readVCard( filename )[0]; | 604 | me = OContact::readVCard( filename )[0]; |
587 | if (bAbEditFirstTime) { | 605 | if (bAbEditFirstTime) { |
@@ -601,5 +619,5 @@ void AddressbookWindow::editPersonal() | |||
601 | setFocus(); | 619 | setFocus(); |
602 | Contact new_personal = abEditor->entry(); | 620 | OContact new_personal = abEditor->entry(); |
603 | QString fname = addressbookPersonalVCardName(); | 621 | QString fname = addressbookPersonalVCardName(); |
604 | Contact::writeVCard( fname, new_personal ); | 622 | OContact::writeVCard( fname, new_personal ); |
605 | abView()->init(new_personal); | 623 | abView()->init(new_personal); |
@@ -635,5 +653,5 @@ void AddressbookWindow::slotPersonalView() | |||
635 | QString filename = addressbookPersonalVCardName(); | 653 | QString filename = addressbookPersonalVCardName(); |
636 | Contact me; | 654 | OContact me; |
637 | if (QFile::exists(filename)) | 655 | if (QFile::exists(filename)) |
638 | me = Contact::readVCard( filename )[0]; | 656 | me = OContact::readVCard( filename )[0]; |
639 | 657 | ||
@@ -649,3 +667,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) | |||
649 | { | 667 | { |
650 | Contact entry; | 668 | OContact entry; |
651 | if ( bAbEditFirstTime ) { | 669 | if ( bAbEditFirstTime ) { |
@@ -668,3 +686,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) | |||
668 | if ( entryMode == NewEntry ) { | 686 | if ( entryMode == NewEntry ) { |
669 | Contact insertEntry = abEditor->entry(); | 687 | OContact insertEntry = abEditor->entry(); |
670 | insertEntry.assignUid(); | 688 | insertEntry.assignUid(); |
@@ -672,3 +690,3 @@ void AddressbookWindow::editEntry( EntryMode entryMode ) | |||
672 | } else { | 690 | } else { |
673 | Contact replaceEntry = abEditor->entry(); | 691 | OContact replaceEntry = abEditor->entry(); |
674 | if ( !replaceEntry.isValidUid() ) | 692 | if ( !replaceEntry.isValidUid() ) |
@@ -726,2 +744,3 @@ void AddressbookWindow::closeEvent( QCloseEvent *e ) | |||
726 | //################## shouldn't always save | 744 | //################## shouldn't always save |
745 | // True, but the database handles this automatically ! (se) | ||
727 | if ( save() ) | 746 | if ( save() ) |
@@ -794,4 +813,4 @@ void AddressbookWindow::initFields() | |||
794 | 813 | ||
795 | QStringList xmlFields = Contact::fields(); | 814 | QStringList xmlFields = OContact::fields(); |
796 | QStringList visibleFields = Contact::trfields(); | 815 | QStringList visibleFields = OContact::trfields(); |
797 | xmlFields.remove( "Title" ); | 816 | xmlFields.remove( "Title" ); |
@@ -800,4 +819,3 @@ void AddressbookWindow::initFields() | |||
800 | 819 | ||
801 | int i, | 820 | int i, version; |
802 | version; | ||
803 | Config cfg( "AddressBook" ); | 821 | Config cfg( "AddressBook" ); |
@@ -885,3 +903,3 @@ AbLabel *AddressbookWindow::abView() | |||
885 | mView = new AbLabel( this, "viewer" ); | 903 | mView = new AbLabel( this, "viewer" ); |
886 | mView->init( Contact() ); | 904 | mView->init( OContact() ); |
887 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); | 905 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); |
@@ -913,16 +931,36 @@ void AddressbookWindow::slotSetCategory( int c ) | |||
913 | { | 931 | { |
932 | |||
933 | QString cat, book; | ||
934 | |||
914 | if ( c <= 0 ) | 935 | if ( c <= 0 ) |
915 | return; | 936 | return; |
916 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 937 | |
938 | // Checkmark Book Menu Item Selected | ||
939 | if ( c < 6 ) | ||
940 | for ( unsigned int i = 1; i < 6; i++ ) | ||
917 | catMenu->setItemChecked( i, c == (int)i ); | 941 | catMenu->setItemChecked( i, c == (int)i ); |
918 | if ( c == 1 ) { | 942 | |
919 | abList->setShowCategory( QString::null ); | 943 | // Checkmark Category Menu Item Selected |
920 | setCaption( tr("Contacts") + " - " + tr ( "All" ) ); | 944 | else |
921 | } else if ( c == (int)catMenu->count() ) { | 945 | for ( unsigned int i = 6; i < catMenu->count(); i++ ) |
922 | abList->setShowCategory( tr( "Unfiled" ) ); | 946 | catMenu->setItemChecked( i, c == (int)i ); |
923 | setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); | 947 | |
924 | } else { | 948 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
925 | QString cat = abList->categories()[c - 2]; | 949 | if (catMenu->isItemChecked( i )) { |
926 | abList->setShowCategory( cat ); | 950 | if ( i == 1 ) // default List view |
927 | setCaption( tr("Contacts") + " - " + cat ); | 951 | book = QString::null; |
952 | else if ( i == 2 ) | ||
953 | book = "Phone"; | ||
954 | else if ( i == 3 ) | ||
955 | book = "Company"; | ||
956 | else if ( i == 4 ) | ||
957 | book = "Email"; | ||
958 | else if ( i == 5 ) | ||
959 | book = "Cards"; | ||
960 | else if ( i == 6 ) // default All Categories | ||
961 | cat = QString::null; | ||
962 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled | ||
963 | cat = "Unfiled"; | ||
964 | else | ||
965 | cat = abList->categories()[i - 7]; | ||
928 | } | 966 | } |
@@ -930,2 +968,12 @@ void AddressbookWindow::slotSetCategory( int c ) | |||
930 | 968 | ||
969 | abList->setShowCategory( book, cat ); | ||
970 | |||
971 | if ( book.isEmpty() ) | ||
972 | book = "List"; | ||
973 | if ( cat.isEmpty() ) | ||
974 | cat = "All"; | ||
975 | |||
976 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); | ||
977 | } | ||
978 | |||
931 | void AddressbookWindow::slotSetLetter( char c ) { | 979 | void AddressbookWindow::slotSetLetter( char c ) { |
@@ -940,6 +988,13 @@ void AddressbookWindow::populateCategories() | |||
940 | 988 | ||
941 | int id, | 989 | int id, rememberId; |
942 | rememberId; | ||
943 | id = 1; | 990 | id = 1; |
944 | rememberId = 0; | 991 | rememberId = 0; |
992 | |||
993 | catMenu->insertItem( tr( "List" ), id++ ); | ||
994 | catMenu->insertItem( tr( "Phone Book" ), id++ ); | ||
995 | catMenu->insertItem( tr( "Company Book" ), id++ ); | ||
996 | catMenu->insertItem( tr( "Email Book" ), id++ ); | ||
997 | catMenu->insertItem( tr( "Cards" ), id++ ); | ||
998 | catMenu->insertSeparator(); | ||
999 | |||
945 | catMenu->insertItem( tr( "All" ), id++ ); | 1000 | catMenu->insertItem( tr( "All" ), id++ ); |
@@ -954,6 +1009,22 @@ void AddressbookWindow::populateCategories() | |||
954 | } | 1009 | } |
955 | if ( abList->showCategory().isEmpty() ) | 1010 | |
956 | slotSetCategory( 1 ); | 1011 | if ( abList->showBook().isEmpty() ) { |
957 | else | 1012 | catMenu->setItemChecked( 1, true ); |
1013 | } else if ( abList->showBook() == "Phone" ) { | ||
1014 | catMenu->setItemChecked( 2, true ); | ||
1015 | } else if ( abList->showBook() == "Company" ) { | ||
1016 | catMenu->setItemChecked( 3, true ); | ||
1017 | } else if ( abList->showBook() == "Email" ) { | ||
1018 | catMenu->setItemChecked( 4, true ); | ||
1019 | } else if ( abList->showBook() == "Cards" ) { | ||
1020 | catMenu->setItemChecked( 5, true ); | ||
1021 | } | ||
1022 | |||
1023 | if ( abList->showCategory().isEmpty() ) { | ||
1024 | slotSetCategory( 6 ); | ||
1025 | } | ||
1026 | else { | ||
958 | slotSetCategory( rememberId ); | 1027 | slotSetCategory( rememberId ); |
959 | } | 1028 | } |
1029 | } | ||
1030 | |||
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 34ca85d..bf36407 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h | |||
@@ -78,2 +78,3 @@ private slots: | |||
78 | void slotSetFont(int); | 78 | void slotSetFont(int); |
79 | |||
79 | private: | 80 | private: |
@@ -86,4 +87,3 @@ private: | |||
86 | QToolButton *deleteButton; | 87 | QToolButton *deleteButton; |
87 | QValueList<int> allFields, | 88 | QValueList<int> allFields, orderedFields; |
88 | orderedFields; | ||
89 | QStringList slOrderedFields; | 89 | QStringList slOrderedFields; |
@@ -96,4 +96,3 @@ private: | |||
96 | 96 | ||
97 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, | 97 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; |
98 | *actionPersonal, *actionMail; | ||
99 | 98 | ||
@@ -105,2 +104,4 @@ private: | |||
105 | int startFontSize; | 104 | int startFontSize; |
105 | |||
106 | bool isLoading; | ||
106 | }; | 107 | }; |
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index ae86ed0..fd7f009 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -51,3 +51,3 @@ void parseEmailTo( const QString &strDefaultEmail, | |||
51 | 51 | ||
52 | ContactEditor::ContactEditor(const Contact &entry, | 52 | ContactEditor::ContactEditor(const OContact &entry, |
53 | const QValueList<int> *newOrderedValues, | 53 | const QValueList<int> *newOrderedValues, |
@@ -1294,3 +1294,3 @@ void ContactEditor::cleanupFields() { | |||
1294 | 1294 | ||
1295 | void ContactEditor::setEntry( const Contact &entry ) { | 1295 | void ContactEditor::setEntry( const OContact &entry ) { |
1296 | 1296 | ||
diff --git a/core/pim/addressbook/contacteditor.h b/core/pim/addressbook/contacteditor.h index 4f3b56e..8ed8553 100644 --- a/core/pim/addressbook/contacteditor.h +++ b/core/pim/addressbook/contacteditor.h | |||
@@ -23,3 +23,3 @@ | |||
23 | 23 | ||
24 | #include <qpe/contact.h> | 24 | #include <opie/ocontact.h> |
25 | 25 | ||
@@ -54,3 +54,3 @@ class ContactEditor : public QDialog { | |||
54 | public: | 54 | public: |
55 | ContactEditor(const Contact &entry, | 55 | ContactEditor(const OContact &entry, |
56 | const QValueList<int> *newOrderedValues, | 56 | const QValueList<int> *newOrderedValues, |
@@ -63,3 +63,3 @@ class ContactEditor : public QDialog { | |||
63 | void setNameFocus(); | 63 | void setNameFocus(); |
64 | Contact entry() const { return ent; } | 64 | OContact entry() const { return ent; } |
65 | 65 | ||
@@ -68,3 +68,3 @@ class ContactEditor : public QDialog { | |||
68 | void slotName(); | 68 | void slotName(); |
69 | void setEntry(const Contact &entry); | 69 | void setEntry(const OContact &entry); |
70 | 70 | ||
@@ -103,3 +103,3 @@ class ContactEditor : public QDialog { | |||
103 | 103 | ||
104 | Contact ent; | 104 | OContact ent; |
105 | 105 | ||