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