summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-16 20:33:55 (UTC)
committer alwin <alwin>2004-04-16 20:33:55 (UTC)
commitcc56768485c3785439883dd1c456493f7ece2d84 (patch) (unidiff)
tree8ab6ff6feae6f2cc9cb73b4eaf8215cdd0d53a0d
parent7dc52619640437ec448ea3bccdf924ea9a29bfa6 (diff)
downloadopie-cc56768485c3785439883dd1c456493f7ece2d84.zip
opie-cc56768485c3785439883dd1c456493f7ece2d84.tar.gz
opie-cc56768485c3785439883dd1c456493f7ece2d84.tar.bz2
fixed painting problems when reloading images when widget is visible
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/oimagescrollview.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/libopie2/opiemm/oimagescrollview.cpp b/libopie2/opiemm/oimagescrollview.cpp
index 61b2062..a8165a4 100644
--- a/libopie2/opiemm/oimagescrollview.cpp
+++ b/libopie2/opiemm/oimagescrollview.cpp
@@ -154,13 +154,13 @@ void OImageScrollView::init()
154 _zoomer, (SLOT(setVisiblePoint(int,int))) ); 154 _zoomer, (SLOT(setVisiblePoint(int,int))) );
155 connect(this,SIGNAL(imageSizeChanged(const QSize&)), 155 connect(this,SIGNAL(imageSizeChanged(const QSize&)),
156 _zoomer, SLOT(setImageSize(const QSize&)) ); 156 _zoomer, SLOT(setImageSize(const QSize&)) );
157 connect(this,SIGNAL(viewportSizeChanged(const QSize&)), 157 connect(this,SIGNAL(viewportSizeChanged(const QSize&)),
158 _zoomer, SLOT(setViewPortSize(const QSize&)) ); 158 _zoomer, SLOT(setViewPortSize(const QSize&)) );
159 159
160 viewport()->setBackgroundColor(white); 160 setBackgroundColor(white);
161 setFocusPolicy(QWidget::StrongFocus); 161 setFocusPolicy(QWidget::StrongFocus);
162 setImageScaledLoaded(false); 162 setImageScaledLoaded(false);
163 setImageIsJpeg(false); 163 setImageIsJpeg(false);
164 if (FirstResizeDone()) { 164 if (FirstResizeDone()) {
165 m_last_rot = Rotate0; 165 m_last_rot = Rotate0;
166 generateImage(); 166 generateImage();
@@ -348,54 +348,58 @@ void OImageScrollView::generateImage()
348 } 348 }
349 if (width()>height()&&_original_data.width()<_original_data.height() || 349 if (width()>height()&&_original_data.width()<_original_data.height() ||
350 width()<height()&&_original_data.width()>_original_data.height()) { 350 width()<height()&&_original_data.width()>_original_data.height()) {
351 if (AutoRotate()) r = Rotate90; 351 if (AutoRotate()) r = Rotate90;
352 } 352 }
353 353
354 354 int twidth,theight;
355 odebug << " r = " << r << oendl; 355 odebug << " r = " << r << oendl;
356 if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) { 356 if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) {
357 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { 357 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) {
358 odebug << "Rescaling data" << oendl; 358 odebug << "Rescaling data" << oendl;
359 if (r==Rotate0) { 359 if (r==Rotate0) {
360 _image_data = _original_data; 360 _image_data = _original_data;
361 } else { 361 } else {
362 rotate_into_data(r); 362 rotate_into_data(r);
363 } 363 }
364 } 364 }
365 rescaleImage(width(),height()); 365 rescaleImage(width(),height());
366 resizeContents(_image_data.width(),_image_data.height());
367 } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) { 366 } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) {
368 if (r==Rotate0) { 367 if (r==Rotate0) {
369 _image_data = _original_data; 368 _image_data = _original_data;
370 } else { 369 } else {
371 rotate_into_data(r); 370 rotate_into_data(r);
372 } 371 }
373 m_last_rot = r; 372 m_last_rot = r;
374 resizeContents(_image_data.width(),_image_data.height());
375 } 373 }
376 _pdata.convertFromImage(_image_data); 374 _pdata.convertFromImage(_image_data);
375 twidth = _image_data.width();
376 theight = _image_data.height();
377 377
378 /* 378 /*
379 * update the zoomer 379 * update the zoomer
380 */ 380 */
381 check_zoomer(); 381 check_zoomer();
382 emit imageSizeChanged( _image_data.size() ); 382 emit imageSizeChanged( _image_data.size() );
383 rescaleImage( 128, 128 ); 383 rescaleImage( 128, 128 );
384 resizeContents(twidth,theight);
384 /* 385 /*
385 * move scrollbar 386 * move scrollbar
386 */ 387 */
387 if (_zoomer) { 388 if (_zoomer) {
388 _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, 389 _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2,
389 _image_data.width()/2, _image_data.height()/2 ); 390 _image_data.width()/2, _image_data.height()/2 );
390 _zoomer->setImage( _image_data ); 391 _zoomer->setImage( _image_data );
391 } 392 }
392 /* 393 /*
393 * invalidate 394 * invalidate
394 */ 395 */
395 _image_data=QImage(); 396 _image_data=QImage();
397 if (isVisible()) {
398 updateContents(contentsX(),contentsY(),width(),height());
399 }
396} 400}
397 401
398void OImageScrollView::resizeEvent(QResizeEvent * e) 402void OImageScrollView::resizeEvent(QResizeEvent * e)
399{ 403{
400 odebug << "OImageScrollView resizeEvent" << oendl; 404 odebug << "OImageScrollView resizeEvent" << oendl;
401 QScrollView::resizeEvent(e); 405 QScrollView::resizeEvent(e);
@@ -434,13 +438,13 @@ void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clip
434 int h = cliph; 438 int h = cliph;
435 int x = clipx; 439 int x = clipx;
436 int y = clipy; 440 int y = clipy;
437 bool erase = false; 441 bool erase = false;
438 442
439 if (!_pdata.size().isValid()) { 443 if (!_pdata.size().isValid()) {
440 p->fillRect(clipx,clipy,clipw,cliph,white); 444 p->fillRect(clipx,clipy,clipw,cliph, backgroundColor());
441 return; 445 return;
442 } 446 }
443 if (w>_pdata.width()) { 447 if (w>_pdata.width()) {
444 w=_pdata.width(); 448 w=_pdata.width();
445 x = 0; 449 x = 0;
446 erase = true; 450 erase = true;
@@ -452,13 +456,13 @@ void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clip
452 y = 0; 456 y = 0;
453 erase = true; 457 erase = true;
454 } else if (y+h>_pdata.height()){ 458 } else if (y+h>_pdata.height()){
455 y = _pdata.height()-h; 459 y = _pdata.height()-h;
456 } 460 }
457 if (erase||_original_data.hasAlphaBuffer()) { 461 if (erase||_original_data.hasAlphaBuffer()) {
458 p->fillRect(clipx,clipy,clipw,cliph,white); 462 p->fillRect(clipx,clipy,clipw,cliph, backgroundColor());
459 } 463 }
460 p->drawPixmap(clipx,clipy,_pdata,x,y,w,h); 464 p->drawPixmap(clipx,clipy,_pdata,x,y,w,h);
461} 465}
462 466
463/* using the real geometry points and not the translated points is wanted! */ 467/* using the real geometry points and not the translated points is wanted! */
464void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) 468void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e)