1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 06:36:55 +02:00

* Use item-views on AlbumInfoWidget.

This commit is contained in:
Christian Muehlhaeuser
2012-05-18 12:08:50 +02:00
parent 33c9f59929
commit bf3e2ccb01
2 changed files with 5 additions and 70 deletions

View File

@@ -39,7 +39,7 @@
using namespace Tomahawk; using namespace Tomahawk;
AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, ModelMode startingMode, QWidget* parent ) AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::AlbumInfoWidget ) , ui( new Ui::AlbumInfoWidget )
, m_infoId( uuid() ) , m_infoId( uuid() )
@@ -59,29 +59,12 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, ModelMode st
ui->albumsView->setAlbumModel( m_albumsModel ); ui->albumsView->setAlbumModel( m_albumsModel );
m_tracksModel = new TreeModel( ui->tracksView ); m_tracksModel = new TreeModel( ui->tracksView );
m_tracksModel->setMode( startingMode ); m_tracksModel->setMode( Mixed );
ui->tracksView->setTreeModel( m_tracksModel ); ui->tracksView->setTreeModel( m_tracksModel );
ui->tracksView->setRootIsDecorated( false ); ui->tracksView->setRootIsDecorated( false );
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) ); m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
m_button = new OverlayButton( ui->tracksView );
m_button->setCheckable( true );
m_button->setChecked( m_tracksModel->mode() == InfoSystemMode );
if ( m_button->isChecked() )
m_button->setText( tr( "Click to show SuperCollection Tracks" ) );
else
m_button->setText( tr( "Click to show Official Tracks" ) );
m_buttonAlbums = new OverlayButton( ui->albumsView );
m_buttonAlbums->setCheckable( true );
m_buttonAlbums->setChecked( true );
m_buttonAlbums->setText( tr( "Click to show SuperCollection Albums" ) );
m_buttonAlbums->show();
connect( m_button, SIGNAL( clicked() ), SLOT( onModeToggle() ) );
connect( m_buttonAlbums, SIGNAL( clicked() ), SLOT( onAlbumsModeToggle() ) );
connect( m_tracksModel, SIGNAL( modeChanged( Tomahawk::ModelMode ) ), SLOT( setMode( Tomahawk::ModelMode ) ) );
connect( m_tracksModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) ); connect( m_tracksModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) );
connect( m_tracksModel, SIGNAL( loadingFinished() ), SLOT( onLoadingFinished() ) ); connect( m_tracksModel, SIGNAL( loadingFinished() ), SLOT( onLoadingFinished() ) );
@@ -102,54 +85,15 @@ AlbumInfoWidget::playlistInterface() const
} }
void
AlbumInfoWidget::setMode( ModelMode mode )
{
m_button->setChecked( mode == InfoSystemMode );
if ( m_tracksModel->mode() != mode )
onModeToggle();
if ( mode == InfoSystemMode )
m_button->setText( tr( "Click to show SuperCollection Tracks" ) );
else
m_button->setText( tr( "Click to show Official Tracks" ) );
}
void
AlbumInfoWidget::onModeToggle()
{
m_tracksModel->setMode( m_button->isChecked() ? InfoSystemMode : DatabaseMode );
m_tracksModel->addTracks( m_album, QModelIndex() );
}
void
AlbumInfoWidget::onAlbumsModeToggle()
{
if ( m_buttonAlbums->isChecked() )
m_buttonAlbums->setText( tr( "Click to show SuperCollection Albums" ) );
else
m_buttonAlbums->setText( tr( "Click to show Official Albums" ) );
loadAlbums();
}
void void
AlbumInfoWidget::onLoadingStarted() AlbumInfoWidget::onLoadingStarted()
{ {
m_button->setEnabled( false );
m_button->hide();
} }
void void
AlbumInfoWidget::onLoadingFinished() AlbumInfoWidget::onLoadingFinished()
{ {
m_button->setEnabled( true );
m_button->show();
} }
@@ -216,8 +160,7 @@ AlbumInfoWidget::loadAlbums( bool autoRefetch )
connect( m_album->artist().data(), SIGNAL( albumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ), connect( m_album->artist().data(), SIGNAL( albumsAdded( QList<Tomahawk::album_ptr>, Tomahawk::ModelMode ) ),
SLOT( gotAlbums( QList<Tomahawk::album_ptr> ) ) ); SLOT( gotAlbums( QList<Tomahawk::album_ptr> ) ) );
ModelMode mode = m_buttonAlbums->isChecked() ? InfoSystemMode : DatabaseMode; gotAlbums( m_album->artist()->albums( Mixed ) );
gotAlbums( m_album->artist()->albums( mode ) );
/* tDebug() << "Auto refetching"; /* tDebug() << "Auto refetching";
m_buttonAlbums->setChecked( false ); m_buttonAlbums->setChecked( false );

View File

@@ -53,7 +53,7 @@ class DLLEXPORT AlbumInfoWidget : public QWidget, public Tomahawk::ViewPage
Q_OBJECT Q_OBJECT
public: public:
AlbumInfoWidget( const Tomahawk::album_ptr& album, Tomahawk::ModelMode startingMode = Tomahawk::InfoSystemMode, QWidget* parent = 0 ); AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent = 0 );
~AlbumInfoWidget(); ~AlbumInfoWidget();
virtual QWidget* widget() { return this; } virtual QWidget* widget() { return this; }
@@ -73,8 +73,6 @@ public:
virtual bool isBeingPlayed() const; virtual bool isBeingPlayed() const;
public slots: public slots:
void setMode( Tomahawk::ModelMode mode );
/** \brief Loads information for a given album. /** \brief Loads information for a given album.
* \param album The album that you want to load information for. * \param album The album that you want to load information for.
* *
@@ -98,23 +96,17 @@ private slots:
void gotAlbums( const QList<Tomahawk::album_ptr>& albums ); void gotAlbums( const QList<Tomahawk::album_ptr>& albums );
void onAlbumCoverUpdated(); void onAlbumCoverUpdated();
void onModeToggle();
void onAlbumsModeToggle();
void onLoadingStarted(); void onLoadingStarted();
void onLoadingFinished(); void onLoadingFinished();
private: private:
Ui::AlbumInfoWidget *ui; Ui::AlbumInfoWidget* ui;
Tomahawk::album_ptr m_album; Tomahawk::album_ptr m_album;
AlbumModel* m_albumsModel; AlbumModel* m_albumsModel;
TreeModel* m_tracksModel; TreeModel* m_tracksModel;
OverlayButton* m_button;
OverlayButton* m_buttonAlbums;
QString m_title; QString m_title;
QString m_description; QString m_description;
QString m_longDescription; QString m_longDescription;