-rw-r--r-- | core/pim/addressbook/abview.cpp | 7 | ||||
-rw-r--r-- | core/pim/addressbook/abview.h | 1 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 52 |
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 | |||
@@ -203,192 +203,199 @@ void AbView::setShowByCategory( const QString& cat ) | |||
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | void AbView::setShowToView( Views view ) | 206 | void 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 | ||
221 | void AbView::setShowByLetter( char c ) | 221 | void 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 | ||
243 | void AbView::setListOrder( const QValueList<int>& ordered ) | 243 | void 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 | ||
254 | QString AbView::showCategory() const | 254 | QString 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 | ||
259 | void AbView::showPersonal( bool personal ) | 259 | void 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 | ||
299 | void AbView::setCurrentUid( int uid ){ | ||
300 | |||
301 | m_curr_Contact = uid; | ||
302 | updateView( true ); //true: Don't modificate the UID ! | ||
303 | } | ||
304 | |||
305 | |||
299 | QStringList AbView::categories() | 306 | QStringList 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 |
307 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | 314 | void 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 | ||
348 | void AbView::offSearch() | 355 | void AbView::offSearch() |
349 | { | 356 | { |
350 | m_inSearch = false; | 357 | m_inSearch = false; |
351 | 358 | ||
352 | load(); | 359 | load(); |
353 | } | 360 | } |
354 | 361 | ||
355 | void AbView::slotSwitch(){ | 362 | void 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 | ||
375 | void AbView::clearForCategory() | 382 | void 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 | ||
392 | bool AbView::contactCompare( const OContact &cnt, int category ) | 399 | bool 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); |
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 | ||
15 | class AbView: public QWidget | 15 | class AbView: public QWidget |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
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 | ||
49 | signals: | 50 | signals: |
50 | void signalNotFound(); | 51 | void signalNotFound(); |
51 | void signalClearLetterPicker(); | 52 | void signalClearLetterPicker(); |
52 | void signalViewSwitched ( int ); | 53 | void signalViewSwitched ( int ); |
53 | 54 | ||
54 | public slots: | 55 | public 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 | ||
59 | private: | 60 | private: |
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 | |||
@@ -593,222 +593,224 @@ void AddressbookWindow::slotBeam() | |||
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 | ||
617 | void AddressbookWindow::beamDone( Ir *ir ) | 617 | void 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 | ||
625 | static void parseName( const QString& name, QString *first, QString *middle, | 625 | static 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 | ||
653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 653 | void 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 | ||
722 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 724 | void 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 | ||
759 | void AddressbookWindow::editPersonal() | 761 | void 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 | ||
783 | void AddressbookWindow::slotPersonalView() | 785 | void 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 | ||