mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Auto-resize PlaylistWidget.
This commit is contained in:
@@ -43,7 +43,6 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
|
||||||
|
|
||||||
#define HISTORY_PLAYLIST_ITEMS 10
|
#define HISTORY_PLAYLIST_ITEMS 10
|
||||||
#define HISTORY_TRACK_ITEMS 15
|
#define HISTORY_TRACK_ITEMS 15
|
||||||
|
|
||||||
@@ -243,7 +242,7 @@ void
|
|||||||
Dashboard::onPlaylistActivated( const QModelIndex& item )
|
Dashboard::onPlaylistActivated( const QModelIndex& item )
|
||||||
{
|
{
|
||||||
Tomahawk::playlist_ptr pl = item.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >();
|
Tomahawk::playlist_ptr pl = item.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >();
|
||||||
if( Tomahawk::dynplaylist_ptr dynplaylist = pl.dynamicCast< Tomahawk::DynamicPlaylist >() )
|
if ( Tomahawk::dynplaylist_ptr dynplaylist = pl.dynamicCast< Tomahawk::DynamicPlaylist >() )
|
||||||
ViewManager::instance()->show( dynplaylist );
|
ViewManager::instance()->show( dynplaylist );
|
||||||
else
|
else
|
||||||
ViewManager::instance()->show( pl );
|
ViewManager::instance()->show( pl );
|
||||||
@@ -412,5 +411,22 @@ void
|
|||||||
PlaylistWidget::setModel( QAbstractItemModel* model )
|
PlaylistWidget::setModel( QAbstractItemModel* model )
|
||||||
{
|
{
|
||||||
QListView::setModel( model );
|
QListView::setModel( model );
|
||||||
|
|
||||||
|
connect( model, SIGNAL( modelReset() ), SLOT( verifySize() ) );
|
||||||
|
connect( model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
||||||
|
connect( model, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( verifySize() ) );
|
||||||
|
|
||||||
emit modelChanged();
|
emit modelChanged();
|
||||||
|
verifySize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PlaylistWidget::verifySize()
|
||||||
|
{
|
||||||
|
if ( !model() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( model()->rowCount() > 0 )
|
||||||
|
setFixedHeight( model()->rowCount() * itemDelegate()->sizeHint( QStyleOptionViewItem(), model()->index( 0, 0 ) ).height() + frameWidth() * 2 );
|
||||||
|
}
|
@@ -73,6 +73,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void modelChanged();
|
void modelChanged();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void verifySize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayWidget* m_overlay;
|
OverlayWidget* m_overlay;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user