1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 19:30:21 +02:00

* Allow for overriding of a TrackView's PlaylistInterface.

This commit is contained in:
Christian Muehlhaeuser
2012-11-09 06:40:03 +01:00
parent fa98d23a13
commit 9208a0244c
2 changed files with 25 additions and 5 deletions

View File

@@ -102,8 +102,13 @@ TrackView::~TrackView()
void
TrackView::setGuid( const QString& guid )
{
m_guid = guid;
m_header->setGuid( guid );
if ( !guid.isEmpty() )
{
tDebug() << Q_FUNC_INFO << "Setting guid on header" << guid << "for a view with" << m_proxyModel->columnCount() << "columns";
m_guid = QString( "%1/%2" ).arg( guid ).arg( m_proxyModel->columnCount() );
m_header->setGuid( m_guid );
}
}
@@ -143,6 +148,7 @@ TrackView::setPlayableModel( PlayableModel* model )
setAcceptDrops( true );
m_header->setDefaultColumnWeights( m_proxyModel->columnWeights() );
setGuid( m_proxyModel->guid() );
switch( m_proxyModel->style() )
{
@@ -303,7 +309,7 @@ TrackView::tryToPlayItem( const QModelIndex& index )
if ( item && !item->query().isNull() )
{
m_proxyModel->setCurrentIndex( index );
AudioEngine::instance()->playItem( m_proxyModel->playlistInterface(), item->query() );
AudioEngine::instance()->playItem( playlistInterface(), item->query() );
return true;
}
@@ -710,7 +716,19 @@ TrackView::mousePressEvent( QMouseEvent* event )
Tomahawk::playlistinterface_ptr
TrackView::playlistInterface() const
{
return proxyModel()->playlistInterface();
if ( m_playlistInterface.isNull() )
{
return proxyModel()->playlistInterface();
}
return m_playlistInterface;
}
void
TrackView::setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface )
{
m_playlistInterface = playlistInterface;
}

View File

@@ -64,6 +64,7 @@ public:
virtual QWidget* widget() { return this; }
virtual Tomahawk::playlistinterface_ptr playlistInterface() const;
void setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface );
virtual QString title() const;
virtual QString description() const;
@@ -123,7 +124,7 @@ private slots:
void onCustomContextMenu( const QPoint& pos );
void autoPlayResolveFinished( const Tomahawk::query_ptr& query, int row );
void autoPlayResolveFinished( const Tomahawk::query_ptr& query, int row );
private:
void startAutoPlay( const QModelIndex& index );
@@ -145,6 +146,7 @@ private:
bool m_updateContextView;
Tomahawk::playlistinterface_ptr m_playlistInterface;
QModelIndex m_hoveredIndex;
QModelIndex m_contextMenuIndex;