author | zautrix <zautrix> | 2005-01-18 14:09:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-18 14:09:00 (UTC) |
commit | ced210b0c4643ddac6a2e80eab4c85c1994b20e0 (patch) (unidiff) | |
tree | 5126b599b1213553ae71512a400f46d7b2037d92 /kaddressbook/imagewidget.cpp | |
parent | 4b82a36d1b2479dd2e6f00aef45af848f6793099 (diff) | |
download | kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.zip kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.gz kdepimpi-ced210b0c4643ddac6a2e80eab4c85c1994b20e0.tar.bz2 |
ab sync fixes
Diffstat (limited to 'kaddressbook/imagewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/imagewidget.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 1e9743c..d0f52ea 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -146,166 +146,167 @@ ImageWidget::~ImageWidget() | |||
146 | { | 146 | { |
147 | } | 147 | } |
148 | 148 | ||
149 | void ImageWidget::setPhoto( const KABC::Picture &photo ) | 149 | void ImageWidget::setPhoto( const KABC::Picture &photo ) |
150 | { | 150 | { |
151 | bool blocked = signalsBlocked(); | 151 | bool blocked = signalsBlocked(); |
152 | blockSignals( true ); | 152 | blockSignals( true ); |
153 | 153 | ||
154 | if ( photo.isIntern() ) { | 154 | if ( photo.isIntern() ) { |
155 | //US | 155 | //US |
156 | //US mPhotoLabel->setPixmap( photo.data() ); | 156 | //US mPhotoLabel->setPixmap( photo.data() ); |
157 | if (photo.data().isNull() != true) | 157 | if (photo.data().isNull() != true) |
158 | { | 158 | { |
159 | QPixmap pm; | 159 | QPixmap pm; |
160 | pm.convertFromImage(photo.data()); | 160 | pm.convertFromImage(photo.data()); |
161 | 161 | ||
162 | mPhotoLabel->setPixmap( pm ); | 162 | mPhotoLabel->setPixmap( pm ); |
163 | } | 163 | } |
164 | 164 | ||
165 | mUsePhotoUrl->setChecked( false ); | 165 | mUsePhotoUrl->setChecked( false ); |
166 | } else { | 166 | } else { |
167 | mPhotoUrl->setURL( photo.url() ); | 167 | mPhotoUrl->setURL( photo.url() ); |
168 | if ( !photo.url().isEmpty() ) | 168 | if ( !photo.url().isEmpty() ) |
169 | mUsePhotoUrl->setChecked( true ); | 169 | mUsePhotoUrl->setChecked( true ); |
170 | loadPhoto(); | 170 | loadPhoto(); |
171 | } | 171 | } |
172 | 172 | ||
173 | blockSignals( blocked ); | 173 | blockSignals( blocked ); |
174 | } | 174 | } |
175 | 175 | ||
176 | KABC::Picture ImageWidget::photo() const | 176 | KABC::Picture ImageWidget::photo() const |
177 | { | 177 | { |
178 | KABC::Picture photo; | 178 | KABC::Picture photo; |
179 | 179 | ||
180 | if ( mUsePhotoUrl->isChecked() ) | 180 | if ( mUsePhotoUrl->isChecked() ) |
181 | photo.setUrl( mPhotoUrl->url() ); | 181 | photo.setUrl( mPhotoUrl->url() ); |
182 | else { | 182 | else { |
183 | QPixmap *px = mPhotoLabel->pixmap(); | 183 | QPixmap *px = mPhotoLabel->pixmap(); |
184 | if ( px ) { | 184 | if ( px ) { |
185 | #ifndef KAB_EMBEDDED | 185 | #ifndef KAB_EMBEDDED |
186 | if ( px->height() > px->width() ) | 186 | if ( px->height() > px->width() ) |
187 | photo.setData( px->convertToImage().scaleHeight( 140 ) ); | 187 | photo.setData( px->convertToImage().scaleHeight( 140 ) ); |
188 | else | 188 | else |
189 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); | 189 | photo.setData( px->convertToImage().scaleWidth( 100 ) ); |
190 | #else //KAB_EMBEDDED | 190 | #else //KAB_EMBEDDED |
191 | //US add teh nullcheck | 191 | //US add teh nullcheck |
192 | if (px->isNull() != true ) | 192 | if (px->isNull() != true ) |
193 | photo.setData( px->convertToImage() ); | 193 | photo.setData( px->convertToImage() ); |
194 | #endif //KAB_EMBEDDED | 194 | #endif //KAB_EMBEDDED |
195 | 195 | ||
196 | photo.setType( "PNG" ); | 196 | photo.setType( "PNG" ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | return photo; | 200 | return photo; |
201 | } | 201 | } |
202 | 202 | ||
203 | void ImageWidget::setLogo( const KABC::Picture &logo ) | 203 | void ImageWidget::setLogo( const KABC::Picture &logo ) |
204 | { | 204 | { |
205 | bool blocked = signalsBlocked(); | 205 | bool blocked = signalsBlocked(); |
206 | blockSignals( true ); | 206 | blockSignals( true ); |
207 | 207 | ||
208 | if ( logo.isIntern() ) { | 208 | if ( logo.isIntern() ) { |
209 | //US | 209 | //US |
210 | //US mLogoLabel->setPixmap( logo.data() ); | 210 | //US mLogoLabel->setPixmap( logo.data() ); |
211 | if (logo.data().isNull() != true) | 211 | if (logo.data().isNull() != true) |
212 | { | 212 | { |
213 | QPixmap pm; | 213 | QPixmap pm; |
214 | pm.convertFromImage(logo.data()); | 214 | pm.convertFromImage(logo.data()); |
215 | mLogoLabel->setPixmap( pm ); | 215 | mLogoLabel->setPixmap( pm ); |
216 | } | 216 | } |
217 | mUseLogoUrl->setChecked( false ); | 217 | mUseLogoUrl->setChecked( false ); |
218 | } else { | 218 | } else { |
219 | mLogoUrl->setURL( logo.url() ); | 219 | mLogoUrl->setURL( logo.url() ); |
220 | if ( !logo.url().isEmpty() ) | 220 | if ( !logo.url().isEmpty() ) |
221 | mUseLogoUrl->setChecked( true ); | 221 | mUseLogoUrl->setChecked( true ); |
222 | loadLogo(); | 222 | loadLogo(); |
223 | } | 223 | } |
224 | 224 | ||
225 | blockSignals( blocked ); | 225 | blockSignals( blocked ); |
226 | } | 226 | } |
227 | 227 | ||
228 | KABC::Picture ImageWidget::logo() const | 228 | KABC::Picture ImageWidget::logo() const |
229 | { | 229 | { |
230 | KABC::Picture logo; | 230 | KABC::Picture logo; |
231 | 231 | ||
232 | if ( mUseLogoUrl->isChecked() ) | 232 | if ( mUseLogoUrl->isChecked() ) |
233 | logo.setUrl( mLogoUrl->url() ); | 233 | logo.setUrl( mLogoUrl->url() ); |
234 | else { | 234 | else { |
235 | QPixmap *px = mLogoLabel->pixmap(); | 235 | QPixmap *px = mLogoLabel->pixmap(); |
236 | if ( px ) { | 236 | if ( px ) { |
237 | #ifndef KAB_EMBEDDED | 237 | #ifndef KAB_EMBEDDED |
238 | if ( px->height() > px->width() ) | 238 | if ( px->height() > px->width() ) |
239 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); | 239 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); |
240 | else | 240 | else |
241 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); | 241 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); |
242 | #else //KAB_EMBEDDED | 242 | #else //KAB_EMBEDDED |
243 | logo.setData( px->convertToImage() ); | 243 | if (px->isNull() != true ) |
244 | logo.setData( px->convertToImage() ); | ||
244 | #endif //KAB_EMBEDDED | 245 | #endif //KAB_EMBEDDED |
245 | 246 | ||
246 | logo.setType( "PNG" ); | 247 | logo.setType( "PNG" ); |
247 | 248 | ||
248 | } | 249 | } |
249 | } | 250 | } |
250 | return logo; | 251 | return logo; |
251 | } | 252 | } |
252 | void ImageWidget::removePhoto() | 253 | void ImageWidget::removePhoto() |
253 | { | 254 | { |
254 | setPhoto(KABC::Picture() ); | 255 | setPhoto(KABC::Picture() ); |
255 | } | 256 | } |
256 | 257 | ||
257 | void ImageWidget::removeLogo() | 258 | void ImageWidget::removeLogo() |
258 | { | 259 | { |
259 | setLogo(KABC::Picture() ); | 260 | setLogo(KABC::Picture() ); |
260 | } | 261 | } |
261 | 262 | ||
262 | void ImageWidget::loadPhoto() | 263 | void ImageWidget::loadPhoto() |
263 | { | 264 | { |
264 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); | 265 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); |
265 | } | 266 | } |
266 | 267 | ||
267 | void ImageWidget::loadLogo() | 268 | void ImageWidget::loadLogo() |
268 | { | 269 | { |
269 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); | 270 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); |
270 | } | 271 | } |
271 | 272 | ||
272 | void ImageWidget::updateGUI() | 273 | void ImageWidget::updateGUI() |
273 | { | 274 | { |
274 | KURLRequester *ptr = (KURLRequester*)sender(); | 275 | KURLRequester *ptr = (KURLRequester*)sender(); |
275 | 276 | ||
276 | 277 | ||
277 | if ( ptr == mPhotoUrl ) | 278 | if ( ptr == mPhotoUrl ) |
278 | mUsePhotoUrl->setEnabled( true ); | 279 | mUsePhotoUrl->setEnabled( true ); |
279 | else if ( ptr == mLogoUrl ) | 280 | else if ( ptr == mLogoUrl ) |
280 | mUseLogoUrl->setEnabled( true ); | 281 | mUseLogoUrl->setEnabled( true ); |
281 | } | 282 | } |
282 | 283 | ||
283 | QPixmap ImageWidget::loadPixmap( const KURL &url ) | 284 | QPixmap ImageWidget::loadPixmap( const KURL &url ) |
284 | { | 285 | { |
285 | QString tempFile; | 286 | QString tempFile; |
286 | QPixmap pixmap; | 287 | QPixmap pixmap; |
287 | 288 | ||
288 | if ( url.isEmpty() ) | 289 | if ( url.isEmpty() ) |
289 | return pixmap; | 290 | return pixmap; |
290 | 291 | ||
291 | if ( url.isLocalFile() ) | 292 | if ( url.isLocalFile() ) |
292 | pixmap = QPixmap( url.path() ); | 293 | pixmap = QPixmap( url.path() ); |
293 | else | 294 | else |
294 | { | 295 | { |
295 | #ifndef KAB_EMBEDDED | 296 | #ifndef KAB_EMBEDDED |
296 | if ( KIO::NetAccess::download( url, tempFile ) ) { | 297 | if ( KIO::NetAccess::download( url, tempFile ) ) { |
297 | pixmap = QPixmap( tempFile ); | 298 | pixmap = QPixmap( tempFile ); |
298 | KIO::NetAccess::removeTempFile( tempFile ); | 299 | KIO::NetAccess::removeTempFile( tempFile ); |
299 | } | 300 | } |
300 | #else //KAB_EMBEDDED | 301 | #else //KAB_EMBEDDED |
301 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); | 302 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); |
302 | #endif //KAB_EMBEDDED | 303 | #endif //KAB_EMBEDDED |
303 | 304 | ||
304 | } | 305 | } |
305 | 306 | ||
306 | return pixmap; | 307 | return pixmap; |
307 | } | 308 | } |
308 | 309 | ||
309 | #ifndef KAB_EMBEDDED | 310 | #ifndef KAB_EMBEDDED |
310 | #include "imagewidget.moc" | 311 | #include "imagewidget.moc" |
311 | #endif //KAB_EMBEDDED | 312 | #endif //KAB_EMBEDDED |