1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

* Fixed GridView's auto-size mode not working correctly.

This commit is contained in:
Christian Muehlhaeuser 2012-12-22 14:23:27 +01:00
parent 982791f574
commit 63fc41d23d

View File

@ -81,8 +81,6 @@ GridView::GridView( QWidget* parent )
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
connect( this, SIGNAL( customContextMenuRequested( QPoint ) ), SLOT( onCustomContextMenu( QPoint ) ) );
connect( proxyModel(), SIGNAL( modelReset() ), SLOT( layoutItems() ) );
}
@ -100,13 +98,15 @@ GridView::setProxyModel( PlayableProxyModel* model )
disconnect( m_proxyModel, SIGNAL( filterChanged( QString ) ), this, SLOT( onFilterChanged( QString ) ) );
disconnect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
disconnect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
disconnect( proxyModel(), SIGNAL( modelReset() ), this, SLOT( layoutItems() ) );
}
m_proxyModel = model;
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( verifySize() ) );
connect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( verifySize() ) );
connect( proxyModel(), SIGNAL( modelReset() ), SLOT( layoutItems() ) );
if ( m_delegate )
delete m_delegate;
@ -133,8 +133,7 @@ void
GridView::setPlayableModel( PlayableModel* model )
{
if ( m_model )
{
}
delete m_model;
m_inited = false;
m_model = model;
@ -142,7 +141,7 @@ GridView::setPlayableModel( PlayableModel* model )
if ( m_proxyModel )
{
m_proxyModel->setSourcePlayableModel( m_model );
m_proxyModel->sort( 0 );
m_proxyModel->sort( -1 );
}
emit modelChanged();
@ -237,10 +236,10 @@ GridView::verifySize()
const int rows = floor( (double)m_model->rowCount( QModelIndex() ) / (double)itemsPerRow );
const int newHeight = rows * m_delegate->itemSize().height();
m_proxyModel->setMaxVisibleItems( m_model->rowCount( QModelIndex() ) - overlapRows );
if ( newHeight > 0 )
setFixedHeight( newHeight );
m_proxyModel->setMaxVisibleItems( m_model->rowCount( QModelIndex() ) - overlapRows );
}