summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp1
-rw-r--r--core/pim/addressbook/abview.cpp44
-rw-r--r--core/pim/addressbook/addressbook.cpp7
3 files changed, 25 insertions, 27 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 0be7d1a..49e66ad 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -1,674 +1,673 @@
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( TRUE );
128 connect( this, SIGNAL(clicked(int,int,int,const QPoint&)), 128 connect( this, SIGNAL(clicked(int,int,int,const QPoint&)),
129 this, SLOT(itemClicked(int,int)) ); 129 this, SLOT(itemClicked(int,int)) );
130 130
131 // contactList.clear(); 131 // contactList.clear();
132 //odebug << "C'tor end" << oendl; 132 //odebug << "C'tor end" << oendl;
133} 133}
134 134
135AbTable::~AbTable() 135AbTable::~AbTable()
136{ 136{
137} 137}
138 138
139void AbTable::init() 139void AbTable::init()
140{ 140{
141 // :SX showChar = '\0'; 141 // :SX showChar = '\0';
142 setNumRows( 0 ); 142 setNumRows( 0 );
143 setNumCols( 2 ); 143 setNumCols( 2 );
144 144
145 horizontalHeader()->setLabel( 0, tr( "Full Name" )); 145 horizontalHeader()->setLabel( 0, tr( "Full Name" ));
146 horizontalHeader()->setLabel( 1, tr( "Contact" )); 146 horizontalHeader()->setLabel( 1, tr( "Contact" ));
147 setLeftMargin( 0 ); 147 setLeftMargin( 0 );
148 verticalHeader()->hide(); 148 verticalHeader()->hide();
149 columnVisible = true; 149 columnVisible = true;
150} 150}
151 151
152void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList ) 152void AbTable::setContacts( const Opie::OPimContactAccess::List& viewList )
153{ 153{
154 odebug << "AbTable::setContacts()" << oendl; 154 odebug << "AbTable::setContacts()" << oendl;
155 155
156 clear(); 156 clear();
157 m_viewList = viewList; 157 m_viewList = viewList;
158 158
159 setSorting( false ); 159 setSorting( false );
160 setPaintingEnabled( FALSE ); 160 setPaintingEnabled( FALSE );
161 161
162 Opie::OPimContactAccess::List::Iterator it;
163 setNumRows( m_viewList.count() ); 162 setNumRows( m_viewList.count() );
164 //int row = 0; 163 //int row = 0;
165 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) 164 // for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
166 // insertIntoTable( *it, row++ ); 165 // insertIntoTable( *it, row++ );
167 166
168 // setSorting( true ); 167 // setSorting( true );
169 168
170 // resort(); 169 // resort();
171 170
172 updateVisible(); 171 updateVisible();
173 172
174 setPaintingEnabled( TRUE ); 173 setPaintingEnabled( TRUE );
175 174
176} 175}
177 176
178void AbTable::setOrderedList( const QValueList<int> ordered ) 177void AbTable::setOrderedList( const QValueList<int> ordered )
179{ 178{
180 intFields = ordered; 179 intFields = ordered;
181} 180}
182 181
183 182
184bool AbTable::selectContact( int UID ) 183bool AbTable::selectContact( int UID )
185{ 184{
186 odebug << "AbTable::selectContact( " << UID << " )" << oendl; 185 odebug << "AbTable::selectContact( " << UID << " )" << oendl;
187 int rows = numRows(); 186 int rows = numRows();
188 bool found = false; 187 bool found = false;
189 188
190 setPaintingEnabled( FALSE ); 189 setPaintingEnabled( FALSE );
191 odebug << "Search start" << oendl; 190 odebug << "Search start" << oendl;
192 for ( int r = 0; r < rows; ++r ) { 191 for ( int r = 0; r < rows; ++r ) {
193 if ( m_viewList.uidAt( r ) == UID ){ 192 if ( m_viewList.uidAt( r ) == UID ){
194 ensureCellVisible( r, 0 ); 193 ensureCellVisible( r, 0 );
195 setCurrentCell( r, 0 ); 194 setCurrentCell( r, 0 );
196 found = true; 195 found = true;
197 break; 196 break;
198 } 197 }
199 } 198 }
200 odebug << "Search end" << oendl; 199 odebug << "Search end" << oendl;
201 200
202 if ( !found ){ 201 if ( !found ){
203 ensureCellVisible( 0,0 ); 202 ensureCellVisible( 0,0 );
204 setCurrentCell( 0, 0 ); 203 setCurrentCell( 0, 0 );
205 } 204 }
206 205
207 setPaintingEnabled( TRUE ); 206 setPaintingEnabled( TRUE );
208 207
209 return true; 208 return true;
210} 209}
211 210
212#if 0 211#if 0
213void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row ) 212void AbTable::insertIntoTable( const Opie::OPimContact& cnt, int row )
214{ 213{
215 odebug << "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, " 214 odebug << "void AbTable::insertIntoTable( const Opie::OPimContact& cnt, "
216 << row << " )" << oendl; 215 << row << " )" << oendl;
217 QString strName; 216 QString strName;
218 ContactItem contactItem; 217 ContactItem contactItem;
219 218
220 strName = findContactName( cnt ); 219 strName = findContactName( cnt );
221 contactItem = findContactContact( cnt, row ); 220 contactItem = findContactContact( cnt, row );
222 221
223 AbTableItem *ati; 222 AbTableItem *ati;
224 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value ); 223 ati = new AbTableItem( this, QTableItem::Never, strName, contactItem.value );
225 contactList.insert( ati, cnt ); 224 contactList.insert( ati, cnt );
226 setItem( row, 0, ati ); 225 setItem( row, 0, ati );
227 ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName); 226 ati = new AbTableItem( this, QTableItem::Never, contactItem.value, strName);
228 if ( !contactItem.icon.isNull() ) 227 if ( !contactItem.icon.isNull() )
229 ati->setPixmap( contactItem.icon ); 228 ati->setPixmap( contactItem.icon );
230 setItem( row, 1, ati ); 229 setItem( row, 1, ati );
231 230
232 //### cannot do this; table only has two columns at this point 231 //### cannot do this; table only has two columns at this point
233 // setItem( row, 2, new AbPickItem( this ) ); 232 // setItem( row, 2, new AbPickItem( this ) );
234 233
235} 234}
236#endif 235#endif
237 236
238 237
239void AbTable::columnClicked( int col ) 238void AbTable::columnClicked( int col )
240{ 239{
241 if ( !sorting() ) 240 if ( !sorting() )
242 return; 241 return;
243 242
244 if ( lastSortCol == -1 ) 243 if ( lastSortCol == -1 )
245 lastSortCol = col; 244 lastSortCol = col;
246 245
247 if ( col == lastSortCol ) { 246 if ( col == lastSortCol ) {
248 asc = !asc; 247 asc = !asc;
249 } else { 248 } else {
250 lastSortCol = col; 249 lastSortCol = col;
251 asc = TRUE; 250 asc = TRUE;
252 } 251 }
253 //QMessageBox::information( this, "resort", "columnClicked" ); 252 //QMessageBox::information( this, "resort", "columnClicked" );
254 resort(); 253 resort();
255} 254}
256 255
257void AbTable::resort() 256void AbTable::resort()
258{ 257{
259 owarn << "void AbTable::resort() NOT POSSIBLE !!" << oendl; 258 owarn << "void AbTable::resort() NOT POSSIBLE !!" << oendl;
260#if 0 259#if 0
261 setPaintingEnabled( FALSE ); 260 setPaintingEnabled( FALSE );
262 if ( sorting() ) { 261 if ( sorting() ) {
263 if ( lastSortCol == -1 ) 262 if ( lastSortCol == -1 )
264 lastSortCol = 0; 263 lastSortCol = 0;
265 sortColumn( lastSortCol, asc, TRUE ); 264 sortColumn( lastSortCol, asc, TRUE );
266 //QMessageBox::information( this, "resort", "resort" ); 265 //QMessageBox::information( this, "resort", "resort" );
267 updateVisible(); 266 updateVisible();
268 } 267 }
269 setPaintingEnabled( TRUE ); 268 setPaintingEnabled( TRUE );
270#endif 269#endif
271} 270}
272 271
273Opie::OPimContact AbTable::currentEntry() 272Opie::OPimContact AbTable::currentEntry()
274{ 273{
275 return m_viewList[currentRow()]; 274 return m_viewList[currentRow()];
276} 275}
277 276
278int AbTable::currentEntry_UID() 277int AbTable::currentEntry_UID()
279{ 278{
280 return ( currentEntry().uid() ); 279 return ( currentEntry().uid() );
281} 280}
282 281
283void AbTable::clear() 282void AbTable::clear()
284{ 283{
285 odebug << "void AbTable::clear()" << oendl; 284 odebug << "void AbTable::clear()" << oendl;
286 // contactList.clear(); 285 // contactList.clear();
287 286
288 setPaintingEnabled( FALSE ); 287 setPaintingEnabled( FALSE );
289 for ( int r = 0; r < numRows(); ++r ) { 288 for ( int r = 0; r < numRows(); ++r ) {
290 for ( int c = 0; c < numCols(); ++c ) { 289 for ( int c = 0; c < numCols(); ++c ) {
291 if ( cellWidget( r, c ) ) 290 if ( cellWidget( r, c ) )
292 clearCellWidget( r, c ); 291 clearCellWidget( r, c );
293 clearCell( r, c ); 292 clearCell( r, c );
294 } 293 }
295 } 294 }
296 setNumRows( 0 ); 295 setNumRows( 0 );
297 setPaintingEnabled( TRUE ); 296 setPaintingEnabled( TRUE );
298} 297}
299 298
300// Refresh updates column 2 if the contactsettings changed 299// Refresh updates column 2 if the contactsettings changed
301void AbTable::refresh() 300void AbTable::refresh()
302{ 301{
303 owarn << "void AbTable::refresh() NOT IMPLEMENTED !!" << oendl; 302 owarn << "void AbTable::refresh() NOT IMPLEMENTED !!" << oendl;
304 303
305#if 0 304#if 0
306 int rows = numRows(); 305 int rows = numRows();
307 AbTableItem *abi; 306 AbTableItem *abi;
308 ContactItem contactItem; 307 ContactItem contactItem;
309 308
310 setPaintingEnabled( FALSE ); 309 setPaintingEnabled( FALSE );
311 for ( int r = 0; r < rows; ++r ) { 310 for ( int r = 0; r < rows; ++r ) {
312 abi = static_cast<AbTableItem*>( item(r, 0) ); 311 abi = static_cast<AbTableItem*>( item(r, 0) );
313 contactItem = findContactContact( contactList[abi], r ); 312 contactItem = findContactContact( contactList[abi], r );
314 static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() ); 313 static_cast<AbTableItem*>( item(r, 1) )->setItem( contactItem.value, abi->text() );
315 if ( !contactItem.icon.isNull() ){ 314 if ( !contactItem.icon.isNull() ){
316 static_cast<AbTableItem*>( item(r, 1) )-> 315 static_cast<AbTableItem*>( item(r, 1) )->
317 setPixmap( contactItem.icon ); 316 setPixmap( contactItem.icon );
318 }else{ 317 }else{
319 static_cast<AbTableItem*>( item(r, 1) )-> 318 static_cast<AbTableItem*>( item(r, 1) )->
320 setPixmap( QPixmap() ); 319 setPixmap( QPixmap() );
321 } 320 }
322 } 321 }
323 resort(); 322 resort();
324 setPaintingEnabled( TRUE ); 323 setPaintingEnabled( TRUE );
325 324
326#endif 325#endif
327} 326}
328 327
329void AbTable::keyPressEvent( QKeyEvent *e ) 328void AbTable::keyPressEvent( QKeyEvent *e )
330{ 329{
331 char key = toupper( e->ascii() ); 330 char key = toupper( e->ascii() );
332 331
333 if ( key >= 'A' && key <= 'Z' ) 332 if ( key >= 'A' && key <= 'Z' )
334 moveTo( key ); 333 moveTo( key );
335 334
336 // odebug << "Received key .." << oendl; 335 // odebug << "Received key .." << oendl;
337 switch( e->key() ) { 336 switch( e->key() ) {
338 case Qt::Key_Space: 337 case Qt::Key_Space:
339 case Qt::Key_Return: 338 case Qt::Key_Return:
340 case Qt::Key_Enter: 339 case Qt::Key_Enter:
341 emit signalSwitch(); 340 emit signalSwitch();
342 break; 341 break;
343 // case Qt::Key_Up: 342 // case Qt::Key_Up:
344 // odebug << "a" << oendl; 343 // odebug << "a" << oendl;
345 // emit signalKeyUp(); 344 // emit signalKeyUp();
346 // break; 345 // break;
347 // case Qt::Key_Down: 346 // case Qt::Key_Down:
348 // odebug << "b" << oendl; 347 // odebug << "b" << oendl;
349 // emit signalKeyDown(); 348 // emit signalKeyDown();
350 // break; 349 // break;
351 default: 350 default:
352 QTable::keyPressEvent( e ); 351 QTable::keyPressEvent( e );
353 } 352 }
354 353
355} 354}
356 355
357void AbTable::moveTo( char /*c*/ ) 356void AbTable::moveTo( char /*c*/ )
358{ 357{
359 odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl; 358 odebug << "void AbTable::moveTo( char c ) NOT IMPLEMENTED !!" << oendl;
360 359
361#if 0 360#if 0
362 int rows = numRows(); 361 int rows = numRows();
363 QString value; 362 QString value;
364 AbTableItem *abi; 363 AbTableItem *abi;
365 int r; 364 int r;
366 if ( asc ) { 365 if ( asc ) {
367 r = 0; 366 r = 0;
368 while ( r < rows-1) { 367 while ( r < rows-1) {
369 abi = static_cast<AbTableItem*>( item(r, 0) ); 368 abi = static_cast<AbTableItem*>( item(r, 0) );
370 QChar first = abi->key()[0]; 369 QChar first = abi->key()[0];
371 //### is there a bug in QChar to char comparison??? 370 //### is there a bug in QChar to char comparison???
372 if ( first.row() || first.cell() >= c ) 371 if ( first.row() || first.cell() >= c )
373 break; 372 break;
374 r++; 373 r++;
375 } 374 }
376 } else { 375 } else {
377 //### should probably disable reverse sorting instead 376 //### should probably disable reverse sorting instead
378 r = rows - 1; 377 r = rows - 1;
379 while ( r > 0 ) { 378 while ( r > 0 ) {
380 abi = static_cast<AbTableItem*>( item(r, 0) ); 379 abi = static_cast<AbTableItem*>( item(r, 0) );
381 QChar first = abi->key()[0]; 380 QChar first = abi->key()[0];
382 //### is there a bug in QChar to char comparison??? 381 //### is there a bug in QChar to char comparison???
383 if ( first.row() || first.cell() >= c ) 382 if ( first.row() || first.cell() >= c )
384 break; 383 break;
385 r--; 384 r--;
386 } 385 }
387 } 386 }
388 setCurrentCell( r, currentColumn() ); 387 setCurrentCell( r, currentColumn() );
389 388
390#endif 389#endif
391} 390}
392 391
393#if 0 392#if 0
394// Useless.. Nobody uses it .. (se) 393// Useless.. Nobody uses it .. (se)
395QString AbTable::findContactName( const Opie::OPimContact &entry ) 394QString AbTable::findContactName( const Opie::OPimContact &entry )
396{ 395{
397 // We use the fileAs, then company, defaultEmail 396 // We use the fileAs, then company, defaultEmail
398 QString str; 397 QString str;
399 str = entry.fileAs(); 398 str = entry.fileAs();
400 if ( str.isEmpty() ) { 399 if ( str.isEmpty() ) {
401 str = entry.company(); 400 str = entry.company();
402 if ( str.isEmpty() ) { 401 if ( str.isEmpty() ) {
403 str = entry.defaultEmail(); 402 str = entry.defaultEmail();
404 } 403 }
405 } 404 }
406 return str; 405 return str;
407} 406}
408#endif 407#endif
409 408
410 409
411void AbTable::resizeRows() { 410void AbTable::resizeRows() {
412 /* 411 /*
413 if (numRows()) { 412 if (numRows()) {
414 for (int i = 0; i < numRows(); i++) { 413 for (int i = 0; i < numRows(); i++) {
415 setRowHeight( i, size ); 414 setRowHeight( i, size );
416 } 415 }
417 } 416 }
418 updateVisible(); 417 updateVisible();
419 */ 418 */
420} 419}
421 420
422 421
423void AbTable::realignTable() 422void AbTable::realignTable()
424{ 423{
425 //odebug << "void AbTable::realignTable()" << oendl; 424 //odebug << "void AbTable::realignTable()" << oendl;
426 425
427 setPaintingEnabled( FALSE ); 426 setPaintingEnabled( FALSE );
428 427
429 resizeRows(); 428 resizeRows();
430 fitColumns(); 429 fitColumns();
431 430
432 setPaintingEnabled( TRUE ); 431 setPaintingEnabled( TRUE );
433 432
434} 433}
435 434
436 435
437 436
438 437
439#if QT_VERSION <= 230 438#if QT_VERSION <= 230
440#ifndef SINGLE_APP 439#ifndef SINGLE_APP
441void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) 440void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
442{ 441{
443 // Region of the rect we should draw 442 // Region of the rect we should draw
444 QRegion reg( QRect( cx, cy, cw, ch ) ); 443 QRegion reg( QRect( cx, cy, cw, ch ) );
445 // Subtract the table from it 444 // Subtract the table from it
446 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); 445 reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
447 // And draw the rectangles (transformed as needed) 446 // And draw the rectangles (transformed as needed)
448 QArray<QRect> r = reg.rects(); 447 QArray<QRect> r = reg.rects();
449 for (unsigned int i=0; i<r.count(); i++) 448 for (unsigned int i=0; i<r.count(); i++)
450 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); 449 p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
451} 450}
452#endif 451#endif
453#endif 452#endif
454 453
455 454
456// int AbTable::rowHeight( int ) const 455// int AbTable::rowHeight( int ) const
457// { 456// {
458// return 18; 457// return 18;
459// } 458// }
460 459
461// int AbTable::rowPos( int row ) const 460// int AbTable::rowPos( int row ) const
462// { 461// {
463// return 18*row; 462// return 18*row;
464// } 463// }
465 464
466// int AbTable::rowAt( int pos ) const 465// int AbTable::rowAt( int pos ) const
467// { 466// {
468// return QMIN( pos/18, numRows()-1 ); 467// return QMIN( pos/18, numRows()-1 );
469// } 468// }
470 469
471 470
472 471
473void AbTable::fitColumns() 472void AbTable::fitColumns()
474{ 473{
475 odebug << "void AbTable::fitColumns()" << oendl; 474 odebug << "void AbTable::fitColumns()" << oendl;
476 int contentsWidth = visibleWidth() / 2; 475 int contentsWidth = visibleWidth() / 2;
477 // Fix to better value 476 // Fix to better value
478 // contentsWidth = 130; 477 // contentsWidth = 130;
479 478
480 setPaintingEnabled( FALSE ); 479 setPaintingEnabled( FALSE );
481 480
482 if ( columnVisible == false ){ 481 if ( columnVisible == false ){
483 showColumn(0); 482 showColumn(0);
484 columnVisible = true; 483 columnVisible = true;
485 } 484 }
486 485
487 //odebug << "Width: " << contentsWidth << oendl; 486 //odebug << "Width: " << contentsWidth << oendl;
488 487
489 setColumnWidth( 0, contentsWidth ); 488 setColumnWidth( 0, contentsWidth );
490 adjustColumn(1); 489 adjustColumn(1);
491 if ( columnWidth(1) < contentsWidth ) 490 if ( columnWidth(1) < contentsWidth )
492 setColumnWidth( 1, contentsWidth ); 491 setColumnWidth( 1, contentsWidth );
493 492
494 setPaintingEnabled( TRUE ); 493 setPaintingEnabled( TRUE );
495} 494}
496 495
497void AbTable::show() 496void AbTable::show()
498{ 497{
499 //odebug << "void AbTable::show()" << oendl; 498 //odebug << "void AbTable::show()" << oendl;
500 realignTable(); 499 realignTable();
501 QTable::show(); 500 QTable::show();
502} 501}
503 502
504#if 0 503#if 0
505void AbTable::setChoiceNames( const QStringList& list) 504void AbTable::setChoiceNames( const QStringList& list)
506{ 505{
507 choicenames = list; 506 choicenames = list;
508 if ( choicenames.isEmpty() ) { 507 if ( choicenames.isEmpty() ) {
509 // hide pick column 508 // hide pick column
510 setNumCols( 2 ); 509 setNumCols( 2 );
511 } else { 510 } else {
512 // show pick column 511 // show pick column
513 setNumCols( 3 ); 512 setNumCols( 3 );
514 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); 513 setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
515 horizontalHeader()->setLabel( 2, tr( "Pick" )); 514 horizontalHeader()->setLabel( 2, tr( "Pick" ));
516 } 515 }
517 fitColumns(); 516 fitColumns();
518} 517}
519#endif 518#endif
520 519
521void AbTable::itemClicked(int,int col) 520void AbTable::itemClicked(int,int col)
522{ 521{
523 //odebug << "AbTable::itemClicked(int, col: " << col << ")" << oendl; 522 //odebug << "AbTable::itemClicked(int, col: " << col << ")" << oendl;
524 if ( col == 2 ) { 523 if ( col == 2 ) {
525 return; 524 return;
526 } else { 525 } else {
527 //odebug << "Emitting signalSwitch()" << oendl; 526 //odebug << "Emitting signalSwitch()" << oendl;
528 emit signalSwitch(); 527 emit signalSwitch();
529 } 528 }
530} 529}
531 530
532#if 0 531#if 0
533QStringList AbTable::choiceNames() const 532QStringList AbTable::choiceNames() const
534{ 533{
535 return choicenames; 534 return choicenames;
536} 535}
537 536
538#endif 537#endif
539void AbTable::setChoiceSelection( const QValueList<int>& list ) 538void AbTable::setChoiceSelection( const QValueList<int>& list )
540{ 539{
541 intFields = list; 540 intFields = list;
542} 541}
543 542
544QStringList AbTable::choiceSelection(int /*index*/) const 543QStringList AbTable::choiceSelection(int /*index*/) const
545{ 544{
546 QStringList r; 545 QStringList r;
547 /* ###### 546 /* ######
548 547
549 QString selname = choicenames.at(index); 548 QString selname = choicenames.at(index);
550 for (each row) { 549 for (each row) {
551 Opie::OPimContact *c = contactForRow(row); 550 Opie::OPimContact *c = contactForRow(row);
552 if ( text(row,2) == selname ) { 551 if ( text(row,2) == selname ) {
553 r.append(c->email); 552 r.append(c->email);
554 } 553 }
555 } 554 }
556 555
557 */ 556 */
558 return r; 557 return r;
559} 558}
560 559
561 560
562void AbTable::updateVisible() 561void AbTable::updateVisible()
563{ 562{
564 //odebug << "void AbTable::updateVisible()" << oendl; 563 //odebug << "void AbTable::updateVisible()" << oendl;
565 564
566 int visible, 565 int visible,
567 totalRows, 566 totalRows,
568 row, 567 row,
569 selectedRow = 0; 568 selectedRow = 0;
570 569
571 visible = 0; 570 visible = 0;
572 571
573 setPaintingEnabled( FALSE ); 572 setPaintingEnabled( FALSE );
574 573
575 realignTable(); 574 realignTable();
576 575
577 totalRows = numRows(); 576 totalRows = numRows();
578 for ( row = 0; row < totalRows; row++ ) { 577 for ( row = 0; row < totalRows; row++ ) {
579 if ( rowHeight(row) == 0 ) { 578 if ( rowHeight(row) == 0 ) {
580 showRow( row ); 579 showRow( row );
581 adjustRow( row ); 580 adjustRow( row );
582 if ( isSelected( row,0 ) || isSelected( row,1 ) ) 581 if ( isSelected( row,0 ) || isSelected( row,1 ) )
583 selectedRow = row; 582 selectedRow = row;
584 } 583 }
585 visible++; 584 visible++;
586 } 585 }
587 586
588 if ( selectedRow ) 587 if ( selectedRow )
589 setCurrentCell( selectedRow, 0 ); 588 setCurrentCell( selectedRow, 0 );
590 589
591 if ( !visible ) 590 if ( !visible )
592 setCurrentCell( -1, 0 ); 591 setCurrentCell( -1, 0 );
593 592
594 setPaintingEnabled( TRUE ); 593 setPaintingEnabled( TRUE );
595} 594}
596 595
597 596
598void AbTable::setPaintingEnabled( bool e ) 597void AbTable::setPaintingEnabled( bool e )
599{ 598{
600 //odebug << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: " 599 //odebug << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: "
601 // << countNested << oendl; 600 // << countNested << oendl;
602 601
603 if ( e ) { 602 if ( e ) {
604 if ( countNested > 0 ) 603 if ( countNested > 0 )
605 --countNested; 604 --countNested;
606 if ( ! countNested ){ 605 if ( ! countNested ){
607 setUpdatesEnabled( true ); 606 setUpdatesEnabled( true );
608 enablePainting = true; 607 enablePainting = true;
609 rowHeightChanged( 0 ); 608 rowHeightChanged( 0 );
610 viewport()->update(); 609 viewport()->update();
611 } 610 }
612 } else { 611 } else {
613 ++countNested; 612 ++countNested;
614 enablePainting = false; 613 enablePainting = false;
615 setUpdatesEnabled( false ); 614 setUpdatesEnabled( false );
616 } 615 }
617 //odebug << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: " 616 //odebug << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: "
618 // << countNested << oendl; 617 // << countNested << oendl;
619} 618}
620 619
621void AbTable::viewportPaintEvent( QPaintEvent* e ) { 620void AbTable::viewportPaintEvent( QPaintEvent* e ) {
622 //odebug << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> " 621 //odebug << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> "
623 // << enablePainting << oendl; 622 // << enablePainting << oendl;
624 if ( enablePainting ) 623 if ( enablePainting )
625 QTable::viewportPaintEvent( e ); 624 QTable::viewportPaintEvent( e );
626} 625}
627 626
628void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 627void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
629 const QColorGroup &cg = colorGroup(); 628 const QColorGroup &cg = colorGroup();
630 629
631 p->save(); 630 p->save();
632 631
633 //odebug << "Paint row: " << row << oendl; 632 //odebug << "Paint row: " << row << oendl;
634 633
635 Opie::OPimContact act_contact = m_viewList[row]; 634 Opie::OPimContact act_contact = m_viewList[row];
636 635
637 // Paint alternating background bars 636 // Paint alternating background bars
638 if ( (row % 2 ) == 0 ) { 637 if ( (row % 2 ) == 0 ) {
639 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 638 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
640 p->setPen( QPen( cg.text() ) ); 639 p->setPen( QPen( cg.text() ) );
641 } 640 }
642 else { 641 else {
643 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); 642 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
644 p->setPen( QPen( cg.buttonText() ) ); 643 p->setPen( QPen( cg.buttonText() ) );
645 } 644 }
646 645
647 QFont f = p->font(); 646 QFont f = p->font();
648 QFontMetrics fm(f); 647 QFontMetrics fm(f);
649 648
650 int marg = 2; 649 int marg = 2;
651 int x = 0; 650 int x = 0;
652 int y = ( cr.height() - 14 ) / 2; 651 int y = ( cr.height() - 14 ) / 2;
653 652
654 QString nameText = act_contact.fileAs(); 653 QString nameText = act_contact.fileAs();
655 654
656 switch( col ){ 655 switch( col ){
657 case 0: 656 case 0:
658 p->drawText( x + marg,2 + fm.ascent(), nameText ); 657 p->drawText( x + marg,2 + fm.ascent(), nameText );
659 break; 658 break;
660 case 1:{ 659 case 1:{
661 660
662 ContactItem contactItem = findContactContact( act_contact, 0 ); 661 ContactItem contactItem = findContactContact( act_contact, 0 );
663 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */ 662 QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */
664 QString contactText = contactItem.value; 663 QString contactText = contactItem.value;
665 664
666 if ( !contactPic.isNull() ) 665 if ( !contactPic.isNull() )
667 { 666 {
668 p->drawPixmap( x + marg, y, contactPic ); 667 p->drawPixmap( x + marg, y, contactPic );
669 p->drawText( x + marg + contactPic.width() 668 p->drawText( x + marg + contactPic.width()
670 + 4,2 + fm.ascent(), contactText ); 669 + 4,2 + fm.ascent(), contactText );
671 } 670 }
672 else 671 else
673 { 672 {
674 p->drawText( x + marg,2 + fm.ascent(), contactText ); 673 p->drawText( x + marg,2 + fm.ascent(), contactText );
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 6be19f8..34035fd 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,520 +1,516 @@
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_curr_category( -1 ), 45 m_curr_category( 0 ),
46 m_curr_View( TableView ), 46 m_curr_View( TableView ),
47 m_prev_View( TableView ), 47 m_prev_View( TableView ),
48 m_curr_Contact ( 0 ), 48 m_curr_Contact ( 0 ),
49 m_contactdb ( 0l ), 49 m_contactdb ( 0l ),
50 m_storedDB ( 0l ), 50 m_storedDB ( 0l ),
51 m_viewStack( 0l ), 51 m_viewStack( 0l ),
52 m_abTable( 0l ), 52 m_abTable( 0l ),
53 m_orderedFields( ordered ) 53 m_orderedFields( ordered )
54{ 54{
55 odebug << "AbView::c'tor" << oendl; 55 odebug << "AbView::c'tor" << oendl;
56 // Load default database and handle syncing myself.. ! 56 // Load default database and handle syncing myself.. !
57 m_contactdb = new Opie::OPimContactAccess ( "addressbook", 0l, 0l, false ); 57 m_contactdb = new Opie::OPimContactAccess ( "addressbook", 0l, 0l, false );
58 m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available 58 m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available
59 mCat.load( categoryFileName() ); 59 mCat.load( categoryFileName() );
60 60
61 // Create Layout and put WidgetStack into it. 61 // Create Layout and put WidgetStack into it.
62 QVBoxLayout *vb = new QVBoxLayout( this ); 62 QVBoxLayout *vb = new QVBoxLayout( this );
63 m_viewStack = new QWidgetStack( this ); 63 m_viewStack = new QWidgetStack( this );
64 vb->addWidget( m_viewStack ); 64 vb->addWidget( m_viewStack );
65 65
66 // Creat TableView 66 // Creat TableView
67 QVBox* tableBox = new QVBox( m_viewStack ); 67 QVBox* tableBox = new QVBox( m_viewStack );
68 m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); 68 m_abTable = new AbTable( m_orderedFields, tableBox, "table" );
69 m_abTable->setCurrentCell( 0, 0 ); 69 m_abTable->setCurrentCell( 0, 0 );
70 m_abTable->setFocus(); 70 m_abTable->setFocus();
71 71
72 // Add TableView to WidgetStack and raise it 72 // Add TableView to WidgetStack and raise it
73 m_viewStack -> addWidget( tableBox , TableView ); 73 m_viewStack -> addWidget( tableBox , TableView );
74 74
75 // Create CardView and add it to WidgetStack 75 // Create CardView and add it to WidgetStack
76 QVBox* cardBox = new QVBox( m_viewStack ); 76 QVBox* cardBox = new QVBox( m_viewStack );
77 m_ablabel = new AbLabel( cardBox, "CardView"); 77 m_ablabel = new AbLabel( cardBox, "CardView");
78 m_viewStack -> addWidget( cardBox , CardView ); 78 m_viewStack -> addWidget( cardBox , CardView );
79 79
80 // Connect views to me 80 // Connect views to me
81 connect ( m_abTable, SIGNAL( signalSwitch(void) ), 81 connect ( m_abTable, SIGNAL( signalSwitch(void) ),
82 this, SLOT( slotSwitch(void) ) ); 82 this, SLOT( slotSwitch(void) ) );
83 connect ( m_ablabel, SIGNAL( signalOkPressed(void) ), 83 connect ( m_ablabel, SIGNAL( signalOkPressed(void) ),
84 this, SLOT( slotSwitch(void) ) ); 84 this, SLOT( slotSwitch(void) ) );
85 85
86 load(); 86 load();
87} 87}
88 88
89AbView::~AbView() 89AbView::~AbView()
90{ 90{
91 m_contactdb -> save(); 91 m_contactdb -> save();
92 delete m_contactdb; 92 delete m_contactdb;
93 93
94 if ( m_storedDB ){ 94 if ( m_storedDB ){
95 m_storedDB -> save(); 95 m_storedDB -> save();
96 delete m_storedDB; 96 delete m_storedDB;
97 } 97 }
98} 98}
99 99
100 100
101void AbView::setView( Views view ) 101void AbView::setView( Views view )
102{ 102{
103 odebug << "AbView::setView( Views view )" << oendl; 103 odebug << "AbView::setView( Views view )" << oendl;
104 m_curr_View = view; 104 m_curr_View = view;
105 load(); 105 load();
106} 106}
107 107
108void AbView::addEntry( const Opie::OPimContact &newContact ) 108void AbView::addEntry( const Opie::OPimContact &newContact )
109{ 109{
110 odebug << "AbView::AddContact" << oendl; 110 odebug << "AbView::AddContact" << oendl;
111 m_contactdb->add ( newContact ); 111 m_contactdb->add ( newContact );
112 load(); 112 load();
113 113
114} 114}
115void AbView::removeEntry( const int UID ) 115void AbView::removeEntry( const int UID )
116{ 116{
117 odebug << "AbView;:RemoveContact" << oendl; 117 odebug << "AbView;:RemoveContact" << oendl;
118 m_contactdb->remove( UID ); 118 m_contactdb->remove( UID );
119 load(); 119 load();
120} 120}
121 121
122void AbView::replaceEntry( const Opie::OPimContact &contact ) 122void AbView::replaceEntry( const Opie::OPimContact &contact )
123{ 123{
124 odebug << "AbView::ReplaceContact" << oendl; 124 odebug << "AbView::ReplaceContact" << oendl;
125 m_contactdb->replace( contact ); 125 m_contactdb->replace( contact );
126 load(); 126 load();
127 127
128} 128}
129 129
130Opie::OPimContact AbView::currentEntry() 130Opie::OPimContact AbView::currentEntry()
131{ 131{
132 Opie::OPimContact currentContact; 132 Opie::OPimContact currentContact;
133 133
134 switch ( (int) m_curr_View ) { 134 switch ( (int) m_curr_View ) {
135 case TableView: 135 case TableView:
136 currentContact = m_abTable -> currentEntry(); 136 currentContact = m_abTable -> currentEntry();
137 break; 137 break;
138 case CardView: 138 case CardView:
139 currentContact = m_ablabel -> currentEntry(); 139 currentContact = m_ablabel -> currentEntry();
140 break; 140 break;
141 } 141 }
142 m_curr_Contact = currentContact.uid(); 142 m_curr_Contact = currentContact.uid();
143 return currentContact; 143 return currentContact;
144} 144}
145 145
146bool AbView::save() 146bool AbView::save()
147{ 147{
148 //odebug << "AbView::Save data" << oendl; 148 //odebug << "AbView::Save data" << oendl;
149 149
150 return m_contactdb->save(); 150 return m_contactdb->save();
151} 151}
152 152
153void AbView::load() 153void AbView::load()
154{ 154{
155 odebug << "AbView::Load data" << oendl; 155 odebug << "AbView::Load data" << oendl;
156 156
157 // Letter Search is stopped at this place 157 // Letter Search is stopped at this place
158 emit signalClearLetterPicker(); 158 emit signalClearLetterPicker();
159 159
160 if ( m_curr_category == 0 ) { 160 m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName,
161 // Show unfiled 161 Opie::OPimContactAccess::FilterCategory, m_curr_category );
162 m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, 162
163 Opie::OPimContactAccess::DoNotShowWithCategory, 0 );
164 } elseif ( m_curr_category != -1 ){
165 // Just show selected category
166 m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName,
167 Opie::OPimBase::FilterCategory, m_curr_category );
168 } else {
169 // Show all categories
170 m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName,
171 Opie::OPimBase::FilterOff, 0 );
172 }
173
174 // if ( m_curr_category != -1 ) 163 // if ( m_curr_category != -1 )
175 // clearForCategory(); 164 // clearForCategory();
176 165
177 odebug << "Number of contacts: " << m_list.count() << oendl; 166 odebug << "Number of contacts: " << m_list.count() << oendl;
178 167
179 updateView( true ); 168 updateView( true );
180 169
181} 170}
182 171
183void AbView::reload() 172void AbView::reload()
184{ 173{
185 odebug << "AbView::::reload()" << oendl; 174 odebug << "AbView::::reload()" << oendl;
186 175
187 m_contactdb->reload(); 176 m_contactdb->reload();
188 load(); 177 load();
189} 178}
190 179
191void AbView::clear() 180void AbView::clear()
192{ 181{
193 // :SX 182 // :SX
194} 183}
195 184
196void AbView::setShowByCategory( const QString& cat ) 185void AbView::setShowByCategory( const QString& cat )
197{ 186{
198 odebug << "AbView::setShowCategory( const QString& cat )" << oendl; 187 odebug << "AbView::setShowCategory( const QString& cat )" << oendl;
199 188
200 int intCat = 0; 189 int intCat = 0;
201 190
202 // All (cat == NULL) will be stored as -1 191 // Unfiled will be stored as -1
203 if ( cat.isNull() ) 192 if ( cat == tr( "Unfiled" ) )
204 intCat = -1; 193 intCat = -1;
194 else if ( cat.isNull() )
195 intCat = 0;
205 else 196 else
206 intCat = mCat.id("Contacts", cat ); 197 intCat = mCat.id("Contacts", cat );
207 198
208 // Just do anything if we really change the category 199 // Just do anything if we really change the category
209 if ( intCat != m_curr_category ){ 200 if ( intCat != m_curr_category ){
210 // odebug << "Categories: Selected " << cat << ".. Number: " 201 // odebug << "Categories: Selected " << cat << ".. Number: "
211 // << m_curr_category << oendl; 202 // << m_curr_category << oendl;
212 203
213 m_curr_category = intCat; 204 m_curr_category = intCat;
214 emit signalClearLetterPicker(); 205 emit signalClearLetterPicker();
215
216 load(); 206 load();
217 } 207 }
208 m_curr_category = intCat;
218 209
219} 210}
220 211
221void AbView::setShowToView( Views view ) 212void AbView::setShowToView( Views view )
222{ 213{
223 odebug << "void AbView::setShowToView( View " << view << " )" << oendl; 214 odebug << "void AbView::setShowToView( View " << view << " )" << oendl;
224 215
225 if ( m_curr_View != view ){ 216 if ( m_curr_View != view ){
226 odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; 217 odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl;
227 m_prev_View = m_curr_View; 218 m_prev_View = m_curr_View;
228 m_curr_View = view; 219 m_curr_View = view;
229 220
230 updateView(); 221 updateView();
231 } 222 }
232 223
233} 224}
234 225
235void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) 226void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode )
236{ 227{
237 odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; 228 odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl;
238 229
239 assert( mode < AbConfig::LASTELEMENT ); 230 assert( mode < AbConfig::LASTELEMENT );
240 231
241 Opie::OPimContact query; 232 Opie::OPimContact query;
242 if ( c == 0 ){ 233 if ( c == 0 ){
243 load(); 234 load();
244 return; 235 return;
245 }else{ 236 }else{
246 // If the current Backend is unable to solve the query, we will 237 // If the current Backend is unable to solve the query, we will
247 // ignore the request .. 238 // ignore the request ..
248 if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | 239 if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards |
249 Opie::OPimContactAccess::IgnoreCase ) ){ 240 Opie::OPimContactAccess::IgnoreCase ) ){
250 owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl; 241 owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl;
251 owarn << "I have to ignore this access!" << oendl; 242 owarn << "I have to ignore this access!" << oendl;
252 return; 243 return;
253 } 244 }
254 245
255 switch( mode ){ 246 switch( mode ){
256 case AbConfig::LastName: 247 case AbConfig::LastName:
257 query.setLastName( QString("%1*").arg(c) ); 248 query.setLastName( QString("%1*").arg(c) );
258 break; 249 break;
259 case AbConfig::FileAs: 250 case AbConfig::FileAs:
260 query.setFileAs( QString("%1*").arg(c) ); 251 query.setFileAs( QString("%1*").arg(c) );
261 break; 252 break;
262 default: 253 default:
263 owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl 254 owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl
264 << "I will ignore it.." << oendl; 255 << "I will ignore it.." << oendl;
265 return; 256 return;
266 } 257 }
267 m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); 258 m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase );
268 if ( m_curr_category != -1 ) 259
260 if ( m_curr_category != 0 )
269 clearForCategory(); 261 clearForCategory();
262
263 // Sort filtered results
264 m_list = m_contactdb->sorted( m_list, true, Opie::OPimContactAccess::SortFileAsName,
265 Opie::OPimContactAccess::FilterCategory, m_curr_category );
270 m_curr_Contact = 0; 266 m_curr_Contact = 0;
271 } 267 }
272 updateView( true ); 268 updateView( true );
273} 269}
274 270
275void AbView::setListOrder( const QValueList<int>& ordered ) 271void AbView::setListOrder( const QValueList<int>& ordered )
276{ 272{
277 m_orderedFields = ordered; 273 m_orderedFields = ordered;
278 if ( m_abTable ){ 274 if ( m_abTable ){
279 m_abTable->setOrderedList( ordered ); 275 m_abTable->setOrderedList( ordered );
280 m_abTable->refresh(); 276 m_abTable->refresh();
281 } 277 }
282 updateView(); 278 updateView();
283} 279}
284 280
285 281
286QString AbView::showCategory() const 282QString AbView::showCategory() const
287{ 283{
288 return mCat.label( "Contacts", m_curr_category ); 284 return mCat.label( "Contacts", m_curr_category );
289} 285}
290 286
291void AbView::showPersonal( bool personal ) 287void AbView::showPersonal( bool personal )
292{ 288{
293 odebug << "void AbView::showPersonal( " << personal << " )" << oendl; 289 odebug << "void AbView::showPersonal( " << personal << " )" << oendl;
294 290
295 if ( personal ){ 291 if ( personal ){
296 292
297 if ( m_inPersonal ) 293 if ( m_inPersonal )
298 return; 294 return;
299 295
300 // Now switch to vCard Backend and load data. 296 // Now switch to vCard Backend and load data.
301 // The current default backend will be stored 297 // The current default backend will be stored
302 // to avoid unneeded load/stores. 298 // to avoid unneeded load/stores.
303 m_storedDB = m_contactdb; 299 m_storedDB = m_contactdb;
304 300
305 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 301 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
306 addressbookPersonalVCardName() ); 302 addressbookPersonalVCardName() );
307 m_contactdb = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 303 m_contactdb = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
308 304
309 m_inPersonal = true; 305 m_inPersonal = true;
310 m_curr_View = CardView; 306 m_curr_View = CardView;
311 307
312 }else{ 308 }else{
313 309
314 if ( !m_inPersonal ) 310 if ( !m_inPersonal )
315 return; 311 return;
316 312
317 // Remove vCard Backend and restore default 313 // Remove vCard Backend and restore default
318 m_contactdb->save(); 314 m_contactdb->save();
319 delete m_contactdb; 315 delete m_contactdb;
320 316
321 m_contactdb = m_storedDB; 317 m_contactdb = m_storedDB;
322 m_storedDB = 0l; 318 m_storedDB = 0l;
323 319
324 m_curr_View = TableView; 320 m_curr_View = TableView;
325 m_inPersonal = false; 321 m_inPersonal = false;
326 322
327 } 323 }
328 load(); 324 load();
329} 325}
330 326
331void AbView::setCurrentUid( int uid ){ 327void AbView::setCurrentUid( int uid ){
332 328
333 m_curr_Contact = uid; 329 m_curr_Contact = uid;
334 updateView( true ); //true: Don't modificate the UID ! 330 updateView( true ); //true: Don't modificate the UID !
335} 331}
336 332
337 333
338QStringList AbView::categories() 334QStringList AbView::categories()
339{ 335{
340 mCat.load( categoryFileName() ); 336 mCat.load( categoryFileName() );
341 QStringList categoryList = mCat.labels( "Contacts" ); 337 QStringList categoryList = mCat.labels( "Contacts" );
342 return categoryList; 338 return categoryList;
343} 339}
344 340
345// BEGIN: Slots 341// BEGIN: Slots
346void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 342void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
347 bool , QString cat ) 343 bool , QString cat )
348{ 344{
349 //owarn << "void AbView::slotDoFind" << oendl; 345 //owarn << "void AbView::slotDoFind" << oendl;
350 346
351 // We reloading the data: Deselect Letterpicker 347 // We reloading the data: Deselect Letterpicker
352 emit signalClearLetterPicker(); 348 emit signalClearLetterPicker();
353 349
354 // Use the current Category if nothing else selected 350 // Use the current Category if nothing else selected
355 int category = 0; 351 int category = 0;
356 352
357 if ( cat.isEmpty() ) 353 if ( cat.isEmpty() )
358 category = m_curr_category; 354 category = m_curr_category;
359 else{ 355 else{
360 category = mCat.id("Contacts", cat ); 356 category = mCat.id("Contacts", cat );
361 } 357 }
362 358
363 //odebug << "Find in Category " << category << oendl; 359 //odebug << "Find in Category " << category << oendl;
364 360
365 QRegExp r( str ); 361 QRegExp r( str );
366 r.setCaseSensitive( caseSensitive ); 362 r.setCaseSensitive( caseSensitive );
367 r.setWildcard( !useRegExp ); 363 r.setWildcard( !useRegExp );
368 364
369 // Get all matching entries out of the database 365 // Get all matching entries out of the database
370 m_list = m_contactdb->matchRegexp( r ); 366 m_list = m_contactdb->matchRegexp( r );
371 367
372 //odebug << "Found: " << m_list.count() << oendl; 368 //odebug << "Found: " << m_list.count() << oendl;
373 if ( m_list.count() == 0 ){ 369 if ( m_list.count() == 0 ){
374 emit signalNotFound(); 370 emit signalNotFound();
375 return; 371 return;
376 } 372 }
377 373
378 // Now remove all contacts with wrong category (if any selected) 374 // Now remove all contacts with wrong category (if any selected)
379 // This algorithm is a litte bit ineffective, but 375 // This algorithm is a litte bit ineffective, but
380 // we will not have a lot of matching entries.. 376 // we will not have a lot of matching entries..
381 if ( m_curr_category != -1 ) 377 if ( m_curr_category != 0 )
382 clearForCategory(); 378 clearForCategory();
383 379
384 // Now show all found entries 380 // Now show all found entries
385 updateView( true ); 381 updateView( true );
386} 382}
387 383
388void AbView::offSearch() 384void AbView::offSearch()
389{ 385{
390 m_inSearch = false; 386 m_inSearch = false;
391 387
392 load(); 388 load();
393} 389}
394 390
395void AbView::slotSwitch(){ 391void AbView::slotSwitch(){
396 //odebug << "AbView::slotSwitch()" << oendl; 392 //odebug << "AbView::slotSwitch()" << oendl;
397 393
398 m_prev_View = m_curr_View; 394 m_prev_View = m_curr_View;
399 switch ( (int) m_curr_View ){ 395 switch ( (int) m_curr_View ){
400 case TableView: 396 case TableView:
401 odebug << "Switching to CardView" << oendl; 397 odebug << "Switching to CardView" << oendl;
402 m_curr_View = CardView; 398 m_curr_View = CardView;
403 break; 399 break;
404 case CardView: 400 case CardView:
405 odebug << "Switching to TableView" << oendl; 401 odebug << "Switching to TableView" << oendl;
406 m_curr_View = TableView; 402 m_curr_View = TableView;
407 break; 403 break;
408 } 404 }
409 updateView(); 405 updateView();
410 406
411} 407}
412 408
413// END: Slots 409// END: Slots
414 410
415void AbView::clearForCategory() 411void AbView::clearForCategory()
416{ 412{
417 Opie::OPimContactAccess::List::Iterator it; 413 Opie::OPimContactAccess::List::Iterator it;
418 // Now remove all contacts with wrong category if any category selected 414 // Now remove all contacts with wrong category if any category selected
419 415
420 Opie::OPimContactAccess::List allList = m_list; 416 Opie::OPimContactAccess::List allList = m_list;
421 if ( m_curr_category != -1 ){ 417 if ( m_curr_category != 0 ){
422 for ( it = allList.begin(); it != allList.end(); ++it ){ 418 for ( it = allList.begin(); it != allList.end(); ++it ){
423 if ( !contactCompare( *it, m_curr_category ) ){ 419 if ( !contactCompare( *it, m_curr_category ) ){
424 //odebug << "Removing " << (*it).uid() << oendl; 420 //odebug << "Removing " << (*it).uid() << oendl;
425 m_list.remove( (*it).uid() ); 421 m_list.remove( (*it).uid() );
426 } 422 }
427 } 423 }
428 } 424 }
429 425
430} 426}
431 427
432bool AbView::contactCompare( const Opie::OPimContact &cnt, int category ) 428bool AbView::contactCompare( const Opie::OPimContact &cnt, int category )
433{ 429{
434 //odebug << "bool AbView::contactCompare( const Opie::OPimContact &cnt, " 430 //odebug << "bool AbView::contactCompare( const Opie::OPimContact &cnt, "
435 // << category << " )" << oendl; 431 // << category << " )" << oendl;
436 432
437 bool returnMe; 433 bool returnMe;
438 QArray<int> cats; 434 QArray<int> cats;
439 cats = cnt.categories(); 435 cats = cnt.categories();
440 436
441 //odebug << "Number of categories: " << cats.count() << oendl; 437 //odebug << "Number of categories: " << cats.count() << oendl;
442 438
443 returnMe = false; 439 returnMe = false;
444 if ( cats.count() == 0 && category == 0 ) 440 if ( cats.count() == 0 && category == -1 )
445 // Contacts with no category will just shown on "All" and "Unfiled" 441 // Contacts with no category will just shown on "All" and "Unfiled"
446 returnMe = true; 442 returnMe = true;
447 else { 443 else {
448 int i; 444 int i;
449 for ( i = 0; i < int(cats.count()); i++ ) { 445 for ( i = 0; i < int(cats.count()); i++ ) {
450 //odebug << "Comparing " << cats[i] << " with " << category << oendl; 446 //odebug << "Comparing " << cats[i] << " with " << category << oendl;
451 if ( cats[i] == category ) { 447 if ( cats[i] == category ) {
452 returnMe = true; 448 returnMe = true;
453 break; 449 break;
454 } 450 }
455 } 451 }
456 } 452 }
457 //odebug << "Return: " << returnMe << oendl; 453 //odebug << "Return: " << returnMe << oendl;
458 return returnMe; 454 return returnMe;
459} 455}
460 456
461// In Some rare cases we have to update all lists.. 457// In Some rare cases we have to update all lists..
462void AbView::updateListinViews() 458void AbView::updateListinViews()
463{ 459{
464 m_abTable -> setContacts( m_list ); 460 m_abTable -> setContacts( m_list );
465 m_ablabel -> setContacts( m_list ); 461 m_ablabel -> setContacts( m_list );
466} 462}
467 463
468void AbView::updateView( bool newdata ) 464void AbView::updateView( bool newdata )
469{ 465{
470 //odebug << "AbView::updateView()" << oendl; 466 //odebug << "AbView::updateView()" << oendl;
471 467
472 if ( m_viewStack -> visibleWidget() ){ 468 if ( m_viewStack -> visibleWidget() ){
473 m_viewStack -> visibleWidget() -> clearFocus(); 469 m_viewStack -> visibleWidget() -> clearFocus();
474 } 470 }
475 471
476 // If we switching the view, we have to store some information 472 // If we switching the view, we have to store some information
477 if ( !newdata ){ 473 if ( !newdata ){
478 if ( m_list.count() ){ 474 if ( m_list.count() ){
479 switch ( (int) m_prev_View ) { 475 switch ( (int) m_prev_View ) {
480 case TableView: 476 case TableView:
481 m_curr_Contact = m_abTable -> currentEntry_UID(); 477 m_curr_Contact = m_abTable -> currentEntry_UID();
482 break; 478 break;
483 case CardView: 479 case CardView:
484 m_curr_Contact = m_ablabel -> currentEntry_UID(); 480 m_curr_Contact = m_ablabel -> currentEntry_UID();
485 break; 481 break;
486 } 482 }
487 }else 483 }else
488 m_curr_Contact = 0; 484 m_curr_Contact = 0;
489 } 485 }
490 486
491 // Feed all views with new lists 487 // Feed all views with new lists
492 if ( newdata ) 488 if ( newdata )
493 updateListinViews(); 489 updateListinViews();
494 490
495 // Tell the world that the view is changed 491 // Tell the world that the view is changed
496 if ( m_curr_View != m_prev_View ) 492 if ( m_curr_View != m_prev_View )
497 emit signalViewSwitched ( (int) m_curr_View ); 493 emit signalViewSwitched ( (int) m_curr_View );
498 494
499 m_prev_View = m_curr_View; 495 m_prev_View = m_curr_View;
500 496
501 // Switch to new View 497 // Switch to new View
502 switch ( (int) m_curr_View ) { 498 switch ( (int) m_curr_View ) {
503 case TableView: 499 case TableView:
504 m_abTable -> setChoiceSelection( m_orderedFields ); 500 m_abTable -> setChoiceSelection( m_orderedFields );
505 if ( m_curr_Contact != 0 ) 501 if ( m_curr_Contact != 0 )
506 m_abTable -> selectContact ( m_curr_Contact ); 502 m_abTable -> selectContact ( m_curr_Contact );
507 m_abTable -> setFocus(); 503 m_abTable -> setFocus();
508 break; 504 break;
509 case CardView: 505 case CardView:
510 if ( m_curr_Contact != 0 ) 506 if ( m_curr_Contact != 0 )
511 m_ablabel -> selectContact( m_curr_Contact ); 507 m_ablabel -> selectContact( m_curr_Contact );
512 m_ablabel -> setFocus(); 508 m_ablabel -> setFocus();
513 break; 509 break;
514 } 510 }
515 511
516 // Raise the current View 512 // Raise the current View
517 m_viewStack -> raiseWidget( m_curr_View ); 513 m_viewStack -> raiseWidget( m_curr_View );
518} 514}
519 515
520 516
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 6984501..faae0a9 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -345,542 +345,545 @@ void AddressbookWindow::slotItemNew()
345void AddressbookWindow::slotItemEdit() 345void AddressbookWindow::slotItemEdit()
346{ 346{
347 if(!syncing) { 347 if(!syncing) {
348 if (m_actionPersonal->isOn()) { 348 if (m_actionPersonal->isOn()) {
349 editPersonal(); 349 editPersonal();
350 } else { 350 } else {
351 editEntry( EditEntry ); 351 editEntry( EditEntry );
352 } 352 }
353 } else { 353 } else {
354 QMessageBox::warning( this, tr("Contacts"), 354 QMessageBox::warning( this, tr("Contacts"),
355 tr("Can not edit data, currently syncing") ); 355 tr("Can not edit data, currently syncing") );
356 } 356 }
357} 357}
358 358
359void AddressbookWindow::slotItemDuplicate() 359void AddressbookWindow::slotItemDuplicate()
360{ 360{
361 if(!syncing) 361 if(!syncing)
362 { 362 {
363 Opie::OPimContact entry = m_abView->currentEntry(); 363 Opie::OPimContact entry = m_abView->currentEntry();
364 entry.assignUid(); 364 entry.assignUid();
365 m_abView->addEntry( entry ); 365 m_abView->addEntry( entry );
366 m_abView->setCurrentUid( entry.uid() ); 366 m_abView->setCurrentUid( entry.uid() );
367 } 367 }
368 else 368 else
369 { 369 {
370 QMessageBox::warning( this, tr("Contacts"), 370 QMessageBox::warning( this, tr("Contacts"),
371 tr("Can not edit data, currently syncing") ); 371 tr("Can not edit data, currently syncing") );
372 } 372 }
373} 373}
374 374
375void AddressbookWindow::slotItemDelete() 375void AddressbookWindow::slotItemDelete()
376{ 376{
377 if(!syncing) { 377 if(!syncing) {
378 Opie::OPimContact tmpEntry = m_abView ->currentEntry(); 378 Opie::OPimContact tmpEntry = m_abView ->currentEntry();
379 379
380 // get a name, do the best we can... 380 // get a name, do the best we can...
381 QString strName = tmpEntry.fullName(); 381 QString strName = tmpEntry.fullName();
382 if ( strName.isEmpty() ) { 382 if ( strName.isEmpty() ) {
383 strName = tmpEntry.company(); 383 strName = tmpEntry.company();
384 if ( strName.isEmpty() ) 384 if ( strName.isEmpty() )
385 strName = "No Name"; 385 strName = "No Name";
386 } 386 }
387 387
388 388
389 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 389 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
390 strName ) ) { 390 strName ) ) {
391 m_abView->removeEntry( tmpEntry.uid() ); 391 m_abView->removeEntry( tmpEntry.uid() );
392 } 392 }
393 } else { 393 } else {
394 QMessageBox::warning( this, tr("Contacts"), 394 QMessageBox::warning( this, tr("Contacts"),
395 tr("Can not edit data, currently syncing") ); 395 tr("Can not edit data, currently syncing") );
396 } 396 }
397} 397}
398 398
399static const char * beamfile = "/tmp/obex/contact.vcf"; 399static const char * beamfile = "/tmp/obex/contact.vcf";
400 400
401void AddressbookWindow::slotItemBeam() 401void AddressbookWindow::slotItemBeam()
402{ 402{
403 QString beamFilename; 403 QString beamFilename;
404 Opie::OPimContact c; 404 Opie::OPimContact c;
405 if ( m_actionPersonal->isOn() ) { 405 if ( m_actionPersonal->isOn() ) {
406 beamFilename = addressbookPersonalVCardName(); 406 beamFilename = addressbookPersonalVCardName();
407 if ( !QFile::exists( beamFilename ) ) 407 if ( !QFile::exists( beamFilename ) )
408 return; // can't beam a non-existent file 408 return; // can't beam a non-existent file
409 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 409 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
410 beamFilename ); 410 beamFilename );
411 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 411 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
412 Opie::OPimContactAccess::List allList = access->allRecords(); 412 Opie::OPimContactAccess::List allList = access->allRecords();
413 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 413 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
414 c = *it; 414 c = *it;
415 415
416 delete access; 416 delete access;
417 } else { 417 } else {
418 unlink( beamfile ); // delete if exists 418 unlink( beamfile ); // delete if exists
419 mkdir("/tmp/obex/", 0755); 419 mkdir("/tmp/obex/", 0755);
420 c = m_abView -> currentEntry(); 420 c = m_abView -> currentEntry();
421 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 421 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
422 beamfile ); 422 beamfile );
423 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 423 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
424 access->add( c ); 424 access->add( c );
425 access->save(); 425 access->save();
426 delete access; 426 delete access;
427 427
428 beamFilename = beamfile; 428 beamFilename = beamfile;
429 } 429 }
430 430
431 odebug << "Beaming: " << beamFilename << oendl; 431 odebug << "Beaming: " << beamFilename << oendl;
432 432
433 Ir *ir = new Ir( this ); 433 Ir *ir = new Ir( this );
434 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 434 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
435 QString description = c.fullName(); 435 QString description = c.fullName();
436 ir->send( beamFilename, description, "text/x-vCard" ); 436 ir->send( beamFilename, description, "text/x-vCard" );
437} 437}
438 438
439void AddressbookWindow::slotItemFind() 439void AddressbookWindow::slotItemFind()
440{ 440{
441} 441}
442 442
443void AddressbookWindow::slotConfigure() 443void AddressbookWindow::slotConfigure()
444{ 444{
445 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 445 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
446 dlg -> setConfig( m_config ); 446 dlg -> setConfig( m_config );
447 if ( QPEApplication::execDialog( dlg ) ) { 447 if ( QPEApplication::execDialog( dlg ) ) {
448 odebug << "Config Dialog accepted!" << oendl; 448 odebug << "Config Dialog accepted!" << oendl;
449 m_config = dlg -> getConfig(); 449 m_config = dlg -> getConfig();
450 if ( m_curFontSize != m_config.fontSize() ){ 450 if ( m_curFontSize != m_config.fontSize() ){
451 odebug << "Font was changed!" << oendl; 451 odebug << "Font was changed!" << oendl;
452 m_curFontSize = m_config.fontSize(); 452 m_curFontSize = m_config.fontSize();
453 emit slotSetFont( m_curFontSize ); 453 emit slotSetFont( m_curFontSize );
454 } 454 }
455 m_abView -> setListOrder( m_config.orderList() ); 455 m_abView -> setListOrder( m_config.orderList() );
456 } 456 }
457 457
458 delete dlg; 458 delete dlg;
459} 459}
460 460
461void AddressbookWindow::slotShowFind( bool show ) 461void AddressbookWindow::slotShowFind( bool show )
462{ 462{
463 if ( show ) 463 if ( show )
464 { 464 {
465 // Display search bar 465 // Display search bar
466 m_searchBar->show(); 466 m_searchBar->show();
467 m_abView -> inSearch(); 467 m_abView -> inSearch();
468 m_searchEdit->setFocus(); 468 m_searchEdit->setFocus();
469 } 469 }
470 else 470 else
471 { 471 {
472 // Hide search bar 472 // Hide search bar
473 m_searchBar->hide(); 473 m_searchBar->hide();
474 m_abView -> offSearch(); 474 m_abView -> offSearch();
475 } 475 }
476} 476}
477 477
478void AddressbookWindow::slotFind() 478void AddressbookWindow::slotFind()
479{ 479{
480 m_abView->slotDoFind( m_searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); 480 m_abView->slotDoFind( m_searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
481 481
482 m_searchEdit->clearFocus(); 482 m_searchEdit->clearFocus();
483 // m_abView->setFocus(); 483 // m_abView->setFocus();
484 484
485} 485}
486 486
487void AddressbookWindow::slotViewBack() 487void AddressbookWindow::slotViewBack()
488{ 488{
489 // :SX showList(); 489 // :SX showList();
490} 490}
491 491
492void AddressbookWindow::writeMail() 492void AddressbookWindow::writeMail()
493{ 493{
494 Opie::OPimContact c = m_abView -> currentEntry(); 494 Opie::OPimContact c = m_abView -> currentEntry();
495 QString name = c.fileAs(); 495 QString name = c.fileAs();
496 QString email = c.defaultEmail(); 496 QString email = c.defaultEmail();
497 497
498 // I prefer the OPIE-Environment variable before the 498 // I prefer the OPIE-Environment variable before the
499 // QPE-one.. 499 // QPE-one..
500 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 500 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
501 if ( basepath.isEmpty() ) 501 if ( basepath.isEmpty() )
502 basepath = QString::fromLatin1( getenv("QPEDIR") ); 502 basepath = QString::fromLatin1( getenv("QPEDIR") );
503 503
504 // Try to access the preferred. If not possible, try to 504 // Try to access the preferred. If not possible, try to
505 // switch to the other one.. 505 // switch to the other one..
506 if ( m_config.useQtMail() ){ 506 if ( m_config.useQtMail() ){
507 odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl; 507 odebug << "Accessing: " << (basepath + "/bin/qtmail") << oendl;
508 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 508 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
509 odebug << "QCop" << oendl; 509 odebug << "QCop" << oendl;
510 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 510 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
511 e << name << email; 511 e << name << email;
512 return; 512 return;
513 } else 513 } else
514 m_config.setUseOpieMail( true ); 514 m_config.setUseOpieMail( true );
515 } 515 }
516 if ( m_config.useOpieMail() ){ 516 if ( m_config.useOpieMail() ){
517 odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl; 517 odebug << "Accessing: " << (basepath + "/bin/opiemail") << oendl;
518 if ( QFile::exists( basepath + "/bin/opiemail" ) ){ 518 if ( QFile::exists( basepath + "/bin/opiemail" ) ){
519 odebug << "QCop" << oendl; 519 odebug << "QCop" << oendl;
520 QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)"); 520 QCopEnvelope e("QPE/Application/opiemail", "writeMail(QString,QString)");
521 e << name << email; 521 e << name << email;
522 return; 522 return;
523 } else 523 } else
524 m_config.setUseQtMail( true ); 524 m_config.setUseQtMail( true );
525 } 525 }
526 526
527} 527}
528 528
529void AddressbookWindow::beamDone( Ir *ir ) 529void AddressbookWindow::beamDone( Ir *ir )
530{ 530{
531 531
532 delete ir; 532 delete ir;
533 unlink( beamfile ); 533 unlink( beamfile );
534} 534}
535 535
536 536
537static void parseName( const QString& name, QString *first, QString *middle, 537static void parseName( const QString& name, QString *first, QString *middle,
538 QString * last ) 538 QString * last )
539{ 539{
540 540
541 int comma = name.find ( "," ); 541 int comma = name.find ( "," );
542 QString rest; 542 QString rest;
543 if ( comma > 0 ) { 543 if ( comma > 0 ) {
544 *last = name.left( comma ); 544 *last = name.left( comma );
545 comma++; 545 comma++;
546 while ( comma < int(name.length()) && name[comma] == ' ' ) 546 while ( comma < int(name.length()) && name[comma] == ' ' )
547 comma++; 547 comma++;
548 rest = name.mid( comma ); 548 rest = name.mid( comma );
549 } else { 549 } else {
550 int space = name.findRev( ' ' ); 550 int space = name.findRev( ' ' );
551 *last = name.mid( space+1 ); 551 *last = name.mid( space+1 );
552 rest = name.left( space ); 552 rest = name.left( space );
553 } 553 }
554 int space = rest.find( ' ' ); 554 int space = rest.find( ' ' );
555 if ( space <= 0 ) { 555 if ( space <= 0 ) {
556 *first = rest; 556 *first = rest;
557 } else { 557 } else {
558 *first = rest.left( space ); 558 *first = rest.left( space );
559 *middle = rest.mid( space+1 ); 559 *middle = rest.mid( space+1 );
560 } 560 }
561 561
562} 562}
563 563
564 564
565void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 565void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
566{ 566{
567 bool needShow = false; 567 bool needShow = false;
568 odebug << "Receiving QCop-Call with message " << msg << oendl; 568 odebug << "Receiving QCop-Call with message " << msg << oendl;
569 569
570 570
571 if (msg == "editPersonal()") { 571 if (msg == "editPersonal()") {
572 editPersonal(); 572 editPersonal();
573 573
574 // Categories might have changed, so reload 574 // Categories might have changed, so reload
575 reloadCategories(); 575 reloadCategories();
576 } else if (msg == "editPersonalAndClose()") { 576 } else if (msg == "editPersonalAndClose()") {
577 editPersonal(); 577 editPersonal();
578 close(); 578 close();
579 } else if ( msg == "addContact(QString,QString)" ) { 579 } else if ( msg == "addContact(QString,QString)" ) {
580 QDataStream stream(data,IO_ReadOnly); 580 QDataStream stream(data,IO_ReadOnly);
581 QString name, email; 581 QString name, email;
582 stream >> name >> email; 582 stream >> name >> email;
583 583
584 Opie::OPimContact cnt; 584 Opie::OPimContact cnt;
585 QString fn, mn, ln; 585 QString fn, mn, ln;
586 parseName( name, &fn, &mn, &ln ); 586 parseName( name, &fn, &mn, &ln );
587 //odebug << " " << fn << " - " << mn " - " << ln << oendl; 587 //odebug << " " << fn << " - " << mn " - " << ln << oendl;
588 cnt.setFirstName( fn ); 588 cnt.setFirstName( fn );
589 cnt.setMiddleName( mn ); 589 cnt.setMiddleName( mn );
590 cnt.setLastName( ln ); 590 cnt.setLastName( ln );
591 cnt.insertEmails( email ); 591 cnt.insertEmails( email );
592 cnt.setDefaultEmail( email ); 592 cnt.setDefaultEmail( email );
593 cnt.setFileAs(); 593 cnt.setFileAs();
594 594
595 m_abView -> addEntry( cnt ); 595 m_abView -> addEntry( cnt );
596 596
597 // :SXm_abView()->init( cnt ); 597 // :SXm_abView()->init( cnt );
598 editEntry( EditEntry ); 598 editEntry( EditEntry );
599 599
600 // Categories might have changed, so reload 600 // Categories might have changed, so reload
601 reloadCategories(); 601 reloadCategories();
602 } else if ( msg == "beamBusinessCard()" ) { 602 } else if ( msg == "beamBusinessCard()" ) {
603 QString beamFilename = addressbookPersonalVCardName(); 603 QString beamFilename = addressbookPersonalVCardName();
604 if ( !QFile::exists( beamFilename ) ) 604 if ( !QFile::exists( beamFilename ) )
605 return; // can't beam a non-existent file 605 return; // can't beam a non-existent file
606 606
607 Ir *ir = new Ir( this ); 607 Ir *ir = new Ir( this );
608 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 608 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
609 QString description = "mycard.vcf"; 609 QString description = "mycard.vcf";
610 ir->send( beamFilename, description, "text/x-vCard" ); 610 ir->send( beamFilename, description, "text/x-vCard" );
611 } else if ( msg == "show(int)" ) { 611 } else if ( msg == "show(int)" ) {
612 raise(); 612 raise();
613 QDataStream stream(data,IO_ReadOnly); 613 QDataStream stream(data,IO_ReadOnly);
614 int uid; 614 int uid;
615 stream >> uid; 615 stream >> uid;
616 616
617 odebug << "Showing uid: " << uid << oendl; 617 odebug << "Showing uid: " << uid << oendl;
618 618
619 // Deactivate Personal View.. 619 // Deactivate Personal View..
620 if ( m_actionPersonal->isOn() ){ 620 if ( m_actionPersonal->isOn() ){
621 m_actionPersonal->setOn( false ); 621 m_actionPersonal->setOn( false );
622 slotPersonalView(); 622 slotPersonalView();
623 } 623 }
624 624
625 // Reset category and show as card.. 625 // Reset category and show as card..
626 m_abView -> setShowByCategory( QString::null ); 626 m_abView -> setShowByCategory( QString::null );
627 m_abView -> setCurrentUid( uid ); 627 m_abView -> setCurrentUid( uid );
628 slotViewSwitched ( AbView::CardView ); 628 slotViewSwitched ( AbView::CardView );
629 629
630 needShow = true; 630 needShow = true;
631 631
632 632
633 } else if ( msg == "edit(int)" ) { 633 } else if ( msg == "edit(int)" ) {
634 QDataStream stream(data,IO_ReadOnly); 634 QDataStream stream(data,IO_ReadOnly);
635 int uid; 635 int uid;
636 stream >> uid; 636 stream >> uid;
637 637
638 // Deactivate Personal View.. 638 // Deactivate Personal View..
639 if ( m_actionPersonal->isOn() ){ 639 if ( m_actionPersonal->isOn() ){
640 m_actionPersonal->setOn( false ); 640 m_actionPersonal->setOn( false );
641 slotPersonalView(); 641 slotPersonalView();
642 } 642 }
643 643
644 // Reset category and edit.. 644 // Reset category and edit..
645 m_abView -> setShowByCategory( QString::null ); 645 m_abView -> setShowByCategory( QString::null );
646 m_abView -> setCurrentUid( uid ); 646 m_abView -> setCurrentUid( uid );
647 slotItemEdit(); 647 slotItemEdit();
648 648
649 // Categories might have changed, so reload 649 // Categories might have changed, so reload
650 reloadCategories(); 650 reloadCategories();
651 } 651 }
652 652
653 if (needShow) 653 if (needShow)
654 QPEApplication::setKeepRunning(); 654 QPEApplication::setKeepRunning();
655} 655}
656 656
657void AddressbookWindow::editEntry( EntryMode entryMode ) 657void AddressbookWindow::editEntry( EntryMode entryMode )
658{ 658{
659 Opie::OPimContact entry; 659 Opie::OPimContact entry;
660 if ( !abEditor ) { 660 if ( !abEditor ) {
661 abEditor = new ContactEditor( entry, this, "editor" ); 661 abEditor = new ContactEditor( entry, this, "editor" );
662 } 662 }
663 if ( entryMode == EditEntry ) 663 if ( entryMode == EditEntry )
664 abEditor->setEntry( m_abView -> currentEntry() ); 664 abEditor->setEntry( m_abView -> currentEntry() );
665 else if ( entryMode == NewEntry ) 665 else if ( entryMode == NewEntry )
666 abEditor->setEntry( entry ); 666 abEditor->setEntry( entry );
667 667
668 // Set the dialog caption 668 // Set the dialog caption
669 if ( m_actionPersonal->isOn() ) 669 if ( m_actionPersonal->isOn() )
670 abEditor->setCaption( tr( "Edit My Personal Details" ) ); 670 abEditor->setCaption( tr( "Edit My Personal Details" ) );
671 else 671 else
672 abEditor->setCaption( tr( "Edit Contact" ) ); 672 abEditor->setCaption( tr( "Edit Contact" ) );
673 673
674 // fix the focus... 674 // fix the focus...
675 abEditor->setNameFocus(); 675 abEditor->setNameFocus();
676 if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) { 676 if ( QPEApplication::execDialog( abEditor ) == QDialog::Accepted ) {
677 setFocus(); 677 setFocus();
678 if ( entryMode == NewEntry ) { 678 if ( entryMode == NewEntry ) {
679 Opie::OPimContact insertEntry = abEditor->entry(); 679 Opie::OPimContact insertEntry = abEditor->entry();
680 insertEntry.assignUid(); 680 insertEntry.assignUid();
681 m_abView -> addEntry( insertEntry ); 681 m_abView -> addEntry( insertEntry );
682 m_abView -> setCurrentUid( insertEntry.uid() ); 682 m_abView -> setCurrentUid( insertEntry.uid() );
683 } else { 683 } else {
684 Opie::OPimContact replEntry = abEditor->entry(); 684 Opie::OPimContact replEntry = abEditor->entry();
685 685
686 if ( !replEntry.isValidUid() ) 686 if ( !replEntry.isValidUid() )
687 replEntry.assignUid(); 687 replEntry.assignUid();
688 688
689 m_abView -> replaceEntry( replEntry ); 689 m_abView -> replaceEntry( replEntry );
690 } 690 }
691 691
692 // Categories might have changed, so reload 692 // Categories might have changed, so reload
693 reloadCategories(); 693 reloadCategories();
694 } 694 }
695} 695}
696 696
697void AddressbookWindow::editPersonal() 697void AddressbookWindow::editPersonal()
698{ 698{
699 Opie::OPimContact entry; 699 Opie::OPimContact entry;
700 700
701 // Switch to personal view if not selected 701 // Switch to personal view if not selected
702 // but take care of the menu, too 702 // but take care of the menu, too
703 if ( ! m_actionPersonal->isOn() ){ 703 if ( ! m_actionPersonal->isOn() ){
704 odebug << "*** ++++" << oendl; 704 odebug << "*** ++++" << oendl;
705 m_actionPersonal->setOn( true ); 705 m_actionPersonal->setOn( true );
706 slotPersonalView(); 706 slotPersonalView();
707 } 707 }
708 708
709 if ( !abEditor ) { 709 if ( !abEditor ) {
710 abEditor = new ContactEditor( entry, this, "editor" ); 710 abEditor = new ContactEditor( entry, this, "editor" );
711 } 711 }
712 712
713 abEditor->setPersonalView( true ); 713 abEditor->setPersonalView( true );
714 editEntry( EditEntry ); 714 editEntry( EditEntry );
715 abEditor->setPersonalView( false ); 715 abEditor->setPersonalView( false );
716 716
717} 717}
718 718
719 719
720void AddressbookWindow::slotPersonalView() 720void AddressbookWindow::slotPersonalView()
721{ 721{
722 odebug << "slotPersonalView()" << oendl; 722 odebug << "slotPersonalView()" << oendl;
723 723
724 bool personal = m_actionPersonal->isOn(); 724 bool personal = m_actionPersonal->isOn();
725 725
726 // Disable actions when showing personal details 726 // Disable actions when showing personal details
727 setItemNewEnabled( !personal ); 727 setItemNewEnabled( !personal );
728 setItemDuplicateEnabled( !personal ); 728 setItemDuplicateEnabled( !personal );
729 setItemDeleteEnabled( !personal ); 729 setItemDeleteEnabled( !personal );
730 m_actionMail->setEnabled( !personal ); 730 m_actionMail->setEnabled( !personal );
731 setShowCategories( !personal ); 731 setShowCategories( !personal );
732 732
733 // Display appropriate view 733 // Display appropriate view
734 m_abView->showPersonal( personal ); 734 m_abView->showPersonal( personal );
735 735
736 if ( personal ) 736 if ( personal )
737 { 737 {
738 setCaption( tr( "Contacts - My Personal Details") ); 738 setCaption( tr( "Contacts - My Personal Details") );
739 739
740 // Set category to 'All' to make sure personal details is visible 740 // Set category to 'All' to make sure personal details is visible
741 setViewCategory( "All" ); 741 setViewCategory( "All" );
742 m_abView->setShowByCategory( "All" ); 742 m_abView->setShowByCategory( "All" );
743 743
744 // Temporarily disable letter picker 744 // Temporarily disable letter picker
745 pLabel->hide(); 745 pLabel->hide();
746 } 746 }
747 else 747 else
748 { 748 {
749 setCaption( tr( "Contacts") ); 749 setCaption( tr( "Contacts") );
750 750
751 // Re-enable letter picker 751 // Re-enable letter picker
752 pLabel->show(); 752 pLabel->show();
753 } 753 }
754} 754}
755 755
756void AddressbookWindow::reload() 756void AddressbookWindow::reload()
757{ 757{
758 syncing = false; 758 syncing = false;
759 m_abView->clear(); 759 m_abView->clear();
760 m_abView->reload(); 760 m_abView->reload();
761} 761}
762 762
763void AddressbookWindow::flush() 763void AddressbookWindow::flush()
764{ 764{
765 syncing = true; 765 syncing = true;
766 m_abView->save(); 766 m_abView->save();
767} 767}
768 768
769 769
770void AddressbookWindow::closeEvent( QCloseEvent *e ) 770void AddressbookWindow::closeEvent( QCloseEvent *e )
771{ 771{
772 if ( active_view == AbView::CardView ) 772 if ( active_view == AbView::CardView )
773 { 773 {
774 if ( !m_actionPersonal->isOn() ) 774 if ( !m_actionPersonal->isOn() )
775 { 775 {
776 // Switch to table view only if not editing personal details 776 // Switch to table view only if not editing personal details
777 slotViewSwitched( AbView::TableView ); 777 slotViewSwitched( AbView::TableView );
778 } 778 }
779 else 779 else
780 { 780 {
781 // If currently editing personal details, switch off personal view 781 // If currently editing personal details, switch off personal view
782 m_actionPersonal->setOn( false ); 782 m_actionPersonal->setOn( false );
783 slotPersonalView(); 783 slotPersonalView();
784 } 784 }
785 785
786 e->ignore(); 786 e->ignore();
787 return; 787 return;
788 } 788 }
789 if(syncing) { 789 if(syncing) {
790 /* shouldn't we save, I hear you say? well its already been set 790 /* shouldn't we save, I hear you say? well its already been set
791 so that an edit can not occur during a sync, and we flushed 791 so that an edit can not occur during a sync, and we flushed
792 at the start of the sync, so there is no need to save 792 at the start of the sync, so there is no need to save
793 Saving however itself would cause problems. */ 793 Saving however itself would cause problems. */
794 e->accept(); 794 e->accept();
795 return; 795 return;
796 } 796 }
797 //################## shouldn't always save 797 //################## shouldn't always save
798 // True, but the database handles this automatically ! (se) 798 // True, but the database handles this automatically ! (se)
799 if ( save() ) 799 if ( save() )
800 e->accept(); 800 e->accept();
801 else 801 else
802 e->ignore(); 802 e->ignore();
803} 803}
804 804
805/* 805/*
806 Returns true if it is OK to exit 806 Returns true if it is OK to exit
807*/ 807*/
808 808
809bool AddressbookWindow::save() 809bool AddressbookWindow::save()
810{ 810{
811 if ( !m_abView->save() ) { 811 if ( !m_abView->save() ) {
812 if ( QMessageBox::critical( 0, tr( "Out of space" ), 812 if ( QMessageBox::critical( 0, tr( "Out of space" ),
813 tr("Unable to save information.\n" 813 tr("Unable to save information.\n"
814 "Free up some space\n" 814 "Free up some space\n"
815 "and try again.\n" 815 "and try again.\n"
816 "\nQuit anyway?"), 816 "\nQuit anyway?"),
817 QMessageBox::Yes|QMessageBox::Escape, 817 QMessageBox::Yes|QMessageBox::Escape,
818 QMessageBox::No|QMessageBox::Default ) 818 QMessageBox::No|QMessageBox::Default )
819 != QMessageBox::No ) 819 != QMessageBox::No )
820 return true; 820 return true;
821 else 821 else
822 return false; 822 return false;
823 } 823 }
824 return true; 824 return true;
825} 825}
826 826
827#ifdef __DEBUG_RELEASE 827#ifdef __DEBUG_RELEASE
828void AddressbookWindow::slotSave() 828void AddressbookWindow::slotSave()
829{ 829{
830 save(); 830 save();
831} 831}
832#endif 832#endif
833 833
834 834
835void AddressbookWindow::slotNotFound() 835void AddressbookWindow::slotNotFound()
836{ 836{
837 odebug << "Got not found signal!" << oendl; 837 odebug << "Got not found signal!" << oendl;
838 QMessageBox::information( this, tr( "Not Found" ), 838 QMessageBox::information( this, tr( "Not Found" ),
839 "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); 839 "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" );
840 840
841 841
842} 842}
843void AddressbookWindow::slotWrapAround() 843void AddressbookWindow::slotWrapAround()
844{ 844{
845 odebug << "Got wrap signal!" << oendl; 845 odebug << "Got wrap signal!" << oendl;
846 // if ( doNotifyWrapAround ) 846 // if ( doNotifyWrapAround )
847 // QMessageBox::information( this, tr( "End of list" ), 847 // QMessageBox::information( this, tr( "End of list" ),
848 // tr( "End of list. Wrap around now...!" ) + "\n" ); 848 // tr( "End of list. Wrap around now...!" ) + "\n" );
849 849
850} 850}
851 851
852void AddressbookWindow::slotSetCategory( const QString &category ) 852void AddressbookWindow::slotSetCategory( const QString &category )
853{ 853{
854 odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl; 854 odebug << "void AddressbookWindow::slotSetCategory( " << category << " )" << oendl;
855 855
856 // Tell the view about the selected category 856 // Tell the view about the selected category
857 m_config.setCategory( category ); 857 QString cat = category;
858 m_abView -> setShowByCategory( category ); 858 if ( cat == tr( "All" ) )
859 cat = QString::null;
860 m_config.setCategory( cat );
861 m_abView -> setShowByCategory( cat );
859} 862}
860 863
861void AddressbookWindow::slotViewSwitched( int view ) 864void AddressbookWindow::slotViewSwitched( int view )
862{ 865{
863 odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl; 866 odebug << "void AddressbookWindow::slotViewSwitched( " << view << " )" << oendl;
864 867
865 // Tell the view about the selected view 868 // Tell the view about the selected view
866 m_abView -> setShowToView ( (AbView::Views) view ); 869 m_abView -> setShowToView ( (AbView::Views) view );
867 active_view = view; 870 active_view = view;
868} 871}
869 872
870 873
871void AddressbookWindow::slotListView() 874void AddressbookWindow::slotListView()
872{ 875{
873 slotViewSwitched( AbView::TableView ); 876 slotViewSwitched( AbView::TableView );
874} 877}
875 878
876void AddressbookWindow::slotCardView() 879void AddressbookWindow::slotCardView()
877{ 880{
878 slotViewSwitched( AbView::CardView ); 881 slotViewSwitched( AbView::CardView );
879} 882}
880 883
881void AddressbookWindow::slotSetLetter( char c ) { 884void AddressbookWindow::slotSetLetter( char c ) {
882 885
883 m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); 886 m_abView->setShowByLetter( c, m_config.letterPickerSearch() );
884 887
885} 888}
886 889