mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
* Fixed GridView's auto-size mode not working correctly.
This commit is contained in:
@@ -81,8 +81,6 @@ GridView::GridView( QWidget* parent )
|
|||||||
|
|
||||||
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
|
||||||
connect( this, SIGNAL( customContextMenuRequested( QPoint ) ), SLOT( onCustomContextMenu( QPoint ) ) );
|
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( filterChanged( QString ) ), this, SLOT( onFilterChanged( QString ) ) );
|
||||||
disconnect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
|
disconnect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( verifySize() ) );
|
||||||
disconnect( m_proxyModel, SIGNAL( rowsRemoved( 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;
|
m_proxyModel = model;
|
||||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||||
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
||||||
connect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
connect( m_proxyModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
||||||
|
connect( proxyModel(), SIGNAL( modelReset() ), SLOT( layoutItems() ) );
|
||||||
|
|
||||||
if ( m_delegate )
|
if ( m_delegate )
|
||||||
delete m_delegate;
|
delete m_delegate;
|
||||||
|
|
||||||
@@ -133,8 +133,7 @@ void
|
|||||||
GridView::setPlayableModel( PlayableModel* model )
|
GridView::setPlayableModel( PlayableModel* model )
|
||||||
{
|
{
|
||||||
if ( m_model )
|
if ( m_model )
|
||||||
{
|
delete m_model;
|
||||||
}
|
|
||||||
|
|
||||||
m_inited = false;
|
m_inited = false;
|
||||||
m_model = model;
|
m_model = model;
|
||||||
@@ -142,7 +141,7 @@ GridView::setPlayableModel( PlayableModel* model )
|
|||||||
if ( m_proxyModel )
|
if ( m_proxyModel )
|
||||||
{
|
{
|
||||||
m_proxyModel->setSourcePlayableModel( m_model );
|
m_proxyModel->setSourcePlayableModel( m_model );
|
||||||
m_proxyModel->sort( 0 );
|
m_proxyModel->sort( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
emit modelChanged();
|
emit modelChanged();
|
||||||
@@ -237,10 +236,10 @@ GridView::verifySize()
|
|||||||
const int rows = floor( (double)m_model->rowCount( QModelIndex() ) / (double)itemsPerRow );
|
const int rows = floor( (double)m_model->rowCount( QModelIndex() ) / (double)itemsPerRow );
|
||||||
const int newHeight = rows * m_delegate->itemSize().height();
|
const int newHeight = rows * m_delegate->itemSize().height();
|
||||||
|
|
||||||
|
m_proxyModel->setMaxVisibleItems( m_model->rowCount( QModelIndex() ) - overlapRows );
|
||||||
|
|
||||||
if ( newHeight > 0 )
|
if ( newHeight > 0 )
|
||||||
setFixedHeight( newHeight );
|
setFixedHeight( newHeight );
|
||||||
|
|
||||||
m_proxyModel->setMaxVisibleItems( m_model->rowCount( QModelIndex() ) - overlapRows );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user