summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-03-29 18:35:10 (UTC)
committer zautrix <zautrix>2005-03-29 18:35:10 (UTC)
commitb70d9695bb6a2d567b75965c0530792ad90c84a3 (patch) (unidiff)
treebc27647d044cf4a8d9c75acd19d9a2d078fe00b2 /kabc
parenta7c827aa0e555206b60dec3bc07f7afab4352883 (diff)
downloadkdepimpi-b70d9695bb6a2d567b75965c0530792ad90c84a3.zip
kdepimpi-b70d9695bb6a2d567b75965c0530792ad90c84a3.tar.gz
kdepimpi-b70d9695bb6a2d567b75965c0530792ad90c84a3.tar.bz2
icons
Diffstat (limited to 'kabc') (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
@@ -1,497 +1,503 @@
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#ifdef DESKTOP_VERSION 39#ifdef DESKTOP_VERSION
40#include <qpaintdevicemetrics.h> 40#include <qpaintdevicemetrics.h>
41#include <qprinter.h> 41#include <qprinter.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#endif 43#endif
44 44
45 45
46#include "externalapphandler.h" 46#include "externalapphandler.h"
47#include <kabc/addresseeview.h> 47#include <kabc/addresseeview.h>
48 48
49 49
50//US #ifndef DESKTOP_VERSION 50//US #ifndef DESKTOP_VERSION
51//US #include <qtopia/qcopenvelope_qws.h> 51//US #include <qtopia/qcopenvelope_qws.h>
52//US #include <qpe/qpeapplication.h> 52//US #include <qpe/qpeapplication.h>
53//US #endif 53//US #endif
54 54
55//US static int kphoneInstalled = 0; 55//US static int kphoneInstalled = 0;
56 56
57using namespace KABC; 57using namespace KABC;
58 58
59AddresseeView::AddresseeView( QWidget *parent, const char *name ) 59AddresseeView::AddresseeView( QWidget *parent, const char *name )
60 : QTextBrowser( parent, name ) 60 : QTextBrowser( parent, name )
61 61
62 62
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 );
457 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); 463 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
458 if ( takeloc ) 464 if ( takeloc )
459 lab->setBackgroundColor(Qt::green.light() ); 465 lab->setBackgroundColor(Qt::green.light() );
460 AddresseeView * av = new AddresseeView( subframe ); 466 AddresseeView * av = new AddresseeView( subframe );
461 av->setAddressee( loc ); 467 av->setAddressee( loc );
462 subframe = new QVBox( topframe ); 468 subframe = new QVBox( topframe );
463 bl->addWidget(subframe ); 469 bl->addWidget(subframe );
464 lab = new QLabel( i18n("Remote Addressee"), subframe ); 470 lab = new QLabel( i18n("Remote Addressee"), subframe );
465 if ( !takeloc ) 471 if ( !takeloc )
466 lab->setBackgroundColor(Qt::green.light() ); 472 lab->setBackgroundColor(Qt::green.light() );
467 av = new AddresseeView( subframe ); 473 av = new AddresseeView( subframe );
468 av->setAddressee( rem ); 474 av->setAddressee( rem );
469 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 475 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
470 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 476 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
471#ifndef DESKTOP_VERSION 477#ifndef DESKTOP_VERSION
472 showMaximized(); 478 showMaximized();
473#else 479#else
474 resize ( 640, 400 ); 480 resize ( 640, 400 );
475#endif 481#endif
476} 482}
477 483
478int AddresseeChooser::executeD( bool local ) 484int AddresseeChooser::executeD( bool local )
479{ 485{
480 mSyncResult = 3; 486 mSyncResult = 3;
481 if ( local ) 487 if ( local )
482 findButton( User1 )->setFocus(); 488 findButton( User1 )->setFocus();
483 else 489 else
484 findButton( Ok )->setFocus(); 490 findButton( Ok )->setFocus();
485 exec(); 491 exec();
486 return mSyncResult; 492 return mSyncResult;
487} 493}
488void AddresseeChooser::slot_remote() 494void AddresseeChooser::slot_remote()
489{ 495{
490 mSyncResult = 2; 496 mSyncResult = 2;
491 accept(); 497 accept();
492} 498}
493void AddresseeChooser::slot_local() 499void AddresseeChooser::slot_local()
494{ 500{
495 mSyncResult = 1; 501 mSyncResult = 1;
496 accept(); 502 accept();
497} 503}