summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-03-29 19:00:52 (UTC)
committer zautrix <zautrix>2005-03-29 19:00:52 (UTC)
commitd6e5d0b71d6a6727fbfef895a814e046a2a99aae (patch) (unidiff)
tree2bc757ab32fda4a2c1b4ad78cc99621ef3466415 /kabc
parentb70d9695bb6a2d567b75965c0530792ad90c84a3 (diff)
downloadkdepimpi-d6e5d0b71d6a6727fbfef895a814e046a2a99aae.zip
kdepimpi-d6e5d0b71d6a6727fbfef895a814e046a2a99aae.tar.gz
kdepimpi-d6e5d0b71d6a6727fbfef895a814e046a2a99aae.tar.bz2
fixes
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp48
1 files changed, 42 insertions, 6 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 8f104e0..aa96210 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -6,498 +6,534 @@
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 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
256 if ( picAvailintern ) { 256 if ( picAvailintern ) {
257 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 257 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
258 } else { 258 } else {
259 if ( picAvailUrl ) { 259 if ( picAvailUrl ) {
260 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); 260 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
261 } else { 261 } else {
262 static bool setDefaultImage = false; 262 if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) {
263 if ( !setDefaultImage ) { 263 static bool setDefaultImageChildren = false;
264 qDebug("Setting default pixmap "); 264 if ( !setDefaultImageChildren ) {
265 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultPenguin", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); 265 QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) );
266 setDefaultImage = true; 266 setDefaultImageChildren = true;
267 }
268 picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">";
269
270 } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) {
271 static bool setDefaultImagepouses = false;
272 if ( !setDefaultImagepouses ) {
273 QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) );
274 setDefaultImagepouses = true;
275 }
276 picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">";
277 } else {
278 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
279 if ( gen == "male" ) {
280 static bool setDefaultImageMale = false;
281 if ( !setDefaultImageMale ) {
282 QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) );
283 setDefaultImageMale = true;
284 }
285 picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">";
286
287 } else if ( gen == "female" ) {
288 static bool setDefaultImageFemale = false;
289 if ( !setDefaultImageFemale ) {
290 QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) );
291 setDefaultImageFemale = true;
292 }
293 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">";
294
295 } else {
296 static bool setDefaultImage = false;
297 if ( !setDefaultImage ) {
298 qDebug("Setting default pixmap ");
299 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) );
300 setDefaultImage = true;
301 }
302 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">";
303 }
267 } 304 }
268 picString = "<img src=\"defaultPenguin\" width=\"64\" height=\"64\">";
269 } 305 }
270 } 306 }
271 mText = QString::fromLatin1( 307 mText = QString::fromLatin1(
272 "<html>" 308 "<html>"
273 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 309 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
274 "<table>" 310 "<table>"
275 "<tr>" 311 "<tr>"
276 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 312 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
277 "%3" 313 "%3"
278 "</td>" 314 "</td>"
279 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 315 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
280 "</tr>" 316 "</tr>"
281 "%5" // role 317 "%5" // role
282 "%6" // organization 318 "%6" // organization
283 "<td colspan=\"2\">&nbsp;</td>" 319 "<td colspan=\"2\">&nbsp;</td>"
284 "%7" // dynamic part 320 "%7" // dynamic part
285 "%8" // notes 321 "%8" // notes
286 "</table>" 322 "</table>"
287 "</body>" 323 "</body>"
288 "</html>") 324 "</html>")
289//US 325//US
290 .arg( /*KGlobalSettings::textColor().name()*/ "black" ) 326 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
291//US 327//US
292 .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) 328 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
293 .arg( picString ) 329 .arg( picString )
294 .arg( name ) 330 .arg( name )
295 .arg( aRole ) 331 .arg( aRole )
296 .arg( aOrga ) 332 .arg( aOrga )
297 .arg( dynamicPart ) 333 .arg( dynamicPart )
298 .arg( notes ); 334 .arg( notes );
299 335
300 } else { // no picture! 336 } else { // no picture!
301 337
302mText = "<table width=\"100%\">\n"; 338mText = "<table width=\"100%\">\n";
303 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 339 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
304#ifdef DESKTOP_VERSION 340#ifdef DESKTOP_VERSION
305 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; 341 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
306 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; 342 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>";
307#else 343#else
308 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; 344 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>";
309 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; 345 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>";
310#endif 346#endif
311 347
312 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 348 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
313 349
314 mText += "<table><td colspan=\"2\">&nbsp;</td>"; 350 mText += "<table><td colspan=\"2\">&nbsp;</td>";
315 /* 351 /*
316 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" 352 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
317 "<td align=\"left\"><b>%2</b></td></tr>" ) 353 "<td align=\"left\"><b>%2</b></td></tr>" )
318 .arg( i18n(" ") ) 354 .arg( i18n(" ") )
319 .arg( name ); 355 .arg( name );
320 */ 356 */
321 if ( ! mAddressee.role().isEmpty() ) 357 if ( ! mAddressee.role().isEmpty() )
322 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 358 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
323 "<td align=\"left\">%2</td></tr>" ) 359 "<td align=\"left\">%2</td></tr>" )
324 .arg( i18n(" ") ) 360 .arg( i18n(" ") )
325 .arg( mAddressee.role()); 361 .arg( mAddressee.role());
326 if ( ! mAddressee.organization().isEmpty() ) 362 if ( ! mAddressee.organization().isEmpty() )
327 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 363 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
328 "<td align=\"left\">%2</td></tr>" ) 364 "<td align=\"left\">%2</td></tr>" )
329 .arg( i18n(" ") ) 365 .arg( i18n(" ") )
330 .arg( mAddressee.organization()); 366 .arg( mAddressee.organization());
331 mText += dynamicPart; 367 mText += dynamicPart;
332 mText += notes; 368 mText += notes;
333 mText += "</table>"; 369 mText += "</table>";
334 370
335 } 371 }
336 372
337 // at last display it... 373 // at last display it...
338 setText( mText ); 374 setText( mText );
339 375
340} 376}
341 377
342QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) 378QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred )
343{ 379{
344 ExternalAppHandler* eah = ExternalAppHandler::instance(); 380 ExternalAppHandler* eah = ExternalAppHandler::instance();
345 bool kphoneAvail = eah->isPhoneAppAvailable(); 381 bool kphoneAvail = eah->isPhoneAppAvailable();
346 bool kfaxAvail = eah->isFaxAppAvailable(); 382 bool kfaxAvail = eah->isFaxAppAvailable();
347 bool ksmsAvail = eah->isSMSAppAvailable(); 383 bool ksmsAvail = eah->isSMSAppAvailable();
348 bool kpagerAvail = eah->isPagerAppAvailable(); 384 bool kpagerAvail = eah->isPagerAppAvailable();
349 bool ksipAvail = eah->isSIPAppAvailable(); 385 bool ksipAvail = eah->isSIPAppAvailable();
350 QString dynamicPart; 386 QString dynamicPart;
351 KABC::PhoneNumber::List::ConstIterator phoneIt; 387 KABC::PhoneNumber::List::ConstIterator phoneIt;
352 QString extension; 388 QString extension;
353 int phonetype; 389 int phonetype;
354 QString sms; 390 QString sms;
355 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 391 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
356 phonetype = (*phoneIt).type(); 392 phonetype = (*phoneIt).type();
357 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) 393 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred )
358 continue; 394 continue;
359 if (ksmsAvail && 395 if (ksmsAvail &&
360 ( 396 (
361 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 397 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
362 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 398 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
363 ) 399 )
364 ) 400 )
365 { 401 {
366 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 402 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
367 .arg( (*phoneIt).number() ); 403 .arg( (*phoneIt).number() );
368 404
369 } 405 }
370 else 406 else
371 sms = ""; 407 sms = "";
372 408
373 extension = QString::null; 409 extension = QString::null;
374 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 410 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
375 if (kfaxAvail) extension = "faxto:"; 411 if (kfaxAvail) extension = "faxto:";
376 } 412 }
377 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 413 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
378 if (kpagerAvail) extension = "pagerto:"; 414 if (kpagerAvail) extension = "pagerto:";
379 } 415 }
380 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { 416 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
381 if (ksipAvail) extension = "sipto:"; 417 if (ksipAvail) extension = "sipto:";
382 } 418 }
383 else if (kphoneAvail) { 419 else if (kphoneAvail) {
384 extension = "phoneto:"; 420 extension = "phoneto:";
385 } 421 }
386 else 422 else
387 extension = QString::null; 423 extension = QString::null;
388 424
389 if ( !extension.isEmpty() ) { 425 if ( !extension.isEmpty() ) {
390 dynamicPart += QString( 426 dynamicPart += QString(
391 "<tr><td align=\"right\"><b>%1</b></td>" 427 "<tr><td align=\"right\"><b>%1</b></td>"
392 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 428 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
393 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 429 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
394 .arg( extension ) 430 .arg( extension )
395 .arg( (*phoneIt).number() ) 431 .arg( (*phoneIt).number() )
396 .arg( (*phoneIt).number() ) 432 .arg( (*phoneIt).number() )
397 .arg( sms ); 433 .arg( sms );
398 434
399 } else { 435 } else {
400 dynamicPart += QString( 436 dynamicPart += QString(
401 "<tr><td align=\"right\"><b>%1</b></td>" 437 "<tr><td align=\"right\"><b>%1</b></td>"
402 "<td align=\"left\">%2 %3</td></tr>" ) 438 "<td align=\"left\">%2 %3</td></tr>" )
403 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 439 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
404 .arg( (*phoneIt).number() ) 440 .arg( (*phoneIt).number() )
405 .arg( sms ); 441 .arg( sms );
406 } 442 }
407 } 443 }
408 return dynamicPart; 444 return dynamicPart;
409} 445}
410/* 446/*
411KABC::Addressee AddresseeView::addressee() const 447KABC::Addressee AddresseeView::addressee() const
412{ 448{
413 return mAddressee; 449 return mAddressee;
414} 450}
415*/ 451*/
416void AddresseeView::addTag(const QString & tag,const QString & text) 452void AddresseeView::addTag(const QString & tag,const QString & text)
417{ 453{
418 if ( text.isEmpty() ) 454 if ( text.isEmpty() )
419 return; 455 return;
420 int number=text.contains("\n"); 456 int number=text.contains("\n");
421 QString str = "<" + tag + ">"; 457 QString str = "<" + tag + ">";
422 QString tmpText=text; 458 QString tmpText=text;
423 QString tmpStr=str; 459 QString tmpStr=str;
424 if(number !=-1) 460 if(number !=-1)
425 { 461 {
426 if (number > 0) { 462 if (number > 0) {
427 int pos=0; 463 int pos=0;
428 QString tmp; 464 QString tmp;
429 for(int i=0;i<=number;i++) { 465 for(int i=0;i<=number;i++) {
430 pos=tmpText.find("\n"); 466 pos=tmpText.find("\n");
431 tmp=tmpText.left(pos); 467 tmp=tmpText.left(pos);
432 tmpText=tmpText.right(tmpText.length()-pos-1); 468 tmpText=tmpText.right(tmpText.length()-pos-1);
433 tmpStr+=tmp+"<br>"; 469 tmpStr+=tmp+"<br>";
434 } 470 }
435 } 471 }
436 else tmpStr += tmpText; 472 else tmpStr += tmpText;
437 tmpStr+="</" + tag + ">"; 473 tmpStr+="</" + tag + ">";
438 mText.append(tmpStr); 474 mText.append(tmpStr);
439 } 475 }
440 else 476 else
441 { 477 {
442 str += text + "</" + tag + ">"; 478 str += text + "</" + tag + ">";
443 mText.append(str); 479 mText.append(str);
444 } 480 }
445} 481}
446 482
447AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, 483AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
448 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) 484 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false)
449{ 485{
450 findButton( Close )->setText( i18n("Cancel Sync")); 486 findButton( Close )->setText( i18n("Cancel Sync"));
451 findButton( Ok )->setText( i18n("Remote")); 487 findButton( Ok )->setText( i18n("Remote"));
452 findButton( User1 )->setText( i18n("Local")); 488 findButton( User1 )->setText( i18n("Local"));
453 QWidget* topframe = new QWidget( this ); 489 QWidget* topframe = new QWidget( this );
454 setMainWidget( topframe ); 490 setMainWidget( topframe );
455 QBoxLayout* bl; 491 QBoxLayout* bl;
456 if ( QApplication::desktop()->width() < 640 ) { 492 if ( QApplication::desktop()->width() < 640 ) {
457 bl = new QVBoxLayout( topframe ); 493 bl = new QVBoxLayout( topframe );
458 } else { 494 } else {
459 bl = new QHBoxLayout( topframe ); 495 bl = new QHBoxLayout( topframe );
460 } 496 }
461 QVBox* subframe = new QVBox( topframe ); 497 QVBox* subframe = new QVBox( topframe );
462 bl->addWidget(subframe ); 498 bl->addWidget(subframe );
463 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); 499 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
464 if ( takeloc ) 500 if ( takeloc )
465 lab->setBackgroundColor(Qt::green.light() ); 501 lab->setBackgroundColor(Qt::green.light() );
466 AddresseeView * av = new AddresseeView( subframe ); 502 AddresseeView * av = new AddresseeView( subframe );
467 av->setAddressee( loc ); 503 av->setAddressee( loc );
468 subframe = new QVBox( topframe ); 504 subframe = new QVBox( topframe );
469 bl->addWidget(subframe ); 505 bl->addWidget(subframe );
470 lab = new QLabel( i18n("Remote Addressee"), subframe ); 506 lab = new QLabel( i18n("Remote Addressee"), subframe );
471 if ( !takeloc ) 507 if ( !takeloc )
472 lab->setBackgroundColor(Qt::green.light() ); 508 lab->setBackgroundColor(Qt::green.light() );
473 av = new AddresseeView( subframe ); 509 av = new AddresseeView( subframe );
474 av->setAddressee( rem ); 510 av->setAddressee( rem );
475 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 511 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
476 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 512 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
477#ifndef DESKTOP_VERSION 513#ifndef DESKTOP_VERSION
478 showMaximized(); 514 showMaximized();
479#else 515#else
480 resize ( 640, 400 ); 516 resize ( 640, 400 );
481#endif 517#endif
482} 518}
483 519
484int AddresseeChooser::executeD( bool local ) 520int AddresseeChooser::executeD( bool local )
485{ 521{
486 mSyncResult = 3; 522 mSyncResult = 3;
487 if ( local ) 523 if ( local )
488 findButton( User1 )->setFocus(); 524 findButton( User1 )->setFocus();
489 else 525 else
490 findButton( Ok )->setFocus(); 526 findButton( Ok )->setFocus();
491 exec(); 527 exec();
492 return mSyncResult; 528 return mSyncResult;
493} 529}
494void AddresseeChooser::slot_remote() 530void AddresseeChooser::slot_remote()
495{ 531{
496 mSyncResult = 2; 532 mSyncResult = 2;
497 accept(); 533 accept();
498} 534}
499void AddresseeChooser::slot_local() 535void AddresseeChooser::slot_local()
500{ 536{
501 mSyncResult = 1; 537 mSyncResult = 1;
502 accept(); 538 accept();
503} 539}