mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
* GridView now supports auto-resizing to fit its contents.
This commit is contained in:
parent
4fad494630
commit
87dd871c6c
@ -74,6 +74,7 @@ GridView::GridView( QWidget* parent )
|
||||
setStyleSheet( "QListView { background-color: #323435; }" );
|
||||
|
||||
setAutoFitItems( true );
|
||||
setAutoResize( false );
|
||||
setProxyModel( new PlayableProxyModel( this ) );
|
||||
|
||||
/* 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 ) );
|
||||
|
||||
if ( autoResize() )
|
||||
{
|
||||
int rows = ceil( (double)m_proxyModel->rowCount( QModelIndex() ) / (double)itemsPerRow );
|
||||
int newHeight = rows * newItemWidth;
|
||||
setFixedHeight( newHeight );
|
||||
}
|
||||
|
||||
if ( !m_inited )
|
||||
{
|
||||
m_inited = true;
|
||||
|
@ -54,6 +54,9 @@ public:
|
||||
bool autoFitItems() const { return m_autoFitItems; }
|
||||
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 setModel( QAbstractItemModel* model );
|
||||
|
||||
@ -105,6 +108,7 @@ private:
|
||||
QString m_emptyTip;
|
||||
bool m_inited;
|
||||
bool m_autoFitItems;
|
||||
bool m_autoResize;
|
||||
|
||||
QRect m_paintRect;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user