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