summaryrefslogtreecommitdiff
authortux_mike <tux_mike>2002-04-09 03:22:49 (UTC)
committer tux_mike <tux_mike>2002-04-09 03:22:49 (UTC)
commit0099a303b216b57e22aea5e28ee31abb6fb18736 (patch) (unidiff)
tree308c64b1d48553bf067ae36303728248322311fe
parent3c37907fd38287a8402cca1063ce6ba69c75e954 (diff)
downloadopie-0099a303b216b57e22aea5e28ee31abb6fb18736.zip
opie-0099a303b216b57e22aea5e28ee31abb6fb18736.tar.gz
opie-0099a303b216b57e22aea5e28ee31abb6fb18736.tar.bz2
Added font selection.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp53
-rw-r--r--core/pim/addressbook/addressbook.h6
2 files changed, 57 insertions, 2 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 5a8038b..b7b35bc 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -24,415 +24,462 @@
24#include "ablabel.h" 24#include "ablabel.h"
25#include "abtable.h" 25#include "abtable.h"
26#include "addresssettings.h" 26#include "addresssettings.h"
27#include "addressbook.h" 27#include "addressbook.h"
28 28
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/config.h> 30#include <qpe/config.h>
31#include <qpe/contact.h> 31#include <qpe/contact.h>
32 32
33#ifndef MAKE_FOR_SHARP_ROM 33#ifndef MAKE_FOR_SHARP_ROM
34#include <qpe/finddialog.h> 34#include <qpe/finddialog.h>
35#endif 35#endif
36 36
37#include <qpe/global.h> 37#include <qpe/global.h>
38#include <qpe/resource.h> 38#include <qpe/resource.h>
39#include <qpe/ir.h> 39#include <qpe/ir.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
42 42
43#include <qaction.h> 43#include <qaction.h>
44#include <qdialog.h> 44#include <qdialog.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <qfile.h> 46#include <qfile.h>
47#include <qimage.h> 47#include <qimage.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qpe/qpemenubar.h> 49#include <qpe/qpemenubar.h>
50#include <qmessagebox.h> 50#include <qmessagebox.h>
51#include <qpixmap.h> 51#include <qpixmap.h>
52#include <qpopupmenu.h> 52#include <qpopupmenu.h>
53#include <qpe/qpetoolbar.h> 53#include <qpe/qpetoolbar.h>
54#include <qstringlist.h> 54#include <qstringlist.h>
55#include <qtoolbutton.h> 55#include <qtoolbutton.h>
56#include <qwhatsthis.h> 56#include <qwhatsthis.h>
57 57
58#include <stdlib.h> 58#include <stdlib.h>
59#include <sys/stat.h> 59#include <sys/stat.h>
60#include <sys/types.h> 60#include <sys/types.h>
61#include <fcntl.h> 61#include <fcntl.h>
62#include <unistd.h> 62#include <unistd.h>
63 63
64#include <qdatetime.h> 64#include <qdatetime.h>
65 65
66static QString addressbookOldXMLFilename() 66static QString addressbookOldXMLFilename()
67{ 67{
68 QString filename = QPEApplication::documentDir() + "addressbook.xml"; 68 QString filename = QPEApplication::documentDir() + "addressbook.xml";
69 return filename; 69 return filename;
70} 70}
71 71
72static QString addressbookXMLFilename() 72static QString addressbookXMLFilename()
73{ 73{
74 QString filename = Global::applicationFileName("addressbook", 74 QString filename = Global::applicationFileName("addressbook",
75 "addressbook.xml"); 75 "addressbook.xml");
76 return filename; 76 return filename;
77} 77}
78 78
79static QString addressbookPersonalVCardName() 79static QString addressbookPersonalVCardName()
80{ 80{
81 QString filename = Global::applicationFileName("addressbook", 81 QString filename = Global::applicationFileName("addressbook",
82 "businesscard.vcf"); 82 "businesscard.vcf");
83 return filename; 83 return filename;
84} 84}
85 85
86 86
87AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 87AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
88 WFlags f ) 88 WFlags f )
89 : QMainWindow( parent, name, f ), 89 : QMainWindow( parent, name, f ),
90 abEditor(0), 90 abEditor(0),
91 bAbEditFirstTime(TRUE), 91 bAbEditFirstTime(TRUE),
92 syncing(FALSE) 92 syncing(FALSE)
93{ 93{
94 initFields(); 94 initFields();
95 95
96 setCaption( tr("Contacts") ); 96 setCaption( tr("Contacts") );
97 setIcon( Resource::loadPixmap( "AddressBook" ) ); 97 setIcon( Resource::loadPixmap( "AddressBook" ) );
98 98
99 setToolBarsMovable( FALSE ); 99 setToolBarsMovable( FALSE );
100 100
101 // Create Toolbars 101 // Create Toolbars
102 102
103 QPEToolBar *bar = new QPEToolBar( this ); 103 QPEToolBar *bar = new QPEToolBar( this );
104 bar->setHorizontalStretchable( TRUE ); 104 bar->setHorizontalStretchable( TRUE );
105 105
106 QPEMenuBar *mbList = new QPEMenuBar( bar ); 106 QPEMenuBar *mbList = new QPEMenuBar( bar );
107 mbList->setMargin( 0 ); 107 mbList->setMargin( 0 );
108 108
109 QPopupMenu *edit = new QPopupMenu( this ); 109 QPopupMenu *edit = new QPopupMenu( this );
110 mbList->insertItem( tr( "Contact" ), edit ); 110 mbList->insertItem( tr( "Contact" ), edit );
111 111
112 listTools = new QPEToolBar( this, "list operations" ); 112 listTools = new QPEToolBar( this, "list operations" );
113 113
114 114
115 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 115 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
116 0, this, 0 ); 116 0, this, 0 );
117 actionNew = a; 117 actionNew = a;
118 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); 118 connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
119 a->addTo( edit ); 119 a->addTo( edit );
120 a->addTo( listTools ); 120 a->addTo( listTools );
121 121
122 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, 122 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
123 0, this, 0 ); 123 0, this, 0 );
124 actionEdit = a; 124 actionEdit = a;
125 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); 125 connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
126 a->addTo( edit ); 126 a->addTo( edit );
127 a->addTo( listTools ); 127 a->addTo( listTools );
128 128
129 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 129 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
130 0, this, 0 ); 130 0, this, 0 );
131 actionTrash = a; 131 actionTrash = a;
132 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); 132 connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
133 a->addTo( edit ); 133 a->addTo( edit );
134 a->addTo( listTools ); 134 a->addTo( listTools );
135 135
136#ifndef MAKE_FOR_SHARP_ROM 136#ifndef MAKE_FOR_SHARP_ROM
137 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), 137 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
138 QString::null, 0, this, 0 ); 138 QString::null, 0, this, 0 );
139 actionFind = a; 139 actionFind = a;
140 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 140 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
141 a->addTo( edit ); 141 a->addTo( edit );
142 a->addTo( listTools ); 142 a->addTo( listTools );
143#endif 143#endif
144 144
145 145
146 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), 146 a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
147 QString::null, 0, this, 0 ); 147 QString::null, 0, this, 0 );
148 //a->setEnabled( FALSE ); we got support for it now :) zecke 148 //a->setEnabled( FALSE ); we got support for it now :) zecke
149 actionMail = a; 149 actionMail = a;
150 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); 150 connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
151 a->addTo( edit ); 151 a->addTo( edit );
152 a->addTo( listTools ); 152 a->addTo( listTools );
153 153
154 154
155 155
156 if ( Ir::supported() ) { 156 if ( Ir::supported() ) {
157 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, 157 a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
158 0, this, 0 ); 158 0, this, 0 );
159 actionBeam = a; 159 actionBeam = a;
160 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 160 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
161 a->addTo( edit ); 161 a->addTo( edit );
162 a->addTo( listTools ); 162 a->addTo( listTools );
163 } 163 }
164 164
165 edit->insertSeparator(); 165 edit->insertSeparator();
166 166
167 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); 167 a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
168 actionPersonal = a; 168 actionPersonal = a;
169 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); 169 connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
170 a->addTo( edit ); 170 a->addTo( edit );
171 171
172 172
173 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); 173 a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
174 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 174 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
175 a->addTo( edit ); 175 a->addTo( edit );
176 176
177 // Create Views 177 // Create Views
178 178
179 // This is safe to call without checking to see if it exists... 179 // This is safe to call without checking to see if it exists...
180 // not to mention it also does the necessary stuff for the 180 // not to mention it also does the necessary stuff for the
181 // journaling... 181 // journaling...
182 QString str = addressbookXMLFilename(); 182 QString str = addressbookXMLFilename();
183 if ( str.isNull() ) { 183 if ( str.isNull() ) {
184 QMessageBox::warning( this, tr("Out of Space"), 184 QMessageBox::warning( this, tr("Out of Space"),
185 tr("There is not enough space to create\n" 185 tr("There is not enough space to create\n"
186 "neccessary startup files.\n" 186 "neccessary startup files.\n"
187 "\nFree up some space before\nentering data!") 187 "\nFree up some space before\nentering data!")
188 ); 188 );
189 } 189 }
190 190
191 abList = new AbTable( &orderedFields, this, "table" ); 191 abList = new AbTable( &orderedFields, this, "table" );
192 abList->setHScrollBarMode( QScrollView::AlwaysOff ); 192 abList->setHScrollBarMode( QScrollView::AlwaysOff );
193 connect( abList, SIGNAL( empty( bool ) ), 193 connect( abList, SIGNAL( empty( bool ) ),
194 this, SLOT( listIsEmpty( bool ) ) ); 194 this, SLOT( listIsEmpty( bool ) ) );
195 connect( abList, SIGNAL( details() ), 195 connect( abList, SIGNAL( details() ),
196 this, SLOT( slotListView() ) ); 196 this, SLOT( slotListView() ) );
197 connect( abList, SIGNAL(currentChanged(int,int)), 197 connect( abList, SIGNAL(currentChanged(int,int)),
198 this, SLOT(slotUpdateToolbar()) ); 198 this, SLOT(slotUpdateToolbar()) );
199 199
200 mView = 0; 200 mView = 0;
201 201
202 abList->load( addressbookXMLFilename() ); 202 abList->load( addressbookXMLFilename() );
203 if ( QFile::exists(addressbookOldXMLFilename()) ) { 203 if ( QFile::exists(addressbookOldXMLFilename()) ) {
204 abList->load( addressbookOldXMLFilename() ); 204 abList->load( addressbookOldXMLFilename() );
205 QFile::remove(addressbookOldXMLFilename()); 205 QFile::remove(addressbookOldXMLFilename());
206 } 206 }
207 207
208 catMenu = new QPopupMenu( this ); 208 catMenu = new QPopupMenu( this );
209 catMenu->setCheckable( TRUE ); 209 catMenu->setCheckable( TRUE );
210 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); 210 connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
211 populateCategories(); 211 populateCategories();
212 212
213 mbList->insertItem( tr("View"), catMenu ); 213 mbList->insertItem( tr("View"), catMenu );
214 setCentralWidget( abList ); 214 setCentralWidget( abList );
215 215
216 fontMenu = new QPopupMenu(this);
217 fontMenu->setCheckable( true );
218 connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
219
220 fontMenu->insertItem("Small", 0);
221 fontMenu->insertItem("Normal", 1);
222 fontMenu->insertItem("Large", 2);
223
224 defaultFont = new QFont( abList->font() );
225
226 slotSetFont(startFontSize);
227
228 mbList->insertItem( tr("Font"), fontMenu);
229 setCentralWidget(abList);
230
216 // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); 231 // qDebug("adressbook contrsuction: t=%d", t.elapsed() );
217} 232}
233void AddressbookWindow::slotSetFont( int size ) {
234
235 if (size > 2 || size < 0)
236 size = 1;
237
238 startFontSize = size;
239
240 switch (size) {
241 case 0:
242 fontMenu->setItemChecked(0, true);
243 fontMenu->setItemChecked(1, false);
244 fontMenu->setItemChecked(2, false);
245 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
246 break;
247 case 1:
248 fontMenu->setItemChecked(0, false);
249 fontMenu->setItemChecked(1, true);
250 fontMenu->setItemChecked(2, false);
251 abList->setFont( *defaultFont );
252 break;
253 case 2:
254 fontMenu->setItemChecked(0, false);
255 fontMenu->setItemChecked(1, false);
256 fontMenu->setItemChecked(2, true);
257 abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
258 break;
259 }
260}
261
218 262
219void AddressbookWindow::setDocument( const QString &filename ) 263void AddressbookWindow::setDocument( const QString &filename )
220{ 264{
221 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return; 265 if ( filename.find(".vcf") != int(filename.length()) - 4 ) return;
222 266
223 QValueList<Contact> cl = Contact::readVCard( filename ); 267 QValueList<Contact> cl = Contact::readVCard( filename );
224 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { 268 for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
225 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") 269 // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?")
226 // .arg( (*it).fullName() ); 270 // .arg( (*it).fullName() );
227 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == 271 // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) ==
228 // QMessageBox::Ok ) { 272 // QMessageBox::Ok ) {
229 abList->addEntry( *it ); 273 abList->addEntry( *it );
230 // } 274 // }
231 } 275 }
232 276
233} 277}
234 278
235void AddressbookWindow::resizeEvent( QResizeEvent *e ) 279void AddressbookWindow::resizeEvent( QResizeEvent *e )
236{ 280{
237 QMainWindow::resizeEvent( e ); 281 QMainWindow::resizeEvent( e );
238 282
239 if ( centralWidget() == abList ) 283 if ( centralWidget() == abList )
240 showList(); 284 showList();
241 else if ( centralWidget() == mView ) 285 else if ( centralWidget() == mView )
242 showView(); 286 showView();
243} 287}
244 288
245AddressbookWindow::~AddressbookWindow() 289AddressbookWindow::~AddressbookWindow()
246{ 290{
291 Config cfg("AddressBook");
292 cfg.setGroup("Font");
293 cfg.writeEntry("fontSize", startFontSize);
247} 294}
248 295
249void AddressbookWindow::slotUpdateToolbar() 296void AddressbookWindow::slotUpdateToolbar()
250{ 297{
251 Contact ce = abList->currentEntry(); 298 Contact ce = abList->currentEntry();
252 actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); 299 actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
253} 300}
254 301
255void AddressbookWindow::showList() 302void AddressbookWindow::showList()
256{ 303{
257 if ( mView ) mView->hide(); 304 if ( mView ) mView->hide();
258 setCentralWidget( abList ); 305 setCentralWidget( abList );
259 abList->show(); 306 abList->show();
260 // update our focues... (or use a stack widget!); 307 // update our focues... (or use a stack widget!);
261 abList->setFocus(); 308 abList->setFocus();
262} 309}
263 310
264void AddressbookWindow::showView() 311void AddressbookWindow::showView()
265{ 312{
266 if ( abList->numRows() > 0 ) { 313 if ( abList->numRows() > 0 ) {
267 abList->hide(); 314 abList->hide();
268 setCentralWidget( abView() ); 315 setCentralWidget( abView() );
269 mView->show(); 316 mView->show();
270 mView->setFocus(); 317 mView->setFocus();
271 } 318 }
272} 319}
273 320
274void AddressbookWindow::slotListNew() 321void AddressbookWindow::slotListNew()
275{ 322{
276 Contact cnt; 323 Contact cnt;
277 if( !syncing ) { 324 if( !syncing ) {
278 if ( abEditor ) 325 if ( abEditor )
279 abEditor->setEntry( cnt ); 326 abEditor->setEntry( cnt );
280 abView()->init( cnt ); 327 abView()->init( cnt );
281 editEntry( NewEntry ); 328 editEntry( NewEntry );
282 } else { 329 } else {
283 QMessageBox::warning(this, tr("Contacts"), 330 QMessageBox::warning(this, tr("Contacts"),
284 tr("Can not edit data, currently syncing")); 331 tr("Can not edit data, currently syncing"));
285 } 332 }
286} 333}
287 334
288void AddressbookWindow::slotListView() 335void AddressbookWindow::slotListView()
289{ 336{
290 abView()->init( abList->currentEntry() ); 337 abView()->init( abList->currentEntry() );
291 mView->sync(); 338 mView->sync();
292 showView(); 339 showView();
293} 340}
294 341
295void AddressbookWindow::slotListDelete() 342void AddressbookWindow::slotListDelete()
296{ 343{
297 if(!syncing) { 344 if(!syncing) {
298 Contact tmpEntry = abList->currentEntry(); 345 Contact tmpEntry = abList->currentEntry();
299 346
300 // get a name, do the best we can... 347 // get a name, do the best we can...
301 QString strName = tmpEntry.fullName(); 348 QString strName = tmpEntry.fullName();
302 if ( strName.isEmpty() ) { 349 if ( strName.isEmpty() ) {
303 strName = tmpEntry.company(); 350 strName = tmpEntry.company();
304 if ( strName.isEmpty() ) 351 if ( strName.isEmpty() )
305 strName = "No Name"; 352 strName = "No Name";
306 } 353 }
307 354
308 355
309 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), 356 if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ),
310 strName ) ) { 357 strName ) ) {
311 abList->deleteCurrentEntry(); 358 abList->deleteCurrentEntry();
312 showList(); 359 showList();
313 } 360 }
314 } else { 361 } else {
315 QMessageBox::warning( this, tr("Contacts"), 362 QMessageBox::warning( this, tr("Contacts"),
316 tr("Can not edit data, currently syncing") ); 363 tr("Can not edit data, currently syncing") );
317 } 364 }
318} 365}
319 366
320void AddressbookWindow::slotViewBack() 367void AddressbookWindow::slotViewBack()
321{ 368{
322 showList(); 369 showList();
323} 370}
324 371
325void AddressbookWindow::slotViewEdit() 372void AddressbookWindow::slotViewEdit()
326{ 373{
327 if(!syncing) { 374 if(!syncing) {
328 if (actionPersonal->isOn()) { 375 if (actionPersonal->isOn()) {
329 editPersonal(); 376 editPersonal();
330 } else { 377 } else {
331 if ( !bAbEditFirstTime ) 378 if ( !bAbEditFirstTime )
332 abEditor->setEntry( abList->currentEntry() ); 379 abEditor->setEntry( abList->currentEntry() );
333 editEntry( EditEntry ); 380 editEntry( EditEntry );
334 } 381 }
335 } else { 382 } else {
336 QMessageBox::warning( this, tr("Contacts"), 383 QMessageBox::warning( this, tr("Contacts"),
337 tr("Can not edit data, currently syncing") ); 384 tr("Can not edit data, currently syncing") );
338 } 385 }
339} 386}
340 387
341 388
342 389
343void AddressbookWindow::writeMail() 390void AddressbookWindow::writeMail()
344{ 391{
345 Contact c = abList->currentEntry(); 392 Contact c = abList->currentEntry();
346 QString name = c.fileAs(); 393 QString name = c.fileAs();
347 QString email = c.defaultEmail(); 394 QString email = c.defaultEmail();
348 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); 395 QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)");
349 e << name << email; 396 e << name << email;
350} 397}
351 398
352 399
353 400
354 401
355static const char * beamfile = "/tmp/obex/contact.vcf"; 402static const char * beamfile = "/tmp/obex/contact.vcf";
356 403
357void AddressbookWindow::slotBeam() 404void AddressbookWindow::slotBeam()
358{ 405{
359 QString filename; 406 QString filename;
360 Contact c; 407 Contact c;
361 if ( actionPersonal->isOn() ) { 408 if ( actionPersonal->isOn() ) {
362 filename = addressbookPersonalVCardName(); 409 filename = addressbookPersonalVCardName();
363 if (!QFile::exists(filename)) 410 if (!QFile::exists(filename))
364 return; // can't beam a non-existent file 411 return; // can't beam a non-existent file
365 c = Contact::readVCard( filename )[0]; 412 c = Contact::readVCard( filename )[0];
366 } else { 413 } else {
367 unlink( beamfile ); // delete if exists 414 unlink( beamfile ); // delete if exists
368 c = abList->currentEntry(); 415 c = abList->currentEntry();
369 mkdir("/tmp/obex/", 0755); 416 mkdir("/tmp/obex/", 0755);
370 Contact::writeVCard( beamfile, c ); 417 Contact::writeVCard( beamfile, c );
371 filename = beamfile; 418 filename = beamfile;
372 } 419 }
373 Ir *ir = new Ir( this ); 420 Ir *ir = new Ir( this );
374 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 421 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
375 QString description = c.fullName(); 422 QString description = c.fullName();
376 ir->send( filename, description, "text/x-vCard" ); 423 ir->send( filename, description, "text/x-vCard" );
377} 424}
378 425
379void AddressbookWindow::beamDone( Ir *ir ) 426void AddressbookWindow::beamDone( Ir *ir )
380{ 427{
381 delete ir; 428 delete ir;
382 unlink( beamfile ); 429 unlink( beamfile );
383} 430}
384 431
385 432
386static void parseName( const QString& name, QString *first, QString *middle, 433static void parseName( const QString& name, QString *first, QString *middle,
387 QString * last ) 434 QString * last )
388{ 435{
389 436
390 int comma = name.find ( "," ); 437 int comma = name.find ( "," );
391 QString rest; 438 QString rest;
392 if ( comma > 0 ) { 439 if ( comma > 0 ) {
393 *last = name.left( comma ); 440 *last = name.left( comma );
394 comma++; 441 comma++;
395 while ( comma < int(name.length()) && name[comma] == ' ' ) 442 while ( comma < int(name.length()) && name[comma] == ' ' )
396 comma++; 443 comma++;
397 rest = name.mid( comma ); 444 rest = name.mid( comma );
398 } else { 445 } else {
399 int space = name.findRev( ' ' ); 446 int space = name.findRev( ' ' );
400 *last = name.mid( space+1 ); 447 *last = name.mid( space+1 );
401 rest = name.left( space ); 448 rest = name.left( space );
402 } 449 }
403 int space = rest.find( ' ' ); 450 int space = rest.find( ' ' );
404 if ( space <= 0 ) { 451 if ( space <= 0 ) {
405 *first = rest; 452 *first = rest;
406 } else { 453 } else {
407 *first = rest.left( space ); 454 *first = rest.left( space );
408 *middle = rest.mid( space+1 ); 455 *middle = rest.mid( space+1 );
409 } 456 }
410 457
411} 458}
412 459
413 460
414void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) 461void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data)
415{ 462{
416 if (msg == "editPersonal()") { 463 if (msg == "editPersonal()") {
417 editPersonal(); 464 editPersonal();
418 } else if (msg == "editPersonalAndClose()") { 465 } else if (msg == "editPersonalAndClose()") {
419 editPersonal(); 466 editPersonal();
420 close(); 467 close();
421 } else if ( msg == "addContact(QString,QString)" ) { 468 } else if ( msg == "addContact(QString,QString)" ) {
422 QDataStream stream(data,IO_ReadOnly); 469 QDataStream stream(data,IO_ReadOnly);
423 QString name, email; 470 QString name, email;
424 stream >> name >> email; 471 stream >> name >> email;
425 472
426 Contact cnt; 473 Contact cnt;
427 QString fn, mn, ln; 474 QString fn, mn, ln;
428 parseName( name, &fn, &mn, &ln ); 475 parseName( name, &fn, &mn, &ln );
429 //qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); 476 //qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() );
430 cnt.setFirstName( fn ); 477 cnt.setFirstName( fn );
431 cnt.setMiddleName( mn ); 478 cnt.setMiddleName( mn );
432 cnt.setLastName( ln ); 479 cnt.setLastName( ln );
433 cnt.setEmails( email ); 480 cnt.setEmails( email );
434 cnt.setDefaultEmail( email ); 481 cnt.setDefaultEmail( email );
435 cnt.setFileAs(); 482 cnt.setFileAs();
436 483
437 if ( bAbEditFirstTime ) { 484 if ( bAbEditFirstTime ) {
438 abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, 485 abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields,
@@ -524,324 +571,330 @@ void AddressbookWindow::slotPersonalView()
524 return; 571 return;
525 } 572 }
526 573
527 // XXX need to disable some QActions. 574 // XXX need to disable some QActions.
528 actionNew->setEnabled(FALSE); 575 actionNew->setEnabled(FALSE);
529 actionTrash->setEnabled(FALSE); 576 actionTrash->setEnabled(FALSE);
530#ifndef MAKE_FOR_SHARP_ROM 577#ifndef MAKE_FOR_SHARP_ROM
531 actionFind->setEnabled(FALSE); 578 actionFind->setEnabled(FALSE);
532#endif 579#endif
533 actionMail->setEnabled(FALSE); 580 actionMail->setEnabled(FALSE);
534 581
535 setCaption( tr("Contacts - My Personal Details") ); 582 setCaption( tr("Contacts - My Personal Details") );
536 QString filename = addressbookPersonalVCardName(); 583 QString filename = addressbookPersonalVCardName();
537 Contact me; 584 Contact me;
538 if (QFile::exists(filename)) 585 if (QFile::exists(filename))
539 me = Contact::readVCard( filename )[0]; 586 me = Contact::readVCard( filename )[0];
540 587
541 abView()->init( me ); 588 abView()->init( me );
542 abView()->sync(); 589 abView()->sync();
543 abList->hide(); 590 abList->hide();
544 setCentralWidget( abView() ); 591 setCentralWidget( abView() );
545 mView->show(); 592 mView->show();
546 mView->setFocus(); 593 mView->setFocus();
547} 594}
548 595
549void AddressbookWindow::editEntry( EntryMode entryMode ) 596void AddressbookWindow::editEntry( EntryMode entryMode )
550{ 597{
551 Contact entry; 598 Contact entry;
552 if ( bAbEditFirstTime ) { 599 if ( bAbEditFirstTime ) {
553 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, 600 abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields,
554 this, "editor" ); 601 this, "editor" );
555 bAbEditFirstTime = FALSE; 602 bAbEditFirstTime = FALSE;
556 if ( entryMode == EditEntry ) 603 if ( entryMode == EditEntry )
557 abEditor->setEntry( abList->currentEntry() ); 604 abEditor->setEntry( abList->currentEntry() );
558 } 605 }
559 // other things may chane the caption. 606 // other things may chane the caption.
560 abEditor->setCaption( tr("Edit Address") ); 607 abEditor->setCaption( tr("Edit Address") );
561 608
562#if defined(Q_WS_QWS) || defined(_WS_QWS_) 609#if defined(Q_WS_QWS) || defined(_WS_QWS_)
563 abEditor->showMaximized(); 610 abEditor->showMaximized();
564#endif 611#endif
565 // fix the foxus... 612 // fix the foxus...
566 abEditor->setNameFocus(); 613 abEditor->setNameFocus();
567 if ( abEditor->exec() ) { 614 if ( abEditor->exec() ) {
568 setFocus(); 615 setFocus();
569 if ( entryMode == NewEntry ) { 616 if ( entryMode == NewEntry ) {
570 Contact insertEntry = abEditor->entry(); 617 Contact insertEntry = abEditor->entry();
571 insertEntry.assignUid(); 618 insertEntry.assignUid();
572 abList->addEntry( insertEntry ); 619 abList->addEntry( insertEntry );
573 } else { 620 } else {
574 Contact replaceEntry = abEditor->entry(); 621 Contact replaceEntry = abEditor->entry();
575 if ( !replaceEntry.isValidUid() ) 622 if ( !replaceEntry.isValidUid() )
576 replaceEntry.assignUid(); 623 replaceEntry.assignUid();
577 abList->replaceCurrentEntry( replaceEntry ); 624 abList->replaceCurrentEntry( replaceEntry );
578 } 625 }
579 } 626 }
580 populateCategories(); 627 populateCategories();
581 showList(); 628 showList();
582} 629}
583 630
584void AddressbookWindow::listIsEmpty( bool empty ) 631void AddressbookWindow::listIsEmpty( bool empty )
585{ 632{
586 if ( !empty ) { 633 if ( !empty ) {
587 deleteButton->setEnabled( TRUE ); 634 deleteButton->setEnabled( TRUE );
588 } 635 }
589} 636}
590 637
591void AddressbookWindow::reload() 638void AddressbookWindow::reload()
592{ 639{
593 syncing = FALSE; 640 syncing = FALSE;
594 abList->clear(); 641 abList->clear();
595 abList->load( addressbookXMLFilename() ); 642 abList->load( addressbookXMLFilename() );
596} 643}
597 644
598void AddressbookWindow::flush() 645void AddressbookWindow::flush()
599{ 646{
600 syncing = TRUE; 647 syncing = TRUE;
601 abList->save( addressbookXMLFilename() ); 648 abList->save( addressbookXMLFilename() );
602} 649}
603 650
604 651
605void AddressbookWindow::closeEvent( QCloseEvent *e ) 652void AddressbookWindow::closeEvent( QCloseEvent *e )
606{ 653{
607 if ( centralWidget() == mView ) { 654 if ( centralWidget() == mView ) {
608 if (actionPersonal->isOn()) { 655 if (actionPersonal->isOn()) {
609 // pretend we clicked it off 656 // pretend we clicked it off
610 actionPersonal->setOn(FALSE); 657 actionPersonal->setOn(FALSE);
611 slotPersonalView(); 658 slotPersonalView();
612 } else { 659 } else {
613 showList(); 660 showList();
614 } 661 }
615 e->ignore(); 662 e->ignore();
616 return; 663 return;
617 } 664 }
618 665
619 if(syncing) { 666 if(syncing) {
620 /* shouldn't we save, I hear you say? well its already been set 667 /* shouldn't we save, I hear you say? well its already been set
621 so that an edit can not occur during a sync, and we flushed 668 so that an edit can not occur during a sync, and we flushed
622 at the start of the sync, so there is no need to save 669 at the start of the sync, so there is no need to save
623 Saving however itself would cause problems. */ 670 Saving however itself would cause problems. */
624 e->accept(); 671 e->accept();
625 return; 672 return;
626 } 673 }
627//################## shouldn't always save 674//################## shouldn't always save
628 if ( save() ) 675 if ( save() )
629 e->accept(); 676 e->accept();
630 else 677 else
631 e->ignore(); 678 e->ignore();
632} 679}
633 680
634/* 681/*
635 Returns TRUE if it is OK to exit 682 Returns TRUE if it is OK to exit
636 */ 683 */
637 684
638bool AddressbookWindow::save() 685bool AddressbookWindow::save()
639{ 686{
640 QString str = addressbookXMLFilename(); 687 QString str = addressbookXMLFilename();
641 if ( str.isNull() ) { 688 if ( str.isNull() ) {
642 if ( QMessageBox::critical( 0, tr("Out of space"), 689 if ( QMessageBox::critical( 0, tr("Out of space"),
643 tr("Unable to save information.\n" 690 tr("Unable to save information.\n"
644 "Free up some space\n" 691 "Free up some space\n"
645 "and try again.\n" 692 "and try again.\n"
646 "\nQuit anyway?"), 693 "\nQuit anyway?"),
647 QMessageBox::Yes|QMessageBox::Escape, 694 QMessageBox::Yes|QMessageBox::Escape,
648 QMessageBox::No|QMessageBox::Default ) 695 QMessageBox::No|QMessageBox::Default )
649 != QMessageBox::No ) 696 != QMessageBox::No )
650 return TRUE; 697 return TRUE;
651 else 698 else
652 return FALSE; 699 return FALSE;
653 } else { 700 } else {
654 if ( !abList->save( str ) ) { 701 if ( !abList->save( str ) ) {
655 if ( QMessageBox::critical( 0, tr( "Out of space" ), 702 if ( QMessageBox::critical( 0, tr( "Out of space" ),
656 tr("Unable to save information.\n" 703 tr("Unable to save information.\n"
657 "Free up some space\n" 704 "Free up some space\n"
658 "and try again.\n" 705 "and try again.\n"
659 "\nQuit anyway?"), 706 "\nQuit anyway?"),
660 QMessageBox::Yes|QMessageBox::Escape, 707 QMessageBox::Yes|QMessageBox::Escape,
661 QMessageBox::No|QMessageBox::Default ) 708 QMessageBox::No|QMessageBox::Default )
662 != QMessageBox::No ) 709 != QMessageBox::No )
663 return TRUE; 710 return TRUE;
664 else 711 else
665 return FALSE; 712 return FALSE;
666 } 713 }
667 } 714 }
668 return TRUE; 715 return TRUE;
669} 716}
670 717
671void AddressbookWindow::slotSettings() 718void AddressbookWindow::slotSettings()
672{ 719{
673 AddressSettings frmSettings( this ); 720 AddressSettings frmSettings( this );
674#if defined(Q_WS_QWS) || defined(_WS_QWS_) 721#if defined(Q_WS_QWS) || defined(_WS_QWS_)
675 frmSettings.showMaximized(); 722 frmSettings.showMaximized();
676#endif 723#endif
677 724
678 if ( frmSettings.exec() ) { 725 if ( frmSettings.exec() ) {
679 allFields.clear(); 726 allFields.clear();
680 orderedFields.clear(); 727 orderedFields.clear();
681 slOrderedFields.clear(); 728 slOrderedFields.clear();
682 initFields(); 729 initFields();
683 if ( abEditor ) 730 if ( abEditor )
684 abEditor->loadFields(); 731 abEditor->loadFields();
685 abList->refresh(); 732 abList->refresh();
686 } 733 }
687} 734}
688 735
689 736
690void AddressbookWindow::initFields() 737void AddressbookWindow::initFields()
691{ 738{
692 // we really don't need the things from the configuration, anymore 739 // we really don't need the things from the configuration, anymore
693 // only thing that is important are the important categories. So, 740 // only thing that is important are the important categories. So,
694 // Call the contact functions that correspond to these old functions... 741 // Call the contact functions that correspond to these old functions...
695 742
696 QStringList xmlFields = Contact::fields(); 743 QStringList xmlFields = Contact::fields();
697 QStringList visibleFields = Contact::trfields(); 744 QStringList visibleFields = Contact::trfields();
698 xmlFields.remove( "Title" ); 745 xmlFields.remove( "Title" );
699 visibleFields.remove( tr("Name Title") ); 746 visibleFields.remove( tr("Name Title") );
700 visibleFields.remove( tr("Notes") ); 747 visibleFields.remove( tr("Notes") );
701 748
702 int i, 749 int i,
703 version; 750 version;
704 Config cfg( "AddressBook" ); 751 Config cfg( "AddressBook" );
705 QString zn; 752 QString zn;
706 753
707 // ### Write a function to keep this from happening again... 754 // ### Write a function to keep this from happening again...
708 QStringList::ConstIterator it; 755 QStringList::ConstIterator it;
709 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { 756 for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) {
710 allFields.append( i + 3 ); 757 allFields.append( i + 3 );
711 } 758 }
712 759
713 cfg.setGroup( "Version" ); 760 cfg.setGroup( "Version" );
714 version = cfg.readNumEntry( "version" ); 761 version = cfg.readNumEntry( "version" );
715 i = 0; 762 i = 0;
763 startFontSize = 1;
764
716 if ( version >= ADDRESSVERSION ) { 765 if ( version >= ADDRESSVERSION ) {
717 766
718 cfg.setGroup( "ImportantCategory" ); 767 cfg.setGroup( "ImportantCategory" );
719 768
720 zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); 769 zn = cfg.readEntry( "Category" + QString::number(i), QString::null );
721 while ( !zn.isNull() ) { 770 while ( !zn.isNull() ) {
722 if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) { 771 if ( zn.contains( tr("Work") ) || zn.contains( tr("Mb") ) ) {
723 slOrderedFields.clear(); 772 slOrderedFields.clear();
724 break; 773 break;
725 } 774 }
726 slOrderedFields.append( zn ); 775 slOrderedFields.append( zn );
727 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); 776 zn = cfg.readEntry( "Category" + QString::number(++i), QString::null );
728 } 777 }
778 cfg.setGroup( "Font" );
779 startFontSize = cfg.readNumEntry( "fontSize", 1 );
780
781
729 } else { 782 } else {
730 QString str; 783 QString str;
731 str = getenv("HOME"); 784 str = getenv("HOME");
732 str += "/Settings/AddressBook.conf"; 785 str += "/Settings/AddressBook.conf";
733 QFile::remove( str ); 786 QFile::remove( str );
734 } 787 }
735 if ( slOrderedFields.count() > 0 ) { 788 if ( slOrderedFields.count() > 0 ) {
736 for( QStringList::ConstIterator it = slOrderedFields.begin(); 789 for( QStringList::ConstIterator it = slOrderedFields.begin();
737 it != slOrderedFields.end(); ++it ) { 790 it != slOrderedFields.end(); ++it ) {
738 QValueList<int>::ConstIterator itVl; 791 QValueList<int>::ConstIterator itVl;
739 QStringList::ConstIterator itVis; 792 QStringList::ConstIterator itVis;
740 itVl = allFields.begin(); 793 itVl = allFields.begin();
741 for ( itVis = visibleFields.begin(); 794 for ( itVis = visibleFields.begin();
742 itVis != visibleFields.end() && itVl != allFields.end(); 795 itVis != visibleFields.end() && itVl != allFields.end();
743 ++itVis, ++itVl ) { 796 ++itVis, ++itVl ) {
744 if ( *it == *itVis && itVl != allFields.end() ) { 797 if ( *it == *itVis && itVl != allFields.end() ) {
745 orderedFields.append( *itVl ); 798 orderedFields.append( *itVl );
746 } 799 }
747 } 800 }
748 } 801 }
749 } else { 802 } else {
750 QValueList<int>::ConstIterator it; 803 QValueList<int>::ConstIterator it;
751 for ( it = allFields.begin(); it != allFields.end(); ++it ) 804 for ( it = allFields.begin(); it != allFields.end(); ++it )
752 orderedFields.append( *it ); 805 orderedFields.append( *it );
753 806
754 slOrderedFields = visibleFields; 807 slOrderedFields = visibleFields;
755 orderedFields.remove( Qtopia::AddressUid ); 808 orderedFields.remove( Qtopia::AddressUid );
756 orderedFields.remove( Qtopia::Title ); 809 orderedFields.remove( Qtopia::Title );
757 orderedFields.remove( Qtopia::Groups ); 810 orderedFields.remove( Qtopia::Groups );
758 orderedFields.remove( Qtopia::AddressCategory ); 811 orderedFields.remove( Qtopia::AddressCategory );
759 orderedFields.remove( Qtopia::FirstName ); 812 orderedFields.remove( Qtopia::FirstName );
760 orderedFields.remove( Qtopia::LastName ); 813 orderedFields.remove( Qtopia::LastName );
761 orderedFields.remove( Qtopia::DefaultEmail ); 814 orderedFields.remove( Qtopia::DefaultEmail );
762 orderedFields.remove( Qtopia::FileAs ); 815 orderedFields.remove( Qtopia::FileAs );
763 orderedFields.remove( Qtopia::Notes ); 816 orderedFields.remove( Qtopia::Notes );
764 orderedFields.remove( Qtopia::Gender ); 817 orderedFields.remove( Qtopia::Gender );
765 slOrderedFields.remove( tr("Name Title") ); 818 slOrderedFields.remove( tr("Name Title") );
766 slOrderedFields.remove( tr("First Name") ); 819 slOrderedFields.remove( tr("First Name") );
767 slOrderedFields.remove( tr("Last Name") ); 820 slOrderedFields.remove( tr("Last Name") );
768 slOrderedFields.remove( tr("File As") ); 821 slOrderedFields.remove( tr("File As") );
769 slOrderedFields.remove( tr("Default Email") ); 822 slOrderedFields.remove( tr("Default Email") );
770 slOrderedFields.remove( tr("Notes") ); 823 slOrderedFields.remove( tr("Notes") );
771 slOrderedFields.remove( tr("Gender") ); 824 slOrderedFields.remove( tr("Gender") );
772 825
773 } 826 }
774} 827}
775 828
776 829
777AbLabel *AddressbookWindow::abView() 830AbLabel *AddressbookWindow::abView()
778{ 831{
779 if ( !mView ) { 832 if ( !mView ) {
780 mView = new AbLabel( this, "viewer" ); 833 mView = new AbLabel( this, "viewer" );
781 mView->init( Contact() ); 834 mView->init( Contact() );
782 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); 835 connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
783 } 836 }
784 return mView; 837 return mView;
785} 838}
786 839
787void AddressbookWindow::slotFind() 840void AddressbookWindow::slotFind()
788{ 841{
789#ifndef MAKE_FOR_SHARP_ROM 842#ifndef MAKE_FOR_SHARP_ROM
790 if ( centralWidget() == abView() ) 843 if ( centralWidget() == abView() )
791 showList(); 844 showList();
792 845
793 FindDialog frmFind( "Contacts", this ); 846 FindDialog frmFind( "Contacts", this );
794 QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int))); 847 QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int)));
795 QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); 848 QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
796 QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); 849 QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
797 850
798 frmFind.exec(); 851 frmFind.exec();
799 852
800 if ( abList->numSelections() ) 853 if ( abList->numSelections() )
801 abList->clearSelection(); 854 abList->clearSelection();
802 855
803 abList->clearFindRow(); 856 abList->clearFindRow();
804#endif 857#endif
805} 858}
806 859
807void AddressbookWindow::slotSetCategory( int c ) 860void AddressbookWindow::slotSetCategory( int c )
808{ 861{
809 if ( c <= 0 ) 862 if ( c <= 0 )
810 return; 863 return;
811 for ( unsigned int i = 1; i < catMenu->count(); i++ ) 864 for ( unsigned int i = 1; i < catMenu->count(); i++ )
812 catMenu->setItemChecked( i, c == (int)i ); 865 catMenu->setItemChecked( i, c == (int)i );
813 if ( c == 1 ) { 866 if ( c == 1 ) {
814 abList->setShowCategory( QString::null ); 867 abList->setShowCategory( QString::null );
815 setCaption( tr("Contacts") + " - " + tr ( "All" ) ); 868 setCaption( tr("Contacts") + " - " + tr ( "All" ) );
816 } else if ( c == (int)catMenu->count() ) { 869 } else if ( c == (int)catMenu->count() ) {
817 abList->setShowCategory( tr( "Unfiled" ) ); 870 abList->setShowCategory( tr( "Unfiled" ) );
818 setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) ); 871 setCaption( tr("Contacts") + " - " + tr( "Unfiled" ) );
819 } else { 872 } else {
820 QString cat = abList->categories()[c - 2]; 873 QString cat = abList->categories()[c - 2];
821 abList->setShowCategory( cat ); 874 abList->setShowCategory( cat );
822 setCaption( tr("Contacts") + " - " + cat ); 875 setCaption( tr("Contacts") + " - " + cat );
823 } 876 }
824} 877}
825 878
826void AddressbookWindow::populateCategories() 879void AddressbookWindow::populateCategories()
827{ 880{
828 catMenu->clear(); 881 catMenu->clear();
829 882
830 int id, 883 int id,
831 rememberId; 884 rememberId;
832 id = 1; 885 id = 1;
833 catMenu->insertItem( tr( "All" ), id++ ); 886 catMenu->insertItem( tr( "All" ), id++ );
834 QStringList categories = abList->categories(); 887 QStringList categories = abList->categories();
835 categories.append( tr( "Unfiled" ) ); 888 categories.append( tr( "Unfiled" ) );
836 for ( QStringList::Iterator it = categories.begin(); 889 for ( QStringList::Iterator it = categories.begin();
837 it != categories.end(); ++it ) { 890 it != categories.end(); ++it ) {
838 catMenu->insertItem( *it, id ); 891 catMenu->insertItem( *it, id );
839 if ( *it == abList->showCategory() ) 892 if ( *it == abList->showCategory() )
840 rememberId = id; 893 rememberId = id;
841 ++id; 894 ++id;
842 } 895 }
843 if ( abList->showCategory().isEmpty() ) 896 if ( abList->showCategory().isEmpty() )
844 slotSetCategory( 1 ); 897 slotSetCategory( 1 );
845 else 898 else
846 slotSetCategory( rememberId ); 899 slotSetCategory( rememberId );
847} 900}
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index 342077f..e2a7100 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -1,99 +1,101 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef Addressbook_H 20#ifndef Addressbook_H
21#define Addressbook_H 21#define Addressbook_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24 24
25class ContactEditor; 25class ContactEditor;
26class AbLabel; 26class AbLabel;
27class AbTable; 27class AbTable;
28class QPEToolBar; 28class QPEToolBar;
29class QPopupMenu; 29class QPopupMenu;
30class QToolButton; 30class QToolButton;
31class QDialog; 31class QDialog;
32class Ir; 32class Ir;
33class QAction; 33class QAction;
34 34
35class AddressbookWindow: public QMainWindow 35class AddressbookWindow: public QMainWindow
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38public: 38public:
39 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 39 AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
40 ~AddressbookWindow(); 40 ~AddressbookWindow();
41 41
42protected: 42protected:
43 void resizeEvent( QResizeEvent * e ); 43 void resizeEvent( QResizeEvent * e );
44 void showList(); 44 void showList();
45 void showView(); 45 void showView();
46 enum EntryMode { NewEntry=0, EditEntry }; 46 enum EntryMode { NewEntry=0, EditEntry };
47 void editPersonal(); 47 void editPersonal();
48 void editEntry( EntryMode ); 48 void editEntry( EntryMode );
49 void closeEvent( QCloseEvent *e ); 49 void closeEvent( QCloseEvent *e );
50 bool save(); 50 bool save();
51 51
52public slots: 52public slots:
53 void flush(); 53 void flush();
54 void reload(); 54 void reload();
55 void appMessage(const QCString &, const QByteArray &); 55 void appMessage(const QCString &, const QByteArray &);
56 void setDocument( const QString & ); 56 void setDocument( const QString & );
57 57
58private slots: 58private slots:
59 void slotListNew(); 59 void slotListNew();
60 void slotListView(); 60 void slotListView();
61 void slotListDelete(); 61 void slotListDelete();
62 void slotViewBack(); 62 void slotViewBack();
63 void slotViewEdit(); 63 void slotViewEdit();
64 void slotPersonalView(); 64 void slotPersonalView();
65 void listIsEmpty( bool ); 65 void listIsEmpty( bool );
66 void slotSettings(); 66 void slotSettings();
67 void writeMail(); 67 void writeMail();
68 void slotBeam(); 68 void slotBeam();
69 void beamDone( Ir * ); 69 void beamDone( Ir * );
70 void slotFind(); 70 void slotFind();
71 void slotSetCategory( int ); 71 void slotSetCategory( int );
72 void slotUpdateToolbar(); 72 void slotUpdateToolbar();
73 73 void slotSetFont(int);
74private: 74private:
75 void initFields();// inititialize our fields... 75 void initFields();// inititialize our fields...
76 AbLabel *abView(); 76 AbLabel *abView();
77 void populateCategories(); 77 void populateCategories();
78 78
79 QPopupMenu *catMenu; 79 QPopupMenu *catMenu, *fontMenu;
80 QPEToolBar *listTools; 80 QPEToolBar *listTools;
81 QToolButton *deleteButton; 81 QToolButton *deleteButton;
82 QValueList<int> allFields, 82 QValueList<int> allFields,
83 orderedFields; 83 orderedFields;
84 QStringList slOrderedFields; 84 QStringList slOrderedFields;
85 enum Panes { paneList=0, paneView, paneEdit }; 85 enum Panes { paneList=0, paneView, paneEdit };
86 ContactEditor *abEditor; 86 ContactEditor *abEditor;
87 AbLabel *mView; 87 AbLabel *mView;
88 AbTable *abList; 88 AbTable *abList;
89 89
90 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, 90 QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
91 *actionPersonal, *actionMail; 91 *actionPersonal, *actionMail;
92 92
93 bool bAbEditFirstTime; 93 bool bAbEditFirstTime;
94 int viewMargin; 94 int viewMargin;
95 95
96 bool syncing; 96 bool syncing;
97 QFont *defaultFont;
98 int startFontSize;
97}; 99};
98 100
99#endif 101#endif