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