From d2eef6974be6c9d65f0108bb86fc94e141330c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 25 Mar 2013 20:58:45 +0100 Subject: [PATCH] Mystery meat layout hack to get things aligned --- gui/mainwindow.cpp | 5 ++--- libgroupview/src/kcategorizedview.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 68654889f..642f67d23 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -73,7 +73,7 @@ MainWindow::MainWindow ( QWidget *parent ) : pal.setBrush(QPalette::Base, QBrush(QPixmap(QString::fromUtf8(":/backgrounds/kitteh")))); view->setPalette(pal); */ - + /* view->setStyleSheet( "QListView\ {\ @@ -84,7 +84,7 @@ MainWindow::MainWindow ( QWidget *parent ) : background-repeat: none;\ background-color:palette(base);\ }"); - + */ view->setSelectionMode ( QAbstractItemView::SingleSelection ); //view->setSpacing( KDialog::spacingHint() ); view->setCategoryDrawer ( drawer ); @@ -97,7 +97,6 @@ MainWindow::MainWindow ( QWidget *parent ) : auto delegate = new ListViewDelegate(); view->setItemDelegate(delegate); view->setSpacing(10); - //view->setCategorySpacing(10); view->setUniformItemWidths(true); model = new InstanceModel ( instList,this ); diff --git a/libgroupview/src/kcategorizedview.cpp b/libgroupview/src/kcategorizedview.cpp index 19f9a0afd..4da4271f7 100644 --- a/libgroupview/src/kcategorizedview.cpp +++ b/libgroupview/src/kcategorizedview.cpp @@ -452,7 +452,8 @@ void KCategorizedView::Private::leftToRightVisualRect ( const QModelIndex &index { 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(); @@ -1314,7 +1315,8 @@ QModelIndex KCategorizedView::moveCursor ( CursorAction cursorAction, const QSize itemSize = d->hasGrid() ? gridSize() : sizeHintForIndex ( current ); const Private::Block &block = d->blocks[d->categoryForIndex ( current )]; - const int maxItemsPerRow = qMax ( ( d->viewportWidth() - spacing() ) / ( itemSize.width() + spacing() ), 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(); @@ -1354,7 +1356,8 @@ QModelIndex KCategorizedView::moveCursor ( CursorAction cursorAction, const QSize itemSize = d->hasGrid() ? gridSize() : sizeHintForIndex ( current ); const Private::Block &block = d->blocks[d->categoryForIndex ( current )]; - const int maxItemsPerRow = qMax ( ( d->viewportWidth() - spacing() ) / ( itemSize.width() + spacing() ), 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 )