1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
4
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
6
* Tomahawk is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Tomahawk is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
20
#include "RelatedArtistsContext.h"
22
#include <QHeaderView>
24
#include "playlist/TreeView.h"
25
#include "playlist/TreeModel.h"
28
using namespace Tomahawk;
31
RelatedArtistsContext::RelatedArtistsContext()
34
m_relatedView = new TreeView();
35
m_relatedView->setGuid( "RelatedArtistsContext" );
36
m_relatedView->setUpdatesContextView( false );
37
m_relatedModel = new TreeModel( m_relatedView );
38
m_relatedView->proxyModel()->setStyle( PlayableProxyModel::Large );
39
m_relatedView->setTreeModel( m_relatedModel );
40
m_relatedView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
41
m_relatedView->setSortingEnabled( false );
42
m_relatedView->proxyModel()->sort( -1 );
44
QPalette pal = m_relatedView->palette();
45
pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
46
m_relatedView->setPalette( pal );
48
m_proxy = new QGraphicsProxyWidget();
49
m_proxy->setWidget( m_relatedView );
53
RelatedArtistsContext::~RelatedArtistsContext()
59
RelatedArtistsContext::setArtist( const Tomahawk::artist_ptr& artist )
61
if ( artist.isNull() )
63
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
66
if ( !m_artist.isNull() )
68
disconnect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), this, SLOT( onSimilarArtistsLoaded() ) );
73
connect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), SLOT( onSimilarArtistsLoaded() ) );
75
m_relatedModel->clear();
76
onSimilarArtistsLoaded();
81
RelatedArtistsContext::setQuery( const Tomahawk::query_ptr& query )
86
setArtist( Artist::get( query->artist(), false ) );
91
RelatedArtistsContext::setAlbum( const Tomahawk::album_ptr& album )
96
setArtist( album->artist() );
101
RelatedArtistsContext::onSimilarArtistsLoaded()
103
foreach ( const artist_ptr& artist, m_artist->similarArtists() )
105
m_relatedModel->addArtists( artist );