mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
* Use item-views on ArtistInfoWidget.
This commit is contained in:
@@ -65,14 +65,13 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
|||||||
TomahawkUtils::unmarginLayout( ui->layoutWidget2->layout() );
|
TomahawkUtils::unmarginLayout( ui->layoutWidget2->layout() );
|
||||||
TomahawkUtils::unmarginLayout( ui->albumHeader->layout() );
|
TomahawkUtils::unmarginLayout( ui->albumHeader->layout() );
|
||||||
|
|
||||||
m_albumsModel = new TreeModel( ui->albums );
|
m_albumsModel = new AlbumModel( ui->albums );
|
||||||
m_albumsModel->setMode( InfoSystemMode );
|
ui->albums->setAlbumModel( m_albumsModel );
|
||||||
ui->albums->setTreeModel( m_albumsModel );
|
|
||||||
|
|
||||||
m_relatedModel = new TreeModel( ui->relatedArtists );
|
m_relatedModel = new AlbumModel( ui->relatedArtists );
|
||||||
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
|
// m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
|
||||||
ui->relatedArtists->setTreeModel( m_relatedModel );
|
ui->relatedArtists->setAlbumModel( m_relatedModel );
|
||||||
ui->relatedArtists->setSortingEnabled( false );
|
// ui->relatedArtists->setSortingEnabled( false );
|
||||||
ui->relatedArtists->proxyModel()->sort( -1 );
|
ui->relatedArtists->proxyModel()->sort( -1 );
|
||||||
|
|
||||||
m_topHitsModel = new PlaylistModel( ui->topHits );
|
m_topHitsModel = new PlaylistModel( ui->topHits );
|
||||||
@@ -82,13 +81,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
|||||||
|
|
||||||
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
|
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
|
||||||
|
|
||||||
m_button = new OverlayButton( ui->albums );
|
|
||||||
m_button->setText( tr( "Click to show SuperCollection Albums" ) );
|
|
||||||
m_button->setCheckable( true );
|
|
||||||
m_button->setChecked( true );
|
|
||||||
|
|
||||||
connect( m_button, SIGNAL( clicked() ), SLOT( onModeToggle() ) );
|
|
||||||
connect( m_albumsModel, SIGNAL( modeChanged( Tomahawk::ModelMode ) ), SLOT( setMode( Tomahawk::ModelMode ) ) );
|
|
||||||
connect( m_albumsModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) );
|
connect( m_albumsModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) );
|
||||||
connect( m_albumsModel, SIGNAL( loadingFinished() ), SLOT( onLoadingFinished() ) );
|
connect( m_albumsModel, SIGNAL( loadingFinished() ), SLOT( onLoadingFinished() ) );
|
||||||
|
|
||||||
@@ -113,42 +105,15 @@ ArtistInfoWidget::playlistInterface() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ArtistInfoWidget::setMode( ModelMode mode )
|
|
||||||
{
|
|
||||||
m_button->setChecked( mode == InfoSystemMode );
|
|
||||||
|
|
||||||
if ( m_albumsModel->mode() != mode )
|
|
||||||
onModeToggle();
|
|
||||||
|
|
||||||
if ( mode == InfoSystemMode )
|
|
||||||
m_button->setText( tr( "Click to show SuperCollection Albums" ) );
|
|
||||||
else
|
|
||||||
m_button->setText( tr( "Click to show Official Albums" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ArtistInfoWidget::onModeToggle()
|
|
||||||
{
|
|
||||||
m_albumsModel->setMode( m_button->isChecked() ? InfoSystemMode : DatabaseMode );
|
|
||||||
m_albumsModel->fetchAlbums( m_artist );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ArtistInfoWidget::onLoadingStarted()
|
ArtistInfoWidget::onLoadingStarted()
|
||||||
{
|
{
|
||||||
m_button->setEnabled( false );
|
|
||||||
m_button->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ArtistInfoWidget::onLoadingFinished()
|
ArtistInfoWidget::onLoadingFinished()
|
||||||
{
|
{
|
||||||
m_button->setEnabled( true );
|
|
||||||
m_button->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -193,7 +158,10 @@ ArtistInfoWidget::load( const artist_ptr& artist )
|
|||||||
m_artist = artist;
|
m_artist = artist;
|
||||||
m_title = artist->name();
|
m_title = artist->name();
|
||||||
|
|
||||||
m_albumsModel->fetchAlbums( artist );
|
connect( artist.data(), SIGNAL( albumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ),
|
||||||
|
SLOT( onAlbumsFound( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ) );
|
||||||
|
|
||||||
|
onAlbumsFound( artist->albums( Mixed ), Mixed );
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoStringHash artistInfo;
|
Tomahawk::InfoSystem::InfoStringHash artistInfo;
|
||||||
artistInfo["artist"] = artist->name();
|
artistInfo["artist"] = artist->name();
|
||||||
@@ -224,6 +192,7 @@ ArtistInfoWidget::load( const artist_ptr& artist )
|
|||||||
void
|
void
|
||||||
ArtistInfoWidget::onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, ModelMode mode )
|
ArtistInfoWidget::onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, ModelMode mode )
|
||||||
{
|
{
|
||||||
|
m_albumsModel->addAlbums( albums );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -284,10 +253,12 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
|
|||||||
case InfoSystem::InfoArtistSimilars:
|
case InfoSystem::InfoArtistSimilars:
|
||||||
{
|
{
|
||||||
const QStringList artists = returnedData["artists"].toStringList();
|
const QStringList artists = returnedData["artists"].toStringList();
|
||||||
|
QList<artist_ptr> al;
|
||||||
foreach ( const QString& artist, artists )
|
foreach ( const QString& artist, artists )
|
||||||
{
|
{
|
||||||
m_relatedModel->addArtists( Artist::get( artist ) );
|
al << Artist::get( artist );
|
||||||
}
|
}
|
||||||
|
m_relatedModel->addArtists( al );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -39,8 +39,8 @@
|
|||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
class AlbumModel;
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
class TreeModel;
|
|
||||||
class OverlayButton;
|
class OverlayButton;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@@ -91,14 +91,11 @@ protected:
|
|||||||
void changeEvent( QEvent* e );
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setMode( Tomahawk::ModelMode mode );
|
|
||||||
|
|
||||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
void onArtistImageUpdated();
|
void onArtistImageUpdated();
|
||||||
|
|
||||||
void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
|
void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
|
||||||
|
|
||||||
void onModeToggle();
|
|
||||||
void onLoadingStarted();
|
void onLoadingStarted();
|
||||||
void onLoadingFinished();
|
void onLoadingFinished();
|
||||||
|
|
||||||
@@ -107,13 +104,11 @@ private:
|
|||||||
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
Tomahawk::artist_ptr m_artist;
|
||||||
|
|
||||||
TreeModel* m_relatedModel;
|
AlbumModel* m_relatedModel;
|
||||||
TreeModel* m_albumsModel;
|
AlbumModel* m_albumsModel;
|
||||||
PlaylistModel* m_topHitsModel;
|
PlaylistModel* m_topHitsModel;
|
||||||
Tomahawk::playlistinterface_ptr m_plInterface;
|
Tomahawk::playlistinterface_ptr m_plInterface;
|
||||||
|
|
||||||
OverlayButton* m_button;
|
|
||||||
|
|
||||||
QString m_title;
|
QString m_title;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
QString m_longDescription;
|
QString m_longDescription;
|
||||||
|
@@ -57,10 +57,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="ArtistView" name="relatedArtists">
|
<widget class="AlbumView" name="relatedArtists">
|
||||||
<property name="headerHidden">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@@ -82,7 +79,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="ArtistView" name="albums"/>
|
<widget class="AlbumView" name="albums"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -116,6 +113,11 @@
|
|||||||
<extends>QTreeView</extends>
|
<extends>QTreeView</extends>
|
||||||
<header location="global">ArtistView.h</header>
|
<header location="global">ArtistView.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>AlbumView</class>
|
||||||
|
<extends>QListView</extends>
|
||||||
|
<header location="global">AlbumView.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Reference in New Issue
Block a user