summaryrefslogtreecommitdiffabout
path: root/kabc/addresseeview.cpp
Unidiff
Diffstat (limited to 'kabc/addresseeview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index af149a0..0564e85 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -1,475 +1,474 @@
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> 33#include <qvbox.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qwidget.h> 35#include <qwidget.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39 39
40 40
41#include "externalapphandler.h" 41#include "externalapphandler.h"
42#include "addresseeview.h" 42#include "addresseeview.h"
43 43
44 44
45//US #ifndef DESKTOP_VERSION 45//US #ifndef DESKTOP_VERSION
46//US #include <qtopia/qcopenvelope_qws.h> 46//US #include <qtopia/qcopenvelope_qws.h>
47//US #include <qpe/qpeapplication.h> 47//US #include <qpe/qpeapplication.h>
48//US #endif 48//US #endif
49 49
50//US static int kphoneInstalled = 0; 50//US static int kphoneInstalled = 0;
51 51
52using namespace KPIM; 52using namespace KPIM;
53 53
54AddresseeView::AddresseeView( QWidget *parent, const char *name ) 54AddresseeView::AddresseeView( QWidget *parent, const char *name )
55//US : KTextBrowser( parent, name ) 55//US : KTextBrowser( parent, name )
56 : QTextBrowser( parent, name ) 56 : QTextBrowser( parent, name )
57 57
58 58
59{ 59{
60//US setWrapPolicy( QTextEdit::AtWordBoundary ); 60//US setWrapPolicy( QTextEdit::AtWordBoundary );
61 setLinkUnderline( false ); 61 setLinkUnderline( false );
62 // setVScrollBarMode( QScrollView::AlwaysOff ); 62 // setVScrollBarMode( QScrollView::AlwaysOff );
63 //setHScrollBarMode( QScrollView::AlwaysOff ); 63 //setHScrollBarMode( QScrollView::AlwaysOff );
64 64
65//US QStyleSheet *sheet = styleSheet(); 65//US QStyleSheet *sheet = styleSheet();
66//US QStyleSheetItem *link = sheet->item( "a" ); 66//US QStyleSheetItem *link = sheet->item( "a" );
67//US link->setColor( KGlobalSettings::linkColor() ); 67//US link->setColor( KGlobalSettings::linkColor() );
68 68
69} 69}
70 70
71void AddresseeView::setSource(const QString& n) 71void AddresseeView::setSource(const QString& n)
72{ 72{
73 //qDebug("********AddresseeView::setSource %s", n.latin1()); 73 //qDebug("********AddresseeView::setSource %s", n.latin1());
74 74
75 if ( n.left( 6 ) == "mailto" ) 75 if ( n.left( 6 ) == "mailto" )
76 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); 76 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
77 else if ( n.left( 7 ) == "phoneto" ) 77 else if ( n.left( 7 ) == "phoneto" )
78 ExternalAppHandler::instance()->callByPhone( n.mid(8) ); 78 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
79 else if ( n.left( 5 ) == "faxto" ) 79 else if ( n.left( 5 ) == "faxto" )
80 ExternalAppHandler::instance()->callByFax( n.mid(6) ); 80 ExternalAppHandler::instance()->callByFax( n.mid(6) );
81 else if ( n.left( 5 ) == "smsto" ) 81 else if ( n.left( 5 ) == "smsto" )
82 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 82 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
83 else if ( n.left( 7 ) == "pagerto" ) 83 else if ( n.left( 7 ) == "pagerto" )
84 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 84 ExternalAppHandler::instance()->callByPager( n.mid(8) );
85 else if ( n.left( 5 ) == "sipto" ) 85 else if ( n.left( 5 ) == "sipto" )
86 ExternalAppHandler::instance()->callBySIP( n.mid(6) ); 86 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
87 87
88} 88}
89void AddresseeView::setAddressee( const KABC::Addressee& addr ) 89void AddresseeView::setAddressee( const KABC::Addressee& addr )
90{ 90{
91 ExternalAppHandler* eah = ExternalAppHandler::instance(); 91 ExternalAppHandler* eah = ExternalAppHandler::instance();
92 bool kemailAvail = eah->isEmailAppAvailable(); 92 bool kemailAvail = eah->isEmailAppAvailable();
93 93
94 94
95 95
96 mAddressee = addr; 96 mAddressee = addr;
97 // clear view 97 // clear view
98 setText( QString::null ); 98 setText( QString::null );
99 99
100 if ( mAddressee.isEmpty() ) 100 if ( mAddressee.isEmpty() )
101 return; 101 return;
102 102
103 QString name = ( mAddressee.assembledName().isEmpty() ? 103 QString name = ( mAddressee.assembledName().isEmpty() ?
104 mAddressee.formattedName() : mAddressee.assembledName() ); 104 mAddressee.formattedName() : mAddressee.assembledName() );
105 105
106 QString dynamicPart; 106 QString dynamicPart;
107 107
108 dynamicPart += getPhoneNumbers( true ); 108 dynamicPart += getPhoneNumbers( true );
109 qDebug("dynamic preferred %s ",dynamicPart.latin1() );
110 QStringList emails = mAddressee.emails(); 109 QStringList emails = mAddressee.emails();
111 QStringList::ConstIterator emailIt; 110 QStringList::ConstIterator emailIt;
112 QString type = i18n( "Email" ); 111 QString type = i18n( "Email" );
113 emailIt = emails.begin(); 112 emailIt = emails.begin();
114 if ( emailIt != emails.end() ) { 113 if ( emailIt != emails.end() ) {
115 if ( kemailAvail ) { 114 if ( kemailAvail ) {
116 dynamicPart += QString( 115 dynamicPart += QString(
117 "<tr><td align=\"right\"><b>%1</b></td>" 116 "<tr><td align=\"right\"><b>%1</b></td>"
118 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 117 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
119 .arg( type ) 118 .arg( type )
120 .arg( name ) 119 .arg( name )
121 .arg( *emailIt ) 120 .arg( *emailIt )
122 .arg( *emailIt ); 121 .arg( *emailIt );
123 ++emailIt; 122 ++emailIt;
124 } else { 123 } else {
125 dynamicPart += QString( 124 dynamicPart += QString(
126 "<tr><td align=\"right\"><b>%1</b></td>" 125 "<tr><td align=\"right\"><b>%1</b></td>"
127 "<td align=\"left\">%2</td></tr>" ) 126 "<td align=\"left\">%2</td></tr>" )
128 .arg( type ) 127 .arg( type )
129 .arg( *emailIt ); 128 .arg( *emailIt );
130 ++emailIt; 129 ++emailIt;
131 } 130 }
132 } 131 }
133 if ( mAddressee.birthday().date().isValid() ) { 132 if ( mAddressee.birthday().date().isValid() ) {
134 dynamicPart += QString( 133 dynamicPart += QString(
135 "<tr><td align=\"right\"><b>%1</b></td>" 134 "<tr><td align=\"right\"><b>%1</b></td>"
136 "<td align=\"left\">%2</td></tr>" ) 135 "<td align=\"left\">%2</td></tr>" )
137 .arg( i18n ("Birthday") ) 136 .arg( i18n ("Birthday") )
138 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 137 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
139 } 138 }
140 dynamicPart += getPhoneNumbers( false ); 139 dynamicPart += getPhoneNumbers( false );
141 140
142 for ( ; emailIt != emails.end(); ++emailIt ) { 141 for ( ; emailIt != emails.end(); ++emailIt ) {
143 if ( kemailAvail ) { 142 if ( kemailAvail ) {
144 dynamicPart += QString( 143 dynamicPart += QString(
145 "<tr><td align=\"right\"><b>%1</b></td>" 144 "<tr><td align=\"right\"><b>%1</b></td>"
146 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 145 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
147 .arg( type ) 146 .arg( type )
148 .arg( name ) 147 .arg( name )
149 .arg( *emailIt ) 148 .arg( *emailIt )
150 .arg( *emailIt ); 149 .arg( *emailIt );
151 } else { 150 } else {
152 dynamicPart += QString( 151 dynamicPart += QString(
153 "<tr><td align=\"right\"><b>%1</b></td>" 152 "<tr><td align=\"right\"><b>%1</b></td>"
154 "<td align=\"left\">%2</td></tr>" ) 153 "<td align=\"left\">%2</td></tr>" )
155 .arg( type ) 154 .arg( type )
156 .arg( *emailIt ); 155 .arg( *emailIt );
157 } 156 }
158 } 157 }
159 158
160 if ( !mAddressee.url().url().isEmpty() ) { 159 if ( !mAddressee.url().url().isEmpty() ) {
161 dynamicPart += QString( 160 dynamicPart += QString(
162 "<tr><td align=\"right\"><b>%1</b></td>" 161 "<tr><td align=\"right\"><b>%1</b></td>"
163 "<td align=\"left\">%2</td></tr>" ) 162 "<td align=\"left\">%2</td></tr>" )
164 .arg( i18n( "Homepage" ) ) 163 .arg( i18n( "Homepage" ) )
165//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 164//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
166 .arg( mAddressee.url().url() ); 165 .arg( mAddressee.url().url() );
167 //qDebug("AddresseeView::setAddressee has to be verified."); 166 //qDebug("AddresseeView::setAddressee has to be verified.");
168 } 167 }
169 168
170 KABC::Address::List addresses = mAddressee.addresses(); 169 KABC::Address::List addresses = mAddressee.addresses();
171 KABC::Address::List::ConstIterator addrIt; 170 KABC::Address::List::ConstIterator addrIt;
172 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 171 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
173 if ( true /*(*addrIt).label().isEmpty()*/ ) { 172 if ( true /*(*addrIt).label().isEmpty()*/ ) {
174 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 173 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
175//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 174//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
176 //qDebug("adresss %s ",formattedAddress.latin1() ); 175 //qDebug("adresss %s ",formattedAddress.latin1() );
177 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 176 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
178 //qDebug("AddresseeView::setAddressee has to be verified."); 177 //qDebug("AddresseeView::setAddressee has to be verified.");
179 178
180 dynamicPart += QString( 179 dynamicPart += QString(
181 "<tr><td align=\"right\"><b>%1</b></td>" 180 "<tr><td align=\"right\"><b>%1</b></td>"
182 "<td align=\"left\">%2</td></tr>" ) 181 "<td align=\"left\">%2</td></tr>" )
183 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 182 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
184 .arg( formattedAddress ); 183 .arg( formattedAddress );
185 } else { 184 } else {
186 185
187 dynamicPart += QString( 186 dynamicPart += QString(
188 "<tr><td align=\"right\"><b>%1</b></td>" 187 "<tr><td align=\"right\"><b>%1</b></td>"
189 "<td align=\"left\">%2</td></tr>" ) 188 "<td align=\"left\">%2</td></tr>" )
190 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 189 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
191//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 190//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
192 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 191 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
193 192
194 } 193 }
195 } 194 }
196 195
197 QString notes; 196 QString notes;
198 if ( !mAddressee.note().isEmpty() ) { 197 if ( !mAddressee.note().isEmpty() ) {
199 notes = QString( 198 notes = QString(
200 "<tr>" 199 "<tr>"
201 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label 200 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
202 "<td align=\"left\">%2</td>" // note 201 "<td align=\"left\">%2</td>" // note
203 "</tr>" ).arg( i18n( "Notes" ) ) 202 "</tr>" ).arg( i18n( "Notes" ) )
204//US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 203//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
205 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 204 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
206 //qDebug("AddresseeView::setAddressee has to be verified."); 205 //qDebug("AddresseeView::setAddressee has to be verified.");
207 } 206 }
208 207
209 QString aRole = ""; 208 QString aRole = "";
210 QString aOrga = ""; 209 QString aOrga = "";
211 if ( true /*!mAddressee.role().isEmpty()*/ ) { 210 if ( true /*!mAddressee.role().isEmpty()*/ ) {
212 aRole = "<tr>" 211 aRole = "<tr>"
213 "<td align=\"left\">" + mAddressee.role() + "</td>" 212 "<td align=\"left\">" + mAddressee.role() + "</td>"
214 "</tr>"; 213 "</tr>";
215 } 214 }
216 if ( true /*!mAddressee.organization().isEmpty()*/ ) { 215 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
217 aOrga = "<tr>" 216 aOrga = "<tr>"
218 "<td align=\"left\">" + mAddressee.organization() + "</td>" ; 217 "<td align=\"left\">" + mAddressee.organization() + "</td>" ;
219 "</tr>"; 218 "</tr>";
220 } 219 }
221 mText = ""; 220 mText = "";
222 QString picString = ""; 221 QString picString = "";
223 KABC::Picture picture = mAddressee.photo(); 222 KABC::Picture picture = mAddressee.photo();
224 bool picAvailintern = false; 223 bool picAvailintern = false;
225 bool picAvailUrl = false; 224 bool picAvailUrl = false;
226 if (! picture.undefined() ) { 225 if (! picture.undefined() ) {
227 picAvailintern = (picture.isIntern() && !picture.data().isNull()); 226 picAvailintern = (picture.isIntern() && !picture.data().isNull());
228 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); 227 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
229 } 228 }
230 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { 229 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
231 if ( picAvailintern ) { 230 if ( picAvailintern ) {
232 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 231 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
233 } else { 232 } else {
234 if ( picAvailUrl ) { 233 if ( picAvailUrl ) {
235 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); 234 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
236 } else { 235 } else {
237 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); 236 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) );
238 } 237 }
239 } 238 }
240 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; 239 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
241 mText = QString::fromLatin1( 240 mText = QString::fromLatin1(
242 "<html>" 241 "<html>"
243 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 242 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
244 "<table>" 243 "<table>"
245 "<tr>" 244 "<tr>"
246 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 245 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
247 "%3" 246 "%3"
248 "</td>" 247 "</td>"
249 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 248 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
250 "</tr>" 249 "</tr>"
251 "%5" // role 250 "%5" // role
252 "%6" // organization 251 "%6" // organization
253 "<td colspan=\"2\">&nbsp;</td>" 252 "<td colspan=\"2\">&nbsp;</td>"
254 "%7" // dynamic part 253 "%7" // dynamic part
255 "%8" // notes 254 "%8" // notes
256 "</table>" 255 "</table>"
257 "</body>" 256 "</body>"
258 "</html>") 257 "</html>")
259//US 258//US
260 .arg( /*KGlobalSettings::textColor().name()*/ "black" ) 259 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
261//US 260//US
262 .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) 261 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
263 .arg( picString ) 262 .arg( picString )
264 .arg( name ) 263 .arg( name )
265 .arg( aRole ) 264 .arg( aRole )
266 .arg( aOrga ) 265 .arg( aOrga )
267 .arg( dynamicPart ) 266 .arg( dynamicPart )
268 .arg( notes ); 267 .arg( notes );
269 268
270 } else { // no picture! 269 } else { // no picture!
271 270
272mText = "<table width=\"100%\">\n"; 271mText = "<table width=\"100%\">\n";
273 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 272 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
274#ifdef DESKTOP_VERSION 273#ifdef DESKTOP_VERSION
275 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; 274 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
276#else 275#else
277 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; 276 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>";
278#endif 277#endif
279 278
280#ifdef DESKTOP_VERSION 279#ifdef DESKTOP_VERSION
281 mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; 280 mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>";
282#else 281#else
283 mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; 282 mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>";
284#endif 283#endif
285 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 284 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
286 285
287 mText += "<table><td colspan=\"2\">&nbsp;</td>"; 286 mText += "<table><td colspan=\"2\">&nbsp;</td>";
288 /* 287 /*
289 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" 288 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
290 "<td align=\"left\"><b>%2</b></td></tr>" ) 289 "<td align=\"left\"><b>%2</b></td></tr>" )
291 .arg( i18n(" ") ) 290 .arg( i18n(" ") )
292 .arg( name ); 291 .arg( name );
293 */ 292 */
294 if ( ! mAddressee.role().isEmpty() ) 293 if ( ! mAddressee.role().isEmpty() )
295 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 294 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
296 "<td align=\"left\">%2</td></tr>" ) 295 "<td align=\"left\">%2</td></tr>" )
297 .arg( i18n(" ") ) 296 .arg( i18n(" ") )
298 .arg( mAddressee.role()); 297 .arg( mAddressee.role());
299 if ( ! mAddressee.organization().isEmpty() ) 298 if ( ! mAddressee.organization().isEmpty() )
300 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 299 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
301 "<td align=\"left\">%2</td></tr>" ) 300 "<td align=\"left\">%2</td></tr>" )
302 .arg( i18n(" ") ) 301 .arg( i18n(" ") )
303 .arg( mAddressee.organization()); 302 .arg( mAddressee.organization());
304 mText += dynamicPart; 303 mText += dynamicPart;
305 mText += notes; 304 mText += notes;
306 mText += "</table>"; 305 mText += "</table>";
307 306
308 } 307 }
309 308
310 // at last display it... 309 // at last display it...
311 setText( mText ); 310 setText( mText );
312 311
313} 312}
314 313
315QString AddresseeView::getPhoneNumbers( bool preferred ) 314QString AddresseeView::getPhoneNumbers( bool preferred )
316{ 315{
317 ExternalAppHandler* eah = ExternalAppHandler::instance(); 316 ExternalAppHandler* eah = ExternalAppHandler::instance();
318 bool kphoneAvail = eah->isPhoneAppAvailable(); 317 bool kphoneAvail = eah->isPhoneAppAvailable();
319 bool kfaxAvail = eah->isFaxAppAvailable(); 318 bool kfaxAvail = eah->isFaxAppAvailable();
320 bool ksmsAvail = eah->isSMSAppAvailable(); 319 bool ksmsAvail = eah->isSMSAppAvailable();
321 bool kpagerAvail = eah->isPagerAppAvailable(); 320 bool kpagerAvail = eah->isPagerAppAvailable();
322 bool ksipAvail = eah->isSIPAppAvailable(); 321 bool ksipAvail = eah->isSIPAppAvailable();
323 QString dynamicPart; 322 QString dynamicPart;
324 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); 323 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
325 KABC::PhoneNumber::List::ConstIterator phoneIt; 324 KABC::PhoneNumber::List::ConstIterator phoneIt;
326 QString extension; 325 QString extension;
327 int phonetype; 326 int phonetype;
328 QString sms; 327 QString sms;
329 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 328 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
330 phonetype = (*phoneIt).type(); 329 phonetype = (*phoneIt).type();
331 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) 330 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred )
332 continue; 331 continue;
333 if (ksmsAvail && 332 if (ksmsAvail &&
334 ( 333 (
335 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 334 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
336 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 335 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
337 ) 336 )
338 ) 337 )
339 { 338 {
340 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 339 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
341 .arg( (*phoneIt).number() ); 340 .arg( (*phoneIt).number() );
342 341
343 } 342 }
344 else 343 else
345 sms = ""; 344 sms = "";
346 345
347 extension = QString::null; 346 extension = QString::null;
348 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 347 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
349 if (kfaxAvail) extension = "faxto:"; 348 if (kfaxAvail) extension = "faxto:";
350 } 349 }
351 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 350 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
352 if (kpagerAvail) extension = "pagerto:"; 351 if (kpagerAvail) extension = "pagerto:";
353 } 352 }
354 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { 353 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
355 if (ksipAvail) extension = "sipto:"; 354 if (ksipAvail) extension = "sipto:";
356 } 355 }
357 else if (kphoneAvail) { 356 else if (kphoneAvail) {
358 extension = "phoneto:"; 357 extension = "phoneto:";
359 } 358 }
360 else 359 else
361 extension = QString::null; 360 extension = QString::null;
362 361
363 if ( !extension.isEmpty() ) { 362 if ( !extension.isEmpty() ) {
364 dynamicPart += QString( 363 dynamicPart += QString(
365 "<tr><td align=\"right\"><b>%1</b></td>" 364 "<tr><td align=\"right\"><b>%1</b></td>"
366 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 365 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
367 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 366 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
368 .arg( extension ) 367 .arg( extension )
369 .arg( (*phoneIt).number() ) 368 .arg( (*phoneIt).number() )
370 .arg( (*phoneIt).number() ) 369 .arg( (*phoneIt).number() )
371 .arg( sms ); 370 .arg( sms );
372 371
373 } else { 372 } else {
374 dynamicPart += QString( 373 dynamicPart += QString(
375 "<tr><td align=\"right\"><b>%1</b></td>" 374 "<tr><td align=\"right\"><b>%1</b></td>"
376 "<td align=\"left\">%2 %3</td></tr>" ) 375 "<td align=\"left\">%2 %3</td></tr>" )
377 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 376 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
378 .arg( (*phoneIt).number() ) 377 .arg( (*phoneIt).number() )
379 .arg( sms ); 378 .arg( sms );
380 } 379 }
381 } 380 }
382 return dynamicPart; 381 return dynamicPart;
383} 382}
384KABC::Addressee AddresseeView::addressee() const 383KABC::Addressee AddresseeView::addressee() const
385{ 384{
386 return mAddressee; 385 return mAddressee;
387} 386}
388void AddresseeView::addTag(const QString & tag,const QString & text) 387void AddresseeView::addTag(const QString & tag,const QString & text)
389{ 388{
390 if ( text.isEmpty() ) 389 if ( text.isEmpty() )
391 return; 390 return;
392 int number=text.contains("\n"); 391 int number=text.contains("\n");
393 QString str = "<" + tag + ">"; 392 QString str = "<" + tag + ">";
394 QString tmpText=text; 393 QString tmpText=text;
395 QString tmpStr=str; 394 QString tmpStr=str;
396 if(number !=-1) 395 if(number !=-1)
397 { 396 {
398 if (number > 0) { 397 if (number > 0) {
399 int pos=0; 398 int pos=0;
400 QString tmp; 399 QString tmp;
401 for(int i=0;i<=number;i++) { 400 for(int i=0;i<=number;i++) {
402 pos=tmpText.find("\n"); 401 pos=tmpText.find("\n");
403 tmp=tmpText.left(pos); 402 tmp=tmpText.left(pos);
404 tmpText=tmpText.right(tmpText.length()-pos-1); 403 tmpText=tmpText.right(tmpText.length()-pos-1);
405 tmpStr+=tmp+"<br>"; 404 tmpStr+=tmp+"<br>";
406 } 405 }
407 } 406 }
408 else tmpStr += tmpText; 407 else tmpStr += tmpText;
409 tmpStr+="</" + tag + ">"; 408 tmpStr+="</" + tag + ">";
410 mText.append(tmpStr); 409 mText.append(tmpStr);
411 } 410 }
412 else 411 else
413 { 412 {
414 str += text + "</" + tag + ">"; 413 str += text + "</" + tag + ">";
415 mText.append(str); 414 mText.append(str);
416 } 415 }
417} 416}
418 417
419AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, 418AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
420 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) 419 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false)
421{ 420{
422 findButton( Close )->setText( i18n("Cancel Sync")); 421 findButton( Close )->setText( i18n("Cancel Sync"));
423 findButton( Ok )->setText( i18n("Remote")); 422 findButton( Ok )->setText( i18n("Remote"));
424 findButton( User1 )->setText( i18n("Local")); 423 findButton( User1 )->setText( i18n("Local"));
425 QWidget* topframe = new QWidget( this ); 424 QWidget* topframe = new QWidget( this );
426 setMainWidget( topframe ); 425 setMainWidget( topframe );
427 QBoxLayout* bl; 426 QBoxLayout* bl;
428 if ( QApplication::desktop()->width() < 640 ) { 427 if ( QApplication::desktop()->width() < 640 ) {
429 bl = new QVBoxLayout( topframe ); 428 bl = new QVBoxLayout( topframe );
430 } else { 429 } else {
431 bl = new QHBoxLayout( topframe ); 430 bl = new QHBoxLayout( topframe );
432 } 431 }
433 QVBox* subframe = new QVBox( topframe ); 432 QVBox* subframe = new QVBox( topframe );
434 bl->addWidget(subframe ); 433 bl->addWidget(subframe );
435 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); 434 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
436 if ( takeloc ) 435 if ( takeloc )
437 lab->setBackgroundColor(Qt::green.light() ); 436 lab->setBackgroundColor(Qt::green.light() );
438 AddresseeView * av = new AddresseeView( subframe ); 437 AddresseeView * av = new AddresseeView( subframe );
439 av->setAddressee( loc ); 438 av->setAddressee( loc );
440 subframe = new QVBox( topframe ); 439 subframe = new QVBox( topframe );
441 bl->addWidget(subframe ); 440 bl->addWidget(subframe );
442 lab = new QLabel( i18n("Remote Addressee"), subframe ); 441 lab = new QLabel( i18n("Remote Addressee"), subframe );
443 if ( !takeloc ) 442 if ( !takeloc )
444 lab->setBackgroundColor(Qt::green.light() ); 443 lab->setBackgroundColor(Qt::green.light() );
445 av = new AddresseeView( subframe ); 444 av = new AddresseeView( subframe );
446 av->setAddressee( rem ); 445 av->setAddressee( rem );
447 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 446 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
448 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 447 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
449#ifndef DESKTOP_VERSION 448#ifndef DESKTOP_VERSION
450 showMaximized(); 449 showMaximized();
451#else 450#else
452 resize ( 640, 400 ); 451 resize ( 640, 400 );
453#endif 452#endif
454} 453}
455 454
456int AddresseeChooser::executeD( bool local ) 455int AddresseeChooser::executeD( bool local )
457{ 456{
458 mSyncResult = 3; 457 mSyncResult = 3;
459 if ( local ) 458 if ( local )
460 findButton( User1 )->setFocus(); 459 findButton( User1 )->setFocus();
461 else 460 else
462 findButton( Ok )->setFocus(); 461 findButton( Ok )->setFocus();
463 exec(); 462 exec();
464 return mSyncResult; 463 return mSyncResult;
465} 464}
466void AddresseeChooser::slot_remote() 465void AddresseeChooser::slot_remote()
467{ 466{
468 mSyncResult = 2; 467 mSyncResult = 2;
469 accept(); 468 accept();
470} 469}
471void AddresseeChooser::slot_local() 470void AddresseeChooser::slot_local()
472{ 471{
473 mSyncResult = 1; 472 mSyncResult = 1;
474 accept(); 473 accept();
475} 474}