-rw-r--r-- | kabc/addresseeview.cpp | 66 | ||||
-rw-r--r-- | kabc/addresseeview.h | 18 |
2 files changed, 84 insertions, 0 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index b4717d7..487e8a5 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -1,97 +1,102 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <kabc/address.h> | 22 | #include <kabc/address.h> |
23 | #include <kabc/addressee.h> | 23 | #include <kabc/addressee.h> |
24 | #include <kabc/phonenumber.h> | 24 | #include <kabc/phonenumber.h> |
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | //US#include <kglobalsettings.h> | 26 | //US#include <kglobalsettings.h> |
27 | #include <kiconloader.h> | 27 | #include <kiconloader.h> |
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | //US #include <kstringhandler.h> | 29 | //US #include <kstringhandler.h> |
30 | #include <qscrollview.h> | 30 | #include <qscrollview.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qvbox.h> | ||
34 | #include <qlabel.h> | ||
35 | #include <qwidget.h> | ||
36 | #include <qlayout.h> | ||
33 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qpushbutton.h> | ||
34 | 39 | ||
35 | 40 | ||
36 | #include "externalapphandler.h" | 41 | #include "externalapphandler.h" |
37 | #include "addresseeview.h" | 42 | #include "addresseeview.h" |
38 | 43 | ||
39 | 44 | ||
40 | //US #ifndef DESKTOP_VERSION | 45 | //US #ifndef DESKTOP_VERSION |
41 | //US #include <qtopia/qcopenvelope_qws.h> | 46 | //US #include <qtopia/qcopenvelope_qws.h> |
42 | //US #include <qpe/qpeapplication.h> | 47 | //US #include <qpe/qpeapplication.h> |
43 | //US #endif | 48 | //US #endif |
44 | 49 | ||
45 | //US static int kphoneInstalled = 0; | 50 | //US static int kphoneInstalled = 0; |
46 | 51 | ||
47 | using namespace KPIM; | 52 | using namespace KPIM; |
48 | 53 | ||
49 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 54 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
50 | //US : KTextBrowser( parent, name ) | 55 | //US : KTextBrowser( parent, name ) |
51 | : QTextBrowser( parent, name ) | 56 | : QTextBrowser( parent, name ) |
52 | 57 | ||
53 | 58 | ||
54 | { | 59 | { |
55 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 60 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
56 | setLinkUnderline( false ); | 61 | setLinkUnderline( false ); |
57 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 62 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
58 | //setHScrollBarMode( QScrollView::AlwaysOff ); | 63 | //setHScrollBarMode( QScrollView::AlwaysOff ); |
59 | 64 | ||
60 | //US QStyleSheet *sheet = styleSheet(); | 65 | //US QStyleSheet *sheet = styleSheet(); |
61 | //US QStyleSheetItem *link = sheet->item( "a" ); | 66 | //US QStyleSheetItem *link = sheet->item( "a" ); |
62 | //US link->setColor( KGlobalSettings::linkColor() ); | 67 | //US link->setColor( KGlobalSettings::linkColor() ); |
63 | 68 | ||
64 | } | 69 | } |
65 | 70 | ||
66 | void AddresseeView::setSource(const QString& n) | 71 | void AddresseeView::setSource(const QString& n) |
67 | { | 72 | { |
68 | //qDebug("********AddresseeView::setSource %s", n.latin1()); | 73 | //qDebug("********AddresseeView::setSource %s", n.latin1()); |
69 | 74 | ||
70 | if ( n.left( 6 ) == "mailto" ) | 75 | if ( n.left( 6 ) == "mailto" ) |
71 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 76 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
72 | else if ( n.left( 7 ) == "phoneto" ) | 77 | else if ( n.left( 7 ) == "phoneto" ) |
73 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); | 78 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); |
74 | else if ( n.left( 5 ) == "faxto" ) | 79 | else if ( n.left( 5 ) == "faxto" ) |
75 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); | 80 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); |
76 | else if ( n.left( 5 ) == "smsto" ) | 81 | else if ( n.left( 5 ) == "smsto" ) |
77 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | 82 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); |
78 | else if ( n.left( 7 ) == "pagerto" ) | 83 | else if ( n.left( 7 ) == "pagerto" ) |
79 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | 84 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); |
80 | else if ( n.left( 5 ) == "sipto" ) | 85 | else if ( n.left( 5 ) == "sipto" ) |
81 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | 86 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); |
82 | 87 | ||
83 | } | 88 | } |
84 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) | 89 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) |
85 | { | 90 | { |
86 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | 91 | ExternalAppHandler* eah = ExternalAppHandler::instance(); |
87 | bool kemailAvail = eah->isEmailAppAvailable(); | 92 | bool kemailAvail = eah->isEmailAppAvailable(); |
88 | bool kphoneAvail = eah->isPhoneAppAvailable(); | 93 | bool kphoneAvail = eah->isPhoneAppAvailable(); |
89 | bool kfaxAvail = eah->isFaxAppAvailable(); | 94 | bool kfaxAvail = eah->isFaxAppAvailable(); |
90 | bool ksmsAvail = eah->isSMSAppAvailable(); | 95 | bool ksmsAvail = eah->isSMSAppAvailable(); |
91 | bool kpagerAvail = eah->isPagerAppAvailable(); | 96 | bool kpagerAvail = eah->isPagerAppAvailable(); |
92 | bool ksipAvail = eah->isSIPAppAvailable(); | 97 | bool ksipAvail = eah->isSIPAppAvailable(); |
93 | 98 | ||
94 | 99 | ||
95 | mAddressee = addr; | 100 | mAddressee = addr; |
96 | // clear view | 101 | // clear view |
97 | setText( QString::null ); | 102 | setText( QString::null ); |
@@ -338,64 +343,125 @@ mText = "<table width=\"100%\">\n"; | |||
338 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 343 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
339 | 344 | ||
340 | mText += "<table><td colspan=\"2\"> </td>"; | 345 | mText += "<table><td colspan=\"2\"> </td>"; |
341 | /* | 346 | /* |
342 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" | 347 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" |
343 | "<td align=\"left\"><b>%2</b></td></tr>" ) | 348 | "<td align=\"left\"><b>%2</b></td></tr>" ) |
344 | .arg( i18n(" ") ) | 349 | .arg( i18n(" ") ) |
345 | .arg( name ); | 350 | .arg( name ); |
346 | */ | 351 | */ |
347 | if ( ! mAddressee.role().isEmpty() ) | 352 | if ( ! mAddressee.role().isEmpty() ) |
348 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
349 | "<td align=\"left\">%2</td></tr>" ) | 354 | "<td align=\"left\">%2</td></tr>" ) |
350 | .arg( i18n(" ") ) | 355 | .arg( i18n(" ") ) |
351 | .arg( mAddressee.role()); | 356 | .arg( mAddressee.role()); |
352 | if ( ! mAddressee.organization().isEmpty() ) | 357 | if ( ! mAddressee.organization().isEmpty() ) |
353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 358 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
354 | "<td align=\"left\">%2</td></tr>" ) | 359 | "<td align=\"left\">%2</td></tr>" ) |
355 | .arg( i18n(" ") ) | 360 | .arg( i18n(" ") ) |
356 | .arg( mAddressee.organization()); | 361 | .arg( mAddressee.organization()); |
357 | mText += dynamicPart; | 362 | mText += dynamicPart; |
358 | mText += notes; | 363 | mText += notes; |
359 | mText += "</table>"; | 364 | mText += "</table>"; |
360 | 365 | ||
361 | } | 366 | } |
362 | 367 | ||
363 | // at last display it... | 368 | // at last display it... |
364 | setText( mText ); | 369 | setText( mText ); |
365 | 370 | ||
366 | } | 371 | } |
367 | 372 | ||
368 | KABC::Addressee AddresseeView::addressee() const | 373 | KABC::Addressee AddresseeView::addressee() const |
369 | { | 374 | { |
370 | return mAddressee; | 375 | return mAddressee; |
371 | } | 376 | } |
372 | void AddresseeView::addTag(const QString & tag,const QString & text) | 377 | void AddresseeView::addTag(const QString & tag,const QString & text) |
373 | { | 378 | { |
374 | if ( text.isEmpty() ) | 379 | if ( text.isEmpty() ) |
375 | return; | 380 | return; |
376 | int number=text.contains("\n"); | 381 | int number=text.contains("\n"); |
377 | QString str = "<" + tag + ">"; | 382 | QString str = "<" + tag + ">"; |
378 | QString tmpText=text; | 383 | QString tmpText=text; |
379 | QString tmpStr=str; | 384 | QString tmpStr=str; |
380 | if(number !=-1) | 385 | if(number !=-1) |
381 | { | 386 | { |
382 | if (number > 0) { | 387 | if (number > 0) { |
383 | int pos=0; | 388 | int pos=0; |
384 | QString tmp; | 389 | QString tmp; |
385 | for(int i=0;i<=number;i++) { | 390 | for(int i=0;i<=number;i++) { |
386 | pos=tmpText.find("\n"); | 391 | pos=tmpText.find("\n"); |
387 | tmp=tmpText.left(pos); | 392 | tmp=tmpText.left(pos); |
388 | tmpText=tmpText.right(tmpText.length()-pos-1); | 393 | tmpText=tmpText.right(tmpText.length()-pos-1); |
389 | tmpStr+=tmp+"<br>"; | 394 | tmpStr+=tmp+"<br>"; |
390 | } | 395 | } |
391 | } | 396 | } |
392 | else tmpStr += tmpText; | 397 | else tmpStr += tmpText; |
393 | tmpStr+="</" + tag + ">"; | 398 | tmpStr+="</" + tag + ">"; |
394 | mText.append(tmpStr); | 399 | mText.append(tmpStr); |
395 | } | 400 | } |
396 | else | 401 | else |
397 | { | 402 | { |
398 | str += text + "</" + tag + ">"; | 403 | str += text + "</" + tag + ">"; |
399 | mText.append(str); | 404 | mText.append(str); |
400 | } | 405 | } |
401 | } | 406 | } |
407 | |||
408 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, | ||
409 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) | ||
410 | { | ||
411 | findButton( Close )->setText( i18n("Cancel Sync")); | ||
412 | findButton( Ok )->setText( i18n("Remote")); | ||
413 | findButton( User1 )->setText( i18n("Local")); | ||
414 | QWidget* topframe = new QWidget( this ); | ||
415 | //QVBox* topframe = new QVBox( this ); | ||
416 | setMainWidget( topframe ); | ||
417 | QBoxLayout* bl; | ||
418 | if ( QApplication::desktop()->width() < 640 ) { | ||
419 | bl = new QVBoxLayout( topframe ); | ||
420 | |||
421 | } else { | ||
422 | bl = new QHBoxLayout( topframe ); | ||
423 | |||
424 | } | ||
425 | QVBox* subframe = new QVBox( topframe ); | ||
426 | bl->addWidget(subframe ); | ||
427 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); | ||
428 | AddresseeView * av = new AddresseeView( subframe ); | ||
429 | av->setAddressee( loc ); | ||
430 | subframe = new QVBox( topframe ); | ||
431 | bl->addWidget(subframe ); | ||
432 | lab = new QLabel( i18n("Remote Addressee"), subframe ); | ||
433 | av = new AddresseeView( subframe ); | ||
434 | av->setAddressee( rem ); | ||
435 | |||
436 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | ||
437 | SLOT(slot_remote())); | ||
438 | QObject::connect(this,SIGNAL(user1Clicked()), | ||
439 | SLOT(slot_local())); | ||
440 | #ifndef DESKTOP_VERSION | ||
441 | showMaximized(); | ||
442 | #else | ||
443 | resize ( 640, 400 ); | ||
444 | #endif | ||
445 | } | ||
446 | |||
447 | int AddresseeChooser::executeD( bool local ) | ||
448 | { | ||
449 | mSyncResult = 3; | ||
450 | if ( local ) | ||
451 | findButton( User1 )->setFocus(); | ||
452 | else | ||
453 | findButton( Ok )->setFocus(); | ||
454 | exec(); | ||
455 | qDebug("returning %d ",mSyncResult ); | ||
456 | return mSyncResult; | ||
457 | } | ||
458 | void AddresseeChooser::slot_remote() | ||
459 | { | ||
460 | mSyncResult = 2; | ||
461 | accept(); | ||
462 | } | ||
463 | void AddresseeChooser::slot_local() | ||
464 | { | ||
465 | mSyncResult = 1; | ||
466 | accept(); | ||
467 | } | ||
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index 1865fc4..689d997 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h | |||
@@ -1,60 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef KPIM_ADDRESSEEVIEW_H | 22 | #ifndef KPIM_ADDRESSEEVIEW_H |
23 | #define KPIM_ADDRESSEEVIEW_H | 23 | #define KPIM_ADDRESSEEVIEW_H |
24 | 24 | ||
25 | #include <kabc/addressee.h> | 25 | #include <kabc/addressee.h> |
26 | #include <kdialogbase.h> | ||
26 | 27 | ||
27 | //US #include <ktextbrowser.h> | 28 | //US #include <ktextbrowser.h> |
28 | #include <qtextbrowser.h> | 29 | #include <qtextbrowser.h> |
29 | 30 | ||
30 | namespace KPIM { | 31 | namespace KPIM { |
31 | 32 | ||
32 | //US class AddresseeView : public KTextBrowser | 33 | //US class AddresseeView : public KTextBrowser |
33 | class AddresseeView : public QTextBrowser | 34 | class AddresseeView : public QTextBrowser |
34 | { | 35 | { |
35 | public: | 36 | public: |
36 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); | 37 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); |
37 | 38 | ||
38 | /** | 39 | /** |
39 | Sets the addressee object. The addressee is displayed immediately. | 40 | Sets the addressee object. The addressee is displayed immediately. |
40 | 41 | ||
41 | @param addr The addressee object. | 42 | @param addr The addressee object. |
42 | */ | 43 | */ |
43 | void setAddressee( const KABC::Addressee& addr ); | 44 | void setAddressee( const KABC::Addressee& addr ); |
44 | void setSource(const QString& n); | 45 | void setSource(const QString& n); |
45 | /** | 46 | /** |
46 | Returns the current addressee object. | 47 | Returns the current addressee object. |
47 | */ | 48 | */ |
48 | KABC::Addressee addressee() const; | 49 | KABC::Addressee addressee() const; |
49 | 50 | ||
50 | private: | 51 | private: |
51 | KABC::Addressee mAddressee; | 52 | KABC::Addressee mAddressee; |
52 | QString mText; | 53 | QString mText; |
53 | void addTag(const QString & tag,const QString & text); | 54 | void addTag(const QString & tag,const QString & text); |
54 | class AddresseeViewPrivate; | 55 | class AddresseeViewPrivate; |
55 | AddresseeViewPrivate *d; | 56 | AddresseeViewPrivate *d; |
56 | }; | 57 | }; |
58 | class AddresseeChooser : public KDialogBase | ||
59 | { | ||
60 | Q_OBJECT | ||
61 | |||
62 | public: | ||
63 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); | ||
64 | |||
65 | int executeD( bool local ); | ||
66 | |||
67 | private: | ||
68 | int mSyncResult; | ||
69 | |||
70 | private slots: | ||
71 | void slot_remote(); | ||
72 | void slot_local(); | ||
73 | |||
74 | }; | ||
57 | 75 | ||
58 | } | 76 | } |
59 | 77 | ||
60 | #endif | 78 | #endif |