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