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