diff options
author | Andrew <forkk@forkk.net> | 2013-03-28 11:37:12 -0500 |
---|---|---|
committer | Andrew <forkk@forkk.net> | 2013-03-28 11:37:12 -0500 |
commit | ebb2c54975e3f0b7b891532e8e72d2ef760f96c4 (patch) | |
tree | 973de7066457a1faddffd3834eb0c260d5191ec2 /libgroupview/src/kcategorizedview.cpp | |
parent | 168ed3e8e58a8e5065ffa720f8d45f4cee0f2069 (diff) | |
parent | 1f13f0c665001a1a79f00cdad1e63e6c9802e55f (diff) | |
download | MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.tar MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.tar.gz MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.tar.lz MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.tar.xz MultiMC-ebb2c54975e3f0b7b891532e8e72d2ef760f96c4.zip |
Merge branch 'master' of git://github.com/peterix/MultiMC5
Conflicts:
CMakeLists.txt
gui/mainwindow.cpp
Diffstat (limited to 'libgroupview/src/kcategorizedview.cpp')
-rw-r--r-- | libgroupview/src/kcategorizedview.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/libgroupview/src/kcategorizedview.cpp b/libgroupview/src/kcategorizedview.cpp index 5b7c8d42..4da4271f 100644 --- a/libgroupview/src/kcategorizedview.cpp +++ b/libgroupview/src/kcategorizedview.cpp @@ -115,6 +115,7 @@ KCategorizedView::Private::Private ( KCategorizedView *q ) , hoveredIndex ( QModelIndex() ) , pressedPosition ( QPoint() ) , rubberBandRect ( QRect() ) + , constantItemWidth( 0 ) { } @@ -447,11 +448,12 @@ void KCategorizedView::Private::leftToRightVisualRect ( const QModelIndex &index } else { - if ( q->uniformItemSizes() ) + if ( q->uniformItemSizes() /*|| q->uniformItemWidths()*/ ) { const int relativeRow = index.row() - firstIndexRow; const QSize itemSize = q->sizeHintForIndex ( index ); - const int maxItemsPerRow = qMax ( ( viewportWidth() - q->spacing() ) / ( itemSize.width() + q->spacing() ), 1 ); + //HACK: Why is the -2 needed? + const int maxItemsPerRow = qMax ( ( viewportWidth() - q->spacing() - 2 ) / ( itemSize.width() + q->spacing() ), 1 ); if ( q->layoutDirection() == Qt::LeftToRight ) { item.topLeft.rx() = ( relativeRow % maxItemsPerRow ) * itemSize.width() + blockPos.x() + categoryDrawer->leftMargin(); @@ -478,7 +480,8 @@ void KCategorizedView::Private::leftToRightVisualRect ( const QModelIndex &index Q_FOREVER { prevIndex = proxyModel->index ( prevIndex.row() - 1, q->modelColumn(), q->rootIndex() ); - const QRect tempRect = q->visualRect ( prevIndex ); + QRect tempRect = q->visualRect ( prevIndex ); + tempRect = mapFromViewport ( tempRect ); if ( tempRect.topLeft().y() < prevRect.topLeft().y() ) { break; @@ -622,6 +625,18 @@ void KCategorizedView::setModel ( QAbstractItemModel *model ) } } + +void KCategorizedView::setUniformItemWidths(bool enable) +{ + d->constantItemWidth = enable; +} + + +bool KCategorizedView::uniformItemWidths() const +{ + return d->constantItemWidth; +} + void KCategorizedView::setGridSize ( const QSize &size ) { setGridSizeOwn ( size ); @@ -1294,13 +1309,14 @@ QModelIndex KCategorizedView::moveCursor ( CursorAction cursorAction, } case MoveDown: { - if ( d->hasGrid() || uniformItemSizes() ) + if ( d->hasGrid() || uniformItemSizes() || uniformItemWidths() ) { const QModelIndex current = currentIndex(); const QSize itemSize = d->hasGrid() ? gridSize() : sizeHintForIndex ( current ); const Private::Block &block = d->blocks[d->categoryForIndex ( current )]; - const int maxItemsPerRow = qMax ( d->viewportWidth() / itemSize.width(), 1 ); + //HACK: Why is the -2 needed? + const int maxItemsPerRow = qMax ( ( d->viewportWidth() - spacing() - 2 ) / ( itemSize.width() + spacing() ), 1 ); const bool canMove = current.row() + maxItemsPerRow < block.firstIndex.row() + block.items.count(); @@ -1334,13 +1350,14 @@ QModelIndex KCategorizedView::moveCursor ( CursorAction cursorAction, } case MoveUp: { - if ( d->hasGrid() || uniformItemSizes() ) + if ( d->hasGrid() || uniformItemSizes() || uniformItemWidths() ) { const QModelIndex current = currentIndex(); const QSize itemSize = d->hasGrid() ? gridSize() : sizeHintForIndex ( current ); const Private::Block &block = d->blocks[d->categoryForIndex ( current )]; - const int maxItemsPerRow = qMax ( d->viewportWidth() / itemSize.width(), 1 ); + //HACK: Why is the -2 needed? + const int maxItemsPerRow = qMax ( ( d->viewportWidth() - spacing() - 2 ) / ( itemSize.width() + spacing() ), 1 ); const bool canMove = current.row() - maxItemsPerRow >= block.firstIndex.row(); if ( canMove ) |