mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 16:14:40 +02:00
* GridView now supports auto-resizing to fit its contents.
This commit is contained in:
@@ -74,6 +74,7 @@ GridView::GridView( QWidget* parent )
|
|||||||
setStyleSheet( "QListView { background-color: #323435; }" );
|
setStyleSheet( "QListView { background-color: #323435; }" );
|
||||||
|
|
||||||
setAutoFitItems( true );
|
setAutoFitItems( true );
|
||||||
|
setAutoResize( false );
|
||||||
setProxyModel( new PlayableProxyModel( this ) );
|
setProxyModel( new PlayableProxyModel( this ) );
|
||||||
|
|
||||||
/* m_overlay->setText( tr( "After you have scanned your music collection you will find your latest album additions right here." ) );
|
/* m_overlay->setText( tr( "After you have scanned your music collection you will find your latest album additions right here." ) );
|
||||||
@@ -221,6 +222,13 @@ GridView::layoutItems()
|
|||||||
|
|
||||||
m_model->setItemSize( QSize( newItemWidth, newItemWidth ) );
|
m_model->setItemSize( QSize( newItemWidth, newItemWidth ) );
|
||||||
|
|
||||||
|
if ( autoResize() )
|
||||||
|
{
|
||||||
|
int rows = ceil( (double)m_proxyModel->rowCount( QModelIndex() ) / (double)itemsPerRow );
|
||||||
|
int newHeight = rows * newItemWidth;
|
||||||
|
setFixedHeight( newHeight );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !m_inited )
|
if ( !m_inited )
|
||||||
{
|
{
|
||||||
m_inited = true;
|
m_inited = true;
|
||||||
|
@@ -54,6 +54,9 @@ public:
|
|||||||
bool autoFitItems() const { return m_autoFitItems; }
|
bool autoFitItems() const { return m_autoFitItems; }
|
||||||
void setAutoFitItems( bool b ) { m_autoFitItems = b; }
|
void setAutoFitItems( bool b ) { m_autoFitItems = b; }
|
||||||
|
|
||||||
|
bool autoResize() const { return m_autoResize; }
|
||||||
|
void setAutoResize( bool b ) { m_autoResize = b; }
|
||||||
|
|
||||||
void setPlayableModel( PlayableModel* model );
|
void setPlayableModel( PlayableModel* model );
|
||||||
void setModel( QAbstractItemModel* model );
|
void setModel( QAbstractItemModel* model );
|
||||||
|
|
||||||
@@ -105,6 +108,7 @@ private:
|
|||||||
QString m_emptyTip;
|
QString m_emptyTip;
|
||||||
bool m_inited;
|
bool m_inited;
|
||||||
bool m_autoFitItems;
|
bool m_autoFitItems;
|
||||||
|
bool m_autoResize;
|
||||||
|
|
||||||
QRect m_paintRect;
|
QRect m_paintRect;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user