summaryrefslogtreecommitdiff
authortux_mike <tux_mike>2002-04-10 03:29:24 (UTC)
committer tux_mike <tux_mike>2002-04-10 03:29:24 (UTC)
commit4eb2a1b8698fdcca7a2c74a3fe9a88a297607754 (patch) (unidiff)
tree0787600f2d3e0d4bb314124fff55fa3046bfb2f5
parent0d5d67ab1225446f1796a08d97c0cc025922958f (diff)
downloadopie-4eb2a1b8698fdcca7a2c74a3fe9a88a297607754.zip
opie-4eb2a1b8698fdcca7a2c74a3fe9a88a297607754.tar.gz
opie-4eb2a1b8698fdcca7a2c74a3fe9a88a297607754.tar.bz2
Made rows resize with fonts.
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,44 +1,46 @@
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");
@@ -428,48 +430,57 @@ QString AbTable::findContactContact( const Contact &entry )
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
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
@@ -65,48 +65,49 @@ public:
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 );
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
@@ -216,66 +216,74 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 );