author | tux_mike <tux_mike> | 2002-04-10 03:29:24 (UTC) |
---|---|---|
committer | tux_mike <tux_mike> | 2002-04-10 03:29:24 (UTC) |
commit | 4eb2a1b8698fdcca7a2c74a3fe9a88a297607754 (patch) (unidiff) | |
tree | 0787600f2d3e0d4bb314124fff55fa3046bfb2f5 | |
parent | 0d5d67ab1225446f1796a08d97c0cc025922958f (diff) | |
download | opie-4eb2a1b8698fdcca7a2c74a3fe9a88a297607754.zip opie-4eb2a1b8698fdcca7a2c74a3fe9a88a297607754.tar.gz opie-4eb2a1b8698fdcca7a2c74a3fe9a88a297607754.tar.bz2 |
Made rows resize with fonts.
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 11 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 1 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 8 |
3 files changed, 20 insertions, 0 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 0911edf..17277b4 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -1,148 +1,150 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_CONTACT_MRE | ||
22 | |||
21 | #include <qpe/categoryselect.h> | 23 | #include <qpe/categoryselect.h> |
22 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
23 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
25 | 27 | ||
26 | #include <qasciidict.h> | 28 | #include <qasciidict.h> |
27 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
28 | #include <qfile.h> | 30 | #include <qfile.h> |
29 | 31 | ||
30 | #include "abtable.h" | 32 | #include "abtable.h" |
31 | 33 | ||
32 | #include <errno.h> | 34 | #include <errno.h> |
33 | #include <fcntl.h> | 35 | #include <fcntl.h> |
34 | #include <unistd.h> | 36 | #include <unistd.h> |
35 | #include <stdlib.h> | 37 | #include <stdlib.h> |
36 | 38 | ||
37 | #include <ctype.h> //toupper() for key hack | 39 | #include <ctype.h> //toupper() for key hack |
38 | 40 | ||
39 | static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ); | 41 | static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ); |
40 | 42 | ||
41 | //### qtmail/addresslist.cpp hardcodes this filename as well | 43 | //### qtmail/addresslist.cpp hardcodes this filename as well |
42 | static QString journalFileName() | 44 | static QString journalFileName() |
43 | { | 45 | { |
44 | QString str = getenv("HOME"); | 46 | QString str = getenv("HOME"); |
45 | str +="/.abjournal"; | 47 | str +="/.abjournal"; |
46 | return str; | 48 | return str; |
47 | } | 49 | } |
48 | 50 | ||
49 | 51 | ||
50 | 52 | ||
51 | /*! | 53 | /*! |
52 | \class AbTableItem abtable.h | 54 | \class AbTableItem abtable.h |
53 | 55 | ||
54 | \brief QTableItem based class for showing a field of an entry | 56 | \brief QTableItem based class for showing a field of an entry |
55 | */ | 57 | */ |
56 | 58 | ||
57 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 59 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, |
58 | const QString &secondSortKey) | 60 | const QString &secondSortKey) |
59 | : QTableItem( t, et, s ) | 61 | : QTableItem( t, et, s ) |
60 | { | 62 | { |
61 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); | 63 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); |
62 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); | 64 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); |
63 | } | 65 | } |
64 | 66 | ||
65 | int AbTableItem::alignment() const | 67 | int AbTableItem::alignment() const |
66 | { | 68 | { |
67 | return AlignLeft|AlignVCenter; | 69 | return AlignLeft|AlignVCenter; |
68 | } | 70 | } |
69 | 71 | ||
70 | QString AbTableItem::key() const | 72 | QString AbTableItem::key() const |
71 | { | 73 | { |
72 | return sortKey; | 74 | return sortKey; |
73 | } | 75 | } |
74 | 76 | ||
75 | // A way to reset the item, without out doing a delete or a new... | 77 | // A way to reset the item, without out doing a delete or a new... |
76 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) | 78 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) |
77 | { | 79 | { |
78 | setText( txt ); | 80 | setText( txt ); |
79 | sortKey = Qtopia::buildSortKey( txt, secondKey ); | 81 | sortKey = Qtopia::buildSortKey( txt, secondKey ); |
80 | 82 | ||
81 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); | 83 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); |
82 | } | 84 | } |
83 | 85 | ||
84 | /*! | 86 | /*! |
85 | \class AbPickItem abtable.h | 87 | \class AbPickItem abtable.h |
86 | 88 | ||
87 | \brief QTableItem based class for showing slection of an entry | 89 | \brief QTableItem based class for showing slection of an entry |
88 | */ | 90 | */ |
89 | 91 | ||
90 | AbPickItem::AbPickItem( QTable *t ) : | 92 | AbPickItem::AbPickItem( QTable *t ) : |
91 | QTableItem(t, WhenCurrent, "?") | 93 | QTableItem(t, WhenCurrent, "?") |
92 | { | 94 | { |
93 | } | 95 | } |
94 | 96 | ||
95 | QWidget *AbPickItem::createEditor() const | 97 | QWidget *AbPickItem::createEditor() const |
96 | { | 98 | { |
97 | QComboBox* combo = new QComboBox( table()->viewport() ); | 99 | QComboBox* combo = new QComboBox( table()->viewport() ); |
98 | ( (AbPickItem*)this )->cb = combo; | 100 | ( (AbPickItem*)this )->cb = combo; |
99 | AbTable* t = static_cast<AbTable*>(table()); | 101 | AbTable* t = static_cast<AbTable*>(table()); |
100 | QStringList c = t->choiceNames(); | 102 | QStringList c = t->choiceNames(); |
101 | int cur = 0; | 103 | int cur = 0; |
102 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { | 104 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { |
103 | if ( *it == text() ) | 105 | if ( *it == text() ) |
104 | cur = combo->count(); | 106 | cur = combo->count(); |
105 | combo->insertItem(*it); | 107 | combo->insertItem(*it); |
106 | } | 108 | } |
107 | combo->setCurrentItem(cur); | 109 | combo->setCurrentItem(cur); |
108 | return combo; | 110 | return combo; |
109 | } | 111 | } |
110 | 112 | ||
111 | void AbPickItem::setContentFromEditor( QWidget *w ) | 113 | void AbPickItem::setContentFromEditor( QWidget *w ) |
112 | { | 114 | { |
113 | if ( w->inherits("QComboBox") ) | 115 | if ( w->inherits("QComboBox") ) |
114 | setText( ( (QComboBox*)w )->currentText() ); | 116 | setText( ( (QComboBox*)w )->currentText() ); |
115 | else | 117 | else |
116 | QTableItem::setContentFromEditor( w ); | 118 | QTableItem::setContentFromEditor( w ); |
117 | } | 119 | } |
118 | 120 | ||
119 | /*! | 121 | /*! |
120 | \class AbTable abtable.h | 122 | \class AbTable abtable.h |
121 | 123 | ||
122 | \brief QTable based class for showing a list of entries | 124 | \brief QTable based class for showing a list of entries |
123 | */ | 125 | */ |
124 | 126 | ||
125 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) | 127 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) |
126 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 128 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
127 | // : QTable( 0, 0, parent, name, TRUE ), | 129 | // : QTable( 0, 0, parent, name, TRUE ), |
128 | // #else | 130 | // #else |
129 | : QTable( parent, name ), | 131 | : QTable( parent, name ), |
130 | // #endif | 132 | // #endif |
131 | lastSortCol( -1 ), | 133 | lastSortCol( -1 ), |
132 | asc( TRUE ), | 134 | asc( TRUE ), |
133 | intFields( order ), | 135 | intFields( order ), |
134 | currFindRow( -2 ), | 136 | currFindRow( -2 ), |
135 | mCat( 0 ) | 137 | mCat( 0 ) |
136 | { | 138 | { |
137 | mCat.load( categoryFileName() ); | 139 | mCat.load( categoryFileName() ); |
138 | setSelectionMode( NoSelection ); | 140 | setSelectionMode( NoSelection ); |
139 | init(); | 141 | init(); |
140 | setSorting( TRUE ); | 142 | setSorting( TRUE ); |
141 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 143 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
142 | this, SLOT(itemClicked(int,int)) ); | 144 | this, SLOT(itemClicked(int,int)) ); |
143 | } | 145 | } |
144 | 146 | ||
145 | AbTable::~AbTable() | 147 | AbTable::~AbTable() |
146 | { | 148 | { |
147 | } | 149 | } |
148 | 150 | ||
@@ -324,256 +326,265 @@ QString AbTable::findContactContact( const Contact &entry ) | |||
324 | break; | 326 | break; |
325 | case Qtopia::Title: | 327 | case Qtopia::Title: |
326 | value = entry.title(); | 328 | value = entry.title(); |
327 | break; | 329 | break; |
328 | case Qtopia::Suffix: | 330 | case Qtopia::Suffix: |
329 | value = entry.suffix(); | 331 | value = entry.suffix(); |
330 | break; | 332 | break; |
331 | case Qtopia::FileAs: | 333 | case Qtopia::FileAs: |
332 | value = entry.fileAs(); | 334 | value = entry.fileAs(); |
333 | break; | 335 | break; |
334 | case Qtopia::DefaultEmail: | 336 | case Qtopia::DefaultEmail: |
335 | value = entry.defaultEmail(); | 337 | value = entry.defaultEmail(); |
336 | case Qtopia::Emails: | 338 | case Qtopia::Emails: |
337 | value = entry.emails(); | 339 | value = entry.emails(); |
338 | break; | 340 | break; |
339 | case Qtopia::HomeStreet: | 341 | case Qtopia::HomeStreet: |
340 | value = entry.homeStreet(); | 342 | value = entry.homeStreet(); |
341 | break; | 343 | break; |
342 | case Qtopia::HomeCity: | 344 | case Qtopia::HomeCity: |
343 | value = entry.homeCity(); | 345 | value = entry.homeCity(); |
344 | break; | 346 | break; |
345 | case Qtopia::HomeState: | 347 | case Qtopia::HomeState: |
346 | value = entry.homeState(); | 348 | value = entry.homeState(); |
347 | break; | 349 | break; |
348 | case Qtopia::HomeZip: | 350 | case Qtopia::HomeZip: |
349 | value = entry.homeZip(); | 351 | value = entry.homeZip(); |
350 | break; | 352 | break; |
351 | case Qtopia::HomeCountry: | 353 | case Qtopia::HomeCountry: |
352 | value = entry.homeCountry(); | 354 | value = entry.homeCountry(); |
353 | break; | 355 | break; |
354 | case Qtopia::HomePhone: | 356 | case Qtopia::HomePhone: |
355 | value = entry.homePhone(); | 357 | value = entry.homePhone(); |
356 | break; | 358 | break; |
357 | case Qtopia::HomeFax: | 359 | case Qtopia::HomeFax: |
358 | value = entry.homeFax(); | 360 | value = entry.homeFax(); |
359 | break; | 361 | break; |
360 | case Qtopia::HomeMobile: | 362 | case Qtopia::HomeMobile: |
361 | value = entry.homeMobile(); | 363 | value = entry.homeMobile(); |
362 | break; | 364 | break; |
363 | case Qtopia::HomeWebPage: | 365 | case Qtopia::HomeWebPage: |
364 | value = entry.homeWebpage(); | 366 | value = entry.homeWebpage(); |
365 | break; | 367 | break; |
366 | case Qtopia::Company: | 368 | case Qtopia::Company: |
367 | value = entry.company(); | 369 | value = entry.company(); |
368 | break; | 370 | break; |
369 | case Qtopia::BusinessCity: | 371 | case Qtopia::BusinessCity: |
370 | value = entry.businessCity(); | 372 | value = entry.businessCity(); |
371 | break; | 373 | break; |
372 | case Qtopia::BusinessStreet: | 374 | case Qtopia::BusinessStreet: |
373 | value = entry.businessStreet(); | 375 | value = entry.businessStreet(); |
374 | break; | 376 | break; |
375 | case Qtopia::BusinessZip: | 377 | case Qtopia::BusinessZip: |
376 | value = entry.businessZip(); | 378 | value = entry.businessZip(); |
377 | break; | 379 | break; |
378 | case Qtopia::BusinessCountry: | 380 | case Qtopia::BusinessCountry: |
379 | value = entry.businessCountry(); | 381 | value = entry.businessCountry(); |
380 | break; | 382 | break; |
381 | case Qtopia::BusinessWebPage: | 383 | case Qtopia::BusinessWebPage: |
382 | value = entry.businessWebpage(); | 384 | value = entry.businessWebpage(); |
383 | break; | 385 | break; |
384 | case Qtopia::JobTitle: | 386 | case Qtopia::JobTitle: |
385 | value = entry.jobTitle(); | 387 | value = entry.jobTitle(); |
386 | break; | 388 | break; |
387 | case Qtopia::Department: | 389 | case Qtopia::Department: |
388 | value = entry.department(); | 390 | value = entry.department(); |
389 | break; | 391 | break; |
390 | case Qtopia::Office: | 392 | case Qtopia::Office: |
391 | value = entry.office(); | 393 | value = entry.office(); |
392 | break; | 394 | break; |
393 | case Qtopia::BusinessPhone: | 395 | case Qtopia::BusinessPhone: |
394 | value = entry.businessPhone(); | 396 | value = entry.businessPhone(); |
395 | break; | 397 | break; |
396 | case Qtopia::BusinessFax: | 398 | case Qtopia::BusinessFax: |
397 | value = entry.businessFax(); | 399 | value = entry.businessFax(); |
398 | break; | 400 | break; |
399 | case Qtopia::BusinessMobile: | 401 | case Qtopia::BusinessMobile: |
400 | value = entry.businessMobile(); | 402 | value = entry.businessMobile(); |
401 | break; | 403 | break; |
402 | case Qtopia::BusinessPager: | 404 | case Qtopia::BusinessPager: |
403 | value = entry.businessPager(); | 405 | value = entry.businessPager(); |
404 | break; | 406 | break; |
405 | case Qtopia::Profession: | 407 | case Qtopia::Profession: |
406 | value = entry.profession(); | 408 | value = entry.profession(); |
407 | break; | 409 | break; |
408 | case Qtopia::Assistant: | 410 | case Qtopia::Assistant: |
409 | value = entry.assistant(); | 411 | value = entry.assistant(); |
410 | break; | 412 | break; |
411 | case Qtopia::Manager: | 413 | case Qtopia::Manager: |
412 | value = entry.manager(); | 414 | value = entry.manager(); |
413 | break; | 415 | break; |
414 | case Qtopia::Spouse: | 416 | case Qtopia::Spouse: |
415 | value = entry.spouse(); | 417 | value = entry.spouse(); |
416 | break; | 418 | break; |
417 | case Qtopia::Gender: | 419 | case Qtopia::Gender: |
418 | value = entry.gender(); | 420 | value = entry.gender(); |
419 | break; | 421 | break; |
420 | case Qtopia::Birthday: | 422 | case Qtopia::Birthday: |
421 | value = entry.birthday(); | 423 | value = entry.birthday(); |
422 | break; | 424 | break; |
423 | case Qtopia::Anniversary: | 425 | case Qtopia::Anniversary: |
424 | value = entry.anniversary(); | 426 | value = entry.anniversary(); |
425 | break; | 427 | break; |
426 | case Qtopia::Nickname: | 428 | case Qtopia::Nickname: |
427 | value = entry.nickname(); | 429 | value = entry.nickname(); |
428 | break; | 430 | break; |
429 | case Qtopia::Children: | 431 | case Qtopia::Children: |
430 | value = entry.children(); | 432 | value = entry.children(); |
431 | break; | 433 | break; |
432 | case Qtopia::Notes: | 434 | case Qtopia::Notes: |
433 | value = entry.notes(); | 435 | value = entry.notes(); |
434 | break; | 436 | break; |
435 | } | 437 | } |
436 | if ( !value.isEmpty() ) | 438 | if ( !value.isEmpty() ) |
437 | break; | 439 | break; |
438 | } | 440 | } |
439 | return value; | 441 | return value; |
440 | } | 442 | } |
441 | 443 | ||
442 | void AbTable::addEntry( const Contact &newCnt ) | 444 | void AbTable::addEntry( const Contact &newCnt ) |
443 | { | 445 | { |
444 | int row = numRows(); | 446 | int row = numRows(); |
445 | setNumRows( row + 1 ); | 447 | setNumRows( row + 1 ); |
446 | updateJournal( newCnt, Contact::ACTION_ADD ); | 448 | updateJournal( newCnt, Contact::ACTION_ADD ); |
447 | insertIntoTable( newCnt, row ); | 449 | insertIntoTable( newCnt, row ); |
448 | setCurrentCell( row, 0 ); | 450 | setCurrentCell( row, 0 ); |
449 | updateVisible(); | 451 | updateVisible(); |
450 | } | 452 | } |
451 | 453 | ||
454 | void AbTable::resizeRows( int size ) { | ||
455 | |||
456 | if (numRows()) { | ||
457 | for (int i = 0; i < numRows(); i++) { | ||
458 | setRowHeight( i, size ); | ||
459 | } | ||
460 | } | ||
461 | } | ||
462 | |||
452 | void AbTable::updateJournal( const Contact &cnt, | 463 | void AbTable::updateJournal( const Contact &cnt, |
453 | Contact::journal_action action, int row ) | 464 | Contact::journal_action action, int row ) |
454 | { | 465 | { |
455 | QFile f( journalFileName() ); | 466 | QFile f( journalFileName() ); |
456 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 467 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
457 | return; | 468 | return; |
458 | QString buf; | 469 | QString buf; |
459 | QCString str; | 470 | QCString str; |
460 | buf = "<Contact "; | 471 | buf = "<Contact "; |
461 | cnt.save( buf ); | 472 | cnt.save( buf ); |
462 | buf += " action=\"" + QString::number( (int)action ) + "\" "; | 473 | buf += " action=\"" + QString::number( (int)action ) + "\" "; |
463 | if ( action == Contact::ACTION_REMOVE || action == Contact::ACTION_REPLACE) | 474 | if ( action == Contact::ACTION_REMOVE || action == Contact::ACTION_REPLACE) |
464 | buf += " actionrow=\"" + QString::number(row) + "\" "; | 475 | buf += " actionrow=\"" + QString::number(row) + "\" "; |
465 | buf += "/>\n"; | 476 | buf += "/>\n"; |
466 | QCString cstr = buf.utf8(); | 477 | QCString cstr = buf.utf8(); |
467 | f.writeBlock( cstr.data(), cstr.length() ); | 478 | f.writeBlock( cstr.data(), cstr.length() ); |
468 | QCopEnvelope( "QPE/PIM", "addressbookUpdated()" ); | 479 | QCopEnvelope( "QPE/PIM", "addressbookUpdated()" ); |
469 | } | 480 | } |
470 | 481 | ||
471 | bool AbTable::save( const QString &fn ) | 482 | bool AbTable::save( const QString &fn ) |
472 | { | 483 | { |
473 | // QTime t; | 484 | // QTime t; |
474 | // t.start(); | 485 | // t.start(); |
475 | 486 | ||
476 | QString strNewFile = fn + ".new"; | 487 | QString strNewFile = fn + ".new"; |
477 | QFile f( strNewFile ); | 488 | QFile f( strNewFile ); |
478 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) | 489 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) |
479 | return false; | 490 | return false; |
480 | 491 | ||
481 | int total_written; | 492 | int total_written; |
482 | QString out; | 493 | QString out; |
483 | out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" | 494 | out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" |
484 | " <Groups>\n" | 495 | " <Groups>\n" |
485 | " </Groups>\n" | 496 | " </Groups>\n" |
486 | " <Contacts>\n"; | 497 | " <Contacts>\n"; |
487 | QMapIterator<AbTableItem*, Contact> it; | 498 | QMapIterator<AbTableItem*, Contact> it; |
488 | for ( it = contactList.begin(); it != contactList.end(); ++it ) { | 499 | for ( it = contactList.begin(); it != contactList.end(); ++it ) { |
489 | out += "<Contact "; | 500 | out += "<Contact "; |
490 | it.data().save( out ); | 501 | it.data().save( out ); |
491 | out += "/>\n"; | 502 | out += "/>\n"; |
492 | QCString cstr = out.utf8(); | 503 | QCString cstr = out.utf8(); |
493 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | 504 | total_written = f.writeBlock( cstr.data(), cstr.length() ); |
494 | if ( total_written != int(cstr.length()) ) { | 505 | if ( total_written != int(cstr.length()) ) { |
495 | f.close(); | 506 | f.close(); |
496 | QFile::remove( strNewFile ); | 507 | QFile::remove( strNewFile ); |
497 | return false; | 508 | return false; |
498 | } | 509 | } |
499 | out = ""; | 510 | out = ""; |
500 | } | 511 | } |
501 | out += " </Contacts>\n</AddressBook>\n"; | 512 | out += " </Contacts>\n</AddressBook>\n"; |
502 | 513 | ||
503 | QCString cstr = out.utf8(); | 514 | QCString cstr = out.utf8(); |
504 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | 515 | total_written = f.writeBlock( cstr.data(), cstr.length() ); |
505 | if ( total_written != int(cstr.length()) ) { | 516 | if ( total_written != int(cstr.length()) ) { |
506 | f.close(); | 517 | f.close(); |
507 | QFile::remove( strNewFile ); | 518 | QFile::remove( strNewFile ); |
508 | return false; | 519 | return false; |
509 | } | 520 | } |
510 | f.close(); | 521 | f.close(); |
511 | 522 | ||
512 | // qDebug("saving: %d", t.elapsed() ); | 523 | // qDebug("saving: %d", t.elapsed() ); |
513 | 524 | ||
514 | // move the file over, I'm just going to use the system call | 525 | // move the file over, I'm just going to use the system call |
515 | // because, I don't feel like using QDir. | 526 | // because, I don't feel like using QDir. |
516 | if ( ::rename( strNewFile.latin1(), fn.latin1() ) < 0 ) { | 527 | if ( ::rename( strNewFile.latin1(), fn.latin1() ) < 0 ) { |
517 | qWarning( "problem renaming file %s to %s, errno: %d", | 528 | qWarning( "problem renaming file %s to %s, errno: %d", |
518 | strNewFile.latin1(), fn.latin1(), errno ); | 529 | strNewFile.latin1(), fn.latin1(), errno ); |
519 | // remove the tmp file... | 530 | // remove the tmp file... |
520 | QFile::remove( strNewFile ); | 531 | QFile::remove( strNewFile ); |
521 | } | 532 | } |
522 | // remove the journal... | 533 | // remove the journal... |
523 | QFile::remove( journalFileName() ); | 534 | QFile::remove( journalFileName() ); |
524 | return true; | 535 | return true; |
525 | } | 536 | } |
526 | 537 | ||
527 | void AbTable::load( const QString &fn ) | 538 | void AbTable::load( const QString &fn ) |
528 | { | 539 | { |
529 | setSorting( false ); | 540 | setSorting( false ); |
530 | loadFile( fn, false ); | 541 | loadFile( fn, false ); |
531 | // merge in the journal | 542 | // merge in the journal |
532 | if ( QFile::exists( journalFileName() ) ) { | 543 | if ( QFile::exists( journalFileName() ) ) { |
533 | loadFile( journalFileName(), true ); | 544 | loadFile( journalFileName(), true ); |
534 | save( fn ); | 545 | save( fn ); |
535 | } | 546 | } |
536 | setSorting( true ); | 547 | setSorting( true ); |
537 | resort(); | 548 | resort(); |
538 | } | 549 | } |
539 | 550 | ||
540 | void AbTable::loadFile( const QString &strFile, bool journalFile ) | 551 | void AbTable::loadFile( const QString &strFile, bool journalFile ) |
541 | { | 552 | { |
542 | // QTime t; | 553 | // QTime t; |
543 | // t.start(); | 554 | // t.start(); |
544 | QFile f( strFile ); | 555 | QFile f( strFile ); |
545 | if ( !f.open(IO_ReadOnly) ) | 556 | if ( !f.open(IO_ReadOnly) ) |
546 | return; | 557 | return; |
547 | QList<Contact> list; | 558 | QList<Contact> list; |
548 | list.setAutoDelete( TRUE ); | 559 | list.setAutoDelete( TRUE ); |
549 | QByteArray ba = f.readAll(); | 560 | QByteArray ba = f.readAll(); |
550 | f.close(); | 561 | f.close(); |
551 | char *uc = ba.data();//(QChar *)data.unicode(); | 562 | char *uc = ba.data();//(QChar *)data.unicode(); |
552 | int len = ba.size();//data.length(); | 563 | int len = ba.size();//data.length(); |
553 | bool foundAction = false; | 564 | bool foundAction = false; |
554 | Contact::journal_action action; | 565 | Contact::journal_action action; |
555 | bool foundKey = false; | 566 | bool foundKey = false; |
556 | int journalKey = 0; | 567 | int journalKey = 0; |
557 | 568 | ||
558 | const int JOURNALACTION = Qtopia::Notes + 1; | 569 | const int JOURNALACTION = Qtopia::Notes + 1; |
559 | const int JOURNALROW = JOURNALACTION + 1; | 570 | const int JOURNALROW = JOURNALACTION + 1; |
560 | 571 | ||
561 | // ********************************** | 572 | // ********************************** |
562 | // CHANGE THE SIZE OF THE DICT IF YOU ADD ANY MORE FIELDS!!!! | 573 | // CHANGE THE SIZE OF THE DICT IF YOU ADD ANY MORE FIELDS!!!! |
563 | // ********************************** | 574 | // ********************************** |
564 | QAsciiDict<int> dict( 47 ); | 575 | QAsciiDict<int> dict( 47 ); |
565 | dict.setAutoDelete( TRUE ); | 576 | dict.setAutoDelete( TRUE ); |
566 | dict.insert( "Uid", new int(Qtopia::AddressUid) ); | 577 | dict.insert( "Uid", new int(Qtopia::AddressUid) ); |
567 | dict.insert( "Title", new int(Qtopia::Title) ); | 578 | dict.insert( "Title", new int(Qtopia::Title) ); |
568 | dict.insert( "FirstName", new int(Qtopia::FirstName) ); | 579 | dict.insert( "FirstName", new int(Qtopia::FirstName) ); |
569 | dict.insert( "MiddleName", new int(Qtopia::MiddleName) ); | 580 | dict.insert( "MiddleName", new int(Qtopia::MiddleName) ); |
570 | dict.insert( "LastName", new int(Qtopia::LastName) ); | 581 | dict.insert( "LastName", new int(Qtopia::LastName) ); |
571 | dict.insert( "Suffix", new int(Qtopia::Suffix) ); | 582 | dict.insert( "Suffix", new int(Qtopia::Suffix) ); |
572 | dict.insert( "FileAs", new int(Qtopia::FileAs) ); | 583 | dict.insert( "FileAs", new int(Qtopia::FileAs) ); |
573 | dict.insert( "Categories", new int(Qtopia::AddressCategory) ); | 584 | dict.insert( "Categories", new int(Qtopia::AddressCategory) ); |
574 | dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) ); | 585 | dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) ); |
575 | dict.insert( "Emails", new int(Qtopia::Emails) ); | 586 | dict.insert( "Emails", new int(Qtopia::Emails) ); |
576 | dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) ); | 587 | dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) ); |
577 | dict.insert( "HomeCity", new int(Qtopia::HomeCity) ); | 588 | dict.insert( "HomeCity", new int(Qtopia::HomeCity) ); |
578 | dict.insert( "HomeState", new int(Qtopia::HomeState) ); | 589 | dict.insert( "HomeState", new int(Qtopia::HomeState) ); |
579 | dict.insert( "HomeZip", new int(Qtopia::HomeZip) ); | 590 | dict.insert( "HomeZip", new int(Qtopia::HomeZip) ); |
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index 9b96997..53635ee 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h | |||
@@ -1,140 +1,141 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef ABTABLE_H | 21 | #ifndef ABTABLE_H |
22 | #define ABTABLE_H | 22 | #define ABTABLE_H |
23 | 23 | ||
24 | #include <qpe/categories.h> | 24 | #include <qpe/categories.h> |
25 | #include <qpe/contact.h> | 25 | #include <qpe/contact.h> |
26 | 26 | ||
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qtable.h> | 28 | #include <qtable.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | 31 | ||
32 | class AbTableItem : public QTableItem | 32 | class AbTableItem : public QTableItem |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | AbTableItem( QTable *t, EditType et, const QString &s, | 35 | AbTableItem( QTable *t, EditType et, const QString &s, |
36 | const QString &secondSortKey); | 36 | const QString &secondSortKey); |
37 | QString entryKey() const; | 37 | QString entryKey() const; |
38 | void setEntryKey( const QString & k ); | 38 | void setEntryKey( const QString & k ); |
39 | virtual int alignment() const; | 39 | virtual int alignment() const; |
40 | virtual QString key() const; | 40 | virtual QString key() const; |
41 | void setItem( const QString &txt, const QString &secondKey ); | 41 | void setItem( const QString &txt, const QString &secondKey ); |
42 | 42 | ||
43 | private: | 43 | private: |
44 | QString sortKey; | 44 | QString sortKey; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | class AbPickItem : public QTableItem | 47 | class AbPickItem : public QTableItem |
48 | { | 48 | { |
49 | public: | 49 | public: |
50 | AbPickItem( QTable *t ); | 50 | AbPickItem( QTable *t ); |
51 | 51 | ||
52 | QWidget *createEditor() const; | 52 | QWidget *createEditor() const; |
53 | void setContentFromEditor( QWidget *w ); | 53 | void setContentFromEditor( QWidget *w ); |
54 | 54 | ||
55 | private: | 55 | private: |
56 | QGuardedPtr<QComboBox> cb; | 56 | QGuardedPtr<QComboBox> cb; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | class AbTable : public QTable | 59 | class AbTable : public QTable |
60 | { | 60 | { |
61 | Q_OBJECT | 61 | Q_OBJECT |
62 | 62 | ||
63 | public: | 63 | public: |
64 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); | 64 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); |
65 | ~AbTable(); | 65 | ~AbTable(); |
66 | // NEW | 66 | // NEW |
67 | void addEntry( const Contact &newContact ); | 67 | void addEntry( const Contact &newContact ); |
68 | Contact currentEntry(); | 68 | Contact currentEntry(); |
69 | void replaceCurrentEntry( const Contact &newContact ); | 69 | void replaceCurrentEntry( const Contact &newContact ); |
70 | 70 | ||
71 | void init(); | 71 | void init(); |
72 | 72 | ||
73 | void deleteCurrentEntry(); | 73 | void deleteCurrentEntry(); |
74 | void clear(); | 74 | void clear(); |
75 | void clearFindRow() { currFindRow = -2; } | 75 | void clearFindRow() { currFindRow = -2; } |
76 | void loadFields(); | 76 | void loadFields(); |
77 | void refresh(); | 77 | void refresh(); |
78 | bool save( const QString &fn ); | 78 | bool save( const QString &fn ); |
79 | void load( const QString &fn ); | 79 | void load( const QString &fn ); |
80 | 80 | ||
81 | // addresspicker mode | 81 | // addresspicker mode |
82 | void setChoiceNames( const QStringList& list); | 82 | void setChoiceNames( const QStringList& list); |
83 | QStringList choiceNames() const; | 83 | QStringList choiceNames() const; |
84 | void setChoiceSelection(int index, const QStringList& list); | 84 | void setChoiceSelection(int index, const QStringList& list); |
85 | QStringList choiceSelection(int index) const; | 85 | QStringList choiceSelection(int index) const; |
86 | void setShowCategory( const QString &c ); | 86 | void setShowCategory( const QString &c ); |
87 | QString showCategory() const; | 87 | QString showCategory() const; |
88 | QStringList categories(); | 88 | QStringList categories(); |
89 | void resizeRows( int size ); | ||
89 | 90 | ||
90 | void show(); | 91 | void show(); |
91 | void setPaintingEnabled( bool e ); | 92 | void setPaintingEnabled( bool e ); |
92 | 93 | ||
93 | public slots: | 94 | public slots: |
94 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, | 95 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, |
95 | int category ); | 96 | int category ); |
96 | signals: | 97 | signals: |
97 | void empty( bool ); | 98 | void empty( bool ); |
98 | void details(); | 99 | void details(); |
99 | void signalNotFound(); | 100 | void signalNotFound(); |
100 | void signalWrapAround(); | 101 | void signalWrapAround(); |
101 | 102 | ||
102 | protected: | 103 | protected: |
103 | virtual void keyPressEvent( QKeyEvent *e ); | 104 | virtual void keyPressEvent( QKeyEvent *e ); |
104 | 105 | ||
105 | // int rowHeight( int ) const; | 106 | // int rowHeight( int ) const; |
106 | // int rowPos( int row ) const; | 107 | // int rowPos( int row ) const; |
107 | // virtual int rowAt( int pos ) const; | 108 | // virtual int rowAt( int pos ) const; |
108 | 109 | ||
109 | 110 | ||
110 | protected slots: | 111 | protected slots: |
111 | void moveTo( char ); | 112 | void moveTo( char ); |
112 | virtual void columnClicked( int col ); | 113 | virtual void columnClicked( int col ); |
113 | void itemClicked(int,int col); | 114 | void itemClicked(int,int col); |
114 | void rowHeightChanged( int row ); | 115 | void rowHeightChanged( int row ); |
115 | 116 | ||
116 | private: | 117 | private: |
117 | void loadFile( const QString &strFile, bool journalFile ); | 118 | void loadFile( const QString &strFile, bool journalFile ); |
118 | void fitColumns(); | 119 | void fitColumns(); |
119 | void resort(); | 120 | void resort(); |
120 | void updateJournal( const Contact &contact, Contact::journal_action action, | 121 | void updateJournal( const Contact &contact, Contact::journal_action action, |
121 | int row = -1 ); | 122 | int row = -1 ); |
122 | void insertIntoTable( const Contact &contact, int row ); | 123 | void insertIntoTable( const Contact &contact, int row ); |
123 | void internalAddEntries( QList<Contact> &list ); | 124 | void internalAddEntries( QList<Contact> &list ); |
124 | QString findContactName( const Contact &entry ); | 125 | QString findContactName( const Contact &entry ); |
125 | QString findContactContact( const Contact &entry ); | 126 | QString findContactContact( const Contact &entry ); |
126 | void journalFreeReplace( const Contact &cnt, int row ); | 127 | void journalFreeReplace( const Contact &cnt, int row ); |
127 | void journalFreeRemove( int row ); | 128 | void journalFreeRemove( int row ); |
128 | void realignTable( int ); | 129 | void realignTable( int ); |
129 | void updateVisible(); | 130 | void updateVisible(); |
130 | int lastSortCol; | 131 | int lastSortCol; |
131 | bool asc; | 132 | bool asc; |
132 | QMap<AbTableItem*, Contact> contactList; | 133 | QMap<AbTableItem*, Contact> contactList; |
133 | const QValueList<int> *intFields; | 134 | const QValueList<int> *intFields; |
134 | int currFindRow; | 135 | int currFindRow; |
135 | QString showCat; | 136 | QString showCat; |
136 | QStringList choicenames; | 137 | QStringList choicenames; |
137 | bool enablePainting; | 138 | bool enablePainting; |
138 | Categories mCat; | 139 | Categories mCat; |
139 | }; | 140 | }; |
140 | #endif // ABTABLE_H | 141 | #endif // ABTABLE_H |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index b7b35bc..95a8521 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -112,274 +112,282 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | |||
112 | listTools = new QPEToolBar( this, "list operations" ); | 112 | listTools = new QPEToolBar( this, "list operations" ); |
113 | 113 | ||
114 | 114 | ||
115 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 115 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
116 | 0, this, 0 ); | 116 | 0, this, 0 ); |
117 | actionNew = a; | 117 | actionNew = a; |
118 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 118 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
119 | a->addTo( edit ); | 119 | a->addTo( edit ); |
120 | a->addTo( listTools ); | 120 | a->addTo( listTools ); |
121 | 121 | ||
122 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 122 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
123 | 0, this, 0 ); | 123 | 0, this, 0 ); |
124 | actionEdit = a; | 124 | actionEdit = a; |
125 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
126 | a->addTo( edit ); | 126 | a->addTo( edit ); |
127 | a->addTo( listTools ); | 127 | a->addTo( listTools ); |
128 | 128 | ||
129 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 129 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
130 | 0, this, 0 ); | 130 | 0, this, 0 ); |
131 | actionTrash = a; | 131 | actionTrash = a; |
132 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
133 | a->addTo( edit ); | 133 | a->addTo( edit ); |
134 | a->addTo( listTools ); | 134 | a->addTo( listTools ); |
135 | 135 | ||
136 | #ifndef MAKE_FOR_SHARP_ROM | 136 | #ifndef MAKE_FOR_SHARP_ROM |
137 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 137 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
138 | QString::null, 0, this, 0 ); | 138 | QString::null, 0, this, 0 ); |
139 | actionFind = a; | 139 | actionFind = a; |
140 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 140 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
141 | a->addTo( edit ); | 141 | a->addTo( edit ); |
142 | a->addTo( listTools ); | 142 | a->addTo( listTools ); |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | 145 | ||
146 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), | 146 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), |
147 | QString::null, 0, this, 0 ); | 147 | QString::null, 0, this, 0 ); |
148 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 148 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
149 | actionMail = a; | 149 | actionMail = a; |
150 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 150 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
151 | a->addTo( edit ); | 151 | a->addTo( edit ); |
152 | a->addTo( listTools ); | 152 | a->addTo( listTools ); |
153 | 153 | ||
154 | 154 | ||
155 | 155 | ||
156 | if ( Ir::supported() ) { | 156 | if ( Ir::supported() ) { |
157 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 157 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
158 | 0, this, 0 ); | 158 | 0, this, 0 ); |
159 | actionBeam = a; | 159 | actionBeam = a; |
160 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 160 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
161 | a->addTo( edit ); | 161 | a->addTo( edit ); |
162 | a->addTo( listTools ); | 162 | a->addTo( listTools ); |
163 | } | 163 | } |
164 | 164 | ||
165 | edit->insertSeparator(); | 165 | edit->insertSeparator(); |
166 | 166 | ||
167 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | 167 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); |
168 | actionPersonal = a; | 168 | actionPersonal = a; |
169 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 169 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
170 | a->addTo( edit ); | 170 | a->addTo( edit ); |
171 | 171 | ||
172 | 172 | ||
173 | a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); | 173 | a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); |
174 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 174 | connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
175 | a->addTo( edit ); | 175 | a->addTo( edit ); |
176 | 176 | ||
177 | // Create Views | 177 | // Create Views |
178 | 178 | ||
179 | // This is safe to call without checking to see if it exists... | 179 | // This is safe to call without checking to see if it exists... |
180 | // not to mention it also does the necessary stuff for the | 180 | // not to mention it also does the necessary stuff for the |
181 | // journaling... | 181 | // journaling... |
182 | QString str = addressbookXMLFilename(); | 182 | QString str = addressbookXMLFilename(); |
183 | if ( str.isNull() ) { | 183 | if ( str.isNull() ) { |
184 | QMessageBox::warning( this, tr("Out of Space"), | 184 | QMessageBox::warning( this, tr("Out of Space"), |
185 | tr("There is not enough space to create\n" | 185 | tr("There is not enough space to create\n" |
186 | "neccessary startup files.\n" | 186 | "neccessary startup files.\n" |
187 | "\nFree up some space before\nentering data!") | 187 | "\nFree up some space before\nentering data!") |
188 | ); | 188 | ); |
189 | } | 189 | } |
190 | 190 | ||
191 | abList = new AbTable( &orderedFields, this, "table" ); | 191 | abList = new AbTable( &orderedFields, this, "table" ); |
192 | abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 192 | abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
193 | connect( abList, SIGNAL( empty( bool ) ), | 193 | connect( abList, SIGNAL( empty( bool ) ), |
194 | this, SLOT( listIsEmpty( bool ) ) ); | 194 | this, SLOT( listIsEmpty( bool ) ) ); |
195 | connect( abList, SIGNAL( details() ), | 195 | connect( abList, SIGNAL( details() ), |
196 | this, SLOT( slotListView() ) ); | 196 | this, SLOT( slotListView() ) ); |
197 | connect( abList, SIGNAL(currentChanged(int,int)), | 197 | connect( abList, SIGNAL(currentChanged(int,int)), |
198 | this, SLOT(slotUpdateToolbar()) ); | 198 | this, SLOT(slotUpdateToolbar()) ); |
199 | 199 | ||
200 | mView = 0; | 200 | mView = 0; |
201 | 201 | ||
202 | abList->load( addressbookXMLFilename() ); | 202 | abList->load( addressbookXMLFilename() ); |
203 | if ( QFile::exists(addressbookOldXMLFilename()) ) { | 203 | if ( QFile::exists(addressbookOldXMLFilename()) ) { |
204 | abList->load( addressbookOldXMLFilename() ); | 204 | abList->load( addressbookOldXMLFilename() ); |
205 | QFile::remove(addressbookOldXMLFilename()); | 205 | QFile::remove(addressbookOldXMLFilename()); |
206 | } | 206 | } |
207 | 207 | ||
208 | catMenu = new QPopupMenu( this ); | 208 | catMenu = new QPopupMenu( this ); |
209 | catMenu->setCheckable( TRUE ); | 209 | catMenu->setCheckable( TRUE ); |
210 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 210 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
211 | populateCategories(); | 211 | populateCategories(); |
212 | 212 | ||
213 | mbList->insertItem( tr("View"), catMenu ); | 213 | mbList->insertItem( tr("View"), catMenu ); |
214 | setCentralWidget( abList ); | 214 | setCentralWidget( abList ); |
215 | 215 | ||
216 | fontMenu = new QPopupMenu(this); | 216 | fontMenu = new QPopupMenu(this); |
217 | fontMenu->setCheckable( true ); | 217 | fontMenu->setCheckable( true ); |
218 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); | 218 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); |
219 | 219 | ||
220 | fontMenu->insertItem("Small", 0); | 220 | fontMenu->insertItem("Small", 0); |
221 | fontMenu->insertItem("Normal", 1); | 221 | fontMenu->insertItem("Normal", 1); |
222 | fontMenu->insertItem("Large", 2); | 222 | fontMenu->insertItem("Large", 2); |
223 | 223 | ||
224 | defaultFont = new QFont( abList->font() ); | 224 | defaultFont = new QFont( abList->font() ); |
225 | 225 | ||
226 | slotSetFont(startFontSize); | 226 | slotSetFont(startFontSize); |
227 | 227 | ||
228 | mbList->insertItem( tr("Font"), fontMenu); | 228 | mbList->insertItem( tr("Font"), fontMenu); |
229 | setCentralWidget(abList); | 229 | setCentralWidget(abList); |
230 | 230 | ||
231 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 231 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
232 | } | 232 | } |
233 | void AddressbookWindow::slotSetFont( int size ) { | 233 | void AddressbookWindow::slotSetFont( int size ) { |
234 | 234 | ||
235 | if (size > 2 || size < 0) | 235 | if (size > 2 || size < 0) |
236 | size = 1; | 236 | size = 1; |
237 | 237 | ||
238 | startFontSize = size; | 238 | startFontSize = size; |
239 | 239 | ||
240 | QFont *currentFont; | ||
241 | |||
240 | switch (size) { | 242 | switch (size) { |
241 | case 0: | 243 | case 0: |
242 | fontMenu->setItemChecked(0, true); | 244 | fontMenu->setItemChecked(0, true); |
243 | fontMenu->setItemChecked(1, false); | 245 | fontMenu->setItemChecked(1, false); |
244 | fontMenu->setItemChecked(2, false); | 246 | fontMenu->setItemChecked(2, false); |
245 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 247 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
248 | currentFont = new QFont (abList->font()); | ||
249 | abList->resizeRows(currentFont->pixelSize() + 7); | ||
246 | break; | 250 | break; |
247 | case 1: | 251 | case 1: |
248 | fontMenu->setItemChecked(0, false); | 252 | fontMenu->setItemChecked(0, false); |
249 | fontMenu->setItemChecked(1, true); | 253 | fontMenu->setItemChecked(1, true); |
250 | fontMenu->setItemChecked(2, false); | 254 | fontMenu->setItemChecked(2, false); |
251 | abList->setFont( *defaultFont ); | 255 | abList->setFont( *defaultFont ); |
256 | currentFont = new QFont (abList->font()); | ||
257 | abList->resizeRows(currentFont->pixelSize() + 7); | ||
252 | break; | 258 | break; |
253 | case 2: | 259 | case 2: |
254 | fontMenu->setItemChecked(0, false); | 260 | fontMenu->setItemChecked(0, false); |
255 | fontMenu->setItemChecked(1, false); | 261 | fontMenu->setItemChecked(1, false); |
256 | fontMenu->setItemChecked(2, true); | 262 | fontMenu->setItemChecked(2, true); |
257 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 263 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
264 | currentFont = new QFont (abList->font()); | ||
265 | abList->resizeRows(currentFont->pixelSize() + 7); | ||
258 | break; | 266 | break; |
259 | } | 267 | } |
260 | } | 268 | } |
261 | 269 | ||
262 | 270 | ||
263 | void AddressbookWindow::setDocument( const QString &filename ) | 271 | void AddressbookWindow::setDocument( const QString &filename ) |
264 | { | 272 | { |
265 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; | 273 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; |
266 | 274 | ||
267 | QValueList<Contact> cl = Contact::readVCard( filename ); | 275 | QValueList<Contact> cl = Contact::readVCard( filename ); |
268 | for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { | 276 | for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { |
269 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") | 277 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") |
270 | // .arg( (*it).fullName() ); | 278 | // .arg( (*it).fullName() ); |
271 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == | 279 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == |
272 | // QMessageBox::Ok ) { | 280 | // QMessageBox::Ok ) { |
273 | abList->addEntry( *it ); | 281 | abList->addEntry( *it ); |
274 | // } | 282 | // } |
275 | } | 283 | } |
276 | 284 | ||
277 | } | 285 | } |
278 | 286 | ||
279 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 287 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
280 | { | 288 | { |
281 | QMainWindow::resizeEvent( e ); | 289 | QMainWindow::resizeEvent( e ); |
282 | 290 | ||
283 | if ( centralWidget() == abList ) | 291 | if ( centralWidget() == abList ) |
284 | showList(); | 292 | showList(); |
285 | else if ( centralWidget() == mView ) | 293 | else if ( centralWidget() == mView ) |
286 | showView(); | 294 | showView(); |
287 | } | 295 | } |
288 | 296 | ||
289 | AddressbookWindow::~AddressbookWindow() | 297 | AddressbookWindow::~AddressbookWindow() |
290 | { | 298 | { |
291 | Config cfg("AddressBook"); | 299 | Config cfg("AddressBook"); |
292 | cfg.setGroup("Font"); | 300 | cfg.setGroup("Font"); |
293 | cfg.writeEntry("fontSize", startFontSize); | 301 | cfg.writeEntry("fontSize", startFontSize); |
294 | } | 302 | } |
295 | 303 | ||
296 | void AddressbookWindow::slotUpdateToolbar() | 304 | void AddressbookWindow::slotUpdateToolbar() |
297 | { | 305 | { |
298 | Contact ce = abList->currentEntry(); | 306 | Contact ce = abList->currentEntry(); |
299 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 307 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
300 | } | 308 | } |
301 | 309 | ||
302 | void AddressbookWindow::showList() | 310 | void AddressbookWindow::showList() |
303 | { | 311 | { |
304 | if ( mView ) mView->hide(); | 312 | if ( mView ) mView->hide(); |
305 | setCentralWidget( abList ); | 313 | setCentralWidget( abList ); |
306 | abList->show(); | 314 | abList->show(); |
307 | // update our focues... (or use a stack widget!); | 315 | // update our focues... (or use a stack widget!); |
308 | abList->setFocus(); | 316 | abList->setFocus(); |
309 | } | 317 | } |
310 | 318 | ||
311 | void AddressbookWindow::showView() | 319 | void AddressbookWindow::showView() |
312 | { | 320 | { |
313 | if ( abList->numRows() > 0 ) { | 321 | if ( abList->numRows() > 0 ) { |
314 | abList->hide(); | 322 | abList->hide(); |
315 | setCentralWidget( abView() ); | 323 | setCentralWidget( abView() ); |
316 | mView->show(); | 324 | mView->show(); |
317 | mView->setFocus(); | 325 | mView->setFocus(); |
318 | } | 326 | } |
319 | } | 327 | } |
320 | 328 | ||
321 | void AddressbookWindow::slotListNew() | 329 | void AddressbookWindow::slotListNew() |
322 | { | 330 | { |
323 | Contact cnt; | 331 | Contact cnt; |
324 | if( !syncing ) { | 332 | if( !syncing ) { |
325 | if ( abEditor ) | 333 | if ( abEditor ) |
326 | abEditor->setEntry( cnt ); | 334 | abEditor->setEntry( cnt ); |
327 | abView()->init( cnt ); | 335 | abView()->init( cnt ); |
328 | editEntry( NewEntry ); | 336 | editEntry( NewEntry ); |
329 | } else { | 337 | } else { |
330 | QMessageBox::warning(this, tr("Contacts"), | 338 | QMessageBox::warning(this, tr("Contacts"), |
331 | tr("Can not edit data, currently syncing")); | 339 | tr("Can not edit data, currently syncing")); |
332 | } | 340 | } |
333 | } | 341 | } |
334 | 342 | ||
335 | void AddressbookWindow::slotListView() | 343 | void AddressbookWindow::slotListView() |
336 | { | 344 | { |
337 | abView()->init( abList->currentEntry() ); | 345 | abView()->init( abList->currentEntry() ); |
338 | mView->sync(); | 346 | mView->sync(); |
339 | showView(); | 347 | showView(); |
340 | } | 348 | } |
341 | 349 | ||
342 | void AddressbookWindow::slotListDelete() | 350 | void AddressbookWindow::slotListDelete() |
343 | { | 351 | { |
344 | if(!syncing) { | 352 | if(!syncing) { |
345 | Contact tmpEntry = abList->currentEntry(); | 353 | Contact tmpEntry = abList->currentEntry(); |
346 | 354 | ||
347 | // get a name, do the best we can... | 355 | // get a name, do the best we can... |
348 | QString strName = tmpEntry.fullName(); | 356 | QString strName = tmpEntry.fullName(); |
349 | if ( strName.isEmpty() ) { | 357 | if ( strName.isEmpty() ) { |
350 | strName = tmpEntry.company(); | 358 | strName = tmpEntry.company(); |
351 | if ( strName.isEmpty() ) | 359 | if ( strName.isEmpty() ) |
352 | strName = "No Name"; | 360 | strName = "No Name"; |
353 | } | 361 | } |
354 | 362 | ||
355 | 363 | ||
356 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 364 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
357 | strName ) ) { | 365 | strName ) ) { |
358 | abList->deleteCurrentEntry(); | 366 | abList->deleteCurrentEntry(); |
359 | showList(); | 367 | showList(); |
360 | } | 368 | } |
361 | } else { | 369 | } else { |
362 | QMessageBox::warning( this, tr("Contacts"), | 370 | QMessageBox::warning( this, tr("Contacts"), |
363 | tr("Can not edit data, currently syncing") ); | 371 | tr("Can not edit data, currently syncing") ); |
364 | } | 372 | } |
365 | } | 373 | } |
366 | 374 | ||
367 | void AddressbookWindow::slotViewBack() | 375 | void AddressbookWindow::slotViewBack() |
368 | { | 376 | { |
369 | showList(); | 377 | showList(); |
370 | } | 378 | } |
371 | 379 | ||
372 | void AddressbookWindow::slotViewEdit() | 380 | void AddressbookWindow::slotViewEdit() |
373 | { | 381 | { |
374 | if(!syncing) { | 382 | if(!syncing) { |
375 | if (actionPersonal->isOn()) { | 383 | if (actionPersonal->isOn()) { |
376 | editPersonal(); | 384 | editPersonal(); |
377 | } else { | 385 | } else { |
378 | if ( !bAbEditFirstTime ) | 386 | if ( !bAbEditFirstTime ) |
379 | abEditor->setEntry( abList->currentEntry() ); | 387 | abEditor->setEntry( abList->currentEntry() ); |
380 | editEntry( EditEntry ); | 388 | editEntry( EditEntry ); |
381 | } | 389 | } |
382 | } else { | 390 | } else { |
383 | QMessageBox::warning( this, tr("Contacts"), | 391 | QMessageBox::warning( this, tr("Contacts"), |
384 | tr("Can not edit data, currently syncing") ); | 392 | tr("Can not edit data, currently syncing") ); |
385 | } | 393 | } |