Skip to content

Commit

Permalink
Mystery meat layout hack to get things aligned
Browse files Browse the repository at this point in the history
  • Loading branch information
peterix committed Mar 25, 2013
1 parent 37852d4 commit d2eef69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions gui/mainwindow.cpp
Expand Up @@ -73,7 +73,7 @@ MainWindow::MainWindow ( QWidget *parent ) :
pal.setBrush(QPalette::Base, QBrush(QPixmap(QString::fromUtf8(":/backgrounds/kitteh")))); pal.setBrush(QPalette::Base, QBrush(QPixmap(QString::fromUtf8(":/backgrounds/kitteh"))));
view->setPalette(pal); view->setPalette(pal);
*/ */

/*
view->setStyleSheet( view->setStyleSheet(
"QListView\ "QListView\
{\ {\
Expand All @@ -84,7 +84,7 @@ MainWindow::MainWindow ( QWidget *parent ) :
background-repeat: none;\ background-repeat: none;\
background-color:palette(base);\ background-color:palette(base);\
}"); }");

*/
view->setSelectionMode ( QAbstractItemView::SingleSelection ); view->setSelectionMode ( QAbstractItemView::SingleSelection );
//view->setSpacing( KDialog::spacingHint() ); //view->setSpacing( KDialog::spacingHint() );
view->setCategoryDrawer ( drawer ); view->setCategoryDrawer ( drawer );
Expand All @@ -97,7 +97,6 @@ MainWindow::MainWindow ( QWidget *parent ) :
auto delegate = new ListViewDelegate(); auto delegate = new ListViewDelegate();
view->setItemDelegate(delegate); view->setItemDelegate(delegate);
view->setSpacing(10); view->setSpacing(10);
//view->setCategorySpacing(10);
view->setUniformItemWidths(true); view->setUniformItemWidths(true);


model = new InstanceModel ( instList,this ); model = new InstanceModel ( instList,this );
Expand Down
9 changes: 6 additions & 3 deletions libgroupview/src/kcategorizedview.cpp
Expand Up @@ -452,7 +452,8 @@ void KCategorizedView::Private::leftToRightVisualRect ( const QModelIndex &index
{ {
const int relativeRow = index.row() - firstIndexRow; const int relativeRow = index.row() - firstIndexRow;
const QSize itemSize = q->sizeHintForIndex ( index ); 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 ) if ( q->layoutDirection() == Qt::LeftToRight )
{ {
item.topLeft.rx() = ( relativeRow % maxItemsPerRow ) * itemSize.width() + blockPos.x() + categoryDrawer->leftMargin(); item.topLeft.rx() = ( relativeRow % maxItemsPerRow ) * itemSize.width() + blockPos.x() + categoryDrawer->leftMargin();
Expand Down Expand Up @@ -1314,7 +1315,8 @@ QModelIndex KCategorizedView::moveCursor ( CursorAction cursorAction,
const QSize itemSize = d->hasGrid() ? gridSize() const QSize itemSize = d->hasGrid() ? gridSize()
: sizeHintForIndex ( current ); : sizeHintForIndex ( current );
const Private::Block &block = d->blocks[d->categoryForIndex ( 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() + const bool canMove = current.row() + maxItemsPerRow < block.firstIndex.row() +
block.items.count(); block.items.count();


Expand Down Expand Up @@ -1354,7 +1356,8 @@ QModelIndex KCategorizedView::moveCursor ( CursorAction cursorAction,
const QSize itemSize = d->hasGrid() ? gridSize() const QSize itemSize = d->hasGrid() ? gridSize()
: sizeHintForIndex ( current ); : sizeHintForIndex ( current );
const Private::Block &block = d->blocks[d->categoryForIndex ( 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(); const bool canMove = current.row() - maxItemsPerRow >= block.firstIndex.row();


if ( canMove ) if ( canMove )
Expand Down

0 comments on commit d2eef69

Please sign in to comment.