Changeset View
Changeset View
Standalone View
Standalone View
lib/documentview/abstractimageview.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 40 | { | |||
---|---|---|---|---|---|
50 | bool mEnlargeSmallerImages; | 50 | bool mEnlargeSmallerImages; | ||
51 | 51 | | |||
52 | qreal mZoom; | 52 | qreal mZoom; | ||
53 | bool mZoomToFit; | 53 | bool mZoomToFit; | ||
54 | bool mZoomToFill; | 54 | bool mZoomToFill; | ||
55 | QPointF mImageOffset; | 55 | QPointF mImageOffset; | ||
56 | QPointF mScrollPos; | 56 | QPointF mScrollPos; | ||
57 | QPointF mLastDragPos; | 57 | QPointF mLastDragPos; | ||
58 | QSizeF mDocumentSize; | ||||
58 | 59 | | |||
59 | void adjustImageOffset(Verbosity verbosity = Notify) | 60 | void adjustImageOffset(Verbosity verbosity = Notify) | ||
60 | { | 61 | { | ||
61 | QSizeF zoomedDocSize = q->documentSize() * mZoom; | 62 | QSizeF zoomedDocSize = q->documentSize() * mZoom; | ||
62 | QSizeF viewSize = q->boundingRect().size(); | 63 | QSizeF viewSize = q->boundingRect().size(); | ||
63 | QPointF offset( | 64 | QPointF offset( | ||
64 | qMax((viewSize.width() - zoomedDocSize.width()) / 2, qreal(0.)), | 65 | qMax((viewSize.width() - zoomedDocSize.width()) / 2, qreal(0.)), | ||
65 | qMax((viewSize.height() - zoomedDocSize.height()) / 2, qreal(0.)) | 66 | qMax((viewSize.height() - zoomedDocSize.height()) / 2, qreal(0.)) | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
163 | } | 164 | } | ||
164 | 165 | | |||
165 | void AbstractImageView::setZoom(qreal zoom, const QPointF& _center, AbstractImageView::UpdateType updateType) | 166 | void AbstractImageView::setZoom(qreal zoom, const QPointF& _center, AbstractImageView::UpdateType updateType) | ||
166 | { | 167 | { | ||
167 | if (!d->mDocument) { | 168 | if (!d->mDocument) { | ||
168 | d->mZoom = zoom; | 169 | d->mZoom = zoom; | ||
169 | return; | 170 | return; | ||
170 | } | 171 | } | ||
171 | if (updateType == UpdateIfNecessary && qFuzzyCompare(zoom, d->mZoom)) { | 172 | | ||
173 | if (updateType == UpdateIfNecessary | ||||
174 | && qFuzzyCompare(zoom, d->mZoom) && documentSize() == d->mDocumentSize) { | ||||
muhlenpfordt: Is there a preferred style for wrapping the conditions? | |||||
You could
You chose the third option, which is fine with me… rkflx: You could
- keep this on a single line (in general some lines in the codebase are quite long… | |||||
172 | return; | 175 | return; | ||
173 | } | 176 | } | ||
174 | qreal oldZoom = d->mZoom; | 177 | qreal oldZoom = d->mZoom; | ||
175 | d->mZoom = zoom; | 178 | d->mZoom = zoom; | ||
179 | d->mDocumentSize = documentSize(); | ||||
176 | 180 | | |||
177 | QPointF center; | 181 | QPointF center; | ||
178 | if (_center == QPointF(-1, -1)) { | 182 | if (_center == QPointF(-1, -1)) { | ||
179 | center = boundingRect().center(); | 183 | center = boundingRect().center(); | ||
180 | } else { | 184 | } else { | ||
181 | center = _center; | 185 | center = _center; | ||
182 | } | 186 | } | ||
183 | 187 | | |||
▲ Show 20 Lines • Show All 392 Lines • Show Last 20 Lines |
Is there a preferred style for wrapping the conditions?