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