Changeset View
Changeset View
Standalone View
Standalone View
lib/documentview/rasterimageview.cpp
Show First 20 Lines • Show All 286 Lines • ▼ Show 20 Line(s) | 281 | { | |||
---|---|---|---|---|---|
287 | 287 | | |||
288 | connect(document().data(), SIGNAL(imageRectUpdated(QRect)), | 288 | connect(document().data(), SIGNAL(imageRectUpdated(QRect)), | ||
289 | SLOT(updateImageRect(QRect))); | 289 | SLOT(updateImageRect(QRect))); | ||
290 | 290 | | |||
291 | if (zoomToFit()) { | 291 | if (zoomToFit()) { | ||
292 | // Force the update otherwise if computeZoomToFit() returns 1, setZoom() | 292 | // Force the update otherwise if computeZoomToFit() returns 1, setZoom() | ||
293 | // will think zoom has not changed and won't update the image | 293 | // will think zoom has not changed and won't update the image | ||
294 | setZoom(computeZoomToFit(), QPointF(-1, -1), ForceUpdate); | 294 | setZoom(computeZoomToFit(), QPointF(-1, -1), ForceUpdate); | ||
295 | } else if (zoomToFitWidth()) { | 295 | } else if (zoomToFill()) { | ||
296 | setZoom(computeZoomToFitWidth(), QPointF(-1, -1), ForceUpdate); | 296 | setZoom(computeZoomToFill(), QPointF(-1, -1), ForceUpdate); | ||
297 | } else { | 297 | } else { | ||
298 | updateBuffer(); | 298 | updateBuffer(); | ||
299 | } | 299 | } | ||
300 | 300 | | |||
301 | d->startAnimationIfNecessary(); | 301 | d->startAnimationIfNecessary(); | ||
302 | update(); | 302 | update(); | ||
303 | } | 303 | } | ||
304 | 304 | | |||
305 | void RasterImageView::updateImageRect(const QRect& imageRect) | 305 | void RasterImageView::updateImageRect(const QRect& imageRect) | ||
306 | { | 306 | { | ||
307 | QRectF viewRect = mapToView(imageRect); | 307 | QRectF viewRect = mapToView(imageRect); | ||
308 | if (!viewRect.intersects(boundingRect())) { | 308 | if (!viewRect.intersects(boundingRect())) { | ||
309 | return; | 309 | return; | ||
310 | } | 310 | } | ||
311 | 311 | | |||
312 | if (zoomToFit()) { | 312 | if (zoomToFit()) { | ||
313 | setZoom(computeZoomToFit()); | 313 | setZoom(computeZoomToFit()); | ||
314 | } else if (zoomToFitWidth()) { | 314 | } else if (zoomToFill()) { | ||
315 | setZoom(computeZoomToFitWidth()); | 315 | setZoom(computeZoomToFill()); | ||
316 | } | 316 | } | ||
317 | 317 | | |||
318 | d->setScalerRegionToVisibleRect(); | 318 | d->setScalerRegionToVisibleRect(); | ||
319 | update(); | 319 | update(); | ||
320 | } | 320 | } | ||
321 | 321 | | |||
322 | void RasterImageView::slotDocumentIsAnimatedUpdated() | 322 | void RasterImageView::slotDocumentIsAnimatedUpdated() | ||
323 | { | 323 | { | ||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | 430 | { | |||
432 | // update: paint() will paint a scaled version of the buffer until resizing | 432 | // update: paint() will paint a scaled version of the buffer until resizing | ||
433 | // is done. This is much faster than rescaling the whole image for each | 433 | // is done. This is much faster than rescaling the whole image for each | ||
434 | // resize event we receive. | 434 | // resize event we receive. | ||
435 | // mUpdateTimer must be started before calling AbstractImageView::resizeEvent() | 435 | // mUpdateTimer must be started before calling AbstractImageView::resizeEvent() | ||
436 | // because AbstractImageView::resizeEvent() will call onZoomChanged(), which | 436 | // because AbstractImageView::resizeEvent() will call onZoomChanged(), which | ||
437 | // will trigger an immediate update unless the mUpdateTimer is active. | 437 | // will trigger an immediate update unless the mUpdateTimer is active. | ||
438 | if (zoomToFit() && !d->mBufferIsEmpty) { | 438 | if (zoomToFit() && !d->mBufferIsEmpty) { | ||
439 | d->mUpdateTimer->start(); | 439 | d->mUpdateTimer->start(); | ||
440 | } else if (zoomToFitWidth() && !d->mBufferIsEmpty) { | 440 | } else if (zoomToFill() && !d->mBufferIsEmpty) { | ||
441 | d->mUpdateTimer->start(); | 441 | d->mUpdateTimer->start(); | ||
442 | } | 442 | } | ||
443 | AbstractImageView::resizeEvent(event); | 443 | AbstractImageView::resizeEvent(event); | ||
444 | if (!zoomToFit()) { | 444 | if (!zoomToFit()) { | ||
445 | // Only update buffer if we are not in zoomToFit mode: if we are | 445 | // Only update buffer if we are not in zoomToFit mode: if we are | ||
446 | // onZoomChanged() will have already updated the buffer. | 446 | // onZoomChanged() will have already updated the buffer. | ||
447 | updateBuffer(); | 447 | updateBuffer(); | ||
448 | } else if (!zoomToFitWidth()) { | 448 | } else if (!zoomToFill()) { | ||
449 | updateBuffer(); | 449 | updateBuffer(); | ||
450 | } | 450 | } | ||
451 | } | 451 | } | ||
452 | 452 | | |||
453 | void RasterImageView::updateBuffer(const QRegion& region) | 453 | void RasterImageView::updateBuffer(const QRegion& region) | ||
454 | { | 454 | { | ||
455 | d->mUpdateTimer->stop(); | 455 | d->mUpdateTimer->stop(); | ||
456 | d->mScaler->setZoom(zoom()); | 456 | d->mScaler->setZoom(zoom()); | ||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |