summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp11
-rw-r--r--core/pim/addressbook/abtable.h1
-rw-r--r--core/pim/addressbook/addressbook.cpp8
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,84 +1,86 @@
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
39static bool contactCompare( const Contact &cnt, const QRegExp &r, int category ); 41static 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
42static QString journalFileName() 44static 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
57AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, 59AbTableItem::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
65int AbTableItem::alignment() const 67int AbTableItem::alignment() const
66{ 68{
67 return AlignLeft|AlignVCenter; 69 return AlignLeft|AlignVCenter;
68} 70}
69 71
70QString AbTableItem::key() const 72QString 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...
76void AbTableItem::setItem( const QString &txt, const QString &secondKey ) 78void 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/*!
@@ -388,128 +390,137 @@ QString AbTable::findContactContact( const Contact &entry )
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
442void AbTable::addEntry( const Contact &newCnt ) 444void 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
454void AbTable::resizeRows( int size ) {
455
456 if (numRows()) {
457 for (int i = 0; i < numRows(); i++) {
458 setRowHeight( i, size );
459 }
460 }
461}
462
452void AbTable::updateJournal( const Contact &cnt, 463void 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
471bool AbTable::save( const QString &fn ) 482bool 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.
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
@@ -25,116 +25,117 @@
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
32class AbTableItem : public QTableItem 32class AbTableItem : public QTableItem
33{ 33{
34public: 34public:
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
43private: 43private:
44 QString sortKey; 44 QString sortKey;
45}; 45};
46 46
47class AbPickItem : public QTableItem 47class AbPickItem : public QTableItem
48{ 48{
49public: 49public:
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
55private: 55private:
56 QGuardedPtr<QComboBox> cb; 56 QGuardedPtr<QComboBox> cb;
57}; 57};
58 58
59class AbTable : public QTable 59class AbTable : public QTable
60{ 60{
61 Q_OBJECT 61 Q_OBJECT
62 62
63public: 63public:
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
93public slots: 94public 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 );
96signals: 97signals:
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
102protected: 103protected:
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
110protected slots: 111protected 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
116private: 117private:
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
@@ -176,146 +176,154 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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}
233void AddressbookWindow::slotSetFont( int size ) { 233void 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
263void AddressbookWindow::setDocument( const QString &filename ) 271void 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
279void AddressbookWindow::resizeEvent( QResizeEvent *e ) 287void 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
289AddressbookWindow::~AddressbookWindow() 297AddressbookWindow::~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
296void AddressbookWindow::slotUpdateToolbar() 304void 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
302void AddressbookWindow::showList() 310void 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
311void AddressbookWindow::showView() 319void 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
321void AddressbookWindow::slotListNew() 329void AddressbookWindow::slotListNew()