summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp93
-rw-r--r--core/pim/addressbook/abtable.h1
-rw-r--r--core/pim/addressbook/abview.cpp14
-rw-r--r--core/pim/addressbook/abview.h2
-rw-r--r--core/pim/addressbook/version.h4
5 files changed, 23 insertions, 91 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 49e66ad..60f3177 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -1,773 +1,694 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file is part of Qt Palmtop Environment. 5** This file is part of Qt Palmtop Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include <opie2/odebug.h> 22#include <opie2/odebug.h>
23#include <opie2/opimrecordlist.h> 23#include <opie2/opimrecordlist.h>
24 24
25#include <qpe/timestring.h> 25#include <qpe/timestring.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27 27
28#include "abtable.h" 28#include "abtable.h"
29 29
30#include <errno.h> 30#include <errno.h>
31#include <fcntl.h> 31#include <fcntl.h>
32#include <unistd.h> 32#include <unistd.h>
33#include <stdlib.h> 33#include <stdlib.h>
34 34
35#include <ctype.h> //toupper() for key hack 35#include <ctype.h> //toupper() for key hack
36 36
37#if 0 37#if 0
38 38
39/*! 39/*!
40 \class AbTableItem abtable.h 40 \class AbTableItem abtable.h
41 41
42 \brief QTableItem based class for showing a field of an entry 42 \brief QTableItem based class for showing a field of an entry
43*/ 43*/
44 44
45AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, 45AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s,
46 const QString &secondSortKey) 46 const QString &secondSortKey)
47 : QTableItem( t, et, s ) 47 : QTableItem( t, et, s )
48{ 48{
49 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); 49 // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower();
50 sortKey = Qtopia::buildSortKey( s, secondSortKey ); 50 sortKey = Qtopia::buildSortKey( s, secondSortKey );
51} 51}
52 52
53int AbTableItem::alignment() const 53int AbTableItem::alignment() const
54{ 54{
55 return AlignLeft|AlignVCenter; 55 return AlignLeft|AlignVCenter;
56} 56}
57 57
58QString AbTableItem::key() const 58QString AbTableItem::key() const
59{ 59{
60 return sortKey; 60 return sortKey;
61} 61}
62 62
63// A way to reset the item, without out doing a delete or a new... 63// A way to reset the item, without out doing a delete or a new...
64void AbTableItem::setItem( const QString &txt, const QString &secondKey ) 64void AbTableItem::setItem( const QString &txt, const QString &secondKey )
65{ 65{
66 setText( txt ); 66 setText( txt );
67 sortKey = Qtopia::buildSortKey( txt, secondKey ); 67 sortKey = Qtopia::buildSortKey( txt, secondKey );
68 68
69 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); 69 // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower();
70} 70}
71 71
72/*! 72/*!
73 \class AbPickItem abtable.h 73 \class AbPickItem abtable.h
74 74
75 \brief QTableItem based class for showing slection of an entry 75 \brief QTableItem based class for showing slection of an entry
76*/ 76*/
77 77
78AbPickItem::AbPickItem( QTable *t ) : 78AbPickItem::AbPickItem( QTable *t ) :
79 QTableItem(t, WhenCurrent, "?") 79 QTableItem(t, WhenCurrent, "?")
80{ 80{
81} 81}
82 82
83QWidget *AbPickItem::createEditor() const 83QWidget *AbPickItem::createEditor() const
84{ 84{
85 QComboBox* combo = new QComboBox( table()->viewport() ); 85 QComboBox* combo = new QComboBox( table()->viewport() );
86 ( (AbPickItem*)this )->cb = combo; 86 ( (AbPickItem*)this )->cb = combo;
87 AbTable* t = static_cast<AbTable*>(table()); 87 AbTable* t = static_cast<AbTable*>(table());
88 QStringList c = t->choiceNames(); 88 QStringList c = t->choiceNames();
89 int cur = 0; 89 int cur = 0;
90 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { 90 for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
91 if ( *it == text() ) 91 if ( *it == text() )
92 cur = combo->count(); 92 cur = combo->count();
93 combo->insertItem(*it); 93 combo->insertItem(*it);
94 } 94 }
95 combo->setCurrentItem(cur); 95 combo->setCurrentItem(cur);
96 return combo; 96 return combo;
97} 97}
98 98
99void AbPickItem::setContentFromEditor( QWidget *w ) 99void AbPickItem::setContentFromEditor( QWidget *w )
100{ 100{
101 if ( w->inherits("QComboBox") ) 101 if ( w->inherits("QComboBox") )
102 setText( ( (QComboBox*)w )->currentText() ); 102 setText( ( (QComboBox*)w )->currentText() );
103 else 103 else
104 QTableItem::setContentFromEditor( w ); 104 QTableItem::setContentFromEditor( w );
105} 105}
106 106
107#endif 107#endif
108 108
109/*! 109/*!
110 \class AbTable abtable.h 110 \class AbTable abtable.h
111 111
112 \brief QTable based class for showing a list of entries 112 \brief QTable based class for showing a list of entries
113*/ 113*/
114 114
115AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) 115AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
116 : QTable( parent, name ), 116 : QTable( parent, name ),
117 lastSortCol( -1 ), 117 lastSortCol( -1 ),
118 asc( TRUE ), 118 asc( TRUE ),
119 intFields( order ), 119 intFields( order ),
120 enablePainting( true ), 120 enablePainting( true ),
121 columnVisible( true ), 121 columnVisible( true ),
122 countNested( 0 ) 122 countNested( 0 )
123{ 123{
124 //odebug << "C'tor start" << oendl; 124 //odebug << "C'tor start" << oendl;
125 setSelectionMode( NoSelection ); 125 setSelectionMode( NoSelection );
126 init(); 126 init();
127 setSorting( TRUE ); 127 setSorting( false ); // The table should not sort by itself!
128
128 connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), 129 connect( this, SIGNAL(clicked(int,int,int,const QPoint&)),
129 this, SLOT(itemClicked(int,int)) ); 130 this, SLOT(itemClicked(int,int)) );
130 131
131 // contactList.clear(); 132 // contactList.clear();
132 //odebug << "C'tor end" << oendl; 133 //odebug << "C'tor end" << oendl;
133} 134}
134 135
135AbTable::~AbTable() 136AbTable::~AbTable()
136{ 137{
137} 138}
138 139
139void AbTable::init() 140void AbTable::init()
140{ 141{
141 // :SX showChar = '\0'; 142 // :SX showChar = '\0';
142 setNumRows( 0 ); 143 setNumRows( 0 );
143 setNumCols( 2 ); 144 setNumCols( 2 );
144 145
145 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 146 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
146 horizontalHeader()->setLabel( 1, tr( "Contact" )); 147 horizontalHeader()->setLabel( 1, tr( "Contact" ));
147 setLeftMargin( 0 ); 148 setLeftMargin( 0 );
148 verticalHeader()->hide(); 149 verticalHeader()->hide();
149 columnVisible = true; 150 columnVisible = true;
150} 151}
151 152
152void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) 153void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList )
153{ 154{
154 odebug << "AbTable::setContacts()" << oendl; 155 odebug << "AbTable::setContacts()" << oendl;
155 156
156 clear(); 157 clear();
157 m_viewList = viewList; 158 m_viewList = viewList;
158 159
159 setSorting( false );
160 setPaintingEnabled( FALSE ); 160 setPaintingEnabled( FALSE );
161 161
162 setNumRows( m_viewList.count() ); 162 setNumRows( m_viewList.count() );
163 //int row = 0;
164 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
165 // insertIntoTable( *it, row++ );
166
167 // setSorting( true );
168 163
169 // resort();
170 164
171 updateVisible(); 165 updateVisible();
172 166
173 setPaintingEnabled( TRUE ); 167 setPaintingEnabled( TRUE );
174 168
175} 169}
176 170
177void AbTable::setOrderedList( const QValueList<int> ordered ) 171void AbTable::setOrderedList( const QValueList<int> ordered )
178{ 172{
179 intFields = ordered; 173 intFields = ordered;
180} 174}
181 175
182 176
183bool AbTable::selectContact( int UID ) 177bool AbTable::selectContact( int UID )
184{ 178{
185 odebug << "AbTable::selectContact( " << UID << " )" << oendl; 179 odebug << "AbTable::selectContact( " << UID << " )" << oendl;
186 int rows = numRows(); 180 int rows = numRows();
187 bool found = false; 181 bool found = false;
188 182
189 setPaintingEnabled( FALSE ); 183 setPaintingEnabled( FALSE );
190 odebug << "Search start" << oendl; 184 odebug << "Search start" << oendl;
191 for ( int r = 0; r < rows; ++r ) { 185 for ( int r = 0; r < rows; ++r ) {
192 if ( m_viewList.uidAt( r ) == UID ){ 186 if ( m_viewList.uidAt( r ) == UID ){
193 ensureCellVisible( r, 0 ); 187 ensureCellVisible( r, 0 );
194 setCurrentCell( r, 0 ); 188 setCurrentCell( r, 0 );
195 found = true; 189 found = true;
196 break; 190 break;
197 } 191 }
198 } 192 }
199 odebug << "Search end" << oendl; 193 odebug << "Search end" << oendl;
200 194
201 if ( !found ){ 195 if ( !found ){
202 ensureCellVisible( 0,0 ); 196 ensureCellVisible( 0,0 );
203 setCurrentCell( 0, 0 ); 197 setCurrentCell( 0, 0 );
204 } 198 }
205 199
206 setPaintingEnabled( TRUE ); 200 setPaintingEnabled( TRUE );
207 201
208 return true; 202 return true;
209} 203}
210 204
211#if 0
212void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row )
213{
214 odebug << "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, "
215 << row << " )" << oendl;
216 QString strName;
217 ContactItem contactItem;
218
219 strName = findContactName( cnt );
220 contactItem = findContactContact( cnt, row );
221
222 AbTableItem *ati;
223 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value );
224 contactList.insert( ati, cnt );
225 setItem( row, 0, ati );
226 ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName);
227 if ( !contactItem.icon.isNull() )
228 ati->setPixmap( contactItem.icon );
229 setItem( row, 1, ati );
230
231 //### cannot do this; table only has two columns at this point
232 // setItem( row, 2, new AbPickItem( this ) );
233
234}
235#endif
236
237 205
238void AbTable::columnClicked( int col ) 206void AbTable::columnClicked( int col )
239{ 207{
240 if ( !sorting() ) 208 odebug << "columClicked(" << col << ")" << oendl;
241 return;
242
243 if ( lastSortCol == -1 )
244 lastSortCol = col;
245 209
246 if ( col == lastSortCol ) { 210 if ( col == 0 ){
211 odebug << "Change sort order: " << asc << oendl;
247 asc = !asc; 212 asc = !asc;
248 } else { 213 emit signalSortOrderChanged( asc );
249 lastSortCol = col;
250 asc = TRUE;
251 } 214 }
252 //QMessageBox::information( this, "resort", "columnClicked" );
253 resort();
254} 215}
255 216
256void AbTable::resort() 217void AbTable::resort()
257{ 218{
258 owarn << "void AbTable::resort() NOT POSSIBLE !!" << oendl; 219 owarn << "void AbTable::resort() NOT POSSIBLE !!" << oendl;
259#if 0 220
260 setPaintingEnabled( FALSE );
261 if ( sorting() ) {
262 if ( lastSortCol == -1 )
263 lastSortCol = 0;
264 sortColumn( lastSortCol, asc, TRUE );
265 //QMessageBox::information( this, "resort", "resort" );
266 updateVisible();
267 }
268 setPaintingEnabled( TRUE );
269#endif
270} 221}
271 222
272Opie::OPimContact AbTable::currentEntry() 223Opie::OPimContact AbTable::currentEntry()
273{ 224{
274 return m_viewList[currentRow()]; 225 return m_viewList[currentRow()];
275} 226}
276 227
277int AbTable::currentEntry_UID() 228int AbTable::currentEntry_UID()
278{ 229{
279 return ( currentEntry().uid() ); 230 return ( currentEntry().uid() );
280} 231}
281 232
282void AbTable::clear() 233void AbTable::clear()
283{ 234{
284 odebug << "void AbTable::clear()" << oendl; 235 odebug << "void AbTable::clear()" << oendl;
285 // contactList.clear(); 236 // contactList.clear();
286 237
287 setPaintingEnabled( FALSE ); 238 setPaintingEnabled( FALSE );
288 for ( int r = 0; r < numRows(); ++r ) { 239 for ( int r = 0; r < numRows(); ++r ) {
289 for ( int c = 0; c < numCols(); ++c ) { 240 for ( int c = 0; c < numCols(); ++c ) {
290 if ( cellWidget( r, c ) ) 241 if ( cellWidget( r, c ) )
291 clearCellWidget( r, c ); 242 clearCellWidget( r, c );
292 clearCell( r, c ); 243 clearCell( r, c );
293 } 244 }
294 } 245 }
295 setNumRows( 0 ); 246 setNumRows( 0 );
296 setPaintingEnabled( TRUE ); 247 setPaintingEnabled( TRUE );
297} 248}
298 249
299// Refresh updates column 2 if the contactsettings changed 250// Refresh updates column 2 if the contactsettings changed
300void AbTable::refresh() 251void AbTable::refresh()
301{ 252{
302 owarn << "void AbTable::refresh() NOT IMPLEMENTED !!" << oendl; 253 owarn << "void AbTable::refresh() NOT IMPLEMENTED !!" << oendl;
303 254
304#if 0 255#if 0
305 int rows = numRows(); 256 int rows = numRows();
306 AbTableItem *abi; 257 AbTableItem *abi;
307 ContactItem contactItem; 258 ContactItem contactItem;
308 259
309 setPaintingEnabled( FALSE ); 260 setPaintingEnabled( FALSE );
310 for ( int r = 0; r < rows; ++r ) { 261 for ( int r = 0; r < rows; ++r ) {
311 abi = static_cast<AbTableItem*>( item(r, 0) ); 262 abi = static_cast<AbTableItem*>( item(r, 0) );
312 contactItem = findContactContact( contactList[abi], r ); 263 contactItem = findContactContact( contactList[abi], r );
313 static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); 264 static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() );
314 if ( !contactItem.icon.isNull() ){ 265 if ( !contactItem.icon.isNull() ){
315 static_cast<AbTableItem*>( item(r, 1) )-> 266 static_cast<AbTableItem*>( item(r, 1) )->
316 setPixmap( contactItem.icon ); 267 setPixmap( contactItem.icon );
317 }else{ 268 }else{
318 static_cast<AbTableItem*>( item(r, 1) )-> 269 static_cast<AbTableItem*>( item(r, 1) )->
319 setPixmap( QPixmap() ); 270 setPixmap( QPixmap() );
320 } 271 }
321 } 272 }
322 resort(); 273 resort();
323 setPaintingEnabled( TRUE ); 274 setPaintingEnabled( TRUE );
324 275
325#endif 276#endif
326} 277}
327 278
328void AbTable::keyPressEvent( QKeyEvent *e ) 279void AbTable::keyPressEvent( QKeyEvent *e )
329{ 280{
330 char key = toupper( e->ascii() ); 281 char key = toupper( e->ascii() );
331 282
332 if ( key >= 'A' && key <= 'Z' ) 283 if ( key >= 'A' && key <= 'Z' )
333 moveTo( key ); 284 moveTo( key );
334 285
335 // odebug << "Received key .." << oendl; 286 // odebug << "Received key .." << oendl;
336 switch( e->key() ) { 287 switch( e->key() ) {
337 case Qt::Key_Space: 288 case Qt::Key_Space:
338 case Qt::Key_Return: 289 case Qt::Key_Return:
339 case Qt::Key_Enter: 290 case Qt::Key_Enter:
340 emit signalSwitch(); 291 emit signalSwitch();
341 break; 292 break;
342 // case Qt::Key_Up: 293 // case Qt::Key_Up:
343 // odebug << "a" << oendl; 294 // odebug << "a" << oendl;
344 // emit signalKeyUp(); 295 // emit signalKeyUp();
345 // break; 296 // break;
346 // case Qt::Key_Down: 297 // case Qt::Key_Down:
347 // odebug << "b" << oendl; 298 // odebug << "b" << oendl;
348 // emit signalKeyDown(); 299 // emit signalKeyDown();
349 // break; 300 // break;
350 default: 301 default:
351 QTable::keyPressEvent( e ); 302 QTable::keyPressEvent( e );
352 } 303 }
353 304
354} 305}
355 306
356void AbTable::moveTo( char /*c*/ ) 307void AbTable::moveTo( char /*c*/ )
357{ 308{
358 odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl; 309 odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl;
359 310
360#if 0
361 int rows = numRows();
362 QString value;
363 AbTableItem *abi;
364 int r;
365 if ( asc ) {
366 r = 0;
367 while ( r < rows-1) {
368 abi = static_cast<AbTableItem*>( item(r, 0) );
369 QChar first = abi->key()[0];
370 //### is there a bug in QChar to char comparison???
371 if ( first.row() || first.cell() >= c )
372 break;
373 r++;
374 }
375 } else {
376 //### should probably disable reverse sorting instead
377 r = rows - 1;
378 while ( r > 0 ) {
379 abi = static_cast<AbTableItem*>( item(r, 0) );
380 QChar first = abi->key()[0];
381 //### is there a bug in QChar to char comparison???
382 if ( first.row() || first.cell() >= c )
383 break;
384 r--;
385 }
386 }
387 setCurrentCell( r, currentColumn() );
388
389#endif
390} 311}
391 312
392#if 0 313#if 0
393// Useless.. Nobody uses it .. (se) 314// Useless.. Nobody uses it .. (se)
394QString AbTable::findContactName( const Opie::OPimContact &entry ) 315QString AbTable::findContactName( const Opie::OPimContact &entry )
395{ 316{
396 // We use the fileAs, then company, defaultEmail 317 // We use the fileAs, then company, defaultEmail
397 QString str; 318 QString str;
398 str = entry.fileAs(); 319 str = entry.fileAs();
399 if ( str.isEmpty() ) { 320 if ( str.isEmpty() ) {
400 str = entry.company(); 321 str = entry.company();
401 if ( str.isEmpty() ) { 322 if ( str.isEmpty() ) {
402 str = entry.defaultEmail(); 323 str = entry.defaultEmail();
403 } 324 }
404 } 325 }
405 return str; 326 return str;
406} 327}
407#endif 328#endif
408 329
409 330
410void AbTable::resizeRows() { 331void AbTable::resizeRows() {
411 /* 332 /*
412 if (numRows()) { 333 if (numRows()) {
413 for (int i = 0; i < numRows(); i++) { 334 for (int i = 0; i < numRows(); i++) {
414 setRowHeight( i, size ); 335 setRowHeight( i, size );
415 } 336 }
416 } 337 }
417 updateVisible(); 338 updateVisible();
418 */ 339 */
419} 340}
420 341
421 342
422void AbTable::realignTable() 343void AbTable::realignTable()
423{ 344{
424 //odebug << "void AbTable::realignTable()" << oendl; 345 //odebug << "void AbTable::realignTable()" << oendl;
425 346
426 setPaintingEnabled( FALSE ); 347 setPaintingEnabled( FALSE );
427 348
428 resizeRows(); 349 resizeRows();
429 fitColumns(); 350 fitColumns();
430 351
431 setPaintingEnabled( TRUE ); 352 setPaintingEnabled( TRUE );
432 353
433} 354}
434 355
435 356
436 357
437 358
438#if QT_VERSION <= 230 359#if QT_VERSION <= 230
439#ifndef SINGLE_APP 360#ifndef SINGLE_APP
440void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) 361void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
441{ 362{
442 // Region of the rect we should draw 363 // Region of the rect we should draw
443 QRegion reg( QRect( cx, cy, cw, ch ) ); 364 QRegion reg( QRect( cx, cy, cw, ch ) );
444 // Subtract the table from it 365 // Subtract the table from it
445 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); 366 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
446 // And draw the rectangles (transformed as needed) 367 // And draw the rectangles (transformed as needed)
447 QArray<QRect> r = reg.rects(); 368 QArray<QRect> r = reg.rects();
448 for (unsigned int i=0; i<r.count(); i++) 369 for (unsigned int i=0; i<r.count(); i++)
449 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); 370 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
450} 371}
451#endif 372#endif
452#endif 373#endif
453 374
454 375
455// int AbTable::rowHeight( int ) const 376// int AbTable::rowHeight( int ) const
456// { 377// {
457// return 18; 378// return 18;
458// } 379// }
459 380
460// int AbTable::rowPos( int row ) const 381// int AbTable::rowPos( int row ) const
461// { 382// {
462// return 18*row; 383// return 18*row;
463// } 384// }
464 385
465// int AbTable::rowAt( int pos ) const 386// int AbTable::rowAt( int pos ) const
466// { 387// {
467// return QMIN( pos/18, numRows()-1 ); 388// return QMIN( pos/18, numRows()-1 );
468// } 389// }
469 390
470 391
471 392
472void AbTable::fitColumns() 393void AbTable::fitColumns()
473{ 394{
474 odebug << "void AbTable::fitColumns()" << oendl; 395 odebug << "void AbTable::fitColumns()" << oendl;
475 int contentsWidth = visibleWidth() / 2; 396 int contentsWidth = visibleWidth() / 2;
476 // Fix to better value 397 // Fix to better value
477 // contentsWidth = 130; 398 // contentsWidth = 130;
478 399
479 setPaintingEnabled( FALSE ); 400 setPaintingEnabled( FALSE );
480 401
481 if ( columnVisible == false ){ 402 if ( columnVisible == false ){
482 showColumn(0); 403 showColumn(0);
483 columnVisible = true; 404 columnVisible = true;
484 } 405 }
485 406
486 //odebug << "Width: " << contentsWidth << oendl; 407 //odebug << "Width: " << contentsWidth << oendl;
487 408
488 setColumnWidth( 0, contentsWidth ); 409 setColumnWidth( 0, contentsWidth );
489 adjustColumn(1); 410 adjustColumn(1);
490 if ( columnWidth(1) < contentsWidth ) 411 if ( columnWidth(1) < contentsWidth )
491 setColumnWidth( 1, contentsWidth ); 412 setColumnWidth( 1, contentsWidth );
492 413
493 setPaintingEnabled( TRUE ); 414 setPaintingEnabled( TRUE );
494} 415}
495 416
496void AbTable::show() 417void AbTable::show()
497{ 418{
498 //odebug << "void AbTable::show()" << oendl; 419 //odebug << "void AbTable::show()" << oendl;
499 realignTable(); 420 realignTable();
500 QTable::show(); 421 QTable::show();
501} 422}
502 423
503#if 0 424#if 0
504void AbTable::setChoiceNames( const QStringList& list) 425void AbTable::setChoiceNames( const QStringList& list)
505{ 426{
506 choicenames = list; 427 choicenames = list;
507 if ( choicenames.isEmpty() ) { 428 if ( choicenames.isEmpty() ) {
508 // hide pick column 429 // hide pick column
509 setNumCols( 2 ); 430 setNumCols( 2 );
510 } else { 431 } else {
511 // show pick column 432 // show pick column
512 setNumCols( 3 ); 433 setNumCols( 3 );
513 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); 434 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
514 horizontalHeader()->setLabel( 2, tr( "Pick" )); 435 horizontalHeader()->setLabel( 2, tr( "Pick" ));
515 } 436 }
516 fitColumns(); 437 fitColumns();
517} 438}
518#endif 439#endif
519 440
520void AbTable::itemClicked(int,int col) 441void AbTable::itemClicked(int,int col)
521{ 442{
522 //odebug << "AbTable::itemClicked(int, col: " << col << ")" << oendl; 443 //odebug << "AbTable::itemClicked(int, col: " << col << ")" << oendl;
523 if ( col == 2 ) { 444 if ( col == 2 ) {
524 return; 445 return;
525 } else { 446 } else {
526 //odebug << "Emitting signalSwitch()" << oendl; 447 //odebug << "Emitting signalSwitch()" << oendl;
527 emit signalSwitch(); 448 emit signalSwitch();
528 } 449 }
529} 450}
530 451
531#if 0 452#if 0
532QStringList AbTable::choiceNames() const 453QStringList AbTable::choiceNames() const
533{ 454{
534 return choicenames; 455 return choicenames;
535} 456}
536 457
537#endif 458#endif
538void AbTable::setChoiceSelection( const QValueList<int>& list ) 459void AbTable::setChoiceSelection( const QValueList<int>& list )
539{ 460{
540 intFields = list; 461 intFields = list;
541} 462}
542 463
543QStringList AbTable::choiceSelection(int /*index*/) const 464QStringList AbTable::choiceSelection(int /*index*/) const
544{ 465{
545 QStringList r; 466 QStringList r;
546 /* ###### 467 /* ######
547 468
548 QString selname = choicenames.at(index); 469 QString selname = choicenames.at(index);
549 for (each row) { 470 for (each row) {
550 Opie::OPimContact *c = contactForRow(row); 471 Opie::OPimContact *c = contactForRow(row);
551 if ( text(row,2) == selname ) { 472 if ( text(row,2) == selname ) {
552 r.append(c->email); 473 r.append(c->email);
553 } 474 }
554 } 475 }
555 476
556 */ 477 */
557 return r; 478 return r;
558} 479}
559 480
560 481
561void AbTable::updateVisible() 482void AbTable::updateVisible()
562{ 483{
563 //odebug << "void AbTable::updateVisible()" << oendl; 484 //odebug << "void AbTable::updateVisible()" << oendl;
564 485
565 int visible, 486 int visible,
566 totalRows, 487 totalRows,
567 row, 488 row,
568 selectedRow = 0; 489 selectedRow = 0;
569 490
570 visible = 0; 491 visible = 0;
571 492
572 setPaintingEnabled( FALSE ); 493 setPaintingEnabled( FALSE );
573 494
574 realignTable(); 495 realignTable();
575 496
576 totalRows = numRows(); 497 totalRows = numRows();
577 for ( row = 0; row < totalRows; row++ ) { 498 for ( row = 0; row < totalRows; row++ ) {
578 if ( rowHeight(row) == 0 ) { 499 if ( rowHeight(row) == 0 ) {
579 showRow( row ); 500 showRow( row );
580 adjustRow( row ); 501 adjustRow( row );
581 if ( isSelected( row,0 ) || isSelected( row,1 ) ) 502 if ( isSelected( row,0 ) || isSelected( row,1 ) )
582 selectedRow = row; 503 selectedRow = row;
583 } 504 }
584 visible++; 505 visible++;
585 } 506 }
586 507
587 if ( selectedRow ) 508 if ( selectedRow )
588 setCurrentCell( selectedRow, 0 ); 509 setCurrentCell( selectedRow, 0 );
589 510
590 if ( !visible ) 511 if ( !visible )
591 setCurrentCell( -1, 0 ); 512 setCurrentCell( -1, 0 );
592 513
593 setPaintingEnabled( TRUE ); 514 setPaintingEnabled( TRUE );
594} 515}
595 516
596 517
597void AbTable::setPaintingEnabled( bool e ) 518void AbTable::setPaintingEnabled( bool e )
598{ 519{
599 //odebug << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: " 520 //odebug << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: "
600 // << countNested << oendl; 521 // << countNested << oendl;
601 522
602 if ( e ) { 523 if ( e ) {
603 if ( countNested > 0 ) 524 if ( countNested > 0 )
604 --countNested; 525 --countNested;
605 if ( ! countNested ){ 526 if ( ! countNested ){
606 setUpdatesEnabled( true ); 527 setUpdatesEnabled( true );
607 enablePainting = true; 528 enablePainting = true;
608 rowHeightChanged( 0 ); 529 rowHeightChanged( 0 );
609 viewport()->update(); 530 viewport()->update();
610 } 531 }
611 } else { 532 } else {
612 ++countNested; 533 ++countNested;
613 enablePainting = false; 534 enablePainting = false;
614 setUpdatesEnabled( false ); 535 setUpdatesEnabled( false );
615 } 536 }
616 //odebug << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: " 537 //odebug << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: "
617 // << countNested << oendl; 538 // << countNested << oendl;
618} 539}
619 540
620void AbTable::viewportPaintEvent( QPaintEvent* e ) { 541void AbTable::viewportPaintEvent( QPaintEvent* e ) {
621 //odebug << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> " 542 //odebug << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> "
622 // << enablePainting << oendl; 543 // << enablePainting << oendl;
623 if ( enablePainting ) 544 if ( enablePainting )
624 QTable::viewportPaintEvent( e ); 545 QTable::viewportPaintEvent( e );
625} 546}
626 547
627void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 548void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
628 const QColorGroup &cg = colorGroup(); 549 const QColorGroup &cg = colorGroup();
629 550
630 p->save(); 551 p->save();
631 552
632 //odebug << "Paint row: " << row << oendl; 553 //odebug << "Paint row: " << row << oendl;
633 554
634 Opie::OPimContact act_contact = m_viewList[row]; 555 Opie::OPimContact act_contact = m_viewList[row];
635 556
636 // Paint alternating background bars 557 // Paint alternating background bars
637 if ( (row % 2 ) == 0 ) { 558 if ( (row % 2 ) == 0 ) {
638 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 559 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
639 p->setPen( QPen( cg.text() ) ); 560 p->setPen( QPen( cg.text() ) );
640 } 561 }
641 else { 562 else {
642 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); 563 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
643 p->setPen( QPen( cg.buttonText() ) ); 564 p->setPen( QPen( cg.buttonText() ) );
644 } 565 }
645 566
646 QFont f = p->font(); 567 QFont f = p->font();
647 QFontMetrics fm(f); 568 QFontMetrics fm(f);
648 569
649 int marg = 2; 570 int marg = 2;
650 int x = 0; 571 int x = 0;
651 int y = ( cr.height() - 14 ) / 2; 572 int y = ( cr.height() - 14 ) / 2;
652 573
653 QString nameText = act_contact.fileAs(); 574 QString nameText = act_contact.fileAs();
654 575
655 switch( col ){ 576 switch( col ){
656 case 0: 577 case 0:
657 p->drawText( x + marg,2 + fm.ascent(), nameText ); 578 p->drawText( x + marg,2 + fm.ascent(), nameText );
658 break; 579 break;
659 case 1:{ 580 case 1:{
660 581
661 ContactItem contactItem = findContactContact( act_contact, 0 ); 582 ContactItem contactItem = findContactContact( act_contact, 0 );
662 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */ 583 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */
663 QString contactText = contactItem.value; 584 QString contactText = contactItem.value;
664 585
665 if ( !contactPic.isNull() ) 586 if ( !contactPic.isNull() )
666 { 587 {
667 p->drawPixmap( x + marg, y, contactPic ); 588 p->drawPixmap( x + marg, y, contactPic );
668 p->drawText( x + marg + contactPic.width() 589 p->drawText( x + marg + contactPic.width()
669 + 4,2 + fm.ascent(), contactText ); 590 + 4,2 + fm.ascent(), contactText );
670 } 591 }
671 else 592 else
672 { 593 {
673 p->drawText( x + marg,2 + fm.ascent(), contactText ); 594 p->drawText( x + marg,2 + fm.ascent(), contactText );
674 } 595 }
675 } 596 }
676 break; 597 break;
677 598
678 } 599 }
679 p->restore(); 600 p->restore();
680} 601}
681 602
682void AbTable::rowHeightChanged( int row ) 603void AbTable::rowHeightChanged( int row )
683{ 604{
684 if ( enablePainting ) 605 if ( enablePainting )
685 QTable::rowHeightChanged( row ); 606 QTable::rowHeightChanged( row );
686} 607}
687ContactItem AbTable::findContactContact( const Opie::OPimContact &entry, int /* row */ ) 608ContactItem AbTable::findContactContact( const Opie::OPimContact &entry, int /* row */ )
688{ 609{
689 610
690 ContactItem item; 611 ContactItem item;
691 612
692 item.value = ""; 613 item.value = "";
693 614
694 for ( QValueList<int>::ConstIterator it = intFields.begin(); 615 for ( QValueList<int>::ConstIterator it = intFields.begin();
695 it != intFields.end(); ++it ) { 616 it != intFields.end(); ++it ) {
696 switch ( *it ) { 617 switch ( *it ) {
697 default: 618 default:
698 break; 619 break;
699 case Qtopia::Title: 620 case Qtopia::Title:
700 item.value = entry.title(); 621 item.value = entry.title();
701 break; 622 break;
702 case Qtopia::Suffix: 623 case Qtopia::Suffix:
703 item.value = entry.suffix(); 624 item.value = entry.suffix();
704 break; 625 break;
705 case Qtopia::FileAs: 626 case Qtopia::FileAs:
706 item.value = entry.fileAs(); 627 item.value = entry.fileAs();
707 break; 628 break;
708 case Qtopia::DefaultEmail: 629 case Qtopia::DefaultEmail:
709 item.value = entry.defaultEmail(); 630 item.value = entry.defaultEmail();
710 if ( !item.value.isEmpty() ) 631 if ( !item.value.isEmpty() )
711 item.icon = Resource::loadPixmap( "addressbook/email" ); 632 item.icon = Resource::loadPixmap( "addressbook/email" );
712 break; 633 break;
713 case Qtopia::Emails: 634 case Qtopia::Emails:
714 item.value = entry.emails(); 635 item.value = entry.emails();
715 if ( !item.value.isEmpty() ) 636 if ( !item.value.isEmpty() )
716 item.icon = Resource::loadPixmap( "addressbook/email" ); 637 item.icon = Resource::loadPixmap( "addressbook/email" );
717 break; 638 break;
718 case Qtopia::HomeStreet: 639 case Qtopia::HomeStreet:
719 item.value = entry.homeStreet(); 640 item.value = entry.homeStreet();
720 break; 641 break;
721 case Qtopia::HomeCity: 642 case Qtopia::HomeCity:
722 item.value = entry.homeCity(); 643 item.value = entry.homeCity();
723 break; 644 break;
724 case Qtopia::HomeState: 645 case Qtopia::HomeState:
725 item.value = entry.homeState(); 646 item.value = entry.homeState();
726 break; 647 break;
727 case Qtopia::HomeZip: 648 case Qtopia::HomeZip:
728 item.value = entry.homeZip(); 649 item.value = entry.homeZip();
729 break; 650 break;
730 case Qtopia::HomeCountry: 651 case Qtopia::HomeCountry:
731 item.value = entry.homeCountry(); 652 item.value = entry.homeCountry();
732 break; 653 break;
733 case Qtopia::HomePhone: 654 case Qtopia::HomePhone:
734 item.value = entry.homePhone(); 655 item.value = entry.homePhone();
735 if ( !item.value.isEmpty() ) 656 if ( !item.value.isEmpty() )
736 item.icon = Resource::loadPixmap( "addressbook/phonehome" ); 657 item.icon = Resource::loadPixmap( "addressbook/phonehome" );
737 break; 658 break;
738 case Qtopia::HomeFax: 659 case Qtopia::HomeFax:
739 item.value = entry.homeFax(); 660 item.value = entry.homeFax();
740 if ( !item.value.isEmpty() ) 661 if ( !item.value.isEmpty() )
741 item.icon = Resource::loadPixmap( "addressbook/faxhome" ); 662 item.icon = Resource::loadPixmap( "addressbook/faxhome" );
742 break; 663 break;
743 case Qtopia::HomeMobile: 664 case Qtopia::HomeMobile:
744 item.value = entry.homeMobile(); 665 item.value = entry.homeMobile();
745 if ( !item.value.isEmpty() ) 666 if ( !item.value.isEmpty() )
746 item.icon = Resource::loadPixmap( "addressbook/mobilehome" ); 667 item.icon = Resource::loadPixmap( "addressbook/mobilehome" );
747 break; 668 break;
748 case Qtopia::HomeWebPage: 669 case Qtopia::HomeWebPage:
749 item.value = entry.homeWebpage(); 670 item.value = entry.homeWebpage();
750 if ( !item.value.isEmpty() ) 671 if ( !item.value.isEmpty() )
751 item.icon = Resource::loadPixmap( "addressbook/webpagehome" ); 672 item.icon = Resource::loadPixmap( "addressbook/webpagehome" );
752 break; 673 break;
753 case Qtopia::Company: 674 case Qtopia::Company:
754 item.value = entry.company(); 675 item.value = entry.company();
755 break; 676 break;
756 case Qtopia::BusinessCity: 677 case Qtopia::BusinessCity:
757 item.value = entry.businessCity(); 678 item.value = entry.businessCity();
758 break; 679 break;
759 case Qtopia::BusinessStreet: 680 case Qtopia::BusinessStreet:
760 item.value = entry.businessStreet(); 681 item.value = entry.businessStreet();
761 break; 682 break;
762 case Qtopia::BusinessZip: 683 case Qtopia::BusinessZip:
763 item.value = entry.businessZip(); 684 item.value = entry.businessZip();
764 break; 685 break;
765 case Qtopia::BusinessCountry: 686 case Qtopia::BusinessCountry:
766 item.value = entry.businessCountry(); 687 item.value = entry.businessCountry();
767 break; 688 break;
768 case Qtopia::BusinessWebPage: 689 case Qtopia::BusinessWebPage:
769 item.value = entry.businessWebpage(); 690 item.value = entry.businessWebpage();
770 if ( !item.value.isEmpty() ) 691 if ( !item.value.isEmpty() )
771 item.icon = Resource::loadPixmap( "addressbook/webpagework" ); 692 item.icon = Resource::loadPixmap( "addressbook/webpagework" );
772 break; 693 break;
773 case Qtopia::JobTitle: 694 case Qtopia::JobTitle:
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 927a5a9..7d2818b 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -1,159 +1,160 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file is part of Qt Palmtop Environment. 5** This file is part of Qt Palmtop Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#ifndef ABTABLE_H 22#ifndef ABTABLE_H
23#define ABTABLE_H 23#define ABTABLE_H
24 24
25#include <opie2/opimcontact.h> 25#include <opie2/opimcontact.h>
26#include <opie2/ocontactaccess.h> 26#include <opie2/ocontactaccess.h>
27 27
28#include <qpe/categories.h> 28#include <qpe/categories.h>
29 29
30#include <qmap.h> 30#include <qmap.h>
31#include <qtable.h> 31#include <qtable.h>
32#include <qstringlist.h> 32#include <qstringlist.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35 35
36#if 0 36#if 0
37class AbTableItem : public QTableItem 37class AbTableItem : public QTableItem
38{ 38{
39public: 39public:
40 AbTableItem( QTable *t, EditType et, const QString &s, 40 AbTableItem( QTable *t, EditType et, const QString &s,
41 const QString &secondSortKey); 41 const QString &secondSortKey);
42 QString entryKey() const; 42 QString entryKey() const;
43 void setEntryKey( const QString & k ); 43 void setEntryKey( const QString & k );
44 virtual int alignment() const; 44 virtual int alignment() const;
45 virtual QString key() const; 45 virtual QString key() const;
46 void setItem( const QString &txt, const QString &secondKey ); 46 void setItem( const QString &txt, const QString &secondKey );
47 47
48private: 48private:
49 QString sortKey; 49 QString sortKey;
50}; 50};
51 51
52#endif 52#endif
53 53
54// This is a simple container, storing all contact 54// This is a simple container, storing all contact
55// information 55// information
56class ContactItem 56class ContactItem
57{ 57{
58 public: 58 public:
59 QPixmap icon; 59 QPixmap icon;
60 QString value; 60 QString value;
61}; 61};
62 62
63#if 0 63#if 0
64class AbPickItem : public QTableItem 64class AbPickItem : public QTableItem
65{ 65{
66public: 66public:
67 AbPickItem( QTable *t ); 67 AbPickItem( QTable *t );
68 68
69 QWidget *createEditor() const; 69 QWidget *createEditor() const;
70 void setContentFromEditor( QWidget *w ); 70 void setContentFromEditor( QWidget *w );
71 71
72private: 72private:
73 QGuardedPtr<QComboBox> cb; 73 QGuardedPtr<QComboBox> cb;
74}; 74};
75 75
76#endif 76#endif
77 77
78class AbTable : public QTable 78class AbTable : public QTable
79{ 79{
80 Q_OBJECT 80 Q_OBJECT
81 81
82public: 82public:
83 AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 ); 83 AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 );
84 ~AbTable(); 84 ~AbTable();
85 85
86 // Set the contacts shown in the table 86 // Set the contacts shown in the table
87 void setContacts( const Opie::OPimContactAccess::List& viewList ); 87 void setContacts( const Opie::OPimContactAccess::List& viewList );
88 88
89 // Set the list for primary contacts 89 // Set the list for primary contacts
90 void setOrderedList( const QValueList<int> ordered ); 90 void setOrderedList( const QValueList<int> ordered );
91 91
92 // Selects a contact of a specific UID 92 // Selects a contact of a specific UID
93 bool selectContact( int UID ); 93 bool selectContact( int UID );
94 94
95 // Get the current selected entry 95 // Get the current selected entry
96 Opie::OPimContact currentEntry(); 96 Opie::OPimContact currentEntry();
97 97
98 // Get the UID of the current selected Entry 98 // Get the UID of the current selected Entry
99 int currentEntry_UID(); 99 int currentEntry_UID();
100 100
101 // QString findContactName( const Opie::OPimContact &entry ); 101 // QString findContactName( const Opie::OPimContact &entry );
102 102
103 void init(); 103 void init();
104 void clear(); 104 void clear();
105 void refresh(); 105 void refresh();
106 106
107 void show(); 107 void show();
108 void setPaintingEnabled( bool e ); 108 void setPaintingEnabled( bool e );
109 void viewportPaintEvent( QPaintEvent* e); 109 void viewportPaintEvent( QPaintEvent* e);
110 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 110 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
111 111
112 // addresspicker mode (What's that ? se) 112 // addresspicker mode (What's that ? se)
113 // void setChoiceNames( const QStringList& list); 113 // void setChoiceNames( const QStringList& list);
114 // QStringList choiceNames() const; 114 // QStringList choiceNames() const;
115 void setChoiceSelection( const QValueList<int>& list ); 115 void setChoiceSelection( const QValueList<int>& list );
116 QStringList choiceSelection(int index) const; 116 QStringList choiceSelection(int index) const;
117 117
118signals: 118signals:
119 void signalSwitch(); 119 void signalSwitch();
120 void signalEditor(); 120 void signalEditor();
121 void signalKeyDown(); 121 void signalKeyDown();
122 void signalKeyUp(); 122 void signalKeyUp();
123 void signalSortOrderChanged( bool order );
123 124
124protected: 125protected:
125 virtual void keyPressEvent( QKeyEvent *e ); 126 virtual void keyPressEvent( QKeyEvent *e );
126 127
127// int rowHeight( int ) const; 128// int rowHeight( int ) const;
128// int rowPos( int row ) const; 129// int rowPos( int row ) const;
129// virtual int rowAt( int pos ) const; 130// virtual int rowAt( int pos ) const;
130 131
131 132
132protected slots: 133protected slots:
133 void moveTo( char ); 134 void moveTo( char );
134 virtual void columnClicked( int col ); 135 virtual void columnClicked( int col );
135 void itemClicked(int,int col); 136 void itemClicked(int,int col);
136 void rowHeightChanged( int row ); 137 void rowHeightChanged( int row );
137 138
138private: 139private:
139 // void insertIntoTable( const Opie::OPimContact &cnt, int row ); 140 // void insertIntoTable( const Opie::OPimContact &cnt, int row );
140 ContactItem findContactContact( const Opie::OPimContact &entry, int row ); 141 ContactItem findContactContact( const Opie::OPimContact &entry, int row );
141 void fitColumns(); 142 void fitColumns();
142 void resizeRows(); 143 void resizeRows();
143 void realignTable(); 144 void realignTable();
144 void resort(); 145 void resort();
145 void updateVisible(); 146 void updateVisible();
146 147
147 int lastSortCol; 148 int lastSortCol;
148 bool asc; 149 bool asc;
149 // QMap<AbTableItem*, Opie::OPimContact> contactList; 150 // QMap<AbTableItem*, Opie::OPimContact> contactList;
150 QValueList<int> intFields; 151 QValueList<int> intFields;
151 QStringList choicenames; 152 QStringList choicenames;
152 bool enablePainting; 153 bool enablePainting;
153 bool columnVisible; 154 bool columnVisible;
154 int countNested; 155 int countNested;
155 156
156 Opie::OPimContactAccess::List m_viewList; 157 Opie::OPimContactAccess::List m_viewList;
157 158
158}; 159};
159#endif // ABTABLE_H 160#endif // ABTABLE_H
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 8a2db96..9f7f71f 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,526 +1,534 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) 2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
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** 14**
15**********************************************************************/ 15**********************************************************************/
16 16
17#include "abview.h" 17#include "abview.h"
18 18
19#include <opie2/ocontactaccessbackend_vcard.h> 19#include <opie2/ocontactaccessbackend_vcard.h>
20#include <opie2/odebug.h> 20#include <opie2/odebug.h>
21 21
22#include <qpe/global.h> 22#include <qpe/global.h>
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25 25
26#include <assert.h> 26#include <assert.h>
27 27
28 28
29// Is defined in LibQPE 29// Is defined in LibQPE
30extern QString categoryFileName(); 30extern QString categoryFileName();
31 31
32QString addressbookPersonalVCardName() 32QString addressbookPersonalVCardName()
33{ 33{
34 QString filename = Global::applicationFileName("addressbook", 34 QString filename = Global::applicationFileName("addressbook",
35 "businesscard.vcf"); 35 "businesscard.vcf");
36 return filename; 36 return filename;
37} 37}
38 38
39 39
40AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): 40AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ):
41 QWidget(parent), 41 QWidget(parent),
42 mCat(0), 42 mCat(0),
43 m_inSearch( false ), 43 m_inSearch( false ),
44 m_inPersonal( false ), 44 m_inPersonal( false ),
45 m_sortOrder( true ),
45 m_curr_category( 0 ), 46 m_curr_category( 0 ),
46 m_curr_View( TableView ), 47 m_curr_View( TableView ),
47 m_prev_View( TableView ), 48 m_prev_View( TableView ),
48 m_curr_Contact ( 0 ), 49 m_curr_Contact ( 0 ),
49 m_contactdb ( 0l ), 50 m_contactdb ( 0l ),
50 m_storedDB ( 0l ), 51 m_storedDB ( 0l ),
51 m_viewStack( 0l ), 52 m_viewStack( 0l ),
52 m_abTable( 0l ), 53 m_abTable( 0l ),
53 m_orderedFields( ordered ) 54 m_orderedFields( ordered )
54{ 55{
55 odebug << "AbView::c'tor" << oendl; 56 odebug << "AbView::c'tor" << oendl;
56 // Load default database and handle syncing myself.. ! 57 // Load default database and handle syncing myself.. !
57 m_contactdb = new Opie::OPimContactAccess ( "addressbook", 0l, 0l, false ); 58 m_contactdb = new Opie::OPimContactAccess ( "addressbook", 0l, 0l, false );
58 m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available 59 m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available
59 mCat.load( categoryFileName() ); 60 mCat.load( categoryFileName() );
60 61
61 // Create Layout and put WidgetStack into it. 62 // Create Layout and put WidgetStack into it.
62 QVBoxLayout *vb = new QVBoxLayout( this ); 63 QVBoxLayout *vb = new QVBoxLayout( this );
63 m_viewStack = new QWidgetStack( this ); 64 m_viewStack = new QWidgetStack( this );
64 vb->addWidget( m_viewStack ); 65 vb->addWidget( m_viewStack );
65 66
66 // Creat TableView 67 // Creat TableView
67 QVBox* tableBox = new QVBox( m_viewStack ); 68 QVBox* tableBox = new QVBox( m_viewStack );
68 m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); 69 m_abTable = new AbTable( m_orderedFields, tableBox, "table" );
69 m_abTable->setCurrentCell( 0, 0 ); 70 m_abTable->setCurrentCell( 0, 0 );
70 m_abTable->setFocus(); 71 m_abTable->setFocus();
71 72
72 // Add TableView to WidgetStack and raise it 73 // Add TableView to WidgetStack and raise it
73 m_viewStack -> addWidget( tableBox , TableView ); 74 m_viewStack -> addWidget( tableBox , TableView );
74 75
75 // Create CardView and add it to WidgetStack 76 // Create CardView and add it to WidgetStack
76 QVBox* cardBox = new QVBox( m_viewStack ); 77 QVBox* cardBox = new QVBox( m_viewStack );
77 m_ablabel = new AbLabel( cardBox, "CardView"); 78 m_ablabel = new AbLabel( cardBox, "CardView");
78 m_viewStack -> addWidget( cardBox , CardView ); 79 m_viewStack -> addWidget( cardBox , CardView );
79 80
80 // Connect views to me 81 // Connect views to me
81 connect ( m_abTable, SIGNAL( signalSwitch(void) ), 82 connect ( m_abTable, SIGNAL( signalSwitch(void) ),
82 this, SLOT( slotSwitch(void) ) ); 83 this, SLOT( slotSwitch(void) ) );
84 connect ( m_abTable, SIGNAL( signalSortOrderChanged( bool ) ),
85 this, SLOT( slotSetSortOrder( bool ) ) );
83 connect ( m_ablabel, SIGNAL( signalOkPressed(void) ), 86 connect ( m_ablabel, SIGNAL( signalOkPressed(void) ),
84 this, SLOT( slotSwitch(void) ) ); 87 this, SLOT( slotSwitch(void) ) );
85 88
86 load(); 89 load();
87} 90}
88 91
89AbView::~AbView() 92AbView::~AbView()
90{ 93{
91 m_contactdb -> save(); 94 m_contactdb -> save();
92 delete m_contactdb; 95 delete m_contactdb;
93 96
94 if ( m_storedDB ){ 97 if ( m_storedDB ){
95 m_storedDB -> save(); 98 m_storedDB -> save();
96 delete m_storedDB; 99 delete m_storedDB;
97 } 100 }
98} 101}
99 102
100 103
101void AbView::setView( Views view ) 104void AbView::setView( Views view )
102{ 105{
103 odebug << "AbView::setView( Views view )" << oendl; 106 odebug << "AbView::setView( Views view )" << oendl;
104 m_curr_View = view; 107 m_curr_View = view;
105 load(); 108 load();
106} 109}
107 110
108void AbView::addEntry( const Opie::OPimContact &newContact ) 111void AbView::addEntry( const Opie::OPimContact &newContact )
109{ 112{
110 odebug << "AbView::AddContact" << oendl; 113 odebug << "AbView::AddContact" << oendl;
111 m_contactdb->add ( newContact ); 114 m_contactdb->add ( newContact );
112 load(); 115 load();
113 116
114} 117}
115void AbView::removeEntry( const int UID ) 118void AbView::removeEntry( const int UID )
116{ 119{
117 odebug << "AbView;:RemoveContact" << oendl; 120 odebug << "AbView;:RemoveContact" << oendl;
118 m_contactdb->remove( UID ); 121 m_contactdb->remove( UID );
119 load(); 122 load();
120} 123}
121 124
122void AbView::replaceEntry( const Opie::OPimContact &contact ) 125void AbView::replaceEntry( const Opie::OPimContact &contact )
123{ 126{
124 odebug << "AbView::ReplaceContact" << oendl; 127 odebug << "AbView::ReplaceContact" << oendl;
125 m_contactdb->replace( contact ); 128 m_contactdb->replace( contact );
126 load(); 129 load();
127 130
128} 131}
129 132
130Opie::OPimContact AbView::currentEntry() 133Opie::OPimContact AbView::currentEntry()
131{ 134{
132 Opie::OPimContact currentContact; 135 Opie::OPimContact currentContact;
133 136
134 switch ( (int) m_curr_View ) { 137 switch ( (int) m_curr_View ) {
135 case TableView: 138 case TableView:
136 currentContact = m_abTable -> currentEntry(); 139 currentContact = m_abTable -> currentEntry();
137 break; 140 break;
138 case CardView: 141 case CardView:
139 currentContact = m_ablabel -> currentEntry(); 142 currentContact = m_ablabel -> currentEntry();
140 break; 143 break;
141 } 144 }
142 m_curr_Contact = currentContact.uid(); 145 m_curr_Contact = currentContact.uid();
143 return currentContact; 146 return currentContact;
144} 147}
145 148
146bool AbView::save() 149bool AbView::save()
147{ 150{
148 //odebug << "AbView::Save data" << oendl; 151 //odebug << "AbView::Save data" << oendl;
149 152
150 return m_contactdb->save(); 153 return m_contactdb->save();
151} 154}
152 155
153void AbView::load() 156void AbView::load()
154{ 157{
155 odebug << "AbView::Load data" << oendl; 158 odebug << "AbView::Load data" << oendl;
156 159
157 // Letter Search is stopped at this place 160 // Letter Search is stopped at this place
158 emit signalClearLetterPicker(); 161 emit signalClearLetterPicker();
159 162
160 odebug << "selected Category: " << m_curr_category << oendl; 163 odebug << "selected Category: " << m_curr_category << oendl;
161 164
162 if ( m_curr_category == -1 ) { 165 if ( m_curr_category == -1 ) {
163 // Show just unfiled contacts 166 // Show just unfiled contacts
164 m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, 167 m_list = m_contactdb->sorted( m_sortOrder, Opie::OPimContactAccess::SortFileAsName,
165 Opie::OPimContactAccess::DoNotShowWithCategory, 0 ); 168 Opie::OPimContactAccess::DoNotShowWithCategory, 0 );
166 } elseif ( m_curr_category == 0 ){ 169 } elseif ( m_curr_category == 0 ){
167 // Just show all contacts 170 // Just show all contacts
168 m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, 171 m_list = m_contactdb->sorted( m_sortOrder, Opie::OPimContactAccess::SortFileAsName,
169 Opie::OPimBase::FilterOff, 0 ); 172 Opie::OPimBase::FilterOff, 0 );
170 } else { 173 } else {
171 // Show contacts with given categories 174 // Show contacts with given categories
172 m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, 175 m_list = m_contactdb->sorted( m_sortOrder, Opie::OPimContactAccess::SortFileAsName,
173 Opie::OPimBase::FilterCategory, m_curr_category ); 176 Opie::OPimBase::FilterCategory, m_curr_category );
174 } 177 }
175 178
176 odebug << "Number of contacts: " << m_list.count() << oendl; 179 odebug << "Number of contacts: " << m_list.count() << oendl;
177 180
178 updateView( true ); 181 updateView( true );
179 182
180} 183}
181 184
182void AbView::reload() 185void AbView::reload()
183{ 186{
184 odebug << "AbView::::reload()" << oendl; 187 odebug << "AbView::::reload()" << oendl;
185 188
186 m_contactdb->reload(); 189 m_contactdb->reload();
187 load(); 190 load();
188} 191}
189 192
190void AbView::clear() 193void AbView::clear()
191{ 194{
192 // :SX 195 // :SX
193} 196}
194 197
195void AbView::setShowByCategory( const QString& cat ) 198void AbView::setShowByCategory( const QString& cat )
196{ 199{
197 odebug << "AbView::setShowCategory( const QString& cat )" << oendl; 200 odebug << "AbView::setShowCategory( const QString& cat )" << oendl;
198 201
199 int intCat = 0; 202 int intCat = 0;
200 203
201 // Unfiled will be stored as -1 204 // Unfiled will be stored as -1
202 if ( cat == tr( "Unfiled" ) ) 205 if ( cat == tr( "Unfiled" ) )
203 intCat = -1; 206 intCat = -1;
204 else if ( cat.isNull() ) 207 else if ( cat.isNull() )
205 intCat = 0; 208 intCat = 0;
206 else 209 else
207 intCat = mCat.id("Contacts", cat ); 210 intCat = mCat.id("Contacts", cat );
208 211
209 // Just do anything if we really change the category 212 // Just do anything if we really change the category
210 if ( intCat != m_curr_category ){ 213 if ( intCat != m_curr_category ){
211 // odebug << "Categories: Selected " << cat << ".. Number: " 214 // odebug << "Categories: Selected " << cat << ".. Number: "
212 // << m_curr_category << oendl; 215 // << m_curr_category << oendl;
213 216
214 m_curr_category = intCat; 217 m_curr_category = intCat;
215 emit signalClearLetterPicker(); 218 emit signalClearLetterPicker();
216 load(); 219 load();
217 } 220 }
218 m_curr_category = intCat; 221 m_curr_category = intCat;
219 222
220} 223}
221 224
222void AbView::setShowToView( Views view ) 225void AbView::setShowToView( Views view )
223{ 226{
224 odebug << "void AbView::setShowToView( View " << view << " )" << oendl; 227 odebug << "void AbView::setShowToView( View " << view << " )" << oendl;
225 228
226 if ( m_curr_View != view ){ 229 if ( m_curr_View != view ){
227 odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; 230 odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl;
228 m_prev_View = m_curr_View; 231 m_prev_View = m_curr_View;
229 m_curr_View = view; 232 m_curr_View = view;
230 233
231 updateView(); 234 updateView();
232 } 235 }
233 236
234} 237}
235 238
236void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) 239void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode )
237{ 240{
238 odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; 241 odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl;
239 242
240 assert( mode < AbConfig::LASTELEMENT ); 243 assert( mode < AbConfig::LASTELEMENT );
241 244
242 Opie::OPimContact query; 245 Opie::OPimContact query;
243 if ( c == 0 ){ 246 if ( c == 0 ){
244 load(); 247 load();
245 return; 248 return;
246 }else{ 249 }else{
247 // If the current Backend is unable to solve the query, we will 250 // If the current Backend is unable to solve the query, we will
248 // ignore the request .. 251 // ignore the request ..
249 if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | 252 if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards |
250 Opie::OPimContactAccess::IgnoreCase ) ){ 253 Opie::OPimContactAccess::IgnoreCase ) ){
251 owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl; 254 owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl;
252 owarn << "I have to ignore this access!" << oendl; 255 owarn << "I have to ignore this access!" << oendl;
253 return; 256 return;
254 } 257 }
255 258
256 switch( mode ){ 259 switch( mode ){
257 case AbConfig::LastName: 260 case AbConfig::LastName:
258 query.setLastName( QString("%1*").arg(c) ); 261 query.setLastName( QString("%1*").arg(c) );
259 break; 262 break;
260 case AbConfig::FileAs: 263 case AbConfig::FileAs:
261 query.setFileAs( QString("%1*").arg(c) ); 264 query.setFileAs( QString("%1*").arg(c) );
262 break; 265 break;
263 default: 266 default:
264 owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl 267 owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl
265 << "I will ignore it.." << oendl; 268 << "I will ignore it.." << oendl;
266 return; 269 return;
267 } 270 }
268 m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); 271 m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase );
269 272
270 if ( m_curr_category != 0 ) 273 if ( m_curr_category != 0 )
271 clearForCategory(); 274 clearForCategory();
272 275
273 // Sort filtered results 276 // Sort filtered results
274 m_list = m_contactdb->sorted( m_list, true, Opie::OPimContactAccess::SortFileAsName, 277 m_list = m_contactdb->sorted( m_list, true, Opie::OPimContactAccess::SortFileAsName,
275 Opie::OPimContactAccess::FilterCategory, m_curr_category ); 278 Opie::OPimContactAccess::FilterCategory, m_curr_category );
276 m_curr_Contact = 0; 279 m_curr_Contact = 0;
277 } 280 }
278 updateView( true ); 281 updateView( true );
279} 282}
280 283
281void AbView::setListOrder( const QValueList<int>& ordered ) 284void AbView::setListOrder( const QValueList<int>& ordered )
282{ 285{
283 m_orderedFields = ordered; 286 m_orderedFields = ordered;
284 if ( m_abTable ){ 287 if ( m_abTable ){
285 m_abTable->setOrderedList( ordered ); 288 m_abTable->setOrderedList( ordered );
286 m_abTable->refresh(); 289 m_abTable->refresh();
287 } 290 }
288 updateView(); 291 updateView();
289} 292}
290 293
291 294
292QString AbView::showCategory() const 295QString AbView::showCategory() const
293{ 296{
294 return mCat.label( "Contacts", m_curr_category ); 297 return mCat.label( "Contacts", m_curr_category );
295} 298}
296 299
297void AbView::showPersonal( bool personal ) 300void AbView::showPersonal( bool personal )
298{ 301{
299 odebug << "void AbView::showPersonal( " << personal << " )" << oendl; 302 odebug << "void AbView::showPersonal( " << personal << " )" << oendl;
300 303
301 if ( personal ){ 304 if ( personal ){
302 305
303 if ( m_inPersonal ) 306 if ( m_inPersonal )
304 return; 307 return;
305 308
306 // Now switch to vCard Backend and load data. 309 // Now switch to vCard Backend and load data.
307 // The current default backend will be stored 310 // The current default backend will be stored
308 // to avoid unneeded load/stores. 311 // to avoid unneeded load/stores.
309 m_storedDB = m_contactdb; 312 m_storedDB = m_contactdb;
310 313
311 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 314 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
312 addressbookPersonalVCardName() ); 315 addressbookPersonalVCardName() );
313 m_contactdb = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 316 m_contactdb = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
314 317
315 m_inPersonal = true; 318 m_inPersonal = true;
316 m_curr_View = CardView; 319 m_curr_View = CardView;
317 320
318 }else{ 321 }else{
319 322
320 if ( !m_inPersonal ) 323 if ( !m_inPersonal )
321 return; 324 return;
322 325
323 // Remove vCard Backend and restore default 326 // Remove vCard Backend and restore default
324 m_contactdb->save(); 327 m_contactdb->save();
325 delete m_contactdb; 328 delete m_contactdb;
326 329
327 m_contactdb = m_storedDB; 330 m_contactdb = m_storedDB;
328 m_storedDB = 0l; 331 m_storedDB = 0l;
329 332
330 m_curr_View = TableView; 333 m_curr_View = TableView;
331 m_inPersonal = false; 334 m_inPersonal = false;
332 335
333 } 336 }
334 load(); 337 load();
335} 338}
336 339
337void AbView::setCurrentUid( int uid ){ 340void AbView::setCurrentUid( int uid ){
338 341
339 m_curr_Contact = uid; 342 m_curr_Contact = uid;
340 updateView( true ); //true: Don't modificate the UID ! 343 updateView( true ); //true: Don't modificate the UID !
341} 344}
342 345
343 346
344QStringList AbView::categories() 347QStringList AbView::categories()
345{ 348{
346 mCat.load( categoryFileName() ); 349 mCat.load( categoryFileName() );
347 QStringList categoryList = mCat.labels( "Contacts" ); 350 QStringList categoryList = mCat.labels( "Contacts" );
348 return categoryList; 351 return categoryList;
349} 352}
350 353
351// BEGIN: Slots 354// BEGIN: Slots
352void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 355void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
353 bool , QString cat ) 356 bool , QString cat )
354{ 357{
355 //owarn << "void AbView::slotDoFind" << oendl; 358 //owarn << "void AbView::slotDoFind" << oendl;
356 359
357 // We reloading the data: Deselect Letterpicker 360 // We reloading the data: Deselect Letterpicker
358 emit signalClearLetterPicker(); 361 emit signalClearLetterPicker();
359 362
360 // Use the current Category if nothing else selected 363 // Use the current Category if nothing else selected
361 int category = 0; 364 int category = 0;
362 365
363 if ( cat.isEmpty() ) 366 if ( cat.isEmpty() )
364 category = m_curr_category; 367 category = m_curr_category;
365 else{ 368 else{
366 category = mCat.id("Contacts", cat ); 369 category = mCat.id("Contacts", cat );
367 } 370 }
368 371
369 //odebug << "Find in Category " << category << oendl; 372 //odebug << "Find in Category " << category << oendl;
370 373
371 QRegExp r( str ); 374 QRegExp r( str );
372 r.setCaseSensitive( caseSensitive ); 375 r.setCaseSensitive( caseSensitive );
373 r.setWildcard( !useRegExp ); 376 r.setWildcard( !useRegExp );
374 377
375 // Get all matching entries out of the database 378 // Get all matching entries out of the database
376 m_list = m_contactdb->matchRegexp( r ); 379 m_list = m_contactdb->matchRegexp( r );
377 380
378 //odebug << "Found: " << m_list.count() << oendl; 381 //odebug << "Found: " << m_list.count() << oendl;
379 if ( m_list.count() == 0 ){ 382 if ( m_list.count() == 0 ){
380 emit signalNotFound(); 383 emit signalNotFound();
381 return; 384 return;
382 } 385 }
383 386
384 // Now remove all contacts with wrong category (if any selected) 387 // Now remove all contacts with wrong category (if any selected)
385 // This algorithm is a litte bit ineffective, but 388 // This algorithm is a litte bit ineffective, but
386 // we will not have a lot of matching entries.. 389 // we will not have a lot of matching entries..
387 if ( m_curr_category != 0 ) 390 if ( m_curr_category != 0 )
388 clearForCategory(); 391 clearForCategory();
389 392
390 // Now show all found entries 393 // Now show all found entries
391 updateView( true ); 394 updateView( true );
392} 395}
393 396
394void AbView::offSearch() 397void AbView::offSearch()
395{ 398{
396 m_inSearch = false; 399 m_inSearch = false;
397 400
398 load(); 401 load();
399} 402}
400 403
401void AbView::slotSwitch(){ 404void AbView::slotSwitch(){
402 //odebug << "AbView::slotSwitch()" << oendl; 405 //odebug << "AbView::slotSwitch()" << oendl;
403 406
404 m_prev_View = m_curr_View; 407 m_prev_View = m_curr_View;
405 switch ( (int) m_curr_View ){ 408 switch ( (int) m_curr_View ){
406 case TableView: 409 case TableView:
407 odebug << "Switching to CardView" << oendl; 410 odebug << "Switching to CardView" << oendl;
408 m_curr_View = CardView; 411 m_curr_View = CardView;
409 break; 412 break;
410 case CardView: 413 case CardView:
411 odebug << "Switching to TableView" << oendl; 414 odebug << "Switching to TableView" << oendl;
412 m_curr_View = TableView; 415 m_curr_View = TableView;
413 break; 416 break;
414 } 417 }
415 updateView(); 418 updateView();
416 419
417} 420}
418 421
422void AbView::slotSetSortOrder( bool order ){
423 m_sortOrder = order;
424 reload();
425}
426
419// END: Slots 427// END: Slots
420 428
421void AbView::clearForCategory() 429void AbView::clearForCategory()
422{ 430{
423 Opie::OPimContactAccess::List::Iterator it; 431 Opie::OPimContactAccess::List::Iterator it;
424 // Now remove all contacts with wrong category if any category selected 432 // Now remove all contacts with wrong category if any category selected
425 433
426 Opie::OPimContactAccess::List allList = m_list; 434 Opie::OPimContactAccess::List allList = m_list;
427 if ( m_curr_category != 0 ){ 435 if ( m_curr_category != 0 ){
428 for ( it = allList.begin(); it != allList.end(); ++it ){ 436 for ( it = allList.begin(); it != allList.end(); ++it ){
429 if ( !contactCompare( *it, m_curr_category ) ){ 437 if ( !contactCompare( *it, m_curr_category ) ){
430 //odebug << "Removing " << (*it).uid() << oendl; 438 //odebug << "Removing " << (*it).uid() << oendl;
431 m_list.remove( (*it).uid() ); 439 m_list.remove( (*it).uid() );
432 } 440 }
433 } 441 }
434 } 442 }
435 443
436} 444}
437 445
438bool AbView::contactCompare( const Opie::OPimContact &cnt, int category ) 446bool AbView::contactCompare( const Opie::OPimContact &cnt, int category )
439{ 447{
440 //odebug << "bool AbView::contactCompare( const Opie::OPimContact &cnt, " 448 //odebug << "bool AbView::contactCompare( const Opie::OPimContact &cnt, "
441 // << category << " )" << oendl; 449 // << category << " )" << oendl;
442 450
443 bool returnMe; 451 bool returnMe;
444 QArray<int> cats; 452 QArray<int> cats;
445 cats = cnt.categories(); 453 cats = cnt.categories();
446 454
447 //odebug << "Number of categories: " << cats.count() << oendl; 455 //odebug << "Number of categories: " << cats.count() << oendl;
448 456
449 returnMe = false; 457 returnMe = false;
450 if ( cats.count() == 0 && category == -1 ) 458 if ( cats.count() == 0 && category == -1 )
451 // Contacts with no category will just shown on "All" and "Unfiled" 459 // Contacts with no category will just shown on "All" and "Unfiled"
452 returnMe = true; 460 returnMe = true;
453 else { 461 else {
454 int i; 462 int i;
455 for ( i = 0; i < int(cats.count()); i++ ) { 463 for ( i = 0; i < int(cats.count()); i++ ) {
456 //odebug << "Comparing " << cats[i] << " with " << category << oendl; 464 //odebug << "Comparing " << cats[i] << " with " << category << oendl;
457 if ( cats[i] == category ) { 465 if ( cats[i] == category ) {
458 returnMe = true; 466 returnMe = true;
459 break; 467 break;
460 } 468 }
461 } 469 }
462 } 470 }
463 //odebug << "Return: " << returnMe << oendl; 471 //odebug << "Return: " << returnMe << oendl;
464 return returnMe; 472 return returnMe;
465} 473}
466 474
467// In Some rare cases we have to update all lists.. 475// In Some rare cases we have to update all lists..
468void AbView::updateListinViews() 476void AbView::updateListinViews()
469{ 477{
470 m_abTable -> setContacts( m_list ); 478 m_abTable -> setContacts( m_list );
471 m_ablabel -> setContacts( m_list ); 479 m_ablabel -> setContacts( m_list );
472} 480}
473 481
474void AbView::updateView( bool newdata ) 482void AbView::updateView( bool newdata )
475{ 483{
476 //odebug << "AbView::updateView()" << oendl; 484 //odebug << "AbView::updateView()" << oendl;
477 485
478 if ( m_viewStack -> visibleWidget() ){ 486 if ( m_viewStack -> visibleWidget() ){
479 m_viewStack -> visibleWidget() -> clearFocus(); 487 m_viewStack -> visibleWidget() -> clearFocus();
480 } 488 }
481 489
482 // If we switching the view, we have to store some information 490 // If we switching the view, we have to store some information
483 if ( !newdata ){ 491 if ( !newdata ){
484 if ( m_list.count() ){ 492 if ( m_list.count() ){
485 switch ( (int) m_prev_View ) { 493 switch ( (int) m_prev_View ) {
486 case TableView: 494 case TableView:
487 m_curr_Contact = m_abTable -> currentEntry_UID(); 495 m_curr_Contact = m_abTable -> currentEntry_UID();
488 break; 496 break;
489 case CardView: 497 case CardView:
490 m_curr_Contact = m_ablabel -> currentEntry_UID(); 498 m_curr_Contact = m_ablabel -> currentEntry_UID();
491 break; 499 break;
492 } 500 }
493 }else 501 }else
494 m_curr_Contact = 0; 502 m_curr_Contact = 0;
495 } 503 }
496 504
497 // Feed all views with new lists 505 // Feed all views with new lists
498 if ( newdata ) 506 if ( newdata )
499 updateListinViews(); 507 updateListinViews();
500 508
501 // Tell the world that the view is changed 509 // Tell the world that the view is changed
502 if ( m_curr_View != m_prev_View ) 510 if ( m_curr_View != m_prev_View )
503 emit signalViewSwitched ( (int) m_curr_View ); 511 emit signalViewSwitched ( (int) m_curr_View );
504 512
505 m_prev_View = m_curr_View; 513 m_prev_View = m_curr_View;
506 514
507 // Switch to new View 515 // Switch to new View
508 switch ( (int) m_curr_View ) { 516 switch ( (int) m_curr_View ) {
509 case TableView: 517 case TableView:
510 m_abTable -> setChoiceSelection( m_orderedFields ); 518 m_abTable -> setChoiceSelection( m_orderedFields );
511 if ( m_curr_Contact != 0 ) 519 if ( m_curr_Contact != 0 )
512 m_abTable -> selectContact ( m_curr_Contact ); 520 m_abTable -> selectContact ( m_curr_Contact );
513 m_abTable -> setFocus(); 521 m_abTable -> setFocus();
514 break; 522 break;
515 case CardView: 523 case CardView:
516 if ( m_curr_Contact != 0 ) 524 if ( m_curr_Contact != 0 )
517 m_ablabel -> selectContact( m_curr_Contact ); 525 m_ablabel -> selectContact( m_curr_Contact );
518 m_ablabel -> setFocus(); 526 m_ablabel -> setFocus();
519 break; 527 break;
520 } 528 }
521 529
522 // Raise the current View 530 // Raise the current View
523 m_viewStack -> raiseWidget( m_curr_View ); 531 m_viewStack -> raiseWidget( m_curr_View );
524} 532}
525 533
526 534
diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h
index b8c8a08..07b6b28 100644
--- a/core/pim/addressbook/abview.h
+++ b/core/pim/addressbook/abview.h
@@ -1,90 +1,92 @@
1#ifndef _ABVIEW_H_ 1#ifndef _ABVIEW_H_
2#define _ABVIEW_H_ 2#define _ABVIEW_H_
3 3
4#include <opie2/opimcontact.h> 4#include <opie2/opimcontact.h>
5#include <opie2/ocontactaccess.h> 5#include <opie2/ocontactaccess.h>
6 6
7#include <qpe/categories.h> 7#include <qpe/categories.h>
8 8
9#include <qwidget.h> 9#include <qwidget.h>
10#include <qwidgetstack.h> 10#include <qwidgetstack.h>
11 11
12#include "contacteditor.h" 12#include "contacteditor.h"
13#include "abtable.h" 13#include "abtable.h"
14#include "ablabel.h" 14#include "ablabel.h"
15#include "abconfig.h" 15#include "abconfig.h"
16 16
17class AbView: public QWidget 17class AbView: public QWidget
18{ 18{
19 Q_OBJECT 19 Q_OBJECT
20 20
21public: 21public:
22 enum Views{ TableView=0, CardView, PersonalView }; 22 enum Views{ TableView=0, CardView, PersonalView };
23 23
24 AbView( QWidget* parent, const QValueList<int>& ordered ); 24 AbView( QWidget* parent, const QValueList<int>& ordered );
25 ~AbView(); 25 ~AbView();
26 26
27 bool save(); 27 bool save();
28 void load(); 28 void load();
29 void reload(); 29 void reload();
30 void clear(); 30 void clear();
31 31
32 void setView( Views view ); 32 void setView( Views view );
33 void showPersonal( bool personal ); 33 void showPersonal( bool personal );
34 void setCurrentUid( int uid ); 34 void setCurrentUid( int uid );
35 void setShowByCategory( const QString& cat ); 35 void setShowByCategory( const QString& cat );
36 void setShowToView( Views view ); 36 void setShowToView( Views view );
37 void setShowByLetter( char c, AbConfig::LPSearchMode mode = AbConfig::LastName ); 37 void setShowByLetter( char c, AbConfig::LPSearchMode mode = AbConfig::LastName );
38 void setListOrder( const QValueList<int>& ordered ); 38 void setListOrder( const QValueList<int>& ordered );
39 39
40 // Add Entry and put to current 40 // Add Entry and put to current
41 void addEntry( const Opie::OPimContact &newContact ); 41 void addEntry( const Opie::OPimContact &newContact );
42 void removeEntry( const int UID ); 42 void removeEntry( const int UID );
43 void replaceEntry( const Opie::OPimContact &contact ); 43 void replaceEntry( const Opie::OPimContact &contact );
44 Opie::OPimContact currentEntry(); 44 Opie::OPimContact currentEntry();
45 45
46 void inSearch() { m_inSearch = true; } 46 void inSearch() { m_inSearch = true; }
47 void offSearch(); 47 void offSearch();
48 48
49 QString showCategory() const; 49 QString showCategory() const;
50 QStringList categories(); 50 QStringList categories();
51 51
52signals: 52signals:
53 void signalNotFound(); 53 void signalNotFound();
54 void signalClearLetterPicker(); 54 void signalClearLetterPicker();
55 void signalViewSwitched ( int ); 55 void signalViewSwitched ( int );
56 56
57public slots: 57public slots:
58 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 58 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
59 bool backwards, QString category = QString::null ); 59 bool backwards, QString category = QString::null );
60 void slotSwitch(); 60 void slotSwitch();
61 void slotSetSortOrder( bool order );
61 62
62private: 63private:
63 void updateListinViews(); 64 void updateListinViews();
64 void updateView( bool newdata = false ); 65 void updateView( bool newdata = false );
65 void clearForCategory(); 66 void clearForCategory();
66 bool contactCompare( const Opie::OPimContact &cnt, int category ); 67 bool contactCompare( const Opie::OPimContact &cnt, int category );
67 void parseName( const QString& name, QString *first, QString *middle, 68 void parseName( const QString& name, QString *first, QString *middle,
68 QString * last ); 69 QString * last );
69 70
70 Categories mCat; 71 Categories mCat;
71 bool m_inSearch; 72 bool m_inSearch;
72 bool m_inPersonal; 73 bool m_inPersonal;
74 bool m_sortOrder;
73 int m_curr_category; 75 int m_curr_category;
74 Views m_curr_View; 76 Views m_curr_View;
75 Views m_prev_View; 77 Views m_prev_View;
76 int m_curr_Contact; 78 int m_curr_Contact;
77 79
78 Opie::OPimContactAccess* m_contactdb; 80 Opie::OPimContactAccess* m_contactdb;
79 Opie::OPimContactAccess* m_storedDB; 81 Opie::OPimContactAccess* m_storedDB;
80 Opie::OPimContactAccess::List m_list; 82 Opie::OPimContactAccess::List m_list;
81 83
82 QWidgetStack* m_viewStack; 84 QWidgetStack* m_viewStack;
83 AbTable* m_abTable; 85 AbTable* m_abTable;
84 AbLabel* m_ablabel; 86 AbLabel* m_ablabel;
85 87
86 QValueList<int> m_orderedFields; 88 QValueList<int> m_orderedFields;
87}; 89};
88 90
89 91
90#endif 92#endif
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h
index 7ce9752..8aafc85 100644
--- a/core/pim/addressbook/version.h
+++ b/core/pim/addressbook/version.h
@@ -1,10 +1,10 @@
1#ifndef _VERSION_H_ 1#ifndef _VERSION_H_
2#define _VERSION_H_ 2#define _VERSION_H_
3 3
4#define MAINVERSION "1" 4#define MAINVERSION "1"
5#define SUBVERSION "1" 5#define SUBVERSION "2"
6#define PATCHVERSION "1" 6#define PATCHVERSION "0"
7 7
8#define APPNAME "OPIE_ADDRESSBOOK" 8#define APPNAME "OPIE_ADDRESSBOOK"
9 9
10#endif 10#endif