author | zautrix <zautrix> | 2005-01-14 11:37:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-14 11:37:40 (UTC) |
commit | 61c95ce0295f1397db6499c5b468a9fb3d32a0f4 (patch) (unidiff) | |
tree | 2bceecc46d42a572adfad7d8e5000d1534642cbd /kaddressbook/imagewidget.cpp | |
parent | a46ecf5ed81460ec9a4e457798e1bf0fb74c5624 (diff) | |
download | kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.zip kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.tar.gz kdepimpi-61c95ce0295f1397db6499c5b468a9fb3d32a0f4.tar.bz2 |
made kapi saving faster
Diffstat (limited to 'kaddressbook/imagewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/imagewidget.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 49d456b..48370e3 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp | |||
@@ -102,68 +102,64 @@ ImageWidget::ImageWidget( QWidget *parent, const char *name ) | |||
102 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); | 102 | mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); |
103 | mUseLogoUrl->setEnabled( false ); | 103 | mUseLogoUrl->setEnabled( false ); |
104 | boxLayout->addWidget( mUseLogoUrl, 1, 1 ); | 104 | boxLayout->addWidget( mUseLogoUrl, 1, 1 ); |
105 | 105 | ||
106 | topLayout->addWidget( logoBox, 1, 0 ); | 106 | topLayout->addWidget( logoBox, 1, 0 ); |
107 | 107 | ||
108 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), | 108 | connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), |
109 | SIGNAL( changed() ) ); | 109 | SIGNAL( changed() ) ); |
110 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 110 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
111 | SLOT( loadPhoto() ) ); | 111 | SLOT( loadPhoto() ) ); |
112 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 112 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
113 | SIGNAL( changed() ) ); | 113 | SIGNAL( changed() ) ); |
114 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), | 114 | connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), |
115 | SLOT( updateGUI() ) ); | 115 | SLOT( updateGUI() ) ); |
116 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), | 116 | connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), |
117 | SIGNAL( changed() ) ); | 117 | SIGNAL( changed() ) ); |
118 | 118 | ||
119 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), | 119 | connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), |
120 | SIGNAL( changed() ) ); | 120 | SIGNAL( changed() ) ); |
121 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 121 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
122 | SLOT( loadLogo() ) ); | 122 | SLOT( loadLogo() ) ); |
123 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 123 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
124 | SIGNAL( changed() ) ); | 124 | SIGNAL( changed() ) ); |
125 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), | 125 | connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), |
126 | SLOT( updateGUI() ) ); | 126 | SLOT( updateGUI() ) ); |
127 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), | 127 | connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), |
128 | SIGNAL( changed() ) ); | 128 | SIGNAL( changed() ) ); |
129 | 129 | ||
130 | #ifndef KAB_EMBEDDED | 130 | #ifndef KAB_EMBEDDED |
131 | KAcceleratorManager::manage( this ); | 131 | KAcceleratorManager::manage( this ); |
132 | #endif //KAB_EMBEDDED | 132 | #endif //KAB_EMBEDDED |
133 | 133 | ||
134 | #ifndef DESKTOP_VERSION | ||
135 | mUsePhotoUrl->setChecked( true ); | ||
136 | mUseLogoUrl->setChecked( true ); | ||
137 | #endif | ||
138 | } | 134 | } |
139 | 135 | ||
140 | ImageWidget::~ImageWidget() | 136 | ImageWidget::~ImageWidget() |
141 | { | 137 | { |
142 | } | 138 | } |
143 | 139 | ||
144 | void ImageWidget::setPhoto( const KABC::Picture &photo ) | 140 | void ImageWidget::setPhoto( const KABC::Picture &photo ) |
145 | { | 141 | { |
146 | bool blocked = signalsBlocked(); | 142 | bool blocked = signalsBlocked(); |
147 | blockSignals( true ); | 143 | blockSignals( true ); |
148 | 144 | ||
149 | if ( photo.isIntern() ) { | 145 | if ( photo.isIntern() ) { |
150 | //US | 146 | //US |
151 | //US mPhotoLabel->setPixmap( photo.data() ); | 147 | //US mPhotoLabel->setPixmap( photo.data() ); |
152 | if (photo.data().isNull() != true) | 148 | if (photo.data().isNull() != true) |
153 | { | 149 | { |
154 | QPixmap pm; | 150 | QPixmap pm; |
155 | pm.convertFromImage(photo.data()); | 151 | pm.convertFromImage(photo.data()); |
156 | 152 | ||
157 | mPhotoLabel->setPixmap( pm ); | 153 | mPhotoLabel->setPixmap( pm ); |
158 | } | 154 | } |
159 | 155 | ||
160 | mUsePhotoUrl->setChecked( false ); | 156 | mUsePhotoUrl->setChecked( false ); |
161 | } else { | 157 | } else { |
162 | mPhotoUrl->setURL( photo.url() ); | 158 | mPhotoUrl->setURL( photo.url() ); |
163 | if ( !photo.url().isEmpty() ) | 159 | if ( !photo.url().isEmpty() ) |
164 | mUsePhotoUrl->setChecked( true ); | 160 | mUsePhotoUrl->setChecked( true ); |
165 | loadPhoto(); | 161 | loadPhoto(); |
166 | } | 162 | } |
167 | 163 | ||
168 | blockSignals( blocked ); | 164 | blockSignals( blocked ); |
169 | } | 165 | } |
@@ -231,69 +227,68 @@ KABC::Picture ImageWidget::logo() const | |||
231 | if ( px ) { | 227 | if ( px ) { |
232 | #ifndef KAB_EMBEDDED | 228 | #ifndef KAB_EMBEDDED |
233 | if ( px->height() > px->width() ) | 229 | if ( px->height() > px->width() ) |
234 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); | 230 | logo.setData( px->convertToImage().scaleHeight( 140 ) ); |
235 | else | 231 | else |
236 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); | 232 | logo.setData( px->convertToImage().scaleWidth( 100 ) ); |
237 | #else //KAB_EMBEDDED | 233 | #else //KAB_EMBEDDED |
238 | logo.setData( px->convertToImage() ); | 234 | logo.setData( px->convertToImage() ); |
239 | #endif //KAB_EMBEDDED | 235 | #endif //KAB_EMBEDDED |
240 | 236 | ||
241 | logo.setType( "PNG" ); | 237 | logo.setType( "PNG" ); |
242 | 238 | ||
243 | } | 239 | } |
244 | } | 240 | } |
245 | 241 | ||
246 | return logo; | 242 | return logo; |
247 | } | 243 | } |
248 | 244 | ||
249 | void ImageWidget::loadPhoto() | 245 | void ImageWidget::loadPhoto() |
250 | { | 246 | { |
251 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); | 247 | mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); |
252 | } | 248 | } |
253 | 249 | ||
254 | void ImageWidget::loadLogo() | 250 | void ImageWidget::loadLogo() |
255 | { | 251 | { |
256 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); | 252 | mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); |
257 | } | 253 | } |
258 | 254 | ||
259 | void ImageWidget::updateGUI() | 255 | void ImageWidget::updateGUI() |
260 | { | 256 | { |
261 | KURLRequester *ptr = (KURLRequester*)sender(); | 257 | KURLRequester *ptr = (KURLRequester*)sender(); |
262 | 258 | ||
263 | #ifdef DESKTOP_VERSION | 259 | |
264 | if ( ptr == mPhotoUrl ) | 260 | if ( ptr == mPhotoUrl ) |
265 | mUsePhotoUrl->setEnabled( true ); | 261 | mUsePhotoUrl->setEnabled( true ); |
266 | else if ( ptr == mLogoUrl ) | 262 | else if ( ptr == mLogoUrl ) |
267 | mUseLogoUrl->setEnabled( true ); | 263 | mUseLogoUrl->setEnabled( true ); |
268 | #endif | ||
269 | } | 264 | } |
270 | 265 | ||
271 | QPixmap ImageWidget::loadPixmap( const KURL &url ) | 266 | QPixmap ImageWidget::loadPixmap( const KURL &url ) |
272 | { | 267 | { |
273 | QString tempFile; | 268 | QString tempFile; |
274 | QPixmap pixmap; | 269 | QPixmap pixmap; |
275 | 270 | ||
276 | if ( url.isEmpty() ) | 271 | if ( url.isEmpty() ) |
277 | return pixmap; | 272 | return pixmap; |
278 | 273 | ||
279 | if ( url.isLocalFile() ) | 274 | if ( url.isLocalFile() ) |
280 | pixmap = QPixmap( url.path() ); | 275 | pixmap = QPixmap( url.path() ); |
281 | else | 276 | else |
282 | { | 277 | { |
283 | #ifndef KAB_EMBEDDED | 278 | #ifndef KAB_EMBEDDED |
284 | if ( KIO::NetAccess::download( url, tempFile ) ) { | 279 | if ( KIO::NetAccess::download( url, tempFile ) ) { |
285 | pixmap = QPixmap( tempFile ); | 280 | pixmap = QPixmap( tempFile ); |
286 | KIO::NetAccess::removeTempFile( tempFile ); | 281 | KIO::NetAccess::removeTempFile( tempFile ); |
287 | } | 282 | } |
288 | #else //KAB_EMBEDDED | 283 | #else //KAB_EMBEDDED |
289 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); | 284 | qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); |
290 | #endif //KAB_EMBEDDED | 285 | #endif //KAB_EMBEDDED |
291 | 286 | ||
292 | } | 287 | } |
293 | 288 | ||
294 | return pixmap; | 289 | return pixmap; |
295 | } | 290 | } |
296 | 291 | ||
297 | #ifndef KAB_EMBEDDED | 292 | #ifndef KAB_EMBEDDED |
298 | #include "imagewidget.moc" | 293 | #include "imagewidget.moc" |
299 | #endif //KAB_EMBEDDED | 294 | #endif //KAB_EMBEDDED |