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