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