diff --git a/src/libtomahawk/playlist/GridView.cpp b/src/libtomahawk/playlist/GridView.cpp index 7bbaf8350..d23a137a6 100644 --- a/src/libtomahawk/playlist/GridView.cpp +++ b/src/libtomahawk/playlist/GridView.cpp @@ -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 ); }