diff options
author | Benoit Walter <b.walter@free.fr> | 2014-09-16 03:19:11 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2014-09-16 03:41:49 +0200 |
commit | 0cce3b0ec191dd8dcb813e6b97d903b7288f4cb1 (patch) | |
tree | 3a12de4cc7f8941bb8c08d60d6c0768e498f8095 | |
parent | 0c5a2640a6ab97b1ba97eb2399bd58fb1e890f0c (diff) | |
download | tqt3-0cce3b0ec191dd8dcb813e6b97d903b7288f4cb1.tar.gz tqt3-0cce3b0ec191dd8dcb813e6b97d903b7288f4cb1.zip |
Remove unnecessary scrollbar in TQIconView
Test case (using konqueror icon view):
- The first icons are being shown (no scrollbar yet)
- When there is no space left, a vertical scrollbar is needed
- The vertical scrollbar may cover the right edge of the icons
(in the last column) => an horizontal scrollbar is needed :-(
Solution:
When using ScrollBarMode::Auto, prevent TQt from drawing icons on the
scrollbar area (before the scrollbar is shown).
Related to KDE bug #69589
-rw-r--r-- | src/iconview/ntqiconview.h | 2 | ||||
-rw-r--r-- | src/iconview/qiconview.cpp | 40 |
2 files changed, 32 insertions, 10 deletions
diff --git a/src/iconview/ntqiconview.h b/src/iconview/ntqiconview.h index e45cfca65..34085827c 100644 --- a/src/iconview/ntqiconview.h +++ b/src/iconview/ntqiconview.h @@ -504,6 +504,8 @@ private: const TQPoint &relativeTo, const TQIconViewItem *item ) const; TQBitmap mask( TQPixmap *pix ) const; + int visibleWidthSB() const; + int visibleHeightSB() const; TQIconViewPrivate *d; diff --git a/src/iconview/qiconview.cpp b/src/iconview/qiconview.cpp index 236768d2a..309882155 100644 --- a/src/iconview/qiconview.cpp +++ b/src/iconview/qiconview.cpp @@ -1107,7 +1107,7 @@ void TQIconViewItem::setText( const TQString &text ) if ( view ) { if ( TQRect( view->contentsX(), view->contentsY(), - view->visibleWidth(), view->visibleHeight() ). + view->visibleWidthSB(), view->visibleHeightSB() ). intersects( oR ) ) view->repaintContents( oR.x() - 1, oR.y() - 1, oR.width() + 2, oR.height() + 2, FALSE ); @@ -1159,7 +1159,7 @@ void TQIconViewItem::setPixmap( const TQPixmap &icon ) if ( view ) { if ( TQRect( view->contentsX(), view->contentsY(), - view->visibleWidth(), view->visibleHeight() ). + view->visibleWidthSB(), view->visibleHeightSB() ). intersects( oR ) ) view->repaintContents( oR.x() - 1, oR.y() - 1, oR.width() + 2, oR.height() + 2, FALSE ); @@ -1195,7 +1195,7 @@ void TQIconViewItem::setPicture( const TQPicture &icon ) if ( view ) { if ( TQRect( view->contentsX(), view->contentsY(), - view->visibleWidth(), view->visibleHeight() ). + view->visibleWidthSB(), view->visibleHeightSB() ). intersects( oR ) ) view->repaintContents( oR.x() - 1, oR.y() - 1, oR.width() + 2, oR.height() + 2, FALSE ); @@ -1263,7 +1263,7 @@ void TQIconViewItem::setPixmap( const TQPixmap &icon, bool recalc, bool redraw ) if ( view ) { if ( TQRect( view->contentsX(), view->contentsY(), - view->visibleWidth(), view->visibleHeight() ). + view->visibleWidthSB(), view->visibleHeightSB() ). intersects( oR ) ) view->repaintContents( oR.x() - 1, oR.y() - 1, oR.width() + 2, oR.height() + 2, FALSE ); @@ -5638,8 +5638,8 @@ void TQIconView::insertInGrid( TQIconViewItem *item ) } item->dirty = FALSE; } else { - TQRegion r( TQRect( 0, 0, TQMAX( contentsWidth(), visibleWidth() ), - TQMAX( contentsHeight(), visibleHeight() ) ) ); + TQRegion r( TQRect( 0, 0, TQMAX( contentsWidth(), visibleWidthSB() ), + TQMAX( contentsHeight(), visibleHeightSB() ) ) ); TQIconViewItem *i = d->firstItem; int y = -1; @@ -5902,7 +5902,7 @@ TQIconViewItem *TQIconView::makeRowLayout( TQIconViewItem *begin, int &y, bool & TQIconViewItem *item = begin; for (;;) { x += d->spacing + item->width(); - if ( x > visibleWidth() && item != begin ) { + if ( x > visibleWidthSB() && item != begin ) { item = item->prev; while (item && (item->isVisible() == FALSE)) { item = item->prev; @@ -5933,7 +5933,7 @@ TQIconViewItem *TQIconView::makeRowLayout( TQIconViewItem *begin, int &y, bool & int x; if ( item == begin ) { if ( reverse ) - x = visibleWidth() - d->spacing - item->width(); + x = visibleWidthSB() - d->spacing - item->width(); else x = d->spacing; } else { @@ -5969,7 +5969,7 @@ TQIconViewItem *TQIconView::makeRowLayout( TQIconViewItem *begin, int &y, bool & i += r; x = i * d->rastX + sp * d->spacing; } - if ( x > visibleWidth() && item != begin ) { + if ( x > visibleWidthSB() && item != begin ) { item = item->prev; while (item && (item->isVisible() == FALSE)) { item = item->prev; @@ -6041,7 +6041,7 @@ TQIconViewItem *TQIconView::makeRowLayout( TQIconViewItem *begin, int &y, bool & TQIconViewItem *item = begin; for (;;) { y += d->spacing + item->height(); - if ( y > visibleHeight() && item != begin ) { + if ( y > visibleHeightSB() && item != begin ) { item = item->prev; while (item && (item->isVisible() == FALSE)) { item = item->prev; @@ -6605,4 +6605,24 @@ bool TQIconView::isRenaming() const #endif } +int TQIconView::visibleWidthSB() const +{ + if ( vScrollBarMode() != Auto ) + return visibleWidth(); + + int offset = verticalScrollBar()->isVisible() ? 0 + : style().pixelMetric( TQStyle::PM_ScrollBarExtent, verticalScrollBar() ); + return TQMAX( 0, visibleWidth() - offset ); +} + +int TQIconView::visibleHeightSB() const +{ + if ( hScrollBarMode() != Auto ) + return visibleHeight(); + + int offset = horizontalScrollBar()->isVisible() ? 0 + : style().pixelMetric( TQStyle::PM_ScrollBarExtent, horizontalScrollBar() ); + return TQMAX( 0, visibleHeight() - offset ); +} + #endif // QT_NO_ICONVIEW |