summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp847
1 files changed, 338 insertions, 509 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 108e66d..e5addec 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -23,6 +23,7 @@
23#include "contacteditor.h" 23#include "contacteditor.h"
24#include "ablabel.h" 24#include "ablabel.h"
25#include "abview.h"
25#include "abtable.h" 26#include "abtable.h"
26#include "addresssettings.h" 27// #include "addresssettings.h"
27#include "addressbook.h" 28#include "addressbook.h"
28 29
@@ -30,13 +31,17 @@
30#include <opie/ofileselector.h> 31#include <opie/ofileselector.h>
31#include <opie/ofiledialog.h> 32#include <opie/ofiledialog.h>
32#include <qpe/qpeapplication.h>
33#include <qpe/config.h>
34#include <opie/ocontact.h> 33#include <opie/ocontact.h>
34#include <opie/ocontactaccessbackend_vcard.h>
35 35
36#include <qpe/global.h>
37#include <qpe/resource.h> 36#include <qpe/resource.h>
38#include <qpe/ir.h> 37#include <qpe/ir.h>
39#include <qpe/qpemessagebox.h> 38#include <qpe/qpemessagebox.h>
40#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/qpetoolbar.h>
41#include <qpe/qpemenubar.h>
42// #include <qtoolbar.h>
43// #include <qmenubar.h>
44#include <qpe/qpeapplication.h>
45#include <qpe/config.h>
41 46
42#include <qaction.h> 47#include <qaction.h>
@@ -46,12 +51,11 @@
46#include <qimage.h> 51#include <qimage.h>
47#include <qlayout.h> 52#include <qlayout.h>
48#include <qpe/qpemenubar.h>
49#include <qmessagebox.h> 53#include <qmessagebox.h>
50#include <qpixmap.h> 54#include <qpixmap.h>
51#include <qpopupmenu.h> 55#include <qpopupmenu.h>
52#include <qpe/qpetoolbar.h>
53#include <qstringlist.h> 56#include <qstringlist.h>
54#include <qtoolbutton.h> 57#include <qtoolbutton.h>
55#include <qwhatsthis.h> 58#include <qwhatsthis.h>
59#include <qdatetime.h>
56 60
57#include <stdlib.h> 61#include <stdlib.h>
@@ -61,63 +65,57 @@
61#include <unistd.h> 65#include <unistd.h>
62 66
63#include <qdatetime.h>
64 67
65#include "picker.h" 68#include "picker.h"
66#include "configdlg.h" 69#include "configdlg.h"
67 70
68static QString addressbookPersonalVCardName() 71extern QString addressbookPersonalVCardName();
69{
70 QString filename = Global::applicationFileName("addressbook",
71 "businesscard.vcf");
72 return filename;
73}
74
75 72
76AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 73AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
77 WFlags f ) 74 WFlags f )
78 : QMainWindow( parent, name, f ), 75 : QMainWindow( parent, name, f ),
79 abEditor(0), 76 catMenu (0l),
80 useRegExp(false), 77 abEditor(0l),
81 doNotifyWrapAround(true), 78 syncing(FALSE),
82 caseSensitive(false), 79 m_tableViewButton(0l),
83 m_useQtMail(true), 80 m_cardViewButton(0l)
84 m_useOpieMail(false),
85 bAbEditFirstTime(TRUE),
86 syncing(FALSE)
87{ 81{
88 isLoading = true; 82 isLoading = true;
89 83
90 // Read Config settings 84 m_config.load();
91 Config cfg("AddressBook");
92 cfg.setGroup("Search");
93 useRegExp = cfg.readBoolEntry( "useRegExp" );
94 caseSensitive = cfg.readBoolEntry( "caseSensitive" );
95 doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" );
96 cfg.setGroup("Mail");
97 m_useQtMail = cfg.readBoolEntry( "useQtMail", true );
98 m_useOpieMail=cfg.readBoolEntry( "useOpieMail" );
99
100 85
101 initFields();
102
103 setCaption( tr("Contacts") ); 86 setCaption( tr("Contacts") );
104 setIcon( Resource::loadPixmap( "AddressBook" ) ); 87 setIcon( Resource::loadPixmap( "AddressBook" ) );
88
89 // Settings for Main Menu
90 setToolBarsMovable( true );
91 setRightJustification( true );
105 92
106 setToolBarsMovable( FALSE ); 93 // Create Toolbar
107 94 listTools = new QPEToolBar( this, "list operations" );
108 // Create Toolbars 95 listTools->setHorizontalStretchable( true );
109 96 addToolBar( listTools );
110 QPEToolBar *bar = new QPEToolBar( this ); 97 moveToolBar( listTools, m_config.getToolBarPos() );
111 bar->setHorizontalStretchable( TRUE );
112 98
113 QPEMenuBar *mbList = new QPEMenuBar( bar ); 99 QPEMenuBar *mbList = new QPEMenuBar( this );
114 mbList->setMargin( 0 ); 100 mbList->setMargin( 0 );
115 101
116 QPopupMenu *edit = new QPopupMenu( this ); 102 QPopupMenu *edit = new QPopupMenu( mbList );
117 mbList->insertItem( tr( "Contact" ), edit ); 103 mbList->insertItem( tr( "Contact" ), edit );
118 104
119 listTools = new QPEToolBar( this, "list operations" );
120
121 105
106 // View Icons
107 m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "datebook/weeklst" ),
108 QString::null, 0, this, 0 );
109 connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) );
110 m_tableViewButton->setToggleAction( true );
111 m_tableViewButton->addTo( listTools );
112 m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 );
113 connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) );
114 m_cardViewButton->setToggleAction( true );
115 m_cardViewButton->addTo( listTools );
116
117 listTools->addSeparator();
118
119 // Other Buttons
122 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 120 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
123 0, this, 0 ); 121 0, this, 0 );
@@ -162,12 +160,14 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
162 searchBar->hide(); 160 searchBar->hide();
163 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 161 searchEdit = new QLineEdit( searchBar, "searchEdit" );
164// QFont f("unifont", 16 /*, QFont::Bold*/); 162
165// searchEdit->setFont( f ); 163 // QFont f("unifont", 16 /*, QFont::Bold*/);
164 // searchEdit->setFont( f );
165
166 searchBar->setStretchableWidget( searchEdit ); 166 searchBar->setStretchableWidget( searchEdit );
167 connect( searchEdit, SIGNAL( returnPressed( ) ), 167 connect( searchEdit, SIGNAL( returnPressed( ) ),
168 this, SLOT( slotFind( ) ) ); 168 this, SLOT( slotFind( ) ) );
169 169
170 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 170 a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
171 connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); 171 connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
172 a->addTo( searchBar ); 172 a->addTo( searchBar );
173 173
@@ -184,6 +184,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
184 a->addTo( listTools ); 184 a->addTo( listTools );
185 185
186
187
188 if ( Ir::supported() ) { 186 if ( Ir::supported() ) {
189 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 187 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
@@ -197,5 +195,5 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
197 edit->insertSeparator(); 195 edit->insertSeparator();
198 196
199 a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); 197 a = new QAction( tr("Import vCard"), QString::null, 0, 0);
200 actionPersonal = a; 198 actionPersonal = a;
201 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); 199 connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
@@ -209,9 +207,4 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
209 a->addTo( edit ); 207 a->addTo( edit );
210 208
211 // Do we need this function ? (se)
212 // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
213 // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
214 // a->addTo( edit );
215
216 209
217#ifdef __DEBUG_RELEASE 210#ifdef __DEBUG_RELEASE
@@ -229,53 +222,39 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
229 // Create Views 222 // Create Views
230 listContainer = new QWidget( this ); 223 listContainer = new QWidget( this );
231
232 QVBoxLayout *vb = new QVBoxLayout( listContainer ); 224 QVBoxLayout *vb = new QVBoxLayout( listContainer );
233 225
234 abList = new AbTable( &orderedFields, listContainer, "table" ); 226 m_abView = new AbView( listContainer, m_config.orderList() );
235 vb->addWidget(abList); 227 vb->addWidget( m_abView );
236 // abList->setHScrollBarMode( QScrollView::AlwaysOff ); 228 // abList->setHScrollBarMode( QScrollView::AlwaysOff );
237 connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); 229 connect( m_abView, SIGNAL( signalViewSwitched ( int ) ),
238 connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); 230 this, SLOT( slotViewSwitched( int ) ) );
239 connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) ); 231
240 connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) );
241 connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) );
242
243 // Maybe we should react on Wraparound and notfound ?
244 QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
245 QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) );
246 232
247 mView = 0; 233 QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
248 234
249 abList->load(); 235 m_abView->load();
250 236
237 // Letter Picker
251 pLabel = new LetterPicker( listContainer ); 238 pLabel = new LetterPicker( listContainer );
252 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); 239 connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
253 vb->addWidget(pLabel); 240 connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) );
241
242 vb->addWidget( pLabel );
243
244 // Category Menu
254 catMenu = new QPopupMenu( this ); 245 catMenu = new QPopupMenu( this );
255 catMenu->setCheckable( TRUE ); 246 catMenu->setCheckable( TRUE );
256 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 247 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
257 populateCategories(); 248 populateCategories();
258
259 mbList->insertItem( tr("View"), catMenu ); 249 mbList->insertItem( tr("View"), catMenu );
260 // setCentralWidget( listContainer );
261 250
262 fontMenu = new QPopupMenu(this); 251 defaultFont = new QFont( m_abView->font() );
263 fontMenu->setCheckable( true ); 252 slotSetFont(m_config.fontSize());
264 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); 253 m_curFontSize = m_config.fontSize();
265 254
266 fontMenu->insertItem(tr( "Small" ), 0);
267 fontMenu->insertItem(tr( "Normal" ), 1);
268 fontMenu->insertItem(tr( "Large" ), 2);
269
270 defaultFont = new QFont( abList->font() );
271
272 slotSetFont(startFontSize);
273
274 mbList->insertItem( tr("Font"), fontMenu);
275 setCentralWidget(listContainer); 255 setCentralWidget(listContainer);
276 256
277 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 257 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
278 258
279 abList->setCurrentCell( 0, 0 );
280 259
281 isLoading = false; 260 isLoading = false;
@@ -286,17 +265,15 @@ void AddressbookWindow::slotConfig()
286{ 265{
287 ConfigDlg* dlg = new ConfigDlg( this, "Config" ); 266 ConfigDlg* dlg = new ConfigDlg( this, "Config" );
288 dlg -> setUseRegExp ( useRegExp ); 267 dlg -> setConfig( m_config );
289 dlg -> setBeCaseSensitive( caseSensitive );
290 dlg -> setSignalWrapAround( doNotifyWrapAround );
291 dlg -> setQtMail ( m_useQtMail );
292 dlg -> setOpieMail ( m_useOpieMail );
293 dlg -> showMaximized(); 268 dlg -> showMaximized();
294 if ( dlg -> exec() ) { 269 if ( dlg -> exec() ) {
295 qWarning ("Config Dialog accepted !"); 270 qWarning ("Config Dialog accepted !");
296 useRegExp = dlg -> useRegExp(); 271 m_config = dlg -> getConfig();
297 caseSensitive = dlg -> beCaseSensitive(); 272 if ( m_curFontSize != m_config.fontSize() ){
298 doNotifyWrapAround = dlg -> signalWrapAround(); 273 qWarning("Font was changed!");
299 m_useQtMail = dlg -> useQtMail(); 274 m_curFontSize = m_config.fontSize();
300 m_useOpieMail= dlg -> useOpieMail(); 275 emit slotSetFont( m_curFontSize );
276 }
277 m_abView -> setListOrder( m_config.orderList() );
301 } 278 }
302 279
@@ -305,10 +282,12 @@ void AddressbookWindow::slotConfig()
305 282
306 283
307void AddressbookWindow::slotSetFont( int size ) { 284void AddressbookWindow::slotSetFont( int size )
285{
286 qWarning("void AddressbookWindow::slotSetFont( %d )", size);
308 287
309 if (size > 2 || size < 0) 288 if (size > 2 || size < 0)
310 size = 1; 289 size = 1;
311 290
312 startFontSize = size; 291 m_config.setFontSize( size );
313 292
314 QFont *currentFont; 293 QFont *currentFont;
@@ -316,29 +295,20 @@ void AddressbookWindow::slotSetFont( int size ) {
316 switch (size) { 295 switch (size) {
317 case 0: 296 case 0:
318 fontMenu->setItemChecked(0, true); 297 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
319 fontMenu->setItemChecked(1, false); 298 currentFont = new QFont (m_abView->font());
320 fontMenu->setItemChecked(2, false); 299 // abList->resizeRows(currentFont->pixelSize() + 7); :SX
321 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); 300 // abList->resizeRows();
322 currentFont = new QFont (abList->font());
323 // abList->resizeRows(currentFont->pixelSize() + 7);
324 abList->resizeRows();
325 break; 301 break;
326 case 1: 302 case 1:
327 fontMenu->setItemChecked(0, false); 303 m_abView->setFont( *defaultFont );
328 fontMenu->setItemChecked(1, true); 304 currentFont = new QFont (m_abView->font());
329 fontMenu->setItemChecked(2, false); 305 // // abList->resizeRows(currentFont->pixelSize() + 7);
330 abList->setFont( *defaultFont ); 306 // abList->resizeRows();
331 currentFont = new QFont (abList->font());
332 // abList->resizeRows(currentFont->pixelSize() + 7);
333 abList->resizeRows();
334 break; 307 break;
335 case 2: 308 case 2:
336 fontMenu->setItemChecked(0, false); 309 m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
337 fontMenu->setItemChecked(1, false); 310 currentFont = new QFont (m_abView->font());
338 fontMenu->setItemChecked(2, true); 311 // //abList->resizeRows(currentFont->pixelSize() + 7);
339 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); 312 // abList->resizeRows();
340 currentFont = new QFont (abList->font());
341 //abList->resizeRows(currentFont->pixelSize() + 7);
342 abList->resizeRows();
343 break; 313 break;
344 } 314 }
@@ -349,6 +319,7 @@ void AddressbookWindow::slotSetFont( int size ) {
349void AddressbookWindow::importvCard() { 319void AddressbookWindow::importvCard() {
350 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); 320 QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
351 if(!str.isEmpty() ) 321 if(!str.isEmpty() ){
352 setDocument((const QString&) str ); 322 setDocument((const QString&) str );
323 }
353 324
354} 325}
@@ -356,17 +327,38 @@ void AddressbookWindow::importvCard() {
356void AddressbookWindow::setDocument( const QString &filename ) 327void AddressbookWindow::setDocument( const QString &filename )
357{ 328{
358 if ( filename.find(".vcf") != int(filename.length()) - 4 ) 329 qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() );
359 return; 330
360 331 if ( filename.find(".vcf") != int(filename.length()) - 4 ){
361 QValueList<OContact> cl = OContact::readVCard( filename ); 332
362 for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { 333
363 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") 334
364 // .arg( (*it).fullName() ); 335 switch( QMessageBox::information( this, tr ( "Right file type ?" ),
365 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == 336 tr( "The selected File" ) + ( "\n" ) +
366 // QMessageBox::Ok ) { 337 tr ("does not end with \".vcf\" ") + ( "\n" ) +
367 abList->addEntry( *it ); 338 tr ( "Do you really want to open it?" ),
368 // } 339 tr( "&Yes" ), tr( "&No" ), QString::null,
340 0, // Enter == button 0
341 2 ) ) { // Escape == button 2
342 case 0:
343 qWarning("YES clicked");
344 break;
345 case 1:
346 qWarning("NO clicked");
347 return;
348 break;
349 }
350 }
351
352 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
353 filename );
354 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
355 OContactAccess::List allList = access->allRecords();
356
357 OContactAccess::List::Iterator it;
358 for ( it = allList.begin(); it != allList.end(); ++it ){
359 m_abView->addEntry( *it );
369 } 360 }
370 361
362 delete access;
371} 363}
372 364
@@ -375,70 +367,27 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e )
375 QMainWindow::resizeEvent( e ); 367 QMainWindow::resizeEvent( e );
376 368
377 if ( centralWidget() == listContainer ) 369
378 showList();
379 else if ( centralWidget() == mView )
380 showView();
381} 370}
382 371
383AddressbookWindow::~AddressbookWindow() 372AddressbookWindow::~AddressbookWindow()
384{ 373{
385 Config cfg("AddressBook"); 374 ToolBarDock dock;
386 cfg.setGroup("Font"); 375 int dummy;
387 cfg.writeEntry("fontSize", startFontSize); 376 bool bDummy;
388 377 getLocation ( listTools, dock, dummy, bDummy, dummy );
389 cfg.setGroup("Search"); 378 m_config.setToolBarDock( dock );
390 cfg.writeEntry("useRegExp", useRegExp); 379 m_config.save();
391 cfg.writeEntry("caseSensitive", caseSensitive);
392 cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround);
393 cfg.setGroup("Mail");
394 cfg.writeEntry( "useQtMail", m_useQtMail );
395 cfg.writeEntry( "useOpieMail", m_useOpieMail);
396} 380}
397 381
398void AddressbookWindow::slotUpdateToolbar() 382void AddressbookWindow::slotUpdateToolbar()
399{ 383{
400 OContact ce = abList->currentEntry(); 384 OContact ce = m_abView->currentEntry();
401 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 385 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
402} 386}
403 387
404void AddressbookWindow::showList()
405{
406 bool visiblemView;
407
408 visiblemView = false;
409 if ( mView ) {
410 mView->hide();
411 visiblemView = true;
412 }
413 setCentralWidget( listContainer );
414 listContainer->show();
415 // update our focues... (or use a stack widget!);
416 abList->setFocus();
417
418 // This makes sure we are scrolled all the way to the left
419 abList->setContentsPos( 0, abList->contentsY() );
420
421 //if ( visiblemView && abList->showBook() == "Cards" )
422 //abList->setShowCategory( abList->showBook(), abList->showCategory() );
423
424}
425
426void AddressbookWindow::showView()
427{
428 if ( abList->numRows() > 0 ) {
429 listContainer->hide();
430 setCentralWidget( abView() );
431 mView->show();
432 mView->setFocus();
433 }
434}
435
436void AddressbookWindow::slotListNew() 388void AddressbookWindow::slotListNew()
437{ 389{
438 OContact cnt; 390 OContact cnt;
439 if( !syncing ) { 391 if( !syncing ) {
440 if ( abEditor )
441 abEditor->setEntry( cnt );
442 abView()->init( cnt );
443 editEntry( NewEntry ); 392 editEntry( NewEntry );
444 } else { 393 } else {
@@ -448,15 +397,15 @@ void AddressbookWindow::slotListNew()
448} 397}
449 398
450void AddressbookWindow::slotListView() 399// void AddressbookWindow::slotListView()
451{ 400// {
452 abView()->init( abList->currentEntry() ); 401 // m_abView -> init( abList->currentEntry() );
453 mView->sync(); 402 // // :SX mView->sync();
454 showView(); 403 // //:SXshowView();
455} 404// }
456 405
457void AddressbookWindow::slotListDelete() 406void AddressbookWindow::slotListDelete()
458{ 407{
459 if(!syncing) { 408 if(!syncing) {
460 OContact tmpEntry = abList->currentEntry(); 409 OContact tmpEntry = m_abView ->currentEntry();
461 410
462 // get a name, do the best we can... 411 // get a name, do the best we can...
@@ -471,6 +420,5 @@ void AddressbookWindow::slotListDelete()
471 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 420 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
472 strName ) ) { 421 strName ) ) {
473 abList->deleteCurrentEntry(); 422 m_abView->removeEntry( tmpEntry.uid() );
474 showList();
475 } 423 }
476 } else { 424 } else {
@@ -480,7 +428,30 @@ void AddressbookWindow::slotListDelete()
480} 428}
481 429
430void AddressbookWindow::slotFindOpen()
431{
432 searchBar->show();
433 m_abView -> inSearch();
434 searchEdit->setFocus();
435}
436void AddressbookWindow::slotFindClose()
437{
438 searchBar->hide();
439 m_abView -> offSearch();
440 // m_abView->setFocus();
441}
442
443
444void AddressbookWindow::slotFind()
445{
446 m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false);
447
448 searchEdit->clearFocus();
449 // m_abView->setFocus();
450
451}
452
482void AddressbookWindow::slotViewBack() 453void AddressbookWindow::slotViewBack()
483{ 454{
484 showList(); 455 // :SX showList();
485} 456}
486 457
@@ -491,6 +462,4 @@ void AddressbookWindow::slotViewEdit()
491 editPersonal(); 462 editPersonal();
492 } else { 463 } else {
493 if ( !bAbEditFirstTime )
494 abEditor->setEntry( abList->currentEntry() );
495 editEntry( EditEntry ); 464 editEntry( EditEntry );
496 } 465 }
@@ -505,5 +474,5 @@ void AddressbookWindow::slotViewEdit()
505void AddressbookWindow::writeMail() 474void AddressbookWindow::writeMail()
506{ 475{
507 OContact c = abList->currentEntry(); 476 OContact c = m_abView -> currentEntry();
508 QString name = c.fileAs(); 477 QString name = c.fileAs();
509 QString email = c.defaultEmail(); 478 QString email = c.defaultEmail();
@@ -517,5 +486,5 @@ void AddressbookWindow::writeMail()
517 // Try to access the preferred. If not possible, try to 486 // Try to access the preferred. If not possible, try to
518 // switch to the other one.. 487 // switch to the other one..
519 if ( m_useQtMail ){ 488 if ( m_config.useQtMail() ){
520 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); 489 qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1());
521 if ( QFile::exists( basepath + "/bin/qtmail" ) ){ 490 if ( QFile::exists( basepath + "/bin/qtmail" ) ){
@@ -525,7 +494,7 @@ void AddressbookWindow::writeMail()
525 return; 494 return;
526 } else 495 } else
527 m_useOpieMail = true; 496 m_config.setUseOpieMail( true );
528 } 497 }
529 if ( m_useOpieMail ){ 498 if ( m_config.useOpieMail() ){
530 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); 499 qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1());
531 if ( QFile::exists( basepath + "/bin/mail" ) ){ 500 if ( QFile::exists( basepath + "/bin/mail" ) ){
@@ -535,5 +504,5 @@ void AddressbookWindow::writeMail()
535 return; 504 return;
536 } else 505 } else
537 m_useQtMail = true; 506 m_config.setUseQtMail( true );
538 } 507 }
539 508
@@ -550,12 +519,27 @@ void AddressbookWindow::slotBeam()
550 if (!QFile::exists(filename)) 519 if (!QFile::exists(filename))
551 return; // can't beam a non-existent file 520 return; // can't beam a non-existent file
552 c = OContact::readVCard( filename )[0]; 521 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
522 filename );
523 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
524 OContactAccess::List allList = access->allRecords();
525 OContactAccess::List::Iterator it = allList.begin(); // Just take first
526 c = *it;
527
528 delete access;
553 } else { 529 } else {
554 unlink( beamfile ); // delete if exists 530 unlink( beamfile ); // delete if exists
555 c = abList->currentEntry();
556 mkdir("/tmp/obex/", 0755); 531 mkdir("/tmp/obex/", 0755);
557 OContact::writeVCard( beamfile, c ); 532 c = m_abView -> currentEntry();
533 OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
534 beamfile );
535 OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
536 access->add( c );
537 access->save();
538 delete access;
539
558 filename = beamfile; 540 filename = beamfile;
559 } 541 }
542
543
560 Ir *ir = new Ir( this ); 544 Ir *ir = new Ir( this );
561 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 545 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
@@ -622,13 +606,8 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
622 cnt.setFileAs(); 606 cnt.setFileAs();
623 607
624 if ( bAbEditFirstTime ) { 608 m_abView -> addEntry( cnt );
625 abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, 609
626 this, "editor" ); 610 // :SXm_abView()->init( cnt );
627 bAbEditFirstTime = FALSE; 611 editEntry( EditEntry );
628 } else {
629 abEditor->setEntry( cnt );
630 }
631 abView()->init( cnt );
632 editEntry( NewEntry );
633 612
634 613
@@ -667,39 +646,56 @@ void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
667} 646}
668 647
669void AddressbookWindow::editPersonal() 648void AddressbookWindow::editEntry( EntryMode entryMode )
670{ 649{
671 QString filename = addressbookPersonalVCardName(); 650 OContact entry;
672 OContact me; 651 if ( !abEditor ) {
673 if (QFile::exists(filename)) 652 abEditor = new ContactEditor( entry, this, "editor" );
674 me = OContact::readVCard( filename )[0];
675 if (bAbEditFirstTime) {
676 qWarning("Editing personal data");
677 abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields,
678 this, "editor" );
679 // don't create a new editor every time
680 bAbEditFirstTime = FALSE;
681 } else{
682 abEditor->setEntry( me );
683 } 653 }
684 654 if ( entryMode == EditEntry )
685 abEditor->setPersonalView( true ); 655 abEditor->setEntry( m_abView -> currentEntry() );
656 else if ( entryMode == NewEntry )
657 abEditor->setEntry( entry );
658 // other things may chane the caption.
659 abEditor->setCaption( tr("Edit Address") );
686 660
687 abEditor->setCaption(tr("Edit My Personal Details")); 661#if defined(Q_WS_QWS) || defined(_WS_QWS_)
688 abEditor->showMaximized(); 662 abEditor->showMaximized();
689 663#endif
690 // fix the foxus... 664 // fix the foxus...
691 abEditor->setNameFocus(); 665 abEditor->setNameFocus();
692 if ( abEditor->exec() ) { 666 if ( abEditor->exec() ) {
693 setFocus(); 667 setFocus();
694 OContact new_personal = abEditor->entry(); 668 if ( entryMode == NewEntry ) {
695 QString fname = addressbookPersonalVCardName(); 669 OContact insertEntry = abEditor->entry();
696 OContact::writeVCard( fname, new_personal ); 670 insertEntry.assignUid();
697 abView()->init(new_personal); 671 m_abView -> addEntry( insertEntry );
698 abView()->sync(); 672 } else {
673 OContact replEntry = abEditor->entry();
674
675 if ( !replEntry.isValidUid() )
676 replEntry.assignUid();
677
678 m_abView -> replaceEntry( replEntry );
679 }
699 } 680 }
700 abEditor->setCaption( tr("Edit Address") ); 681 // populateCategories();
701 abEditor->setPersonalView( false ); 682
683}
684
685void AddressbookWindow::editPersonal()
686{
687 OContact entry;
688 if ( !abEditor ) {
689 abEditor = new ContactEditor( entry, this, "editor" );
690 }
691
692 abEditor->setCaption(tr("Edit My Personal Details"));
693 abEditor->setPersonalView( true );
694 editEntry( EditEntry );
695 abEditor->setPersonalView( false );
696
702} 697}
703 698
699
704void AddressbookWindow::slotPersonalView() 700void AddressbookWindow::slotPersonalView()
705{ 701{
@@ -710,6 +706,9 @@ void AddressbookWindow::slotPersonalView()
710 actionTrash->setEnabled(TRUE); 706 actionTrash->setEnabled(TRUE);
711 actionFind->setEnabled(TRUE); 707 actionFind->setEnabled(TRUE);
712 slotUpdateToolbar(); // maybe some of the above could be moved there 708 actionMail->setEnabled(TRUE);
713 showList(); 709 // slotUpdateToolbar();
710
711 m_abView->showPersonal( false );
712
714 return; 713 return;
715 } 714 }
@@ -718,58 +717,14 @@ void AddressbookWindow::slotPersonalView()
718 actionNew->setEnabled(FALSE); 717 actionNew->setEnabled(FALSE);
719 actionTrash->setEnabled(FALSE); 718 actionTrash->setEnabled(FALSE);
720#ifndef MAKE_FOR_SHARP_ROM
721 actionFind->setEnabled(FALSE); 719 actionFind->setEnabled(FALSE);
722#endif
723 actionMail->setEnabled(FALSE); 720 actionMail->setEnabled(FALSE);
724 721
725 setCaption( tr("Contacts - My Personal Details") ); 722 setCaption( tr("Contacts - My Personal Details") );
726 QString filename = addressbookPersonalVCardName();
727 OContact me;
728 if (QFile::exists(filename))
729 me = OContact::readVCard( filename )[0];
730
731 abView()->init( me );
732 abView()->sync();
733 listContainer->hide();
734 setCentralWidget( abView() );
735 mView->show();
736 mView->setFocus();
737}
738 723
739void AddressbookWindow::editEntry( EntryMode entryMode ) 724 m_abView->showPersonal( true );
740{
741 OContact entry;
742 if ( bAbEditFirstTime ) {
743 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields,
744 this, "editor" );
745 bAbEditFirstTime = FALSE;
746 if ( entryMode == EditEntry )
747 abEditor->setEntry( abList->currentEntry() );
748 }
749 // other things may chane the caption.
750 abEditor->setCaption( tr("Edit Address") );
751 725
752#if defined(Q_WS_QWS) || defined(_WS_QWS_)
753 abEditor->showMaximized();
754#endif
755 // fix the foxus...
756 abEditor->setNameFocus();
757 if ( abEditor->exec() ) {
758 setFocus();
759 if ( entryMode == NewEntry ) {
760 OContact insertEntry = abEditor->entry();
761 insertEntry.assignUid();
762 abList->addEntry( insertEntry );
763 } else {
764 OContact replaceEntry = abEditor->entry();
765 if ( !replaceEntry.isValidUid() )
766 replaceEntry.assignUid();
767 abList->replaceCurrentEntry( replaceEntry );
768 }
769 }
770 populateCategories();
771 showList();
772} 726}
773 727
728
774void AddressbookWindow::listIsEmpty( bool empty ) 729void AddressbookWindow::listIsEmpty( bool empty )
775{ 730{
@@ -782,6 +737,6 @@ void AddressbookWindow::reload()
782{ 737{
783 syncing = FALSE; 738 syncing = FALSE;
784 abList->clear(); 739 m_abView->clear();
785 abList->reload(); 740 m_abView->reload();
786} 741}
787 742
@@ -789,5 +744,5 @@ void AddressbookWindow::flush()
789{ 744{
790 syncing = TRUE; 745 syncing = TRUE;
791 abList->save(); 746 m_abView->save();
792} 747}
793 748
@@ -795,15 +750,4 @@ void AddressbookWindow::flush()
795void AddressbookWindow::closeEvent( QCloseEvent *e ) 750void AddressbookWindow::closeEvent( QCloseEvent *e )
796{ 751{
797 if ( centralWidget() == mView ) {
798 if (actionPersonal->isOn()) {
799 // pretend we clicked it off
800 actionPersonal->setOn(FALSE);
801 slotPersonalView();
802 } else {
803 showList();
804 }
805 e->ignore();
806 return;
807 }
808 752
809 if(syncing) { 753 if(syncing) {
@@ -829,5 +773,5 @@ void AddressbookWindow::closeEvent( QCloseEvent *e )
829bool AddressbookWindow::save() 773bool AddressbookWindow::save()
830{ 774{
831 if ( !abList->save() ) { 775 if ( !m_abView->save() ) {
832 if ( QMessageBox::critical( 0, tr( "Out of space" ), 776 if ( QMessageBox::critical( 0, tr( "Out of space" ),
833 tr("Unable to save information.\n" 777 tr("Unable to save information.\n"
@@ -852,171 +796,4 @@ void AddressbookWindow::slotSave()
852#endif 796#endif
853 797
854void AddressbookWindow::slotSettings()
855{
856 AddressSettings frmSettings( this );
857#if defined(Q_WS_QWS) || defined(_WS_QWS_)
858 frmSettings.showMaximized();
859#endif
860
861 if ( frmSettings.exec() ) {
862 allFields.clear();
863 orderedFields.clear();
864 slOrderedFields.clear();
865 initFields();
866 if ( abEditor )
867 abEditor->loadFields();
868 abList->refresh();
869 }
870}
871
872
873void AddressbookWindow::initFields()
874{
875 // we really don't need the things from the configuration, anymore
876 // only thing that is important are the important categories. So,
877 // Call the contact functions that correspond to these old functions...
878
879 QStringList xmlFields = OContact::fields();
880 QStringList visibleFields = OContact::untrfields();
881 // QStringList trFields = OContact::trfields();
882
883 xmlFields.remove( "Title" );
884 visibleFields.remove( "Name Title" );
885 visibleFields.remove( "Notes" );
886
887 int i, version;
888 Config cfg( "AddressBook" );
889 QString zn;
890
891 // ### Write a function to keep this from happening again...
892 QStringList::ConstIterator it;
893 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) {
894 allFields.append( i + 3 );
895 }
896
897 cfg.setGroup( "Version" );
898 version = cfg.readNumEntry( "version" );
899 i = 0;
900 startFontSize = 1;
901
902 if ( version >= ADDRESSVERSION ) {
903
904 cfg.setGroup( "ImportantCategory" );
905
906 zn = cfg.readEntry( "Category" + QString::number(i), QString::null );
907 while ( !zn.isNull() ) {
908 if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) {
909 slOrderedFields.clear();
910 break;
911 }
912 slOrderedFields.append( zn );
913 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null );
914 }
915 cfg.setGroup( "Font" );
916 startFontSize = cfg.readNumEntry( "fontSize", 1 );
917
918
919 } else {
920 QString str;
921 str = getenv("HOME");
922 str += "/Settings/AddressBook.conf";
923 QFile::remove( str );
924 }
925
926 if ( slOrderedFields.count() > 0 ) {
927 for( QStringList::ConstIterator it = slOrderedFields.begin();
928 it != slOrderedFields.end(); ++it ) {
929 QValueList<int>::ConstIterator itVl;
930 QStringList::ConstIterator itVis;
931 itVl = allFields.begin();
932 for ( itVis = visibleFields.begin();
933 itVis != visibleFields.end() && itVl != allFields.end();
934 ++itVis, ++itVl ) {
935 if ( *it == *itVis && itVl != allFields.end() ) {
936 orderedFields.append( *itVl );
937 }
938 }
939 }
940 } else {
941 QValueList<int>::ConstIterator it;
942 for ( it = allFields.begin(); it != allFields.end(); ++it )
943 orderedFields.append( *it );
944
945 slOrderedFields = visibleFields;
946 orderedFields.remove( Qtopia::AddressUid );
947 orderedFields.remove( Qtopia::Title );
948 orderedFields.remove( Qtopia::Groups );
949 orderedFields.remove( Qtopia::AddressCategory );
950 orderedFields.remove( Qtopia::FirstName );
951 orderedFields.remove( Qtopia::LastName );
952 orderedFields.remove( Qtopia::DefaultEmail );
953 orderedFields.remove( Qtopia::FileAs );
954 orderedFields.remove( Qtopia::Notes );
955 orderedFields.remove( Qtopia::Gender );
956 slOrderedFields.remove( "Name Title" );
957 slOrderedFields.remove( "First Name" );
958 slOrderedFields.remove( "Last Name" );
959 slOrderedFields.remove( "File As" );
960 slOrderedFields.remove( "Default Email" );
961 slOrderedFields.remove( "Notes" );
962 slOrderedFields.remove( "Gender" );
963
964 }
965}
966
967
968AbLabel *AddressbookWindow::abView()
969{
970 if ( !mView ) {
971 mView = new AbLabel( this, "viewer" );
972 mView->init( OContact() );
973 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
974 }
975 return mView;
976}
977
978void AddressbookWindow::slotFindOpen()
979{
980 searchBar->show();
981 abList -> inSearch();
982 searchEdit->setFocus();
983}
984void AddressbookWindow::slotFindClose()
985{
986 searchBar->hide();
987 abList -> offSearch();
988 abList->setFocus();
989}
990void AddressbookWindow::slotFindNext()
991{
992 if ( centralWidget() == abView() )
993 showList();
994
995 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false);
996
997 searchEdit->clearFocus();
998 abList->setFocus();
999 if ( abList->numSelections() )
1000 abList->clearSelection();
1001
1002}
1003void AddressbookWindow::slotFindPrevious()
1004{
1005 if ( centralWidget() == abView() )
1006 showList();
1007
1008 abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true);
1009
1010 if ( abList->numSelections() )
1011 abList->clearSelection();
1012
1013}
1014
1015void AddressbookWindow::slotFind()
1016{
1017
1018 abList->clearFindRow();
1019 slotFindNext();
1020}
1021 798
1022void AddressbookWindow::slotNotFound() 799void AddressbookWindow::slotNotFound()
@@ -1032,7 +809,7 @@ void AddressbookWindow::slotWrapAround()
1032{ 809{
1033 qWarning("Got wrap signal !"); 810 qWarning("Got wrap signal !");
1034 if ( doNotifyWrapAround ) 811 // if ( doNotifyWrapAround )
1035 QMessageBox::information( this, tr( "End of list" ), 812 // QMessageBox::information( this, tr( "End of list" ),
1036 tr( "End of list. Wrap around now.. !" ) + "\n" ); 813 // tr( "End of list. Wrap around now.. !" ) + "\n" );
1037 814
1038} 815}
@@ -1040,37 +817,47 @@ void AddressbookWindow::slotWrapAround()
1040void AddressbookWindow::slotSetCategory( int c ) 817void AddressbookWindow::slotSetCategory( int c )
1041{ 818{
819 qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
1042 820
1043 QString cat, book; 821 QString cat, book;
822 AbView::Views view = AbView::TableView;
1044 823
1045 if ( c <= 0 ) 824 if ( c <= 0 )
1046 return; 825 return;
1047 826
1048 // Set checkItem for selected one 827 // Checkmark Book Menu Item Selected
1049 for ( unsigned int i = 1; i < catMenu->count(); i++ ) 828 if ( c < 3 )
1050 catMenu->setItemChecked( i, c == (int)i ); 829 for ( unsigned int i = 1; i < 3; i++ )
830 catMenu->setItemChecked( i, c == (int)i );
831 // Checkmark Category Menu Item Selected
832 else
833 for ( unsigned int i = 3; i < catMenu->count(); i++ )
834 catMenu->setItemChecked( i, c == (int)i );
1051 835
1052 for ( unsigned int i = 1; i < catMenu->count(); i++ ) { 836 for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
1053 if (catMenu->isItemChecked( i )) { 837 if (catMenu->isItemChecked( i )) {
1054 if ( i == 1 ) // default List view 838 if ( i == 1 ){ // default List view
1055 book = QString::null; 839 book = QString::null;
1056 else if ( i == 2 ) 840 view = AbView::TableView;
1057 book = "Phone"; 841 }else if ( i == 2 ){
1058 else if ( i == 3 ) 842 book = tr( "Cards" );
1059 book = "Company"; 843 view = AbView::CardView;
1060 else if ( i == 4 ) 844 // }else if ( i == 3 ){
1061 book = "Email"; 845 // book = tr( "Personal" );
1062 else if ( i == 5 ) 846 // view = AbView:: PersonalView;
1063 book = "Cards"; 847 }else if ( i == 3 ){ // default All Categories
1064 else if ( i == 6 ) // default All Categories
1065 cat = QString::null; 848 cat = QString::null;
1066 else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled 849 }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
1067 cat = "Unfiled"; 850 cat = "Unfiled";
1068 else 851 qWarning ("Unfiled selected!!!");
1069 cat = abList->categories()[i - 7]; 852 }else{
853 cat = m_abView->categories()[i - 4];
854 }
1070 } 855 }
1071 } 856 }
1072 857
1073 abList->setShowCategory( book, cat ); 858 slotViewSwitched( view );
1074 859
860 m_abView -> setShowByCategory( view, cat );
861
1075 if ( book.isEmpty() ) 862 if ( book.isEmpty() )
1076 book = "List"; 863 book = "List";
@@ -1078,13 +865,56 @@ void AddressbookWindow::slotSetCategory( int c )
1078 cat = "All"; 865 cat = "All";
1079 866
1080 setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); 867 setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
868}
869
870void AddressbookWindow::slotViewSwitched( int view )
871{
872 qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
873 int menu = 0;
874 switch ( view ){
875 case AbView::TableView:
876 menu = 1;
877 m_tableViewButton->setOn(true);
878 m_cardViewButton->setOn(false);
879 break;
880 case AbView::CardView:
881 menu = 2;
882 m_tableViewButton->setOn(false);
883 m_cardViewButton->setOn(true);
884 break;
885 // case AbView::PersonalView:
886 // menu = 3;
887 // break;
888 // case AbView::CompanyBook:
889 // menu = 3;
890 // break;
891 // case AbView::EmailBook:
892 // menu = 4;
893 // break;
894 }
895 for ( unsigned int i = 1; i < 3; i++ ){
896 if ( catMenu )
897 catMenu->setItemChecked( i, menu == (int)i );
898 }
899}
900
901
902void AddressbookWindow::slotListView()
903{
904 emit slotSetCategory( AbView::TableView +1 );
905}
906
907void AddressbookWindow::slotCardView()
908{
909 emit slotSetCategory( AbView::CardView +1 );
1081} 910}
1082 911
1083void AddressbookWindow::slotSetLetter( char c ) { 912void AddressbookWindow::slotSetLetter( char c ) {
1084 913
1085 abList->setShowByLetter( c ); 914 m_abView->setShowByLetter( c );
1086 915
1087} 916}
1088 917
918
1089void AddressbookWindow::populateCategories() 919void AddressbookWindow::populateCategories()
1090{ 920{
@@ -1095,36 +925,35 @@ void AddressbookWindow::populateCategories()
1095 rememberId = 0; 925 rememberId = 0;
1096 926
1097 catMenu->insertItem( tr( "List" ), id++ ); 927 catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ );
1098 catMenu->insertItem( tr( "Phone Book" ), id++ ); 928 catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ );
1099 catMenu->insertItem( tr( "Company Book" ), id++ ); 929 // catMenu->insertItem( tr( "Personal" ), id++ );
1100 catMenu->insertItem( tr( "Email Book" ), id++ );
1101 catMenu->insertItem( tr( "Cards" ), id++ );
1102 catMenu->insertSeparator(); 930 catMenu->insertSeparator();
1103 931
1104 catMenu->insertItem( tr( "All" ), id++ ); 932 catMenu->insertItem( tr( "All" ), id++ );
1105 QStringList categories = abList->categories(); 933 QStringList categories = m_abView->categories();
1106 categories.append( tr( "Unfiled" ) ); 934 categories.append( tr( "Unfiled" ) );
1107 for ( QStringList::Iterator it = categories.begin(); 935 for ( QStringList::Iterator it = categories.begin();
1108 it != categories.end(); ++it ) { 936 it != categories.end(); ++it ) {
1109 catMenu->insertItem( *it, id ); 937 catMenu->insertItem( *it, id );
1110 if ( *it == abList->showCategory() ) 938 if ( *it == m_abView -> showCategory() )
1111 rememberId = id; 939 rememberId = id;
1112 ++id; 940 ++id;
1113 } 941 }
1114 942
1115 if ( abList->showBook().isEmpty() ) { 943 // :SX
1116 catMenu->setItemChecked( 1, true ); 944 // if ( abList->showBook().isEmpty() ) {
1117 } else if ( abList->showBook() == "Phone" ) { 945 // catMenu->setItemChecked( 1, true );
1118 catMenu->setItemChecked( 2, true ); 946 // } else if ( abList->showBook() == "Phone" ) {
1119 } else if ( abList->showBook() == "Company" ) { 947 // catMenu->setItemChecked( 2, true );
1120 catMenu->setItemChecked( 3, true ); 948 // } else if ( abList->showBook() == "Company" ) {
1121 } else if ( abList->showBook() == "Email" ) { 949 // catMenu->setItemChecked( 3, true );
1122 catMenu->setItemChecked( 4, true ); 950 // } else if ( abList->showBook() == "Email" ) {
1123 } else if ( abList->showBook() == "Cards" ) { 951 // catMenu->setItemChecked( 4, true );
1124 catMenu->setItemChecked( 5, true ); 952 // } else if ( abList->showBook() == "Cards" ) {
1125 } 953 // catMenu->setItemChecked( 5, true );
1126 954 // }
1127 if ( abList->showCategory().isEmpty() ) { 955
1128 slotSetCategory( 6 ); 956 if ( m_abView -> showCategory().isEmpty() ) {
957 slotSetCategory( 3 );
1129 } 958 }
1130 else { 959 else {