author | zautrix <zautrix> | 2005-06-26 10:43:45 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-26 10:43:45 (UTC) |
commit | 98bc92a09eb27fef0efa9c3dc5e963f7faa0319c (patch) (unidiff) | |
tree | f80716d3e1239054a0a48bec6e9f67dd57e2156a /kabc | |
parent | f27e8c6cc8abbd27f10167334d608c7e0af7f711 (diff) | |
download | kdepimpi-98bc92a09eb27fef0efa9c3dc5e963f7faa0319c.zip kdepimpi-98bc92a09eb27fef0efa9c3dc5e963f7faa0319c.tar.gz kdepimpi-98bc92a09eb27fef0efa9c3dc5e963f7faa0319c.tar.bz2 |
details addressee better
-rw-r--r-- | kabc/addresseeview.cpp | 200 | ||||
-rw-r--r-- | kabc/addresseeview.h | 5 |
2 files changed, 169 insertions, 36 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 667a5e2..202a718 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -1,492 +1,624 @@ | |||
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 | 60 | ||
60 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 61 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
61 | : QTextBrowser( parent, name ) | 62 | : QTextBrowser( parent, name ) |
62 | 63 | ||
63 | 64 | ||
64 | { | 65 | { |
65 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 66 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
66 | setLinkUnderline( false ); | 67 | setLinkUnderline( false ); |
67 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 68 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
68 | //setHScrollBarMode( QScrollView::AlwaysOff ); | 69 | //setHScrollBarMode( QScrollView::AlwaysOff ); |
69 | 70 | ||
70 | //US QStyleSheet *sheet = styleSheet(); | 71 | //US QStyleSheet *sheet = styleSheet(); |
71 | //US QStyleSheetItem *link = sheet->item( "a" ); | 72 | //US QStyleSheetItem *link = sheet->item( "a" ); |
72 | //US link->setColor( KGlobalSettings::linkColor() ); | 73 | //US link->setColor( KGlobalSettings::linkColor() ); |
73 | 74 | ||
74 | 75 | ||
75 | } | 76 | } |
76 | void AddresseeView::printMe() | 77 | void AddresseeView::printMe() |
77 | { | 78 | { |
78 | #ifdef DESKTOP_VERSION | 79 | #ifdef DESKTOP_VERSION |
79 | QPrinter printer; | 80 | QPrinter printer; |
80 | if (!printer.setup() ) | 81 | if (!printer.setup() ) |
81 | return; | 82 | return; |
82 | QPainter p; | 83 | QPainter p; |
83 | p.begin ( &printer ); | 84 | p.begin ( &printer ); |
84 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 85 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
85 | float dx, dy; | 86 | float dx, dy; |
86 | int wid = (m.width() * 9)/10; | 87 | int wid = (m.width() * 9)/10; |
87 | dx = (float) wid/(float)contentsWidth (); | 88 | dx = (float) wid/(float)contentsWidth (); |
88 | dy = (float)(m.height()) / (float)contentsHeight (); | 89 | dy = (float)(m.height()) / (float)contentsHeight (); |
89 | float scale; | 90 | float scale; |
90 | // scale to fit the width or height of the paper | 91 | // scale to fit the width or height of the paper |
91 | if ( dx < dy ) | 92 | if ( dx < dy ) |
92 | scale = dx; | 93 | scale = dx; |
93 | else | 94 | else |
94 | scale = dy; | 95 | scale = dy; |
95 | p.translate( m.width()/10,0 ); | 96 | p.translate( m.width()/10,0 ); |
96 | p.scale( scale, scale ); | 97 | p.scale( scale, scale ); |
97 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 98 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
98 | p.end(); | 99 | p.end(); |
99 | #endif | 100 | #endif |
100 | } | 101 | } |
101 | void AddresseeView::setSource(const QString& n) | 102 | void AddresseeView::setSource(const QString& n) |
102 | { | 103 | { |
103 | //qDebug("********AddresseeView::setSource %s", n.latin1()); | 104 | qDebug("********AddresseeView::setSource %s", n.latin1()); |
104 | 105 | ||
105 | if ( n.left( 6 ) == "mailto" ) | 106 | if ( n == "allDetails" ) { |
106 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 107 | sFullDetailsMode = true; |
107 | else if ( n.left( 7 ) == "phoneto" ) | 108 | setAddressee( mCurrentContact ); |
108 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); | 109 | } else if ( n == "notAllDetails" ) { |
109 | else if ( n.left( 5 ) == "faxto" ) | 110 | sFullDetailsMode = false; |
110 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); | 111 | setAddressee( mCurrentContact ); |
111 | else if ( n.left( 5 ) == "smsto" ) | 112 | } else if ( n.left( 6 ) == "mailto" ) |
112 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | 113 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
113 | else if ( n.left( 7 ) == "pagerto" ) | 114 | else if ( n.left( 7 ) == "phoneto" ) |
114 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | 115 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); |
115 | else if ( n.left( 5 ) == "sipto" ) | 116 | else if ( n.left( 5 ) == "faxto" ) |
116 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | 117 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); |
118 | else if ( n.left( 5 ) == "smsto" ) | ||
119 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | ||
120 | else if ( n.left( 7 ) == "pagerto" ) | ||
121 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | ||
122 | else if ( n.left( 5 ) == "sipto" ) | ||
123 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | ||
117 | 124 | ||
118 | } | 125 | } |
119 | void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | 126 | void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) |
120 | { | 127 | { |
121 | bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); | 128 | bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); |
122 | // mAddressee = addr; | 129 | // mAddressee = addr; |
123 | // clear view | 130 | // clear view |
124 | //setText( QString::null ); | 131 | //setText( QString::null ); |
125 | 132 | mCurrentContact = mAddressee; | |
126 | if ( mAddressee.isEmpty() ) { | 133 | if ( mAddressee.isEmpty() ) { |
127 | setText( QString::null); | 134 | setText( QString::null); |
128 | return; | 135 | return; |
129 | } | 136 | } |
130 | #if 0 | 137 | #if 0 |
131 | QString name = ( mAddressee.assembledName().isEmpty() ? | 138 | QString name = ( mAddressee.assembledName().isEmpty() ? |
132 | mAddressee.formattedName() : mAddressee.assembledName() ); | 139 | mAddressee.formattedName() : mAddressee.assembledName() ); |
133 | #endif | 140 | #endif |
134 | 141 | ||
135 | QString name = mAddressee.realName(); | 142 | QString name = mAddressee.realName(); |
136 | 143 | ||
137 | QString dynamicPart; | 144 | QString dynamicPart; |
138 | 145 | ||
139 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); | 146 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); |
140 | QStringList emails = mAddressee.emails(); | 147 | QStringList emails = mAddressee.emails(); |
141 | QStringList::ConstIterator emailIt; | 148 | QStringList::ConstIterator emailIt; |
142 | QString type = i18n( "Email" ); | 149 | QString type = i18n( "Email" ); |
143 | emailIt = emails.begin(); | 150 | emailIt = emails.begin(); |
144 | if ( emailIt != emails.end() ) { | 151 | if ( emailIt != emails.end() ) { |
145 | if ( kemailAvail ) { | 152 | if ( kemailAvail ) { |
146 | dynamicPart += QString( | 153 | dynamicPart += QString( |
147 | "<tr><td align=\"right\"><b>%1</b></td>" | 154 | "<tr><td align=\"right\"><b>%1</b></td>" |
148 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 155 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
149 | .arg( type ) | 156 | .arg( type ) |
150 | .arg( name ) | 157 | .arg( name ) |
151 | .arg( *emailIt ) | 158 | .arg( *emailIt ) |
152 | .arg( *emailIt ); | 159 | .arg( *emailIt ); |
153 | ++emailIt; | 160 | ++emailIt; |
154 | } else { | 161 | } else { |
155 | dynamicPart += QString( | 162 | dynamicPart += QString( |
156 | "<tr><td align=\"right\"><b>%1</b></td>" | 163 | "<tr><td align=\"right\"><b>%1</b></td>" |
157 | "<td align=\"left\">%2</td></tr>" ) | 164 | "<td align=\"left\">%2</td></tr>" ) |
158 | .arg( type ) | 165 | .arg( type ) |
159 | .arg( *emailIt ); | 166 | .arg( *emailIt ); |
160 | ++emailIt; | 167 | ++emailIt; |
161 | } | 168 | } |
162 | } | 169 | } |
163 | if ( mAddressee.birthday().date().isValid() ) { | 170 | if ( mAddressee.birthday().date().isValid() ) { |
164 | dynamicPart += QString( | 171 | dynamicPart += QString( |
165 | "<tr><td align=\"right\"><b>%1</b></td>" | 172 | "<tr><td align=\"right\"><b>%1</b></td>" |
166 | "<td align=\"left\">%2</td></tr>" ) | 173 | "<td align=\"left\">%2</td></tr>" ) |
167 | .arg( i18n ("Birthday") ) | 174 | .arg( i18n ("Birthday") ) |
168 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); | 175 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); |
169 | } | 176 | } |
170 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); | 177 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); |
171 | 178 | ||
172 | for ( ; emailIt != emails.end(); ++emailIt ) { | 179 | for ( ; emailIt != emails.end(); ++emailIt ) { |
173 | if ( kemailAvail ) { | 180 | if ( kemailAvail ) { |
174 | dynamicPart += QString( | 181 | dynamicPart += QString( |
175 | "<tr><td align=\"right\"><b>%1</b></td>" | 182 | "<tr><td align=\"right\"><b>%1</b></td>" |
176 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 183 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
177 | .arg( type ) | 184 | .arg( type ) |
178 | .arg( name ) | 185 | .arg( name ) |
179 | .arg( *emailIt ) | 186 | .arg( *emailIt ) |
180 | .arg( *emailIt ); | 187 | .arg( *emailIt ); |
181 | } else { | 188 | } else { |
182 | dynamicPart += QString( | 189 | dynamicPart += QString( |
183 | "<tr><td align=\"right\"><b>%1</b></td>" | 190 | "<tr><td align=\"right\"><b>%1</b></td>" |
184 | "<td align=\"left\">%2</td></tr>" ) | 191 | "<td align=\"left\">%2</td></tr>" ) |
185 | .arg( type ) | 192 | .arg( type ) |
186 | .arg( *emailIt ); | 193 | .arg( *emailIt ); |
187 | } | 194 | } |
188 | } | 195 | } |
189 | 196 | ||
190 | if ( !mAddressee.url().url().isEmpty() ) { | 197 | |
191 | dynamicPart += QString( | ||
192 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
193 | "<td align=\"left\">%2</td></tr>" ) | ||
194 | .arg( i18n( "Homepage" ) ) | ||
195 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); | ||
196 | .arg( mAddressee.url().url() ); | ||
197 | //qDebug("AddresseeView::setAddressee has to be verified."); | ||
198 | } | ||
199 | 198 | ||
200 | KABC::Address::List addresses = mAddressee.addresses(); | 199 | KABC::Address::List addresses = mAddressee.addresses(); |
201 | KABC::Address::List::ConstIterator addrIt; | 200 | KABC::Address::List::ConstIterator addrIt; |
202 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { | 201 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { |
203 | if ( true /*(*addrIt).label().isEmpty()*/ ) { | 202 | if ( true /*(*addrIt).label().isEmpty()*/ ) { |
204 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); | 203 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); |
205 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); | 204 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); |
206 | //qDebug("adresss %s ",formattedAddress.latin1() ); | 205 | //qDebug("adresss %s ",formattedAddress.latin1() ); |
207 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); | 206 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); |
208 | //qDebug("AddresseeView::setAddressee has to be verified."); | 207 | //qDebug("AddresseeView::setAddressee has to be verified."); |
209 | 208 | ||
210 | dynamicPart += QString( | 209 | dynamicPart += QString( |
211 | "<tr><td align=\"right\"><b>%1</b></td>" | 210 | "<tr><td align=\"right\"><b>%1</b></td>" |
212 | "<td align=\"left\">%2</td></tr>" ) | 211 | "<td align=\"left\">%2</td></tr>" ) |
213 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 212 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
214 | .arg( formattedAddress ); | 213 | .arg( formattedAddress ); |
215 | } else { | 214 | } else { |
216 | 215 | ||
217 | dynamicPart += QString( | 216 | dynamicPart += QString( |
218 | "<tr><td align=\"right\"><b>%1</b></td>" | 217 | "<tr><td align=\"right\"><b>%1</b></td>" |
219 | "<td align=\"left\">%2</td></tr>" ) | 218 | "<td align=\"left\">%2</td></tr>" ) |
220 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 219 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
221 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); | 220 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); |
222 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); | 221 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); |
223 | 222 | ||
224 | } | 223 | } |
225 | } | 224 | } |
225 | |||
226 | |||
227 | QString notes; | ||
228 | if ( sFullDetailsMode ) { | ||
229 | notes = QString( | ||
230 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
231 | "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" ) | ||
232 | .arg( i18n("Details:") ) | ||
233 | .arg( i18n("Click here to hide!") ); | ||
234 | |||
235 | QString tempX = mAddressee.secrecy().asString(); | ||
236 | |||
237 | notes += QString( | ||
238 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
239 | "<td align=\"left\">%2</td></tr>" ) | ||
240 | .arg( "" ) | ||
241 | .arg( tempX ); | ||
242 | |||
243 | |||
244 | tempX = mAddressee.categories().join(" - "); | ||
245 | if ( !tempX.isEmpty() ) { | ||
246 | notes += QString( | ||
247 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
248 | "<td align=\"left\">%2</td></tr>" ) | ||
249 | .arg( i18n( "Category" ) ) | ||
250 | .arg( tempX ); | ||
251 | } | ||
252 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Profession" ); | ||
253 | if ( !tempX.isEmpty() ) { | ||
254 | notes += QString( | ||
255 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
256 | "<td align=\"left\">%2</td></tr>" ) | ||
257 | .arg( i18n( "Profession" ) ) | ||
258 | .arg( tempX ); | ||
259 | } | ||
260 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Office" ); | ||
261 | if ( !tempX.isEmpty() ) { | ||
262 | notes += QString( | ||
263 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
264 | "<td align=\"left\">%2</td></tr>" ) | ||
265 | .arg( i18n( "Office" ) ) | ||
266 | .arg( tempX ); | ||
267 | } | ||
268 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Department" ); | ||
269 | if ( !tempX.isEmpty() ) { | ||
270 | notes += QString( | ||
271 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
272 | "<td align=\"left\">%2</td></tr>" ) | ||
273 | .arg( i18n( "Department" ) ) | ||
274 | .arg( tempX ); | ||
275 | } | ||
276 | |||
277 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ); | ||
278 | if ( !tempX.isEmpty() ) { | ||
279 | notes += QString( | ||
280 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
281 | "<td align=\"left\">%2</td></tr>" ) | ||
282 | .arg( i18n( "Manager" ) ) | ||
283 | .arg( tempX ); | ||
284 | } | ||
285 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); | ||
286 | if ( !tempX.isEmpty() ) { | ||
287 | notes += QString( | ||
288 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
289 | "<td align=\"left\">%2</td></tr>" ) | ||
290 | .arg( i18n( "Assistant" ) ) | ||
291 | .arg( tempX ); | ||
292 | } | ||
293 | if ( !mAddressee.url().url().isEmpty() ) { | ||
294 | notes += QString( | ||
295 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
296 | "<td align=\"left\">%2</td></tr>" ) | ||
297 | .arg( i18n( "Homepage" ) ) | ||
298 | .arg( mAddressee.url().url() ); | ||
299 | } | ||
300 | tempX = mAddressee.nickName(); | ||
301 | if ( !tempX.isEmpty() ) { | ||
302 | notes += QString( | ||
303 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
304 | "<td align=\"left\">%2</td></tr>" ) | ||
305 | .arg( i18n( "Nickname" ) ) | ||
306 | .arg( tempX ); | ||
307 | } | ||
308 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ); | ||
309 | if ( !tempX.isEmpty() ) { | ||
310 | notes += QString( | ||
311 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
312 | "<td align=\"left\">%2</td></tr>" ) | ||
313 | .arg( i18n( "Messanger" ) ) | ||
314 | .arg( tempX ); | ||
315 | } | ||
316 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); | ||
317 | if ( !tempX.isEmpty() ) { | ||
318 | notes += QString( | ||
319 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
320 | "<td align=\"left\">%2</td></tr>" ) | ||
321 | .arg( i18n( "Gender" ) ) | ||
322 | .arg( i18n(tempX) ); | ||
323 | } | ||
324 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" ); | ||
325 | if ( !tempX.isEmpty() ) { | ||
326 | QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d"); | ||
327 | tempX = KGlobal::locale()->formatDate(dt, true); | ||
328 | notes += QString( | ||
329 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
330 | "<td align=\"left\">%2</td></tr>" ) | ||
331 | .arg( i18n( "Anniversary" ) ) | ||
332 | .arg( tempX ); | ||
333 | } | ||
334 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ); | ||
335 | if ( !tempX.isEmpty() ) { | ||
336 | notes += QString( | ||
337 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
338 | "<td align=\"left\">%2</td></tr>" ) | ||
339 | .arg( i18n( "Spouse" ) ) | ||
340 | .arg( tempX ); | ||
341 | } | ||
342 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" ); | ||
343 | if ( !tempX.isEmpty() ) { | ||
344 | notes += QString( | ||
345 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
346 | "<td align=\"left\">%2</td></tr>" ) | ||
347 | .arg( i18n( "Children" ) ) | ||
348 | .arg( tempX ); | ||
349 | } | ||
350 | |||
351 | if ( !mAddressee.note().isEmpty() ) { | ||
352 | notes += QString( | ||
353 | "<tr>" | ||
354 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | ||
355 | "<td align=\"left\">%2</td>" // note | ||
356 | "</tr>" ).arg( i18n( "Notes" ) ) | ||
357 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | ||
358 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | ||
359 | //qDebug("AddresseeView::setAddressee has to be verified."); | ||
360 | } | ||
361 | } else { | ||
362 | notes = QString( | ||
363 | "<tr><td align=\"right\"><b>%1</b></td>" | ||
364 | "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" ) | ||
365 | .arg( i18n("Details:") ) | ||
366 | .arg( i18n("Click here to show!") ); | ||
367 | |||
226 | 368 | ||
227 | QString notes; | ||
228 | if ( !mAddressee.note().isEmpty() ) { | ||
229 | notes = QString( | ||
230 | "<tr>" | ||
231 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | ||
232 | "<td align=\"left\">%2</td>" // note | ||
233 | "</tr>" ).arg( i18n( "Notes" ) ) | ||
234 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | ||
235 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | ||
236 | //qDebug("AddresseeView::setAddressee has to be verified."); | ||
237 | } | 369 | } |
238 | 370 | ||
239 | QString aRole = ""; | 371 | QString aRole = ""; |
240 | QString aOrga = ""; | 372 | QString aOrga = ""; |
241 | if ( true /*!mAddressee.role().isEmpty()*/ ) { | 373 | if ( true /*!mAddressee.role().isEmpty()*/ ) { |
242 | aRole = "<tr>" | 374 | aRole = "<tr>" |
243 | "<td align=\"left\">" + mAddressee.role() + "</td>" | 375 | "<td align=\"left\">" + mAddressee.role() + "</td>" |
244 | "</tr>"; | 376 | "</tr>"; |
245 | } | 377 | } |
246 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { | 378 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { |
247 | aOrga = "<tr>" | 379 | aOrga = "<tr>" |
248 | "<td align=\"left\">" + mAddressee.organization() + "</td>" | 380 | "<td align=\"left\">" + mAddressee.organization() + "</td>" |
249 | "</tr>"; | 381 | "</tr>"; |
250 | } | 382 | } |
251 | mText = ""; | 383 | mText = ""; |
252 | QString picString = ""; | 384 | QString picString = ""; |
253 | KABC::Picture picture = mAddressee.photo(); | 385 | KABC::Picture picture = mAddressee.photo(); |
254 | bool picAvailintern = false; | 386 | bool picAvailintern = false; |
255 | bool picAvailUrl = false; | 387 | bool picAvailUrl = false; |
256 | if (! picture.undefined() ) { | 388 | if (! picture.undefined() ) { |
257 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); | 389 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); |
258 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); | 390 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); |
259 | } | 391 | } |
260 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { | 392 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { |
261 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; | 393 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; |
262 | if ( picAvailintern ) { | 394 | if ( picAvailintern ) { |
263 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); | 395 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); |
264 | } else { | 396 | } else { |
265 | if ( picAvailUrl ) { | 397 | if ( picAvailUrl ) { |
266 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); | 398 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); |
267 | } else { | 399 | } else { |
268 | if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { | 400 | if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { |
269 | static bool setDefaultImageChildren = false; | 401 | static bool setDefaultImageChildren = false; |
270 | if ( !setDefaultImageChildren ) { | 402 | if ( !setDefaultImageChildren ) { |
271 | QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); | 403 | QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); |
272 | setDefaultImageChildren = true; | 404 | setDefaultImageChildren = true; |
273 | } | 405 | } |
274 | picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; | 406 | picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; |
275 | 407 | ||
276 | } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { | 408 | } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { |
277 | static bool setDefaultImagepouses = false; | 409 | static bool setDefaultImagepouses = false; |
278 | if ( !setDefaultImagepouses ) { | 410 | if ( !setDefaultImagepouses ) { |
279 | QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); | 411 | QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); |
280 | setDefaultImagepouses = true; | 412 | setDefaultImagepouses = true; |
281 | } | 413 | } |
282 | picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; | 414 | picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; |
283 | } else { | 415 | } else { |
284 | QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); | 416 | QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); |
285 | if ( gen == "male" ) { | 417 | if ( gen == "male" ) { |
286 | static bool setDefaultImageMale = false; | 418 | static bool setDefaultImageMale = false; |
287 | if ( !setDefaultImageMale ) { | 419 | if ( !setDefaultImageMale ) { |
288 | QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); | 420 | QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); |
289 | setDefaultImageMale = true; | 421 | setDefaultImageMale = true; |
290 | } | 422 | } |
291 | picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; | 423 | picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; |
292 | 424 | ||
293 | } else if ( gen == "female" ) { | 425 | } else if ( gen == "female" ) { |
294 | static bool setDefaultImageFemale = false; | 426 | static bool setDefaultImageFemale = false; |
295 | if ( !setDefaultImageFemale ) { | 427 | if ( !setDefaultImageFemale ) { |
296 | QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); | 428 | QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); |
297 | setDefaultImageFemale = true; | 429 | setDefaultImageFemale = true; |
298 | } | 430 | } |
299 | picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; | 431 | picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; |
300 | 432 | ||
301 | } else { | 433 | } else { |
302 | static bool setDefaultImage = false; | 434 | static bool setDefaultImage = false; |
303 | if ( !setDefaultImage ) { | 435 | if ( !setDefaultImage ) { |
304 | //qDebug("Setting default pixmap "); | 436 | //qDebug("Setting default pixmap "); |
305 | QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); | 437 | QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); |
306 | setDefaultImage = true; | 438 | setDefaultImage = true; |
307 | } | 439 | } |
308 | picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; | 440 | picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; |
309 | } | 441 | } |
310 | } | 442 | } |
311 | } | 443 | } |
312 | } | 444 | } |
313 | mText = QString::fromLatin1( | 445 | mText = QString::fromLatin1( |
314 | "<html>" | 446 | "<html>" |
315 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color | 447 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color |
316 | "<table>" | 448 | "<table>" |
317 | "<tr>" | 449 | "<tr>" |
318 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" | 450 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" |
319 | "%3" | 451 | "%3" |
320 | "</td>" | 452 | "</td>" |
321 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name | 453 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name |
322 | "</tr>" | 454 | "</tr>" |
323 | "%5" // role | 455 | "%5" // role |
324 | "%6" // organization | 456 | "%6" // organization |
325 | "<td colspan=\"2\"> </td>" | 457 | "<td colspan=\"2\"> </td>" |
326 | "%7" // dynamic part | 458 | "%7" // dynamic part |
327 | "%8" // notes | 459 | "%8" // notes |
328 | "</table>" | 460 | "</table>" |
329 | "</body>" | 461 | "</body>" |
330 | "</html>") | 462 | "</html>") |
331 | //US | 463 | //US |
332 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) | 464 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) |
333 | //US | 465 | //US |
334 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) | 466 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) |
335 | .arg( picString ) | 467 | .arg( picString ) |
336 | .arg( name ) | 468 | .arg( name ) |
337 | .arg( aRole ) | 469 | .arg( aRole ) |
338 | .arg( aOrga ) | 470 | .arg( aOrga ) |
339 | .arg( dynamicPart ) | 471 | .arg( dynamicPart ) |
340 | .arg( notes ); | 472 | .arg( notes ); |
341 | 473 | ||
342 | } else { // no picture! | 474 | } else { // no picture! |
343 | 475 | ||
344 | mText = "<table width=\"100%\">\n"; | 476 | mText = "<table width=\"100%\">\n"; |
345 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 477 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
346 | #ifdef DESKTOP_VERSION | 478 | #ifdef DESKTOP_VERSION |
347 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; | 479 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; |
348 | mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; | 480 | mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; |
349 | #else | 481 | #else |
350 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; | 482 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; |
351 | mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; | 483 | mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; |
352 | #endif | 484 | #endif |
353 | 485 | ||
354 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 486 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
355 | 487 | ||
356 | mText += "<table><td colspan=\"2\"> </td>"; | 488 | mText += "<table><td colspan=\"2\"> </td>"; |
357 | /* | 489 | /* |
358 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" | 490 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" |
359 | "<td align=\"left\"><b>%2</b></td></tr>" ) | 491 | "<td align=\"left\"><b>%2</b></td></tr>" ) |
360 | .arg( i18n(" ") ) | 492 | .arg( i18n(" ") ) |
361 | .arg( name ); | 493 | .arg( name ); |
362 | */ | 494 | */ |
363 | if ( ! mAddressee.role().isEmpty() ) | 495 | if ( ! mAddressee.role().isEmpty() ) |
364 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 496 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
365 | "<td align=\"left\">%2</td></tr>" ) | 497 | "<td align=\"left\">%2</td></tr>" ) |
366 | .arg( i18n(" ") ) | 498 | .arg( i18n(" ") ) |
367 | .arg( mAddressee.role()); | 499 | .arg( mAddressee.role()); |
368 | if ( ! mAddressee.organization().isEmpty() ) | 500 | if ( ! mAddressee.organization().isEmpty() ) |
369 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 501 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
370 | "<td align=\"left\">%2</td></tr>" ) | 502 | "<td align=\"left\">%2</td></tr>" ) |
371 | .arg( i18n(" ") ) | 503 | .arg( i18n(" ") ) |
372 | .arg( mAddressee.organization()); | 504 | .arg( mAddressee.organization()); |
373 | mText += dynamicPart; | 505 | mText += dynamicPart; |
374 | mText += notes; | 506 | mText += notes; |
375 | mText += "</table>"; | 507 | mText += "</table>"; |
376 | 508 | ||
377 | } | 509 | } |
378 | 510 | ||
379 | // at last display it... | 511 | // at last display it... |
380 | setText( mText ); | 512 | setText( mText ); |
381 | 513 | ||
382 | } | 514 | } |
383 | 515 | ||
384 | QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) | 516 | QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) |
385 | { | 517 | { |
386 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | 518 | ExternalAppHandler* eah = ExternalAppHandler::instance(); |
387 | bool kphoneAvail = eah->isPhoneAppAvailable(); | 519 | bool kphoneAvail = eah->isPhoneAppAvailable(); |
388 | bool kfaxAvail = eah->isFaxAppAvailable(); | 520 | bool kfaxAvail = eah->isFaxAppAvailable(); |
389 | bool ksmsAvail = eah->isSMSAppAvailable(); | 521 | bool ksmsAvail = eah->isSMSAppAvailable(); |
390 | bool kpagerAvail = eah->isPagerAppAvailable(); | 522 | bool kpagerAvail = eah->isPagerAppAvailable(); |
391 | bool ksipAvail = eah->isSIPAppAvailable(); | 523 | bool ksipAvail = eah->isSIPAppAvailable(); |
392 | QString dynamicPart; | 524 | QString dynamicPart; |
393 | KABC::PhoneNumber::List::ConstIterator phoneIt; | 525 | KABC::PhoneNumber::List::ConstIterator phoneIt; |
394 | QString extension; | 526 | QString extension; |
395 | int phonetype; | 527 | int phonetype; |
396 | QString sms; | 528 | QString sms; |
397 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { | 529 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { |
398 | phonetype = (*phoneIt).type(); | 530 | phonetype = (*phoneIt).type(); |
399 | if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) | 531 | if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) |
400 | continue; | 532 | continue; |
401 | if (ksmsAvail && | 533 | if (ksmsAvail && |
402 | ( | 534 | ( |
403 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || | 535 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || |
404 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) | 536 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) |
405 | ) | 537 | ) |
406 | ) | 538 | ) |
407 | { | 539 | { |
408 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) | 540 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) |
409 | .arg( (*phoneIt).number() ); | 541 | .arg( (*phoneIt).number() ); |
410 | 542 | ||
411 | } | 543 | } |
412 | else | 544 | else |
413 | sms = ""; | 545 | sms = ""; |
414 | 546 | ||
415 | extension = QString::null; | 547 | extension = QString::null; |
416 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { | 548 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { |
417 | if (kfaxAvail) extension = "faxto:"; | 549 | if (kfaxAvail) extension = "faxto:"; |
418 | } | 550 | } |
419 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { | 551 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { |
420 | if (kpagerAvail) extension = "pagerto:"; | 552 | if (kpagerAvail) extension = "pagerto:"; |
421 | } | 553 | } |
422 | else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { | 554 | else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { |
423 | if (ksipAvail) extension = "sipto:"; | 555 | if (ksipAvail) extension = "sipto:"; |
424 | } | 556 | } |
425 | else if (kphoneAvail) { | 557 | else if (kphoneAvail) { |
426 | extension = "phoneto:"; | 558 | extension = "phoneto:"; |
427 | } | 559 | } |
428 | else | 560 | else |
429 | extension = QString::null; | 561 | extension = QString::null; |
430 | 562 | ||
431 | if ( !extension.isEmpty() ) { | 563 | if ( !extension.isEmpty() ) { |
432 | dynamicPart += QString( | 564 | dynamicPart += QString( |
433 | "<tr><td align=\"right\"><b>%1</b></td>" | 565 | "<tr><td align=\"right\"><b>%1</b></td>" |
434 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) | 566 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) |
435 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | 567 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) |
436 | .arg( extension ) | 568 | .arg( extension ) |
437 | .arg( (*phoneIt).number() ) | 569 | .arg( (*phoneIt).number() ) |
438 | .arg( (*phoneIt).number() ) | 570 | .arg( (*phoneIt).number() ) |
439 | .arg( sms ); | 571 | .arg( sms ); |
440 | 572 | ||
441 | } else { | 573 | } else { |
442 | dynamicPart += QString( | 574 | dynamicPart += QString( |
443 | "<tr><td align=\"right\"><b>%1</b></td>" | 575 | "<tr><td align=\"right\"><b>%1</b></td>" |
444 | "<td align=\"left\">%2 %3</td></tr>" ) | 576 | "<td align=\"left\">%2 %3</td></tr>" ) |
445 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | 577 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) |
446 | .arg( (*phoneIt).number() ) | 578 | .arg( (*phoneIt).number() ) |
447 | .arg( sms ); | 579 | .arg( sms ); |
448 | } | 580 | } |
449 | } | 581 | } |
450 | return dynamicPart; | 582 | return dynamicPart; |
451 | } | 583 | } |
452 | /* | 584 | /* |
453 | KABC::Addressee AddresseeView::addressee() const | 585 | KABC::Addressee AddresseeView::addressee() const |
454 | { | 586 | { |
455 | return mAddressee; | 587 | return mAddressee; |
456 | } | 588 | } |
457 | */ | 589 | */ |
458 | void AddresseeView::addTag(const QString & tag,const QString & text) | 590 | void AddresseeView::addTag(const QString & tag,const QString & text) |
459 | { | 591 | { |
460 | if ( text.isEmpty() ) | 592 | if ( text.isEmpty() ) |
461 | return; | 593 | return; |
462 | int number=text.contains("\n"); | 594 | int number=text.contains("\n"); |
463 | QString str = "<" + tag + ">"; | 595 | QString str = "<" + tag + ">"; |
464 | QString tmpText=text; | 596 | QString tmpText=text; |
465 | QString tmpStr=str; | 597 | QString tmpStr=str; |
466 | if(number !=-1) | 598 | if(number !=-1) |
467 | { | 599 | { |
468 | if (number > 0) { | 600 | if (number > 0) { |
469 | int pos=0; | 601 | int pos=0; |
470 | QString tmp; | 602 | QString tmp; |
471 | for(int i=0;i<=number;i++) { | 603 | for(int i=0;i<=number;i++) { |
472 | pos=tmpText.find("\n"); | 604 | pos=tmpText.find("\n"); |
473 | tmp=tmpText.left(pos); | 605 | tmp=tmpText.left(pos); |
474 | tmpText=tmpText.right(tmpText.length()-pos-1); | 606 | tmpText=tmpText.right(tmpText.length()-pos-1); |
475 | tmpStr+=tmp+"<br>"; | 607 | tmpStr+=tmp+"<br>"; |
476 | } | 608 | } |
477 | } | 609 | } |
478 | else tmpStr += tmpText; | 610 | else tmpStr += tmpText; |
479 | tmpStr+="</" + tag + ">"; | 611 | tmpStr+="</" + tag + ">"; |
480 | mText.append(tmpStr); | 612 | mText.append(tmpStr); |
481 | } | 613 | } |
482 | else | 614 | else |
483 | { | 615 | { |
484 | str += text + "</" + tag + ">"; | 616 | str += text + "</" + tag + ">"; |
485 | mText.append(str); | 617 | mText.append(str); |
486 | } | 618 | } |
487 | } | 619 | } |
488 | 620 | ||
489 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, | 621 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, |
490 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) | 622 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) |
491 | { | 623 | { |
492 | findButton( Close )->setText( i18n("Cancel Sync")); | 624 | findButton( Close )->setText( i18n("Cancel Sync")); |
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index e977d8f..a4de085 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h | |||
@@ -1,81 +1,82 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef KPIM_ADDRESSEEVIEW_H | 22 | #ifndef KPIM_ADDRESSEEVIEW_H |
23 | #define KPIM_ADDRESSEEVIEW_H | 23 | #define KPIM_ADDRESSEEVIEW_H |
24 | 24 | ||
25 | #include <kabc/addressee.h> | 25 | #include <kabc/addressee.h> |
26 | #include <kdialogbase.h> | 26 | #include <kdialogbase.h> |
27 | 27 | ||
28 | //US #include <ktextbrowser.h> | 28 | //US #include <ktextbrowser.h> |
29 | #include <qtextbrowser.h> | 29 | #include <qtextbrowser.h> |
30 | 30 | ||
31 | namespace KABC { | 31 | namespace KABC { |
32 | 32 | ||
33 | //US class AddresseeView : public KTextBrowser | 33 | //US class AddresseeView : public KTextBrowser |
34 | class AddresseeView : public QTextBrowser | 34 | class AddresseeView : public QTextBrowser |
35 | { | 35 | { |
36 | 36 | ||
37 | public: | 37 | public: |
38 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); | 38 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); |
39 | 39 | ||
40 | /** | 40 | /** |
41 | Sets the addressee object. The addressee is displayed immediately. | 41 | Sets the addressee object. The addressee is displayed immediately. |
42 | 42 | ||
43 | @param addr The addressee object. | 43 | @param addr The addressee object. |
44 | */ | 44 | */ |
45 | void setAddressee( const KABC::Addressee& addr ); | 45 | void setAddressee( const KABC::Addressee& addr ); |
46 | void setSource(const QString& n); | 46 | void setSource(const QString& n); |
47 | /** | 47 | /** |
48 | Returns the current addressee object. | 48 | Returns the current addressee object. |
49 | */ | 49 | */ |
50 | //KABC::Addressee addressee() const; | 50 | //KABC::Addressee addressee() const; |
51 | void printMe(); | 51 | void printMe(); |
52 | 52 | static bool sFullDetailsMode; | |
53 | private: | 53 | private: |
54 | Addressee mCurrentContact; | ||
54 | //KABC::Addressee mAddressee; | 55 | //KABC::Addressee mAddressee; |
55 | QString mText; | 56 | QString mText; |
56 | QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); | 57 | QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); |
57 | void addTag(const QString & tag,const QString & text); | 58 | void addTag(const QString & tag,const QString & text); |
58 | //class AddresseeViewPrivate; | 59 | //class AddresseeViewPrivate; |
59 | //AddresseeViewPrivate *d; | 60 | //AddresseeViewPrivate *d; |
60 | }; | 61 | }; |
61 | class AddresseeChooser : public KDialogBase | 62 | class AddresseeChooser : public KDialogBase |
62 | { | 63 | { |
63 | Q_OBJECT | 64 | Q_OBJECT |
64 | 65 | ||
65 | public: | 66 | public: |
66 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); | 67 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); |
67 | 68 | ||
68 | int executeD( bool local ); | 69 | int executeD( bool local ); |
69 | 70 | ||
70 | private: | 71 | private: |
71 | int mSyncResult; | 72 | int mSyncResult; |
72 | 73 | ||
73 | private slots: | 74 | private slots: |
74 | void slot_remote(); | 75 | void slot_remote(); |
75 | void slot_local(); | 76 | void slot_local(); |
76 | 77 | ||
77 | }; | 78 | }; |
78 | 79 | ||
79 | } | 80 | } |
80 | 81 | ||
81 | #endif | 82 | #endif |