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