summaryrefslogtreecommitdiff
authoreilers <eilers>2003-05-09 08:40:42 (UTC)
committer eilers <eilers>2003-05-09 08:40:42 (UTC)
commitfd1f8bdfc8bad5a0344468118c66c6afe3044fde (patch) (unidiff)
tree58f18282117f9b524c13221f6a54c7bbc94a5827
parenta82928a004882e9aba652061fc6ecffb85d403cf (diff)
downloadopie-fd1f8bdfc8bad5a0344468118c66c6afe3044fde.zip
opie-fd1f8bdfc8bad5a0344468118c66c6afe3044fde.tar.gz
opie-fd1f8bdfc8bad5a0344468118c66c6afe3044fde.tar.bz2
Added two QCop functions for OSearch:
editUid(int), showUid(int)..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abview.cpp7
-rw-r--r--core/pim/addressbook/abview.h1
-rw-r--r--core/pim/addressbook/addressbook.cpp52
3 files changed, 35 insertions, 25 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index b89b794..d3ca783 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,479 +1,486 @@
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 <qlayout.h> 19#include <qlayout.h>
20 20
21#include <qpe/global.h> 21#include <qpe/global.h>
22 22
23#include <opie/ocontactaccessbackend_vcard.h> 23#include <opie/ocontactaccessbackend_vcard.h>
24 24
25 25
26// Is defined in LibQPE 26// Is defined in LibQPE
27extern QString categoryFileName(); 27extern QString categoryFileName();
28 28
29QString addressbookPersonalVCardName() 29QString addressbookPersonalVCardName()
30{ 30{
31 QString filename = Global::applicationFileName("addressbook", 31 QString filename = Global::applicationFileName("addressbook",
32 "businesscard.vcf"); 32 "businesscard.vcf");
33 return filename; 33 return filename;
34} 34}
35 35
36 36
37AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): 37AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ):
38 QWidget(parent), 38 QWidget(parent),
39 mCat(0), 39 mCat(0),
40 m_inSearch( false ), 40 m_inSearch( false ),
41 m_inPersonal( false ), 41 m_inPersonal( false ),
42 m_curr_category( -1 ), 42 m_curr_category( -1 ),
43 m_curr_View( TableView ), 43 m_curr_View( TableView ),
44 m_prev_View( TableView ), 44 m_prev_View( TableView ),
45 m_curr_Contact ( 0 ), 45 m_curr_Contact ( 0 ),
46 m_contactdb ( 0l ), 46 m_contactdb ( 0l ),
47 m_storedDB ( 0l ), 47 m_storedDB ( 0l ),
48 m_viewStack( 0l ), 48 m_viewStack( 0l ),
49 m_abTable( 0l ), 49 m_abTable( 0l ),
50 m_orderedFields( ordered ) 50 m_orderedFields( ordered )
51{ 51{
52 // Load default database and handle syncing myself.. ! 52 // Load default database and handle syncing myself.. !
53 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), 53 m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ),
54 mCat.load( categoryFileName() ); 54 mCat.load( categoryFileName() );
55 55
56 // Create Layout and put WidgetStack into it. 56 // Create Layout and put WidgetStack into it.
57 QVBoxLayout *vb = new QVBoxLayout( this ); 57 QVBoxLayout *vb = new QVBoxLayout( this );
58 m_viewStack = new QWidgetStack( this ); 58 m_viewStack = new QWidgetStack( this );
59 vb->addWidget( m_viewStack ); 59 vb->addWidget( m_viewStack );
60 60
61 // Creat TableView 61 // Creat TableView
62 QVBox* tableBox = new QVBox( m_viewStack ); 62 QVBox* tableBox = new QVBox( m_viewStack );
63 m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); 63 m_abTable = new AbTable( m_orderedFields, tableBox, "table" );
64 m_abTable->setCurrentCell( 0, 0 ); 64 m_abTable->setCurrentCell( 0, 0 );
65 m_abTable->setFocus(); 65 m_abTable->setFocus();
66 66
67 // Add TableView to WidgetStack and raise it 67 // Add TableView to WidgetStack and raise it
68 m_viewStack -> addWidget( tableBox , TableView ); 68 m_viewStack -> addWidget( tableBox , TableView );
69 69
70 // Create CardView and add it to WidgetStack 70 // Create CardView and add it to WidgetStack
71 QVBox* cardBox = new QVBox( m_viewStack ); 71 QVBox* cardBox = new QVBox( m_viewStack );
72 m_ablabel = new AbLabel( cardBox, "CardView"); 72 m_ablabel = new AbLabel( cardBox, "CardView");
73 m_viewStack -> addWidget( cardBox , CardView ); 73 m_viewStack -> addWidget( cardBox , CardView );
74 74
75 // Connect views to me 75 // Connect views to me
76 connect ( m_abTable, SIGNAL( signalSwitch( void ) ), 76 connect ( m_abTable, SIGNAL( signalSwitch( void ) ),
77 this, SLOT( slotSwitch( void ) ) ); 77 this, SLOT( slotSwitch( void ) ) );
78 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), 78 connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ),
79 this, SLOT( slotSwitch( void ) ) ); 79 this, SLOT( slotSwitch( void ) ) );
80 80
81 load(); 81 load();
82} 82}
83 83
84AbView::~AbView() 84AbView::~AbView()
85{ 85{
86 m_contactdb -> save(); 86 m_contactdb -> save();
87 delete m_contactdb; 87 delete m_contactdb;
88 88
89 if ( m_storedDB ){ 89 if ( m_storedDB ){
90 m_storedDB -> save(); 90 m_storedDB -> save();
91 delete m_storedDB; 91 delete m_storedDB;
92 } 92 }
93} 93}
94 94
95 95
96void AbView::setView( Views view ) 96void AbView::setView( Views view )
97{ 97{
98 //qWarning("AbView::setView( Views view )"); 98 //qWarning("AbView::setView( Views view )");
99 m_curr_View = view; 99 m_curr_View = view;
100 load(); 100 load();
101} 101}
102 102
103void AbView::addEntry( const OContact &newContact ) 103void AbView::addEntry( const OContact &newContact )
104{ 104{
105 //qWarning("abview:AddContact"); 105 //qWarning("abview:AddContact");
106 m_contactdb->add ( newContact ); 106 m_contactdb->add ( newContact );
107 load(); 107 load();
108 108
109} 109}
110void AbView::removeEntry( const int UID ) 110void AbView::removeEntry( const int UID )
111{ 111{
112 //qWarning("abview:RemoveContact"); 112 //qWarning("abview:RemoveContact");
113 m_contactdb->remove( UID ); 113 m_contactdb->remove( UID );
114 load(); 114 load();
115} 115}
116 116
117void AbView::replaceEntry( const OContact &contact ) 117void AbView::replaceEntry( const OContact &contact )
118{ 118{
119 //qWarning("abview:ReplaceContact"); 119 //qWarning("abview:ReplaceContact");
120 m_contactdb->replace( contact ); 120 m_contactdb->replace( contact );
121 load(); 121 load();
122 122
123} 123}
124 124
125OContact AbView::currentEntry() 125OContact AbView::currentEntry()
126{ 126{
127 OContact currentContact; 127 OContact currentContact;
128 128
129 switch ( (int) m_curr_View ) { 129 switch ( (int) m_curr_View ) {
130 case TableView: 130 case TableView:
131 currentContact = m_abTable -> currentEntry(); 131 currentContact = m_abTable -> currentEntry();
132 break; 132 break;
133 case CardView: 133 case CardView:
134 currentContact = m_ablabel -> currentEntry(); 134 currentContact = m_ablabel -> currentEntry();
135 break; 135 break;
136 } 136 }
137 m_curr_Contact = currentContact.uid(); 137 m_curr_Contact = currentContact.uid();
138 return currentContact; 138 return currentContact;
139} 139}
140 140
141bool AbView::save() 141bool AbView::save()
142{ 142{
143 //qWarning("abView:Save data"); 143 //qWarning("abView:Save data");
144 144
145 return m_contactdb->save(); 145 return m_contactdb->save();
146} 146}
147 147
148void AbView::load() 148void AbView::load()
149{ 149{
150 //qWarning("abView:Load data"); 150 //qWarning("abView:Load data");
151 151
152 // Letter Search is stopped at this place 152 // Letter Search is stopped at this place
153 emit signalClearLetterPicker(); 153 emit signalClearLetterPicker();
154 154
155 if ( m_inPersonal ) 155 if ( m_inPersonal )
156 // VCard Backend does not sort.. 156 // VCard Backend does not sort..
157 m_list = m_contactdb->allRecords(); 157 m_list = m_contactdb->allRecords();
158 else{ 158 else{
159 m_list = m_contactdb->sorted( true, 0, 0, 0 ); 159 m_list = m_contactdb->sorted( true, 0, 0, 0 );
160 clearForCategory(); 160 clearForCategory();
161 } 161 }
162 162
163 //qWarning ("Number of contacts: %d", m_list.count()); 163 //qWarning ("Number of contacts: %d", m_list.count());
164 164
165 updateView( true ); 165 updateView( true );
166 166
167} 167}
168 168
169void AbView::reload() 169void AbView::reload()
170{ 170{
171 //qWarning( "void AbView::reload()" ); 171 //qWarning( "void AbView::reload()" );
172 172
173 m_contactdb->reload(); 173 m_contactdb->reload();
174 load(); 174 load();
175} 175}
176 176
177void AbView::clear() 177void AbView::clear()
178{ 178{
179 // :SX 179 // :SX
180} 180}
181 181
182void AbView::setShowByCategory( const QString& cat ) 182void AbView::setShowByCategory( const QString& cat )
183{ 183{
184 //qWarning("AbView::setShowCategory( const QString& cat )"); 184 //qWarning("AbView::setShowCategory( const QString& cat )");
185 185
186 int intCat = 0; 186 int intCat = 0;
187 187
188 // All (cat == NULL) will be stored as -1 188 // All (cat == NULL) will be stored as -1
189 if ( cat.isNull() ) 189 if ( cat.isNull() )
190 intCat = -1; 190 intCat = -1;
191 else 191 else
192 intCat = mCat.id("Contacts", cat ); 192 intCat = mCat.id("Contacts", cat );
193 193
194 // Just do anything if we really change the category 194 // Just do anything if we really change the category
195 if ( intCat != m_curr_category ){ 195 if ( intCat != m_curr_category ){
196 // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); 196 // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category);
197 197
198 m_curr_category = intCat; 198 m_curr_category = intCat;
199 emit signalClearLetterPicker(); 199 emit signalClearLetterPicker();
200 200
201 load(); 201 load();
202 } 202 }
203 203
204} 204}
205 205
206void AbView::setShowToView( Views view ) 206void AbView::setShowToView( Views view )
207{ 207{
208 //qWarning("void AbView::setShowToView( View %d )", view); 208 //qWarning("void AbView::setShowToView( View %d )", view);
209 209
210 //qWarning ("Change the View (Category is: %d)", m_curr_category); 210 //qWarning ("Change the View (Category is: %d)", m_curr_category);
211 211
212 if ( m_curr_View != view ){ 212 if ( m_curr_View != view ){
213 m_prev_View = m_curr_View; 213 m_prev_View = m_curr_View;
214 m_curr_View = view; 214 m_curr_View = view;
215 215
216 updateView(); 216 updateView();
217 } 217 }
218 218
219} 219}
220 220
221void AbView::setShowByLetter( char c ) 221void AbView::setShowByLetter( char c )
222{ 222{
223 //qWarning("void AbView::setShowByLetter( %c )", c ); 223 //qWarning("void AbView::setShowByLetter( %c )", c );
224 OContact query; 224 OContact query;
225 if ( c == 0 ){ 225 if ( c == 0 ){
226 load(); 226 load();
227 return; 227 return;
228 }else{ 228 }else{
229 // If the current Backend is unable to solve the query, we will 229 // If the current Backend is unable to solve the query, we will
230 // ignore the request .. 230 // ignore the request ..
231 if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ 231 if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){
232 return; 232 return;
233 } 233 }
234 234
235 query.setLastName( QString("%1*").arg(c) ); 235 query.setLastName( QString("%1*").arg(c) );
236 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); 236 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase );
237 clearForCategory(); 237 clearForCategory();
238 m_curr_Contact = 0; 238 m_curr_Contact = 0;
239 } 239 }
240 updateView( true ); 240 updateView( true );
241} 241}
242 242
243void AbView::setListOrder( const QValueList<int>& ordered ) 243void AbView::setListOrder( const QValueList<int>& ordered )
244{ 244{
245 m_orderedFields = ordered; 245 m_orderedFields = ordered;
246 if ( m_abTable ){ 246 if ( m_abTable ){
247 m_abTable->setOrderedList( ordered ); 247 m_abTable->setOrderedList( ordered );
248 m_abTable->refresh(); 248 m_abTable->refresh();
249 } 249 }
250 updateView(); 250 updateView();
251} 251}
252 252
253 253
254QString AbView::showCategory() const 254QString AbView::showCategory() const
255{ 255{
256 return mCat.label( "Contacts", m_curr_category ); 256 return mCat.label( "Contacts", m_curr_category );
257} 257}
258 258
259void AbView::showPersonal( bool personal ) 259void AbView::showPersonal( bool personal )
260{ 260{
261 //qWarning ("void AbView::showPersonal( %d )", personal); 261 //qWarning ("void AbView::showPersonal( %d )", personal);
262 262
263 if ( personal ){ 263 if ( personal ){
264 264
265 if ( m_inPersonal ) 265 if ( m_inPersonal )
266 return; 266 return;
267 267
268 // Now switch to vCard Backend and load data. 268 // Now switch to vCard Backend and load data.
269 // The current default backend will be stored 269 // The current default backend will be stored
270 // to avoid unneeded load/stores. 270 // to avoid unneeded load/stores.
271 m_storedDB = m_contactdb; 271 m_storedDB = m_contactdb;
272 272
273 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 273 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
274 addressbookPersonalVCardName() ); 274 addressbookPersonalVCardName() );
275 m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 275 m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
276 276
277 m_inPersonal = true; 277 m_inPersonal = true;
278 m_curr_View = CardView; 278 m_curr_View = CardView;
279 279
280 }else{ 280 }else{
281 281
282 if ( !m_inPersonal ) 282 if ( !m_inPersonal )
283 return; 283 return;
284 284
285 // Remove vCard Backend and restore default 285 // Remove vCard Backend and restore default
286 m_contactdb->save(); 286 m_contactdb->save();
287 delete m_contactdb; 287 delete m_contactdb;
288 288
289 m_contactdb = m_storedDB; 289 m_contactdb = m_storedDB;
290 m_storedDB = 0l; 290 m_storedDB = 0l;
291 291
292 m_curr_View = TableView; 292 m_curr_View = TableView;
293 m_inPersonal = false; 293 m_inPersonal = false;
294 294
295 } 295 }
296 load(); 296 load();
297} 297}
298 298
299void AbView::setCurrentUid( int uid ){
300
301 m_curr_Contact = uid;
302 updateView( true ); //true: Don't modificate the UID !
303}
304
305
299QStringList AbView::categories() 306QStringList AbView::categories()
300{ 307{
301 mCat.load( categoryFileName() ); 308 mCat.load( categoryFileName() );
302 QStringList categoryList = mCat.labels( "Contacts" ); 309 QStringList categoryList = mCat.labels( "Contacts" );
303 return categoryList; 310 return categoryList;
304} 311}
305 312
306// BEGIN: Slots 313// BEGIN: Slots
307void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 314void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
308 bool , QString cat ) 315 bool , QString cat )
309{ 316{
310 //qWarning( "void AbView::slotDoFind" ); 317 //qWarning( "void AbView::slotDoFind" );
311 318
312 // We reloading the data: Deselect Letterpicker 319 // We reloading the data: Deselect Letterpicker
313 emit signalClearLetterPicker(); 320 emit signalClearLetterPicker();
314 321
315 // Use the current Category if nothing else selected 322 // Use the current Category if nothing else selected
316 int category = 0; 323 int category = 0;
317 324
318 if ( cat.isEmpty() ) 325 if ( cat.isEmpty() )
319 category = m_curr_category; 326 category = m_curr_category;
320 else{ 327 else{
321 category = mCat.id("Contacts", cat ); 328 category = mCat.id("Contacts", cat );
322 } 329 }
323 330
324 //qWarning ("Find in Category %d", category); 331 //qWarning ("Find in Category %d", category);
325 332
326 QRegExp r( str ); 333 QRegExp r( str );
327 r.setCaseSensitive( caseSensitive ); 334 r.setCaseSensitive( caseSensitive );
328 r.setWildcard( !useRegExp ); 335 r.setWildcard( !useRegExp );
329 336
330 // Get all matching entries out of the database 337 // Get all matching entries out of the database
331 m_list = m_contactdb->matchRegexp( r ); 338 m_list = m_contactdb->matchRegexp( r );
332 339
333 //qWarning( "found: %d", m_list.count() ); 340 //qWarning( "found: %d", m_list.count() );
334 if ( m_list.count() == 0 ){ 341 if ( m_list.count() == 0 ){
335 emit signalNotFound(); 342 emit signalNotFound();
336 return; 343 return;
337 } 344 }
338 345
339 // Now remove all contacts with wrong category (if any selected) 346 // Now remove all contacts with wrong category (if any selected)
340 // This algorithm is a litte bit ineffective, but 347 // This algorithm is a litte bit ineffective, but
341 // we will not have a lot of matching entries.. 348 // we will not have a lot of matching entries..
342 clearForCategory(); 349 clearForCategory();
343 350
344 // Now show all found entries 351 // Now show all found entries
345 updateView( true ); 352 updateView( true );
346} 353}
347 354
348void AbView::offSearch() 355void AbView::offSearch()
349{ 356{
350 m_inSearch = false; 357 m_inSearch = false;
351 358
352 load(); 359 load();
353} 360}
354 361
355void AbView::slotSwitch(){ 362void AbView::slotSwitch(){
356 //qWarning("AbView::slotSwitch()"); 363 //qWarning("AbView::slotSwitch()");
357 364
358 m_prev_View = m_curr_View; 365 m_prev_View = m_curr_View;
359 switch ( (int) m_curr_View ){ 366 switch ( (int) m_curr_View ){
360 case TableView: 367 case TableView:
361 qWarning("Switching to CardView"); 368 qWarning("Switching to CardView");
362 m_curr_View = CardView; 369 m_curr_View = CardView;
363 break; 370 break;
364 case CardView: 371 case CardView:
365 qWarning("Switching to TableView"); 372 qWarning("Switching to TableView");
366 m_curr_View = TableView; 373 m_curr_View = TableView;
367 break; 374 break;
368 } 375 }
369 updateView(); 376 updateView();
370 377
371} 378}
372 379
373// END: Slots 380// END: Slots
374 381
375void AbView::clearForCategory() 382void AbView::clearForCategory()
376{ 383{
377 OContactAccess::List::Iterator it; 384 OContactAccess::List::Iterator it;
378 // Now remove all contacts with wrong category if any category selected 385 // Now remove all contacts with wrong category if any category selected
379 386
380 OContactAccess::List allList = m_list; 387 OContactAccess::List allList = m_list;
381 if ( m_curr_category != -1 ){ 388 if ( m_curr_category != -1 ){
382 for ( it = allList.begin(); it != allList.end(); ++it ){ 389 for ( it = allList.begin(); it != allList.end(); ++it ){
383 if ( !contactCompare( *it, m_curr_category ) ){ 390 if ( !contactCompare( *it, m_curr_category ) ){
384 // qWarning("Removing %d", (*it).uid()); 391 // qWarning("Removing %d", (*it).uid());
385 m_list.remove( (*it).uid() ); 392 m_list.remove( (*it).uid() );
386 } 393 }
387 } 394 }
388 } 395 }
389 396
390} 397}
391 398
392bool AbView::contactCompare( const OContact &cnt, int category ) 399bool AbView::contactCompare( const OContact &cnt, int category )
393{ 400{
394 //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); 401 //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category);
395 402
396 bool returnMe; 403 bool returnMe;
397 QArray<int> cats; 404 QArray<int> cats;
398 cats = cnt.categories(); 405 cats = cnt.categories();
399 406
400 //qWarning ("Number of categories: %d", cats.count() ); 407 //qWarning ("Number of categories: %d", cats.count() );
401 408
402 returnMe = false; 409 returnMe = false;
403 if ( cats.count() == 0 && category == 0 ) 410 if ( cats.count() == 0 && category == 0 )
404 // Contacts with no category will just shown on "All" and "Unfiled" 411 // Contacts with no category will just shown on "All" and "Unfiled"
405 returnMe = true; 412 returnMe = true;
406 else { 413 else {
407 int i; 414 int i;
408 for ( i = 0; i < int(cats.count()); i++ ) { 415 for ( i = 0; i < int(cats.count()); i++ ) {
409 // qWarning("Comparing %d with %d",cats[i],category ); 416 // qWarning("Comparing %d with %d",cats[i],category );
410 if ( cats[i] == category ) { 417 if ( cats[i] == category ) {
411 returnMe = true; 418 returnMe = true;
412 break; 419 break;
413 } 420 }
414 } 421 }
415 } 422 }
416 //qWarning ("Return: %d", returnMe); 423 //qWarning ("Return: %d", returnMe);
417 return returnMe; 424 return returnMe;
418} 425}
419 426
420// In Some rare cases we have to update all lists.. 427// In Some rare cases we have to update all lists..
421void AbView::updateListinViews() 428void AbView::updateListinViews()
422{ 429{
423 m_abTable -> setContacts( m_list ); 430 m_abTable -> setContacts( m_list );
424 m_ablabel -> setContacts( m_list ); 431 m_ablabel -> setContacts( m_list );
425} 432}
426 433
427void AbView::updateView( bool newdata ) 434void AbView::updateView( bool newdata )
428{ 435{
429 //qWarning("AbView::updateView()"); 436 //qWarning("AbView::updateView()");
430 437
431 if ( m_viewStack -> visibleWidget() ){ 438 if ( m_viewStack -> visibleWidget() ){
432 m_viewStack -> visibleWidget() -> clearFocus(); 439 m_viewStack -> visibleWidget() -> clearFocus();
433 } 440 }
434 441
435 // If we switching the view, we have to store some information 442 // If we switching the view, we have to store some information
436 if ( !newdata ){ 443 if ( !newdata ){
437 if ( m_list.count() ){ 444 if ( m_list.count() ){
438 switch ( (int) m_prev_View ) { 445 switch ( (int) m_prev_View ) {
439 case TableView: 446 case TableView:
440 m_curr_Contact = m_abTable -> currentEntry_UID(); 447 m_curr_Contact = m_abTable -> currentEntry_UID();
441 break; 448 break;
442 case CardView: 449 case CardView:
443 m_curr_Contact = m_ablabel -> currentEntry_UID(); 450 m_curr_Contact = m_ablabel -> currentEntry_UID();
444 break; 451 break;
445 } 452 }
446 }else 453 }else
447 m_curr_Contact = 0; 454 m_curr_Contact = 0;
448 } 455 }
449 456
450 // Feed all views with new lists 457 // Feed all views with new lists
451 if ( newdata ) 458 if ( newdata )
452 updateListinViews(); 459 updateListinViews();
453 460
454 // Tell the world that the view is changed 461 // Tell the world that the view is changed
455 if ( m_curr_View != m_prev_View ) 462 if ( m_curr_View != m_prev_View )
456 emit signalViewSwitched ( (int) m_curr_View ); 463 emit signalViewSwitched ( (int) m_curr_View );
457 464
458 m_prev_View = m_curr_View; 465 m_prev_View = m_curr_View;
459 466
460 // Switch to new View 467 // Switch to new View
461 switch ( (int) m_curr_View ) { 468 switch ( (int) m_curr_View ) {
462 case TableView: 469 case TableView:
463 m_abTable -> setChoiceSelection( m_orderedFields ); 470 m_abTable -> setChoiceSelection( m_orderedFields );
464 if ( m_curr_Contact != 0 ) 471 if ( m_curr_Contact != 0 )
465 m_abTable -> selectContact ( m_curr_Contact ); 472 m_abTable -> selectContact ( m_curr_Contact );
466 m_abTable -> setFocus(); 473 m_abTable -> setFocus();
467 break; 474 break;
468 case CardView: 475 case CardView:
469 if ( m_curr_Contact != 0 ) 476 if ( m_curr_Contact != 0 )
470 m_ablabel -> selectContact( m_curr_Contact ); 477 m_ablabel -> selectContact( m_curr_Contact );
471 m_ablabel -> setFocus(); 478 m_ablabel -> setFocus();
472 break; 479 break;
473 } 480 }
474 481
475 // Raise the current View 482 // Raise the current View
476 m_viewStack -> raiseWidget( m_curr_View ); 483 m_viewStack -> raiseWidget( m_curr_View );
477} 484}
478 485
479 486
diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h
index 8570fe7..55c63cc 100644
--- a/core/pim/addressbook/abview.h
+++ b/core/pim/addressbook/abview.h
@@ -1,87 +1,88 @@
1#ifndef _ABVIEW_H_ 1#ifndef _ABVIEW_H_
2#define _ABVIEW_H_ 2#define _ABVIEW_H_
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qwidgetstack.h> 5#include <qwidgetstack.h>
6 6
7#include <qpe/categories.h> 7#include <qpe/categories.h>
8#include <opie/ocontact.h> 8#include <opie/ocontact.h>
9#include <opie/ocontactaccess.h> 9#include <opie/ocontactaccess.h>
10 10
11#include "contacteditor.h" 11#include "contacteditor.h"
12#include "abtable.h" 12#include "abtable.h"
13#include "ablabel.h" 13#include "ablabel.h"
14 14
15class AbView: public QWidget 15class AbView: public QWidget
16{ 16{
17 Q_OBJECT 17 Q_OBJECT
18 18
19public: 19public:
20 enum Views{ TableView=0, CardView, PersonalView }; 20 enum Views{ TableView=0, CardView, PersonalView };
21 21
22 AbView( QWidget* parent, const QValueList<int>& ordered ); 22 AbView( QWidget* parent, const QValueList<int>& ordered );
23 ~AbView(); 23 ~AbView();
24 24
25 bool save(); 25 bool save();
26 void load(); 26 void load();
27 void reload(); 27 void reload();
28 void clear(); 28 void clear();
29 29
30 void setView( Views view ); 30 void setView( Views view );
31 void showPersonal( bool personal ); 31 void showPersonal( bool personal );
32 void setCurrentUid( int uid );
32 void setShowByCategory( const QString& cat ); 33 void setShowByCategory( const QString& cat );
33 void setShowToView( Views view ); 34 void setShowToView( Views view );
34 void setShowByLetter( char c ); 35 void setShowByLetter( char c );
35 void setListOrder( const QValueList<int>& ordered ); 36 void setListOrder( const QValueList<int>& ordered );
36 37
37 // Add Entry and put to current 38 // Add Entry and put to current
38 void addEntry( const OContact &newContact ); 39 void addEntry( const OContact &newContact );
39 void removeEntry( const int UID ); 40 void removeEntry( const int UID );
40 void replaceEntry( const OContact &contact ); 41 void replaceEntry( const OContact &contact );
41 OContact currentEntry(); 42 OContact currentEntry();
42 43
43 void inSearch() { m_inSearch = true; } 44 void inSearch() { m_inSearch = true; }
44 void offSearch(); 45 void offSearch();
45 46
46 QString showCategory() const; 47 QString showCategory() const;
47 QStringList categories(); 48 QStringList categories();
48 49
49signals: 50signals:
50 void signalNotFound(); 51 void signalNotFound();
51 void signalClearLetterPicker(); 52 void signalClearLetterPicker();
52 void signalViewSwitched ( int ); 53 void signalViewSwitched ( int );
53 54
54public slots: 55public slots:
55 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, 56 void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
56 bool backwards, QString category = QString::null ); 57 bool backwards, QString category = QString::null );
57 void slotSwitch(); 58 void slotSwitch();
58 59
59private: 60private:
60 void updateListinViews(); 61 void updateListinViews();
61 void updateView( bool newdata = false ); 62 void updateView( bool newdata = false );
62 void clearForCategory(); 63 void clearForCategory();
63 bool contactCompare( const OContact &cnt, int category ); 64 bool contactCompare( const OContact &cnt, int category );
64 void parseName( const QString& name, QString *first, QString *middle, 65 void parseName( const QString& name, QString *first, QString *middle,
65 QString * last ); 66 QString * last );
66 67
67 Categories mCat; 68 Categories mCat;
68 bool m_inSearch; 69 bool m_inSearch;
69 bool m_inPersonal; 70 bool m_inPersonal;
70 int m_curr_category; 71 int m_curr_category;
71 Views m_curr_View; 72 Views m_curr_View;
72 Views m_prev_View; 73 Views m_prev_View;
73 int m_curr_Contact; 74 int m_curr_Contact;
74 75
75 OContactAccess* m_contactdb; 76 OContactAccess* m_contactdb;
76 OContactAccess* m_storedDB; 77 OContactAccess* m_storedDB;
77 OContactAccess::List m_list; 78 OContactAccess::List m_list;
78 79
79 QWidgetStack* m_viewStack; 80 QWidgetStack* m_viewStack;
80 AbTable* m_abTable; 81 AbTable* m_abTable;
81 AbLabel* m_ablabel; 82 AbLabel* m_ablabel;
82 83
83 QValueList<int> m_orderedFields; 84 QValueList<int> m_orderedFields;
84}; 85};
85 86
86 87
87#endif 88#endif
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 89a3312..e053e94 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -1,1042 +1,1044 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** OContact info@trolltech.com if any conditions of this licensing are 16** OContact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_FD 21#define QTOPIA_INTERNAL_FD
22 22
23#include "contacteditor.h" 23#include "contacteditor.h"
24#include "ablabel.h" 24#include "ablabel.h"
25#include "abview.h" 25#include "abview.h"
26#include "abtable.h" 26#include "abtable.h"
27// #include "addresssettings.h" 27// #include "addresssettings.h"
28#include "addressbook.h" 28#include "addressbook.h"
29 29
30 30
31#include <opie/ofileselector.h> 31#include <opie/ofileselector.h>
32#include <opie/ofiledialog.h> 32#include <opie/ofiledialog.h>
33#include <opie/ocontact.h> 33#include <opie/ocontact.h>
34#include <opie/ocontactaccessbackend_vcard.h> 34#include <opie/ocontactaccessbackend_vcard.h>
35 35
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <qpe/ir.h> 37#include <qpe/ir.h>
38#include <qpe/qpemessagebox.h> 38#include <qpe/qpemessagebox.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/qpetoolbar.h> 40#include <qpe/qpetoolbar.h>
41#include <qpe/qpemenubar.h> 41#include <qpe/qpemenubar.h>
42// #include <qtoolbar.h> 42// #include <qtoolbar.h>
43// #include <qmenubar.h> 43// #include <qmenubar.h>
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45#include <qpe/config.h> 45#include <qpe/config.h>
46 46
47#include <qaction.h> 47#include <qaction.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdir.h> 49#include <qdir.h>
50#include <qfile.h> 50#include <qfile.h>
51#include <qimage.h> 51#include <qimage.h>
52#include <qlayout.h> 52#include <qlayout.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qpixmap.h> 54#include <qpixmap.h>
55#include <qpopupmenu.h> 55#include <qpopupmenu.h>
56#include <qstringlist.h> 56#include <qstringlist.h>
57#include <qtoolbutton.h> 57#include <qtoolbutton.h>
58#include <qwhatsthis.h> 58#include <qwhatsthis.h>
59#include <qdatetime.h> 59#include <qdatetime.h>
60 60
61#include <stdlib.h> 61#include <stdlib.h>
62#include <sys/stat.h> 62#include <sys/stat.h>
63#include <sys/types.h> 63#include <sys/types.h>
64#include <fcntl.h> 64#include <fcntl.h>
65#include <unistd.h> 65#include <unistd.h>
66 66
67 67
68#include "picker.h" 68#include "picker.h"
69#include "configdlg.h" 69#include "configdlg.h"
70 70
71extern QString addressbookPersonalVCardName(); 71extern QString addressbookPersonalVCardName();
72 72
73AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 73AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
74 WFlags f ) 74 WFlags f )
75 : QMainWindow( parent, name, f ), 75 : QMainWindow( parent, name, f ),
76 catMenu (0l), 76 catMenu (0l),
77 abEditor(0l), 77 abEditor(0l),
78 syncing(FALSE), 78 syncing(FALSE),
79 m_tableViewButton(0l), 79 m_tableViewButton(0l),
80 m_cardViewButton(0l) 80 m_cardViewButton(0l)
81{ 81{
82 isLoading = true; 82 isLoading = true;
83 83
84 m_config.load(); 84 m_config.load();
85 85
86 setCaption( tr("Contacts") ); 86 setCaption( tr("Contacts") );
87 setIcon( Resource::loadPixmap( "AddressBook" ) ); 87 setIcon( Resource::loadPixmap( "AddressBook" ) );
88 88
89 // Settings for Main Menu 89 // Settings for Main Menu
90 // setToolBarsMovable( false ); 90 // setToolBarsMovable( false );
91 setToolBarsMovable( !m_config.fixedBars() ); 91 setToolBarsMovable( !m_config.fixedBars() );
92 setRightJustification( true ); 92 setRightJustification( true );
93 93
94 QPEToolBar *bar = new QPEToolBar( this ); 94 QPEToolBar *bar = new QPEToolBar( this );
95 bar->setHorizontalStretchable( TRUE ); 95 bar->setHorizontalStretchable( TRUE );
96 96
97 QPEMenuBar *mbList = new QPEMenuBar( bar ); 97 QPEMenuBar *mbList = new QPEMenuBar( bar );
98 mbList->setMargin( 0 ); 98 mbList->setMargin( 0 );
99 99
100 QPopupMenu *edit = new QPopupMenu( mbList ); 100 QPopupMenu *edit = new QPopupMenu( mbList );
101 mbList->insertItem( tr( "Contact" ), edit ); 101 mbList->insertItem( tr( "Contact" ), edit );
102 102
103 // Category Menu 103 // Category Menu
104 catMenu = new QPopupMenu( this ); 104 catMenu = new QPopupMenu( this );
105 catMenu->setCheckable( TRUE ); 105 catMenu->setCheckable( TRUE );
106 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 106 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
107 mbList->insertItem( tr("View"), catMenu ); 107 mbList->insertItem( tr("View"), catMenu );
108 108
109 // Create Toolbar 109 // Create Toolbar
110 listTools = new QPEToolBar( this, "list operations" ); 110 listTools = new QPEToolBar( this, "list operations" );
111 listTools->setHorizontalStretchable( true ); 111 listTools->setHorizontalStretchable( true );
112 addToolBar( listTools ); 112 addToolBar( listTools );
113 moveToolBar( listTools, m_config.getToolBarPos() ); 113 moveToolBar( listTools, m_config.getToolBarPos() );
114 114
115 // View Icons 115 // View Icons
116 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/weeklst" ), 116 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/weeklst" ),
117 QString::null, 0, this, 0 ); 117 QString::null, 0, this, 0 );
118 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); 118 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
119 m_tableViewButton->setToggleAction( true ); 119 m_tableViewButton->setToggleAction( true );
120 m_tableViewButton->addTo( listTools ); 120 m_tableViewButton->addTo( listTools );
121 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); 121 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 );
122 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); 122 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
123 m_cardViewButton->setToggleAction( true ); 123 m_cardViewButton->setToggleAction( true );
124 m_cardViewButton->addTo( listTools ); 124 m_cardViewButton->addTo( listTools );
125 125
126 listTools->addSeparator(); 126 listTools->addSeparator();
127 127
128 // Other Buttons 128 // Other Buttons
129 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 129 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
130 0, this, 0 ); 130 0, this, 0 );
131 actionNew = a; 131 actionNew = a;
132 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 132 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
133 a->addTo( edit ); 133 a->addTo( edit );
134 a->addTo( listTools ); 134 a->addTo( listTools );
135 135
136 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 136 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
137 0, this, 0 ); 137 0, this, 0 );
138 actionEdit = a; 138 actionEdit = a;
139 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 139 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
140 a->addTo( edit ); 140 a->addTo( edit );
141 a->addTo( listTools ); 141 a->addTo( listTools );
142 142
143 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 143 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
144 0, this, 0 ); 144 0, this, 0 );
145 actionTrash = a; 145 actionTrash = a;
146 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 146 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
147 a->addTo( edit ); 147 a->addTo( edit );
148 a->addTo( listTools ); 148 a->addTo( listTools );
149 149
150 150
151 // make it possible to go directly to businesscard via qcop call 151 // make it possible to go directly to businesscard via qcop call
152 //#if defined(Q_WS_QWS) // Why this ? (se) 152 //#if defined(Q_WS_QWS) // Why this ? (se)
153#if !defined(QT_NO_COP) 153#if !defined(QT_NO_COP)
154 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); 154 QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
155 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 155 connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
156 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 156 this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
157#endif 157#endif
158 // #endif 158 // #endif
159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 159 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
160 QString::null, 0, this, 0 ); 160 QString::null, 0, this, 0 );
161 actionFind = a; 161 actionFind = a;
162 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); 162 connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
163 a->addTo( edit ); 163 a->addTo( edit );
164 a->addTo( listTools ); 164 a->addTo( listTools );
165 165
166 // Much better search widget, taken from QTReader.. (se) 166 // Much better search widget, taken from QTReader.. (se)
167 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); 167 searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
168 searchBar->setHorizontalStretchable( TRUE ); 168 searchBar->setHorizontalStretchable( TRUE );
169 searchBar->hide(); 169 searchBar->hide();
170 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 170 searchEdit = new QLineEdit( searchBar, "searchEdit" );
171 171
172 // QFont f("unifont", 16 /*, QFont::Bold*/); 172 // QFont f("unifont", 16 /*, QFont::Bold*/);
173 // searchEdit->setFont( f ); 173 // searchEdit->setFont( f );
174 174
175 searchBar->setStretchableWidget( searchEdit ); 175 searchBar->setStretchableWidget( searchEdit );
176 connect( searchEdit, SIGNAL( returnPressed( ) ), 176 connect( searchEdit, SIGNAL( returnPressed( ) ),
177 this, SLOT( slotFind( ) ) ); 177 this, SLOT( slotFind( ) ) );
178 178
179 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 179 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
180 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 180 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
181 a->addTo( searchBar ); 181 a->addTo( searchBar );
182 182
183 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 183 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
184 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); 184 connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
185 a->addTo( searchBar ); 185 a->addTo( searchBar );
186 186
187 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), 187 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ),
188 QString::null, 0, this, 0 ); 188 QString::null, 0, this, 0 );
189 //a->setEnabled( FALSE ); we got support for it now :) zecke 189 //a->setEnabled( FALSE ); we got support for it now :) zecke
190 actionMail = a; 190 actionMail = a;
191 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 191 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
192 a->addTo( edit ); 192 a->addTo( edit );
193 a->addTo( listTools ); 193 a->addTo( listTools );
194 194
195 if ( Ir::supported() ) { 195 if ( Ir::supported() ) {
196 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 196 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
197 0, this, 0 ); 197 0, this, 0 );
198 actionBeam = a; 198 actionBeam = a;
199 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 199 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
200 a->addTo( edit ); 200 a->addTo( edit );
201 a->addTo( listTools ); 201 a->addTo( listTools );
202 } 202 }
203 203
204 edit->insertSeparator(); 204 edit->insertSeparator();
205 205
206 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, 206 a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null,
207 0, this, 0); 207 0, this, 0);
208 actionPersonal = a; 208 actionPersonal = a;
209 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 209 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
210 a->addTo( edit ); 210 a->addTo( edit );
211 211
212 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, 212 a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null,
213 0, this, 0); 213 0, this, 0);
214 actionPersonal = a; 214 actionPersonal = a;
215 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); 215 connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) );
216 a->addTo( edit ); 216 a->addTo( edit );
217 217
218 edit->insertSeparator(); 218 edit->insertSeparator();
219 219
220 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), 220 a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ),
221 QString::null, 0, this, 0 , TRUE ); 221 QString::null, 0, this, 0 , TRUE );
222 actionPersonal = a; 222 actionPersonal = a;
223 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 223 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
224 a->addTo( edit ); 224 a->addTo( edit );
225 225
226 226
227#ifdef __DEBUG_RELEASE 227#ifdef __DEBUG_RELEASE
228 // Remove this function for public Release ! This is only 228 // Remove this function for public Release ! This is only
229 // for debug purposes .. 229 // for debug purposes ..
230 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); 230 a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
231 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); 231 connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
232 a->addTo( edit ); 232 a->addTo( edit );
233#endif 233#endif
234 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 234 a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null,
235 0, this, 0 ); 235 0, this, 0 );
236 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); 236 connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
237 a->addTo( edit ); 237 a->addTo( edit );
238 238
239 // Create Views 239 // Create Views
240 listContainer = new QWidget( this ); 240 listContainer = new QWidget( this );
241 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 241 QVBoxLayout *vb = new QVBoxLayout( listContainer );
242 242
243 m_abView = new AbView( listContainer, m_config.orderList() ); 243 m_abView = new AbView( listContainer, m_config.orderList() );
244 vb->addWidget( m_abView ); 244 vb->addWidget( m_abView );
245 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 245 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
246 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), 246 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
247 this, SLOT( slotViewSwitched( int ) ) ); 247 this, SLOT( slotViewSwitched( int ) ) );
248 248
249 249
250 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); 250 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
251 251
252 m_abView->load(); 252 m_abView->load();
253 253
254 // Letter Picker 254 // Letter Picker
255 pLabel = new LetterPicker( listContainer ); 255 pLabel = new LetterPicker( listContainer );
256 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 256 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
257 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); 257 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
258 258
259 vb->addWidget( pLabel ); 259 vb->addWidget( pLabel );
260 260
261 // All Categories into view-menu.. 261 // All Categories into view-menu..
262 populateCategories(); 262 populateCategories();
263 263
264 // Fontsize 264 // Fontsize
265 defaultFont = new QFont( m_abView->font() ); 265 defaultFont = new QFont( m_abView->font() );
266 slotSetFont(m_config.fontSize()); 266 slotSetFont(m_config.fontSize());
267 m_curFontSize = m_config.fontSize(); 267 m_curFontSize = m_config.fontSize();
268 268
269 setCentralWidget(listContainer); 269 setCentralWidget(listContainer);
270 270
271 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 271 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
272 272
273 273
274 isLoading = false; 274 isLoading = false;
275} 275}
276 276
277 277
278void AddressbookWindow::slotConfig() 278void AddressbookWindow::slotConfig()
279{ 279{
280 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 280 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
281 dlg -> setConfig( m_config ); 281 dlg -> setConfig( m_config );
282 dlg -> showMaximized(); 282 dlg -> showMaximized();
283 if ( dlg -> exec() ) { 283 if ( dlg -> exec() ) {
284 qWarning ("Config Dialog accepted!"); 284 qWarning ("Config Dialog accepted!");
285 m_config = dlg -> getConfig(); 285 m_config = dlg -> getConfig();
286 if ( m_curFontSize != m_config.fontSize() ){ 286 if ( m_curFontSize != m_config.fontSize() ){
287 qWarning("Font was changed!"); 287 qWarning("Font was changed!");
288 m_curFontSize = m_config.fontSize(); 288 m_curFontSize = m_config.fontSize();
289 emit slotSetFont( m_curFontSize ); 289 emit slotSetFont( m_curFontSize );
290 } 290 }
291 m_abView -> setListOrder( m_config.orderList() ); 291 m_abView -> setListOrder( m_config.orderList() );
292 } 292 }
293 293
294 delete dlg; 294 delete dlg;
295} 295}
296 296
297 297
298void AddressbookWindow::slotSetFont( int size ) 298void AddressbookWindow::slotSetFont( int size )
299{ 299{
300 qWarning("void AddressbookWindow::slotSetFont( %d )", size); 300 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
301 301
302 if (size > 2 || size < 0) 302 if (size > 2 || size < 0)
303 size = 1; 303 size = 1;
304 304
305 m_config.setFontSize( size ); 305 m_config.setFontSize( size );
306 306
307 QFont *currentFont; 307 QFont *currentFont;
308 308
309 switch (size) { 309 switch (size) {
310 case 0: 310 case 0:
311 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 311 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
312 currentFont = new QFont (m_abView->font()); 312 currentFont = new QFont (m_abView->font());
313 // abList->resizeRows(currentFont->pixelSize() + 7); :SX 313 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
314 // abList->resizeRows(); 314 // abList->resizeRows();
315 break; 315 break;
316 case 1: 316 case 1:
317 m_abView->setFont( *defaultFont ); 317 m_abView->setFont( *defaultFont );
318 currentFont = new QFont (m_abView->font()); 318 currentFont = new QFont (m_abView->font());
319 // // abList->resizeRows(currentFont->pixelSize() + 7); 319 // // abList->resizeRows(currentFont->pixelSize() + 7);
320 // abList->resizeRows(); 320 // abList->resizeRows();
321 break; 321 break;
322 case 2: 322 case 2:
323 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 323 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
324 currentFont = new QFont (m_abView->font()); 324 currentFont = new QFont (m_abView->font());
325 // //abList->resizeRows(currentFont->pixelSize() + 7); 325 // //abList->resizeRows(currentFont->pixelSize() + 7);
326 // abList->resizeRows(); 326 // abList->resizeRows();
327 break; 327 break;
328 } 328 }
329} 329}
330 330
331 331
332 332
333void AddressbookWindow::importvCard() { 333void AddressbookWindow::importvCard() {
334 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 334 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
335 if(!str.isEmpty() ){ 335 if(!str.isEmpty() ){
336 setDocument((const QString&) str ); 336 setDocument((const QString&) str );
337 } 337 }
338 338
339} 339}
340void AddressbookWindow::exportvCard() 340void AddressbookWindow::exportvCard()
341{ 341{
342 qWarning(" void AddressbookWindow::exportvCard()"); 342 qWarning(" void AddressbookWindow::exportvCard()");
343 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); 343 QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this );
344 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ 344 if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){
345 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); 345 qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 );
346 OContact curCont = m_abView->currentEntry(); 346 OContact curCont = m_abView->currentEntry();
347 if ( !curCont.isEmpty() ){ 347 if ( !curCont.isEmpty() ){
348 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 348 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
349 filename ); 349 filename );
350 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); 350 OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true );
351 if ( access ){ 351 if ( access ){
352 access->add( curCont ); 352 access->add( curCont );
353 access->save(); 353 access->save();
354 } 354 }
355 delete access; 355 delete access;
356 }else 356 }else
357 QMessageBox::critical( 0, "Export VCard", 357 QMessageBox::critical( 0, "Export VCard",
358 QString( tr( "You have to select a contact !") ) ); 358 QString( tr( "You have to select a contact !") ) );
359 359
360 }else 360 }else
361 QMessageBox::critical( 0, "Export VCard", 361 QMessageBox::critical( 0, "Export VCard",
362 QString( tr( "You have to set a filename !") ) ); 362 QString( tr( "You have to set a filename !") ) );
363} 363}
364 364
365void AddressbookWindow::setDocument( const QString &filename ) 365void AddressbookWindow::setDocument( const QString &filename )
366{ 366{
367 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); 367 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
368 368
369 if ( filename.find(".vcf") != int(filename.length()) - 4 ){ 369 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
370 370
371 371
372 372
373 switch( QMessageBox::information( this, tr ( "Right file type ?" ), 373 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
374 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), 374 tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ),
375 tr( "&Yes" ), tr( "&No" ), QString::null, 375 tr( "&Yes" ), tr( "&No" ), QString::null,
376 0, // Enter == button 0 376 0, // Enter == button 0
377 2 ) ) { // Escape == button 2 377 2 ) ) { // Escape == button 2
378 case 0: 378 case 0:
379 qWarning("YES clicked"); 379 qWarning("YES clicked");
380 break; 380 break;
381 case 1: 381 case 1:
382 qWarning("NO clicked"); 382 qWarning("NO clicked");
383 return; 383 return;
384 break; 384 break;
385 } 385 }
386 } 386 }
387 387
388 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 388 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
389 filename ); 389 filename );
390 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 390 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
391 OContactAccess::List allList = access->allRecords(); 391 OContactAccess::List allList = access->allRecords();
392 qWarning( "Found number of contacts in File: %d", allList.count() ); 392 qWarning( "Found number of contacts in File: %d", allList.count() );
393 393
394 if ( !allList.count() ) { 394 if ( !allList.count() ) {
395 QMessageBox::information( this, "Import VCard", 395 QMessageBox::information( this, "Import VCard",
396 "It was impossible to import\nthe VCard.\n" 396 "It was impossible to import\nthe VCard.\n"
397 "The VCard may be corrupted!" ); 397 "The VCard may be corrupted!" );
398 } 398 }
399 399
400 bool doAsk = true; 400 bool doAsk = true;
401 OContactAccess::List::Iterator it; 401 OContactAccess::List::Iterator it;
402 for ( it = allList.begin(); it != allList.end(); ++it ){ 402 for ( it = allList.begin(); it != allList.end(); ++it ){
403 qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); 403 qWarning("Adding Contact from: %s", (*it).fullName().latin1() );
404 if ( doAsk ){ 404 if ( doAsk ){
405 switch( QMessageBox::information( this, tr ( "Add Contact?" ), 405 switch( QMessageBox::information( this, tr ( "Add Contact?" ),
406 tr( "Do you really want add contact for \n%1?" ) 406 tr( "Do you really want add contact for \n%1?" )
407 .arg( (*it).fullName().latin1() ), 407 .arg( (*it).fullName().latin1() ),
408 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), 408 tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"),
409 0, // Enter == button 0 409 0, // Enter == button 0
410 2 ) ) { // Escape == button 2 410 2 ) ) { // Escape == button 2
411 case 0: 411 case 0:
412 qWarning("YES clicked"); 412 qWarning("YES clicked");
413 m_abView->addEntry( *it ); 413 m_abView->addEntry( *it );
414 break; 414 break;
415 case 1: 415 case 1:
416 qWarning("NO clicked"); 416 qWarning("NO clicked");
417 break; 417 break;
418 case 2: 418 case 2:
419 qWarning("YesAll clicked"); 419 qWarning("YesAll clicked");
420 doAsk = false; 420 doAsk = false;
421 break; 421 break;
422 } 422 }
423 }else 423 }else
424 m_abView->addEntry( *it ); 424 m_abView->addEntry( *it );
425 425
426 } 426 }
427 427
428 delete access; 428 delete access;
429} 429}
430 430
431void AddressbookWindow::resizeEvent( QResizeEvent *e ) 431void AddressbookWindow::resizeEvent( QResizeEvent *e )
432{ 432{
433 QMainWindow::resizeEvent( e ); 433 QMainWindow::resizeEvent( e );
434 434
435 435
436} 436}
437 437
438AddressbookWindow::~AddressbookWindow() 438AddressbookWindow::~AddressbookWindow()
439{ 439{
440 ToolBarDock dock; 440 ToolBarDock dock;
441 int dummy; 441 int dummy;
442 bool bDummy; 442 bool bDummy;
443 getLocation ( listTools, dock, dummy, bDummy, dummy ); 443 getLocation ( listTools, dock, dummy, bDummy, dummy );
444 m_config.setToolBarDock( dock ); 444 m_config.setToolBarDock( dock );
445 m_config.save(); 445 m_config.save();
446} 446}
447 447
448void AddressbookWindow::slotUpdateToolbar() 448void AddressbookWindow::slotUpdateToolbar()
449{ 449{
450 OContact ce = m_abView->currentEntry(); 450 OContact ce = m_abView->currentEntry();
451 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 451 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
452} 452}
453 453
454void AddressbookWindow::slotListNew() 454void AddressbookWindow::slotListNew()
455{ 455{
456 OContact cnt; 456 OContact cnt;
457 if( !syncing ) { 457 if( !syncing ) {
458 editEntry( NewEntry ); 458 editEntry( NewEntry );
459 } else { 459 } else {
460 QMessageBox::warning(this, tr("Contacts"), 460 QMessageBox::warning(this, tr("Contacts"),
461 tr("Can not edit data, currently syncing")); 461 tr("Can not edit data, currently syncing"));
462 } 462 }
463} 463}
464 464
465// void AddressbookWindow::slotListView() 465// void AddressbookWindow::slotListView()
466// { 466// {
467 // m_abView -> init( abList->currentEntry() ); 467 // m_abView -> init( abList->currentEntry() );
468 // // :SX mView->sync(); 468 // // :SX mView->sync();
469 // //:SXshowView(); 469 // //:SXshowView();
470// } 470// }
471 471
472void AddressbookWindow::slotListDelete() 472void AddressbookWindow::slotListDelete()
473{ 473{
474 if(!syncing) { 474 if(!syncing) {
475 OContact tmpEntry = m_abView ->currentEntry(); 475 OContact tmpEntry = m_abView ->currentEntry();
476 476
477 // get a name, do the best we can... 477 // get a name, do the best we can...
478 QString strName = tmpEntry.fullName(); 478 QString strName = tmpEntry.fullName();
479 if ( strName.isEmpty() ) { 479 if ( strName.isEmpty() ) {
480 strName = tmpEntry.company(); 480 strName = tmpEntry.company();
481 if ( strName.isEmpty() ) 481 if ( strName.isEmpty() )
482 strName = "No Name"; 482 strName = "No Name";
483 } 483 }
484 484
485 485
486 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 486 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
487 strName ) ) { 487 strName ) ) {
488 m_abView->removeEntry( tmpEntry.uid() ); 488 m_abView->removeEntry( tmpEntry.uid() );
489 } 489 }
490 } else { 490 } else {
491 QMessageBox::warning( this, tr("Contacts"), 491 QMessageBox::warning( this, tr("Contacts"),
492 tr("Can not edit data, currently syncing") ); 492 tr("Can not edit data, currently syncing") );
493 } 493 }
494} 494}
495 495
496void AddressbookWindow::slotFindOpen() 496void AddressbookWindow::slotFindOpen()
497{ 497{
498 searchBar->show(); 498 searchBar->show();
499 m_abView -> inSearch(); 499 m_abView -> inSearch();
500 searchEdit->setFocus(); 500 searchEdit->setFocus();
501} 501}
502void AddressbookWindow::slotFindClose() 502void AddressbookWindow::slotFindClose()
503{ 503{
504 searchBar->hide(); 504 searchBar->hide();
505 m_abView -> offSearch(); 505 m_abView -> offSearch();
506 // m_abView->setFocus(); 506 // m_abView->setFocus();
507} 507}
508 508
509 509
510void AddressbookWindow::slotFind() 510void AddressbookWindow::slotFind()
511{ 511{
512 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); 512 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
513 513
514 searchEdit->clearFocus(); 514 searchEdit->clearFocus();
515 // m_abView->setFocus(); 515 // m_abView->setFocus();
516 516
517} 517}
518 518
519void AddressbookWindow::slotViewBack() 519void AddressbookWindow::slotViewBack()
520{ 520{
521 // :SX showList(); 521 // :SX showList();
522} 522}
523 523
524void AddressbookWindow::slotViewEdit() 524void AddressbookWindow::slotViewEdit()
525{ 525{
526 if(!syncing) { 526 if(!syncing) {
527 if (actionPersonal->isOn()) { 527 if (actionPersonal->isOn()) {
528 editPersonal(); 528 editPersonal();
529 } else { 529 } else {
530 editEntry( EditEntry ); 530 editEntry( EditEntry );
531 } 531 }
532 } else { 532 } else {
533 QMessageBox::warning( this, tr("Contacts"), 533 QMessageBox::warning( this, tr("Contacts"),
534 tr("Can not edit data, currently syncing") ); 534 tr("Can not edit data, currently syncing") );
535 } 535 }
536} 536}
537 537
538 538
539 539
540void AddressbookWindow::writeMail() 540void AddressbookWindow::writeMail()
541{ 541{
542 OContact c = m_abView -> currentEntry(); 542 OContact c = m_abView -> currentEntry();
543 QString name = c.fileAs(); 543 QString name = c.fileAs();
544 QString email = c.defaultEmail(); 544 QString email = c.defaultEmail();
545 545
546 // I prefer the OPIE-Environment variable before the 546 // I prefer the OPIE-Environment variable before the
547 // QPE-one.. 547 // QPE-one..
548 QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); 548 QString basepath = QString::fromLatin1( getenv("OPIEDIR") );
549 if ( basepath.isEmpty() ) 549 if ( basepath.isEmpty() )
550 basepath = QString::fromLatin1( getenv("QPEDIR") ); 550 basepath = QString::fromLatin1( getenv("QPEDIR") );
551 551
552 // Try to access the preferred. If not possible, try to 552 // Try to access the preferred. If not possible, try to
553 // switch to the other one.. 553 // switch to the other one..
554 if ( m_config.useQtMail() ){ 554 if ( m_config.useQtMail() ){
555 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 555 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
556 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 556 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
557 qWarning ("QCop"); 557 qWarning ("QCop");
558 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 558 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
559 e << name << email; 559 e << name << email;
560 return; 560 return;
561 } else 561 } else
562 m_config.setUseOpieMail( true ); 562 m_config.setUseOpieMail( true );
563 } 563 }
564 if ( m_config.useOpieMail() ){ 564 if ( m_config.useOpieMail() ){
565 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); 565 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
566 if ( QFile::exists( basepath + "/bin/mail" ) ){ 566 if ( QFile::exists( basepath + "/bin/mail" ) ){
567 qWarning ("QCop"); 567 qWarning ("QCop");
568 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); 568 QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)");
569 e << name << email; 569 e << name << email;
570 return; 570 return;
571 } else 571 } else
572 m_config.setUseQtMail( true ); 572 m_config.setUseQtMail( true );
573 } 573 }
574 574
575} 575}
576 576
577static const char * beamfile = "/tmp/obex/contact.vcf"; 577static const char * beamfile = "/tmp/obex/contact.vcf";
578 578
579void AddressbookWindow::slotBeam() 579void AddressbookWindow::slotBeam()
580{ 580{
581 QString beamFilename; 581 QString beamFilename;
582 OContact c; 582 OContact c;
583 if ( actionPersonal->isOn() ) { 583 if ( actionPersonal->isOn() ) {
584 beamFilename = addressbookPersonalVCardName(); 584 beamFilename = addressbookPersonalVCardName();
585 if ( !QFile::exists( beamFilename ) ) 585 if ( !QFile::exists( beamFilename ) )
586 return; // can't beam a non-existent file 586 return; // can't beam a non-existent file
587 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 587 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
588 beamFilename ); 588 beamFilename );
589 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 589 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
590 OContactAccess::List allList = access->allRecords(); 590 OContactAccess::List allList = access->allRecords();
591 OContactAccess::List::Iterator it = allList.begin(); // Just take first 591 OContactAccess::List::Iterator it = allList.begin(); // Just take first
592 c = *it; 592 c = *it;
593 593
594 delete access; 594 delete access;
595 } else { 595 } else {
596 unlink( beamfile ); // delete if exists 596 unlink( beamfile ); // delete if exists
597 mkdir("/tmp/obex/", 0755); 597 mkdir("/tmp/obex/", 0755);
598 c = m_abView -> currentEntry(); 598 c = m_abView -> currentEntry();
599 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, 599 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
600 beamfile ); 600 beamfile );
601 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); 601 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
602 access->add( c ); 602 access->add( c );
603 access->save(); 603 access->save();
604 delete access; 604 delete access;
605 605
606 beamFilename = beamfile; 606 beamFilename = beamfile;
607 } 607 }
608 608
609 qWarning("Beaming: %s", beamFilename.latin1() ); 609 qWarning("Beaming: %s", beamFilename.latin1() );
610 610
611 Ir *ir = new Ir( this ); 611 Ir *ir = new Ir( this );
612 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 612 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
613 QString description = c.fullName(); 613 QString description = c.fullName();
614 ir->send( beamFilename, description, "text/x-vCard" ); 614 ir->send( beamFilename, description, "text/x-vCard" );
615} 615}
616 616
617void AddressbookWindow::beamDone( Ir *ir ) 617void AddressbookWindow::beamDone( Ir *ir )
618{ 618{
619 619
620 delete ir; 620 delete ir;
621 unlink( beamfile ); 621 unlink( beamfile );
622} 622}
623 623
624 624
625static void parseName( const QString& name, QString *first, QString *middle, 625static void parseName( const QString& name, QString *first, QString *middle,
626 QString * last ) 626 QString * last )
627{ 627{
628 628
629 int comma = name.find ( "," ); 629 int comma = name.find ( "," );
630 QString rest; 630 QString rest;
631 if ( comma > 0 ) { 631 if ( comma > 0 ) {
632 *last = name.left( comma ); 632 *last = name.left( comma );
633 comma++; 633 comma++;
634 while ( comma < int(name.length()) && name[comma] == ' ' ) 634 while ( comma < int(name.length()) && name[comma] == ' ' )
635 comma++; 635 comma++;
636 rest = name.mid( comma ); 636 rest = name.mid( comma );
637 } else { 637 } else {
638 int space = name.findRev( ' ' ); 638 int space = name.findRev( ' ' );
639 *last = name.mid( space+1 ); 639 *last = name.mid( space+1 );
640 rest = name.left( space ); 640 rest = name.left( space );
641 } 641 }
642 int space = rest.find( ' ' ); 642 int space = rest.find( ' ' );
643 if ( space <= 0 ) { 643 if ( space <= 0 ) {
644 *first = rest; 644 *first = rest;
645 } else { 645 } else {
646 *first = rest.left( space ); 646 *first = rest.left( space );
647 *middle = rest.mid( space+1 ); 647 *middle = rest.mid( space+1 );
648 } 648 }
649 649
650} 650}
651 651
652 652
653void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 653void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
654{ 654{
655 if (msg == "editPersonal()") { 655 if (msg == "editPersonal()") {
656 editPersonal(); 656 editPersonal();
657 } else if (msg == "editPersonalAndClose()") { 657 } else if (msg == "editPersonalAndClose()") {
658 editPersonal(); 658 editPersonal();
659 close(); 659 close();
660 } else if ( msg == "addContact(QString,QString)" ) { 660 } else if ( msg == "addContact(QString,QString)" ) {
661 QDataStream stream(data,IO_ReadOnly); 661 QDataStream stream(data,IO_ReadOnly);
662 QString name, email; 662 QString name, email;
663 stream >> name >> email; 663 stream >> name >> email;
664 664
665 OContact cnt; 665 OContact cnt;
666 QString fn, mn, ln; 666 QString fn, mn, ln;
667 parseName( name, &fn, &mn, &ln ); 667 parseName( name, &fn, &mn, &ln );
668 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 668 // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
669 cnt.setFirstName( fn ); 669 cnt.setFirstName( fn );
670 cnt.setMiddleName( mn ); 670 cnt.setMiddleName( mn );
671 cnt.setLastName( ln ); 671 cnt.setLastName( ln );
672 cnt.insertEmails( email ); 672 cnt.insertEmails( email );
673 cnt.setDefaultEmail( email ); 673 cnt.setDefaultEmail( email );
674 cnt.setFileAs(); 674 cnt.setFileAs();
675 675
676 m_abView -> addEntry( cnt ); 676 m_abView -> addEntry( cnt );
677 677
678 // :SXm_abView()->init( cnt ); 678 // :SXm_abView()->init( cnt );
679 editEntry( EditEntry ); 679 editEntry( EditEntry );
680 } else if ( msg == "beamBusinessCard()" ) { 680 } else if ( msg == "beamBusinessCard()" ) {
681 QString beamFilename = addressbookPersonalVCardName(); 681 QString beamFilename = addressbookPersonalVCardName();
682 if ( !QFile::exists( beamFilename ) ) 682 if ( !QFile::exists( beamFilename ) )
683 return; // can't beam a non-existent file 683 return; // can't beam a non-existent file
684 684
685 Ir *ir = new Ir( this ); 685 Ir *ir = new Ir( this );
686 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 686 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
687 QString description = "mycard.vcf"; 687 QString description = "mycard.vcf";
688 ir->send( beamFilename, description, "text/x-vCard" ); 688 ir->send( beamFilename, description, "text/x-vCard" );
689 } 689 } else if ( msg == "showUid(int)" ) {
690#if 0
691 else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) {
692 QDataStream stream(data,IO_ReadOnly); 690 QDataStream stream(data,IO_ReadOnly);
693 QCString ch,m; 691 int uid;
694 QStringList types; 692 stream >> uid;
695 stream >> ch >> m >> types; 693
696 AddressPicker picker(abList,this,0,TRUE); 694 // Deactivate Personal View..
697 picker.showMaximized(); 695 if ( actionPersonal->isOn() ){
698 picker.setChoiceNames(types); 696 actionPersonal->setOn( false );
699 int i=0; 697 slotPersonalView();
700 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) {
701 QStringList sel;
702 stream >> sel;
703 picker.setSelection(i++,sel);
704 } 698 }
705 picker.showMaximized();
706 picker.exec();
707 699
708 // ###### note: contacts may have been added - save here! 700 // Reset category and show as card..
701 m_abView -> setShowByCategory( QString::null );
702 m_abView -> setCurrentUid( uid );
703 slotViewSwitched ( AbView::CardView );
704
705 } else if ( msg == "editUid(int)" ) {
706 QDataStream stream(data,IO_ReadOnly);
707 int uid;
708 stream >> uid;
709 709
710 setCentralWidget(abList); 710 // Deactivate Personal View..
711 QCopEnvelope e(ch,m); 711 if ( actionPersonal->isOn() ){
712 i=0; 712 actionPersonal->setOn( false );
713 for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { 713 slotPersonalView();
714 QStringList sel = picker.selection(i++);
715 e << sel;
716 } 714 }
717 } 715
718#endif 716 // Reset category and edit..
717 m_abView -> setShowByCategory( QString::null );
718 m_abView -> setCurrentUid( uid );
719 slotViewEdit();
720 }
719 721
720} 722}
721 723
722void AddressbookWindow::editEntry( EntryMode entryMode ) 724void AddressbookWindow::editEntry( EntryMode entryMode )
723{ 725{
724 OContact entry; 726 OContact entry;
725 if ( !abEditor ) { 727 if ( !abEditor ) {
726 abEditor = new ContactEditor( entry, this, "editor" ); 728 abEditor = new ContactEditor( entry, this, "editor" );
727 } 729 }
728 if ( entryMode == EditEntry ) 730 if ( entryMode == EditEntry )
729 abEditor->setEntry( m_abView -> currentEntry() ); 731 abEditor->setEntry( m_abView -> currentEntry() );
730 else if ( entryMode == NewEntry ) 732 else if ( entryMode == NewEntry )
731 abEditor->setEntry( entry ); 733 abEditor->setEntry( entry );
732 // other things may change the caption. 734 // other things may change the caption.
733 abEditor->setCaption( tr("Edit Address") ); 735 abEditor->setCaption( tr("Edit Address") );
734 736
735#if defined(Q_WS_QWS) || defined(_WS_QWS_) 737#if defined(Q_WS_QWS) || defined(_WS_QWS_)
736 abEditor->showMaximized(); 738 abEditor->showMaximized();
737#endif 739#endif
738 // fix the foxus... 740 // fix the foxus...
739 abEditor->setNameFocus(); 741 abEditor->setNameFocus();
740 if ( abEditor->exec() ) { 742 if ( abEditor->exec() ) {
741 setFocus(); 743 setFocus();
742 if ( entryMode == NewEntry ) { 744 if ( entryMode == NewEntry ) {
743 OContact insertEntry = abEditor->entry(); 745 OContact insertEntry = abEditor->entry();
744 insertEntry.assignUid(); 746 insertEntry.assignUid();
745 m_abView -> addEntry( insertEntry ); 747 m_abView -> addEntry( insertEntry );
746 } else { 748 } else {
747 OContact replEntry = abEditor->entry(); 749 OContact replEntry = abEditor->entry();
748 750
749 if ( !replEntry.isValidUid() ) 751 if ( !replEntry.isValidUid() )
750 replEntry.assignUid(); 752 replEntry.assignUid();
751 753
752 m_abView -> replaceEntry( replEntry ); 754 m_abView -> replaceEntry( replEntry );
753 } 755 }
754 } 756 }
755 // populateCategories(); 757 // populateCategories();
756 758
757} 759}
758 760
759void AddressbookWindow::editPersonal() 761void AddressbookWindow::editPersonal()
760{ 762{
761 OContact entry; 763 OContact entry;
762 764
763 // Switch to personal view if not selected 765 // Switch to personal view if not selected
764 // but take care of the menu, too 766 // but take care of the menu, too
765 if ( ! actionPersonal->isOn() ){ 767 if ( ! actionPersonal->isOn() ){
766 qWarning("*** ++++"); 768 qWarning("*** ++++");
767 actionPersonal->setOn( true ); 769 actionPersonal->setOn( true );
768 slotPersonalView(); 770 slotPersonalView();
769 } 771 }
770 772
771 if ( !abEditor ) { 773 if ( !abEditor ) {
772 abEditor = new ContactEditor( entry, this, "editor" ); 774 abEditor = new ContactEditor( entry, this, "editor" );
773 } 775 }
774 776
775 abEditor->setCaption(tr("Edit My Personal Details")); 777 abEditor->setCaption(tr("Edit My Personal Details"));
776 abEditor->setPersonalView( true ); 778 abEditor->setPersonalView( true );
777 editEntry( EditEntry ); 779 editEntry( EditEntry );
778 abEditor->setPersonalView( false ); 780 abEditor->setPersonalView( false );
779 781
780} 782}
781 783
782 784
783void AddressbookWindow::slotPersonalView() 785void AddressbookWindow::slotPersonalView()
784{ 786{
785 qWarning("slotPersonalView()"); 787 qWarning("slotPersonalView()");
786 if (!actionPersonal->isOn()) { 788 if (!actionPersonal->isOn()) {
787 // we just turned it off 789 // we just turned it off
788 qWarning("slotPersonalView()-> OFF"); 790 qWarning("slotPersonalView()-> OFF");
789 setCaption( tr("Contacts") ); 791 setCaption( tr("Contacts") );
790 actionNew->setEnabled(TRUE); 792 actionNew->setEnabled(TRUE);
791 actionTrash->setEnabled(TRUE); 793 actionTrash->setEnabled(TRUE);
792 actionFind->setEnabled(TRUE); 794 actionFind->setEnabled(TRUE);
793 actionMail->setEnabled(TRUE); 795 actionMail->setEnabled(TRUE);
794 // slotUpdateToolbar(); 796 // slotUpdateToolbar();
795 797
796 m_abView->showPersonal( false ); 798 m_abView->showPersonal( false );
797 799
798 return; 800 return;
799 } 801 }
800 802
801 qWarning("slotPersonalView()-> ON"); 803 qWarning("slotPersonalView()-> ON");
802 // XXX need to disable some QActions. 804 // XXX need to disable some QActions.
803 actionNew->setEnabled(FALSE); 805 actionNew->setEnabled(FALSE);
804 actionTrash->setEnabled(FALSE); 806 actionTrash->setEnabled(FALSE);
805 actionFind->setEnabled(FALSE); 807 actionFind->setEnabled(FALSE);
806 actionMail->setEnabled(FALSE); 808 actionMail->setEnabled(FALSE);
807 809
808 setCaption( tr("Contacts - My Personal Details") ); 810 setCaption( tr("Contacts - My Personal Details") );
809 811
810 m_abView->showPersonal( true ); 812 m_abView->showPersonal( true );
811 813
812} 814}
813 815
814 816
815void AddressbookWindow::listIsEmpty( bool empty ) 817void AddressbookWindow::listIsEmpty( bool empty )
816{ 818{
817 if ( !empty ) { 819 if ( !empty ) {
818 deleteButton->setEnabled( TRUE ); 820 deleteButton->setEnabled( TRUE );
819 } 821 }
820} 822}
821 823
822void AddressbookWindow::reload() 824void AddressbookWindow::reload()
823{ 825{
824 syncing = FALSE; 826 syncing = FALSE;
825 m_abView->clear(); 827 m_abView->clear();
826 m_abView->reload(); 828 m_abView->reload();
827} 829}
828 830
829void AddressbookWindow::flush() 831void AddressbookWindow::flush()
830{ 832{
831 syncing = TRUE; 833 syncing = TRUE;
832 m_abView->save(); 834 m_abView->save();
833} 835}
834 836
835 837
836void AddressbookWindow::closeEvent( QCloseEvent *e ) 838void AddressbookWindow::closeEvent( QCloseEvent *e )
837{ 839{
838 if(active_view == AbView::CardView){ 840 if(active_view == AbView::CardView){
839 slotViewSwitched( AbView::TableView ); 841 slotViewSwitched( AbView::TableView );
840 e->ignore(); 842 e->ignore();
841 return; 843 return;
842 } 844 }
843 if(syncing) { 845 if(syncing) {
844 /* shouldn't we save, I hear you say? well its already been set 846 /* shouldn't we save, I hear you say? well its already been set
845 so that an edit can not occur during a sync, and we flushed 847 so that an edit can not occur during a sync, and we flushed
846 at the start of the sync, so there is no need to save 848 at the start of the sync, so there is no need to save
847 Saving however itself would cause problems. */ 849 Saving however itself would cause problems. */
848 e->accept(); 850 e->accept();
849 return; 851 return;
850 } 852 }
851 //################## shouldn't always save 853 //################## shouldn't always save
852 // True, but the database handles this automatically ! (se) 854 // True, but the database handles this automatically ! (se)
853 if ( save() ) 855 if ( save() )
854 e->accept(); 856 e->accept();
855 else 857 else
856 e->ignore(); 858 e->ignore();
857} 859}
858 860
859/* 861/*
860 Returns TRUE if it is OK to exit 862 Returns TRUE if it is OK to exit
861*/ 863*/
862 864
863bool AddressbookWindow::save() 865bool AddressbookWindow::save()
864{ 866{
865 if ( !m_abView->save() ) { 867 if ( !m_abView->save() ) {
866 if ( QMessageBox::critical( 0, tr( "Out of space" ), 868 if ( QMessageBox::critical( 0, tr( "Out of space" ),
867 tr("Unable to save information.\n" 869 tr("Unable to save information.\n"
868 "Free up some space\n" 870 "Free up some space\n"
869 "and try again.\n" 871 "and try again.\n"
870 "\nQuit anyway?"), 872 "\nQuit anyway?"),
871 QMessageBox::Yes|QMessageBox::Escape, 873 QMessageBox::Yes|QMessageBox::Escape,
872 QMessageBox::No|QMessageBox::Default ) 874 QMessageBox::No|QMessageBox::Default )
873 != QMessageBox::No ) 875 != QMessageBox::No )
874 return TRUE; 876 return TRUE;
875 else 877 else
876 return FALSE; 878 return FALSE;
877 } 879 }
878 return TRUE; 880 return TRUE;
879} 881}
880 882
881#ifdef __DEBUG_RELEASE 883#ifdef __DEBUG_RELEASE
882void AddressbookWindow::slotSave() 884void AddressbookWindow::slotSave()
883{ 885{
884 save(); 886 save();
885} 887}
886#endif 888#endif
887 889
888 890
889void AddressbookWindow::slotNotFound() 891void AddressbookWindow::slotNotFound()
890{ 892{
891 qWarning("Got notfound signal!"); 893 qWarning("Got notfound signal!");
892 QMessageBox::information( this, tr( "Not Found" ), 894 QMessageBox::information( this, tr( "Not Found" ),
893 tr( "Unable to find a contact for this \n search pattern!" ) ); 895 tr( "Unable to find a contact for this \n search pattern!" ) );
894 896
895 897
896} 898}
897void AddressbookWindow::slotWrapAround() 899void AddressbookWindow::slotWrapAround()
898{ 900{
899 qWarning("Got wrap signal!"); 901 qWarning("Got wrap signal!");
900 // if ( doNotifyWrapAround ) 902 // if ( doNotifyWrapAround )
901 // QMessageBox::information( this, tr( "End of list" ), 903 // QMessageBox::information( this, tr( "End of list" ),
902 // tr( "End of list. Wrap around now...!" ) + "\n" ); 904 // tr( "End of list. Wrap around now...!" ) + "\n" );
903 905
904} 906}
905 907
906void AddressbookWindow::slotSetCategory( int c ) 908void AddressbookWindow::slotSetCategory( int c )
907{ 909{
908 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); 910 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
909 911
910 QString cat, book; 912 QString cat, book;
911 AbView::Views view = AbView::TableView; 913 AbView::Views view = AbView::TableView;
912 914
913 if ( c <= 0 ) 915 if ( c <= 0 )
914 return; 916 return;
915 917
916 // Switch view 918 // Switch view
917 if ( c < 3 ) 919 if ( c < 3 )
918 for ( unsigned int i = 1; i < 3; i++ ){ 920 for ( unsigned int i = 1; i < 3; i++ ){
919 if ( catMenu ) 921 if ( catMenu )
920 catMenu->setItemChecked( i, c == (int)i ); 922 catMenu->setItemChecked( i, c == (int)i );
921 } 923 }
922 else 924 else
923 // Checkmark Category Menu Item Selected 925 // Checkmark Category Menu Item Selected
924 for ( unsigned int i = 3; i < catMenu->count(); i++ ) 926 for ( unsigned int i = 3; i < catMenu->count(); i++ )
925 catMenu->setItemChecked( i, c == (int)i ); 927 catMenu->setItemChecked( i, c == (int)i );
926 928
927 // Now switch to the selected category 929 // Now switch to the selected category
928 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 930 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
929 if (catMenu->isItemChecked( i )) { 931 if (catMenu->isItemChecked( i )) {
930 if ( i == 1 ){ // default List view 932 if ( i == 1 ){ // default List view
931 book = QString::null; 933 book = QString::null;
932 view = AbView::TableView; 934 view = AbView::TableView;
933 }else if ( i == 2 ){ 935 }else if ( i == 2 ){
934 book = tr( "Cards" ); 936 book = tr( "Cards" );
935 view = AbView::CardView; 937 view = AbView::CardView;
936 // }else if ( i == 3 ){ 938 // }else if ( i == 3 ){
937 // book = tr( "Personal" ); 939 // book = tr( "Personal" );
938 // view = AbView:: PersonalView; 940 // view = AbView:: PersonalView;
939 }else if ( i == 3 ){ // default All Categories 941 }else if ( i == 3 ){ // default All Categories
940 cat = QString::null; 942 cat = QString::null;
941 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled 943 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
942 cat = "Unfiled"; 944 cat = "Unfiled";
943 qWarning ("Unfiled selected!!!"); 945 qWarning ("Unfiled selected!!!");
944 }else{ 946 }else{
945 cat = m_abView->categories()[i - 4]; 947 cat = m_abView->categories()[i - 4];
946 } 948 }
947 } 949 }
948 } 950 }
949 951
950 // Switch to the selected View 952 // Switch to the selected View
951 slotViewSwitched( view ); 953 slotViewSwitched( view );
952 954
953 // Tell the view about the selected category 955 // Tell the view about the selected category
954 m_abView -> setShowByCategory( cat ); 956 m_abView -> setShowByCategory( cat );
955 957
956 if ( book.isEmpty() ) 958 if ( book.isEmpty() )
957 book = "List"; 959 book = "List";
958 if ( cat.isEmpty() ) 960 if ( cat.isEmpty() )
959 cat = "All"; 961 cat = "All";
960 962
961 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); 963 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
962} 964}
963 965
964void AddressbookWindow::slotViewSwitched( int view ) 966void AddressbookWindow::slotViewSwitched( int view )
965{ 967{
966 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); 968 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
967 int menu = 0; 969 int menu = 0;
968 970
969 // Switch to selected view 971 // Switch to selected view
970 switch ( view ){ 972 switch ( view ){
971 case AbView::TableView: 973 case AbView::TableView:
972 menu = 1; 974 menu = 1;
973 m_tableViewButton->setOn(true); 975 m_tableViewButton->setOn(true);
974 m_cardViewButton->setOn(false); 976 m_cardViewButton->setOn(false);
975 break; 977 break;
976 case AbView::CardView: 978 case AbView::CardView:
977 menu = 2; 979 menu = 2;
978 m_tableViewButton->setOn(false); 980 m_tableViewButton->setOn(false);
979 m_cardViewButton->setOn(true); 981 m_cardViewButton->setOn(true);
980 break; 982 break;
981 } 983 }
982 for ( unsigned int i = 1; i < 3; i++ ){ 984 for ( unsigned int i = 1; i < 3; i++ ){
983 if ( catMenu ) 985 if ( catMenu )
984 catMenu->setItemChecked( i, menu == (int)i ); 986 catMenu->setItemChecked( i, menu == (int)i );
985 } 987 }
986 988
987 // Tell the view about the selected view 989 // Tell the view about the selected view
988 m_abView -> setShowToView ( (AbView::Views) view ); 990 m_abView -> setShowToView ( (AbView::Views) view );
989 active_view = view; 991 active_view = view;
990} 992}
991 993
992 994
993void AddressbookWindow::slotListView() 995void AddressbookWindow::slotListView()
994{ 996{
995 slotViewSwitched( AbView::TableView ); 997 slotViewSwitched( AbView::TableView );
996} 998}
997 999
998void AddressbookWindow::slotCardView() 1000void AddressbookWindow::slotCardView()
999{ 1001{
1000 slotViewSwitched( AbView::CardView ); 1002 slotViewSwitched( AbView::CardView );
1001} 1003}
1002 1004
1003void AddressbookWindow::slotSetLetter( char c ) { 1005void AddressbookWindow::slotSetLetter( char c ) {
1004 1006
1005 m_abView->setShowByLetter( c ); 1007 m_abView->setShowByLetter( c );
1006 1008
1007} 1009}
1008 1010
1009 1011
1010void AddressbookWindow::populateCategories() 1012void AddressbookWindow::populateCategories()
1011{ 1013{
1012 catMenu->clear(); 1014 catMenu->clear();
1013 1015
1014 int id, rememberId; 1016 int id, rememberId;
1015 id = 1; 1017 id = 1;
1016 rememberId = 0; 1018 rememberId = 0;
1017 1019
1018 catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); 1020 catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ );
1019 catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); 1021 catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ );
1020 // catMenu->insertItem( tr( "Personal" ), id++ ); 1022 // catMenu->insertItem( tr( "Personal" ), id++ );
1021 catMenu->insertSeparator(); 1023 catMenu->insertSeparator();
1022 1024
1023 catMenu->insertItem( tr( "All" ), id++ ); 1025 catMenu->insertItem( tr( "All" ), id++ );
1024 QStringList categories = m_abView->categories(); 1026 QStringList categories = m_abView->categories();
1025 categories.append( tr( "Unfiled" ) ); 1027 categories.append( tr( "Unfiled" ) );
1026 for ( QStringList::Iterator it = categories.begin(); 1028 for ( QStringList::Iterator it = categories.begin();
1027 it != categories.end(); ++it ) { 1029 it != categories.end(); ++it ) {
1028 catMenu->insertItem( *it, id ); 1030 catMenu->insertItem( *it, id );
1029 if ( *it == m_abView -> showCategory() ) 1031 if ( *it == m_abView -> showCategory() )
1030 rememberId = id; 1032 rememberId = id;
1031 ++id; 1033 ++id;
1032 } 1034 }
1033 1035
1034 1036
1035 if ( m_abView -> showCategory().isEmpty() ) { 1037 if ( m_abView -> showCategory().isEmpty() ) {
1036 slotSetCategory( 3 ); 1038 slotSetCategory( 3 );
1037 } 1039 }
1038 else { 1040 else {
1039 slotSetCategory( rememberId ); 1041 slotSetCategory( rememberId );
1040 } 1042 }
1041} 1043}
1042 1044