233
239
if (!m_pagedMode && m_view) {
241
// we need to adjust the document's size to make sure we don't enter
242
// an endless cycle of scrollbars being added, then removed at the next layout.
235
244
bool vss = m_view->verticalScrollBar()->isVisible();
236
245
bool hss = m_view->horizontalScrollBar()->isVisible();
237
QSize s = m_view->maximumViewportSize();
239
int zoomedDocWidth = m_cachedDocWidth*zLevel/100;
240
int zoomedDocHeight = m_cachedDocHeight*zLevel/100;
241
if ( zoomedDocWidth > s.width() )
242
s.setWidth( s.width()-m_view->verticalScrollBar()->sizeHint().width() );
243
if ( zoomedDocHeight > s.height() )
244
s.setHeight( s.height()-m_view->horizontalScrollBar()->sizeHint().height() );
247
// calculate the extent of scrollbars
248
int vsPixSize = m_view->verticalScrollBar()->sizeHint().width();
249
int hsPixSize = m_view->horizontalScrollBar()->sizeHint().height();
251
#ifdef SCROLLBAR_WIDTH_HACK
252
// ### hackish turnaround for a bug in QAbstractScrollArea triggered by Oxygen.
255
if (m_view->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, m_view)) {
256
int fudge = m_view->style()->pixelMetric(QStyle::PM_DefaultFrameWidth)*2;
262
// this variable holds the size the viewport will have after the inner content is resized to
263
// the new document dimensions
264
QSize viewport = m_view->maximumViewportSize();
266
// of course, if the scrollbar policy isn't auto, there's no point adjusting any value..
267
int overrideH = m_view->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded ? 0 : hDocH;
268
int overrideW = m_view->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded ? 0 : hDocW;
270
if ( !overrideW && hDocW > viewport.width() )
271
viewport.setHeight( viewport.height() - hsPixSize );
272
if ( !overrideH && hDocH > viewport.height() )
273
viewport.setWidth( viewport.width() - vsPixSize );
246
275
// if we are about to show a scrollbar, and the document is sized to the viewport w or h,
247
276
// then reserve the scrollbar space so that it doesn't trigger the _other_ scrollbar
249
if (!vss && m_width - m_view->verticalScrollBar()->sizeHint().width() == s.width() &&
250
zoomedDocWidth <= m_width)
251
hDocW = qMin( zoomedDocWidth, s.width() );
278
if (!vss && m_width - vsPixSize == viewport.width() &&
280
hDocW = qMin( hDocW, viewport.width() );
253
if (!hss && m_height - m_view->horizontalScrollBar()->sizeHint().height() == s.height() &&
254
zoomedDocHeight <= m_height)
255
hDocH = qMin( zoomedDocHeight, s.height() );
282
if (!hss && m_height - hsPixSize == viewport.height() &&
284
hDocH = qMin( hDocH, viewport.height() );
257
286
// likewise, if a scrollbar is shown, and we have a cunning plan to turn it off,
258
287
// think again if we are falling downright in the hysteresis zone
260
if (vss && s.width() > zoomedDocWidth && zoomedDocWidth > m_view->visibleWidth())
263
if (hss && s.height() > zoomedDocHeight && zoomedDocHeight > m_view->visibleHeight())
264
hDocH = s.height()+1;
266
m_view->resizeContents(hDocW, hDocH);
268
setWidth( m_viewportWidth = s.width() );
269
setHeight( m_viewportHeight = s.height() );
289
if (vss && viewport.width() > hDocW && hDocW > m_view->visibleWidth())
290
hDocW = viewport.width()+1;
292
if (hss && viewport.height() > hDocH && hDocH > m_view->visibleHeight())
293
hDocH = viewport.height()+1;
295
m_view->resizeContents((overrideW ? overrideW : hDocW), (overrideH ? overrideH : hDocH));
271
298
layer()->resize( qMax( m_cachedDocWidth,int( m_width ) ), qMax( m_cachedDocHeight,m_height ) );