-rw-r--r-- | libkdepim/addresseeview.cpp | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp index 71c7817..e9dc1e9 100644 --- a/libkdepim/addresseeview.cpp +++ b/libkdepim/addresseeview.cpp | |||
@@ -25,101 +25,132 @@ | |||
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 <qapplication.h> | 33 | #include <qapplication.h> |
34 | 34 | ||
35 | 35 | ||
36 | #include "addresseeview.h" | 36 | #include "addresseeview.h" |
37 | 37 | ||
38 | 38 | ||
39 | #ifndef DESKTOP_VERSION | 39 | #ifndef DESKTOP_VERSION |
40 | #include <qtopia/qcopenvelope_qws.h> | 40 | #include <qtopia/qcopenvelope_qws.h> |
41 | #include <qpe/qpeapplication.h> | ||
41 | #endif | 42 | #endif |
42 | 43 | ||
43 | 44 | int kphoneInstalled = 0; | |
44 | 45 | ||
45 | using namespace KPIM; | 46 | using namespace KPIM; |
46 | 47 | ||
47 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 48 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
48 | //US : KTextBrowser( parent, name ) | 49 | //US : KTextBrowser( parent, name ) |
49 | : QTextBrowser( parent, name ) | 50 | : QTextBrowser( parent, name ) |
50 | 51 | ||
51 | 52 | ||
52 | { | 53 | { |
53 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 54 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
54 | setLinkUnderline( false ); | 55 | setLinkUnderline( false ); |
55 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 56 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
56 | //setHScrollBarMode( QScrollView::AlwaysOff ); | 57 | //setHScrollBarMode( QScrollView::AlwaysOff ); |
57 | 58 | ||
58 | //US QStyleSheet *sheet = styleSheet(); | 59 | //US QStyleSheet *sheet = styleSheet(); |
59 | //US QStyleSheetItem *link = sheet->item( "a" ); | 60 | //US QStyleSheetItem *link = sheet->item( "a" ); |
60 | //US link->setColor( KGlobalSettings::linkColor() ); | 61 | //US link->setColor( KGlobalSettings::linkColor() ); |
61 | 62 | ||
62 | } | 63 | } |
63 | void AddresseeView::setSource(const QString& n) | 64 | void AddresseeView::setSource(const QString& n) |
64 | { | 65 | { |
65 | //qDebug("********AddresseeView::setSource %s", n.mid(7).latin1()); | 66 | qDebug("********AddresseeView::setSource %s", n.latin1()); |
66 | #ifndef DESKTOP_VERSION | 67 | #ifndef DESKTOP_VERSION |
67 | QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)"); | 68 | if ( n.left( 6 ) == "mailto" ) { |
68 | e << n.mid(7); | 69 | QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)"); |
70 | e << n.mid(7); | ||
71 | } | ||
72 | if ( n.left( 7 ) == "phoneto" ) { | ||
73 | QString mess = "-ring:" + n.mid(8); | ||
74 | QCopEnvelope e("QPE/Application/kppi", mess.latin1()); | ||
75 | } | ||
69 | #endif | 76 | #endif |
70 | 77 | ||
71 | } | 78 | } |
72 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) | 79 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) |
73 | { | 80 | { |
74 | mAddressee = addr; | 81 | bool kphoneAvail = false; |
75 | 82 | ||
83 | #ifndef DESKTOP_VERSION | ||
84 | if ( ! kphoneInstalled ) { | ||
85 | if ( QFile::exists( QPEApplication::qpeDir() + "/bin/kppi" ) ) | ||
86 | kphoneInstalled = 1; | ||
87 | else | ||
88 | kphoneInstalled = -1; | ||
89 | } else { | ||
90 | if ( kphoneInstalled > 0 ) | ||
91 | kphoneAvail = true; | ||
92 | } | ||
93 | //if ( kphoneAvail ) | ||
94 | // qDebug("KPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPone avail "); | ||
95 | #endif | ||
96 | mAddressee = addr; | ||
76 | // clear view | 97 | // clear view |
77 | setText( QString::null ); | 98 | setText( QString::null ); |
78 | 99 | ||
79 | if ( mAddressee.isEmpty() ) | 100 | if ( mAddressee.isEmpty() ) |
80 | return; | 101 | return; |
81 | 102 | ||
82 | QString name = ( mAddressee.formattedName().isEmpty() ? | 103 | QString name = ( mAddressee.formattedName().isEmpty() ? |
83 | mAddressee.assembledName() : mAddressee.formattedName() ); | 104 | mAddressee.assembledName() : mAddressee.formattedName() ); |
84 | 105 | ||
85 | QString dynamicPart; | 106 | QString dynamicPart; |
86 | 107 | ||
87 | QStringList emails = mAddressee.emails(); | 108 | QStringList emails = mAddressee.emails(); |
88 | QStringList::ConstIterator emailIt; | 109 | QStringList::ConstIterator emailIt; |
89 | QString type = i18n( "Email" ); | 110 | QString type = i18n( "Email" ); |
90 | emailIt = emails.begin(); | 111 | emailIt = emails.begin(); |
91 | if ( emailIt != emails.end() ) { | 112 | if ( emailIt != emails.end() ) { |
92 | dynamicPart += QString( | 113 | dynamicPart += QString( |
93 | "<tr><td align=\"right\"><b>%1</b></td>" | 114 | "<tr><td align=\"right\"><b>%1</b></td>" |
94 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 115 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
95 | .arg( type ) | 116 | .arg( type ) |
96 | .arg( name ) | 117 | .arg( name ) |
97 | .arg( *emailIt ) | 118 | .arg( *emailIt ) |
98 | .arg( *emailIt ); | 119 | .arg( *emailIt ); |
99 | ++emailIt; | 120 | ++emailIt; |
100 | } | 121 | } |
101 | 122 | ||
102 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); | 123 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); |
103 | KABC::PhoneNumber::List::ConstIterator phoneIt; | 124 | KABC::PhoneNumber::List::ConstIterator phoneIt; |
104 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { | 125 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { |
105 | dynamicPart += QString( | 126 | if ( kphoneAvail ) { |
106 | "<tr><td align=\"right\"><b>%1</b></td>" | 127 | dynamicPart += QString( |
107 | "<td align=\"left\">%2</td></tr>" ) | 128 | "<tr><td align=\"right\"><b>%1</b></td>" |
108 | .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) ) | 129 | "<td align=\"left\"><a href=\"phoneto:%2 \">%3</a></td></tr>" ) |
109 | .arg( (*phoneIt).number() ); | 130 | .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) ) |
131 | .arg( (*phoneIt).number() ) | ||
132 | .arg( (*phoneIt).number() ); | ||
133 | |||
134 | } else { | ||
135 | dynamicPart += QString( | ||
136 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
137 | "<td align=\"left\">%2</td></tr>" ) | ||
138 | .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) ) | ||
139 | .arg( (*phoneIt).number() ); | ||
140 | } | ||
110 | } | 141 | } |
111 | 142 | ||
112 | 143 | ||
113 | for ( ; emailIt != emails.end(); ++emailIt ) { | 144 | for ( ; emailIt != emails.end(); ++emailIt ) { |
114 | dynamicPart += QString( | 145 | dynamicPart += QString( |
115 | "<tr><td align=\"right\"><b>%1</b></td>" | 146 | "<tr><td align=\"right\"><b>%1</b></td>" |
116 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 147 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
117 | .arg( type ) | 148 | .arg( type ) |
118 | .arg( name ) | 149 | .arg( name ) |
119 | .arg( *emailIt ) | 150 | .arg( *emailIt ) |
120 | .arg( *emailIt ); | 151 | .arg( *emailIt ); |
121 | } | 152 | } |
122 | 153 | ||
123 | if ( !mAddressee.url().url().isEmpty() ) { | 154 | if ( !mAddressee.url().url().isEmpty() ) { |
124 | dynamicPart += QString( | 155 | dynamicPart += QString( |
125 | "<tr><td align=\"right\"><b>%1</b></td>" | 156 | "<tr><td align=\"right\"><b>%1</b></td>" |