summaryrefslogtreecommitdiffabout
path: root/libkdepim/addresseeview.cpp
Unidiff
Diffstat (limited to 'libkdepim/addresseeview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
index 5c69010..b4717d7 100644
--- a/libkdepim/addresseeview.cpp
+++ b/libkdepim/addresseeview.cpp
@@ -1,257 +1,263 @@
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 <qapplication.h> 33#include <qapplication.h>
34 34
35 35
36#include "externalapphandler.h" 36#include "externalapphandler.h"
37#include "addresseeview.h" 37#include "addresseeview.h"
38 38
39 39
40//US #ifndef DESKTOP_VERSION 40//US #ifndef DESKTOP_VERSION
41//US #include <qtopia/qcopenvelope_qws.h> 41//US #include <qtopia/qcopenvelope_qws.h>
42//US #include <qpe/qpeapplication.h> 42//US #include <qpe/qpeapplication.h>
43//US #endif 43//US #endif
44 44
45//US static int kphoneInstalled = 0; 45//US static int kphoneInstalled = 0;
46 46
47using namespace KPIM; 47using namespace KPIM;
48 48
49AddresseeView::AddresseeView( QWidget *parent, const char *name ) 49AddresseeView::AddresseeView( QWidget *parent, const char *name )
50//US : KTextBrowser( parent, name ) 50//US : KTextBrowser( parent, name )
51 : QTextBrowser( parent, name ) 51 : QTextBrowser( parent, name )
52 52
53 53
54{ 54{
55//US setWrapPolicy( QTextEdit::AtWordBoundary ); 55//US setWrapPolicy( QTextEdit::AtWordBoundary );
56 setLinkUnderline( false ); 56 setLinkUnderline( false );
57 // setVScrollBarMode( QScrollView::AlwaysOff ); 57 // setVScrollBarMode( QScrollView::AlwaysOff );
58 //setHScrollBarMode( QScrollView::AlwaysOff ); 58 //setHScrollBarMode( QScrollView::AlwaysOff );
59 59
60//US QStyleSheet *sheet = styleSheet(); 60//US QStyleSheet *sheet = styleSheet();
61//US QStyleSheetItem *link = sheet->item( "a" ); 61//US QStyleSheetItem *link = sheet->item( "a" );
62//US link->setColor( KGlobalSettings::linkColor() ); 62//US link->setColor( KGlobalSettings::linkColor() );
63 63
64} 64}
65 65
66void AddresseeView::setSource(const QString& n) 66void AddresseeView::setSource(const QString& n)
67{ 67{
68 //qDebug("********AddresseeView::setSource %s", n.latin1()); 68 //qDebug("********AddresseeView::setSource %s", n.latin1());
69 69
70 if ( n.left( 6 ) == "mailto" ) 70 if ( n.left( 6 ) == "mailto" )
71 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); 71 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
72 else if ( n.left( 7 ) == "phoneto" ) 72 else if ( n.left( 7 ) == "phoneto" )
73 ExternalAppHandler::instance()->callByPhone( n.mid(8) ); 73 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
74 else if ( n.left( 5 ) == "faxto" ) 74 else if ( n.left( 5 ) == "faxto" )
75 ExternalAppHandler::instance()->callByFax( n.mid(6) ); 75 ExternalAppHandler::instance()->callByFax( n.mid(6) );
76 else if ( n.left( 5 ) == "smsto" ) 76 else if ( n.left( 5 ) == "smsto" )
77 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 77 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
78 else if ( n.left( 7 ) == "pagerto" ) 78 else if ( n.left( 7 ) == "pagerto" )
79 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 79 ExternalAppHandler::instance()->callByPager( n.mid(8) );
80 else if ( n.left( 5 ) == "sipto" )
81 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
80 82
81} 83}
82void AddresseeView::setAddressee( const KABC::Addressee& addr ) 84void AddresseeView::setAddressee( const KABC::Addressee& addr )
83{ 85{
84 ExternalAppHandler* eah = ExternalAppHandler::instance(); 86 ExternalAppHandler* eah = ExternalAppHandler::instance();
85 bool kemailAvail = eah->isEmailAppAvailable(); 87 bool kemailAvail = eah->isEmailAppAvailable();
86 bool kphoneAvail = eah->isPhoneAppAvailable(); 88 bool kphoneAvail = eah->isPhoneAppAvailable();
87 bool kfaxAvail = eah->isFaxAppAvailable(); 89 bool kfaxAvail = eah->isFaxAppAvailable();
88 bool ksmsAvail = eah->isSMSAppAvailable(); 90 bool ksmsAvail = eah->isSMSAppAvailable();
89 bool kpagerAvail = eah->isPagerAppAvailable(); 91 bool kpagerAvail = eah->isPagerAppAvailable();
92 bool ksipAvail = eah->isSIPAppAvailable();
90 93
91 94
92 mAddressee = addr; 95 mAddressee = addr;
93 // clear view 96 // clear view
94 setText( QString::null ); 97 setText( QString::null );
95 98
96 if ( mAddressee.isEmpty() ) 99 if ( mAddressee.isEmpty() )
97 return; 100 return;
98 101
99 QString name = ( mAddressee.assembledName().isEmpty() ? 102 QString name = ( mAddressee.assembledName().isEmpty() ?
100 mAddressee.formattedName() : mAddressee.assembledName() ); 103 mAddressee.formattedName() : mAddressee.assembledName() );
101 104
102 QString dynamicPart; 105 QString dynamicPart;
103 106
104 QStringList emails = mAddressee.emails(); 107 QStringList emails = mAddressee.emails();
105 QStringList::ConstIterator emailIt; 108 QStringList::ConstIterator emailIt;
106 QString type = i18n( "Email" ); 109 QString type = i18n( "Email" );
107 emailIt = emails.begin(); 110 emailIt = emails.begin();
108 if ( emailIt != emails.end() ) { 111 if ( emailIt != emails.end() ) {
109 if ( kemailAvail ) { 112 if ( kemailAvail ) {
110 dynamicPart += QString( 113 dynamicPart += QString(
111 "<tr><td align=\"right\"><b>%1</b></td>" 114 "<tr><td align=\"right\"><b>%1</b></td>"
112 "<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>" )
113 .arg( type ) 116 .arg( type )
114 .arg( name ) 117 .arg( name )
115 .arg( *emailIt ) 118 .arg( *emailIt )
116 .arg( *emailIt ); 119 .arg( *emailIt );
117 ++emailIt; 120 ++emailIt;
118 } else { 121 } else {
119 dynamicPart += QString( 122 dynamicPart += QString(
120 "<tr><td align=\"right\"><b>%1</b></td>" 123 "<tr><td align=\"right\"><b>%1</b></td>"
121 "<td align=\"left\">%2</td></tr>" ) 124 "<td align=\"left\">%2</td></tr>" )
122 .arg( type ) 125 .arg( type )
123 .arg( *emailIt ); 126 .arg( *emailIt );
124 ++emailIt; 127 ++emailIt;
125 } 128 }
126 } 129 }
127 if ( mAddressee.birthday().date().isValid() ) { 130 if ( mAddressee.birthday().date().isValid() ) {
128 dynamicPart += QString( 131 dynamicPart += QString(
129 "<tr><td align=\"right\"><b>%1</b></td>" 132 "<tr><td align=\"right\"><b>%1</b></td>"
130 "<td align=\"left\">%2</td></tr>" ) 133 "<td align=\"left\">%2</td></tr>" )
131 .arg( i18n ("Birthday") ) 134 .arg( i18n ("Birthday") )
132 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 135 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
133 } 136 }
134 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); 137 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
135 KABC::PhoneNumber::List::ConstIterator phoneIt; 138 KABC::PhoneNumber::List::ConstIterator phoneIt;
136 QString extension; 139 QString extension;
137 int phonetype; 140 int phonetype;
138 QString sms; 141 QString sms;
139 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 142 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
140 phonetype = (*phoneIt).type(); 143 phonetype = (*phoneIt).type();
141 if (ksmsAvail && 144 if (ksmsAvail &&
142 ( 145 (
143 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 146 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
144 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 147 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
145 ) 148 )
146 ) 149 )
147 { 150 {
148 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 151 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
149 .arg( (*phoneIt).number() ); 152 .arg( (*phoneIt).number() );
150 153
151 } 154 }
152 else 155 else
153 sms = ""; 156 sms = "";
154 157
155 extension = QString::null; 158 extension = QString::null;
156 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 159 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
157 if (kfaxAvail) extension = "faxto:"; 160 if (kfaxAvail) extension = "faxto:";
158 } 161 }
159 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 162 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
160 if (kpagerAvail) extension = "pagerto:"; 163 if (kpagerAvail) extension = "pagerto:";
161 } 164 }
165 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
166 if (ksipAvail) extension = "sipto:";
167 }
162 else if (kphoneAvail) { 168 else if (kphoneAvail) {
163 extension = "phoneto:"; 169 extension = "phoneto:";
164 } 170 }
165 else 171 else
166 extension = QString::null; 172 extension = QString::null;
167 173
168 if ( !extension.isEmpty() ) { 174 if ( !extension.isEmpty() ) {
169 dynamicPart += QString( 175 dynamicPart += QString(
170 "<tr><td align=\"right\"><b>%1</b></td>" 176 "<tr><td align=\"right\"><b>%1</b></td>"
171 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 177 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
172 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 178 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
173 .arg( extension ) 179 .arg( extension )
174 .arg( (*phoneIt).number() ) 180 .arg( (*phoneIt).number() )
175 .arg( (*phoneIt).number() ) 181 .arg( (*phoneIt).number() )
176 .arg( sms ); 182 .arg( sms );
177 183
178 } else { 184 } else {
179 dynamicPart += QString( 185 dynamicPart += QString(
180 "<tr><td align=\"right\"><b>%1</b></td>" 186 "<tr><td align=\"right\"><b>%1</b></td>"
181 "<td align=\"left\">%2 %3</td></tr>" ) 187 "<td align=\"left\">%2 %3</td></tr>" )
182 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 188 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
183 .arg( (*phoneIt).number() ) 189 .arg( (*phoneIt).number() )
184 .arg( sms ); 190 .arg( sms );
185 } 191 }
186 } 192 }
187 193
188 194
189 for ( ; emailIt != emails.end(); ++emailIt ) { 195 for ( ; emailIt != emails.end(); ++emailIt ) {
190 if ( kemailAvail ) { 196 if ( kemailAvail ) {
191 dynamicPart += QString( 197 dynamicPart += QString(
192 "<tr><td align=\"right\"><b>%1</b></td>" 198 "<tr><td align=\"right\"><b>%1</b></td>"
193 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 199 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
194 .arg( type ) 200 .arg( type )
195 .arg( name ) 201 .arg( name )
196 .arg( *emailIt ) 202 .arg( *emailIt )
197 .arg( *emailIt ); 203 .arg( *emailIt );
198 } else { 204 } else {
199 dynamicPart += QString( 205 dynamicPart += QString(
200 "<tr><td align=\"right\"><b>%1</b></td>" 206 "<tr><td align=\"right\"><b>%1</b></td>"
201 "<td align=\"left\">%2</td></tr>" ) 207 "<td align=\"left\">%2</td></tr>" )
202 .arg( type ) 208 .arg( type )
203 .arg( *emailIt ); 209 .arg( *emailIt );
204 } 210 }
205 } 211 }
206 212
207 if ( !mAddressee.url().url().isEmpty() ) { 213 if ( !mAddressee.url().url().isEmpty() ) {
208 dynamicPart += QString( 214 dynamicPart += QString(
209 "<tr><td align=\"right\"><b>%1</b></td>" 215 "<tr><td align=\"right\"><b>%1</b></td>"
210 "<td align=\"left\">%2</td></tr>" ) 216 "<td align=\"left\">%2</td></tr>" )
211 .arg( i18n( "Homepage" ) ) 217 .arg( i18n( "Homepage" ) )
212//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 218//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
213 .arg( mAddressee.url().url() ); 219 .arg( mAddressee.url().url() );
214 //qDebug("AddresseeView::setAddressee has to be verified."); 220 //qDebug("AddresseeView::setAddressee has to be verified.");
215 } 221 }
216 222
217 KABC::Address::List addresses = mAddressee.addresses(); 223 KABC::Address::List addresses = mAddressee.addresses();
218 KABC::Address::List::ConstIterator addrIt; 224 KABC::Address::List::ConstIterator addrIt;
219 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 225 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
220 if ( true /*(*addrIt).label().isEmpty()*/ ) { 226 if ( true /*(*addrIt).label().isEmpty()*/ ) {
221 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 227 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
222//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 228//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
223 //qDebug("adresss %s ",formattedAddress.latin1() ); 229 //qDebug("adresss %s ",formattedAddress.latin1() );
224 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 230 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
225 //qDebug("AddresseeView::setAddressee has to be verified."); 231 //qDebug("AddresseeView::setAddressee has to be verified.");
226 232
227 dynamicPart += QString( 233 dynamicPart += QString(
228 "<tr><td align=\"right\"><b>%1</b></td>" 234 "<tr><td align=\"right\"><b>%1</b></td>"
229 "<td align=\"left\">%2</td></tr>" ) 235 "<td align=\"left\">%2</td></tr>" )
230 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 236 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
231 .arg( formattedAddress ); 237 .arg( formattedAddress );
232 } else { 238 } else {
233 239
234 dynamicPart += QString( 240 dynamicPart += QString(
235 "<tr><td align=\"right\"><b>%1</b></td>" 241 "<tr><td align=\"right\"><b>%1</b></td>"
236 "<td align=\"left\">%2</td></tr>" ) 242 "<td align=\"left\">%2</td></tr>" )
237 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 243 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
238//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 244//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
239 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 245 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
240 246
241 } 247 }
242 } 248 }
243 249
244 QString notes; 250 QString notes;
245 if ( !mAddressee.note().isEmpty() ) { 251 if ( !mAddressee.note().isEmpty() ) {
246 notes = QString( 252 notes = QString(
247 "<tr>" 253 "<tr>"
248 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label 254 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
249 "<td align=\"left\">%2</td>" // note 255 "<td align=\"left\">%2</td>" // note
250 "</tr>" ).arg( i18n( "Notes" ) ) 256 "</tr>" ).arg( i18n( "Notes" ) )
251//US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 257//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
252 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 258 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
253 //qDebug("AddresseeView::setAddressee has to be verified."); 259 //qDebug("AddresseeView::setAddressee has to be verified.");
254 } 260 }
255 261
256 QString aRole = ""; 262 QString aRole = "";
257 QString aOrga = ""; 263 QString aOrga = "";