1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 14:46:33 +02:00

* Support official release on album pages.

This commit is contained in:
Christian Muehlhaeuser
2011-10-19 02:06:53 +02:00
parent 03f0870f53
commit a6c838cd39
9 changed files with 100 additions and 12 deletions

View File

@@ -212,6 +212,7 @@ set( libSources
widgets/whatshotwidget.cpp widgets/whatshotwidget.cpp
widgets/RecentlyPlayedPlaylistsModel.cpp widgets/RecentlyPlayedPlaylistsModel.cpp
widgets/RecentPlaylistsModel.cpp widgets/RecentPlaylistsModel.cpp
widgets/OverlayButton.cpp
widgets/overlaywidget.cpp widgets/overlaywidget.cpp
widgets/HeaderLabel.cpp widgets/HeaderLabel.cpp
widgets/HeaderWidget.cpp widgets/HeaderWidget.cpp
@@ -436,6 +437,7 @@ set( libHeaders
widgets/whatshotwidget.h widgets/whatshotwidget.h
widgets/RecentlyPlayedPlaylistsModel.h widgets/RecentlyPlayedPlaylistsModel.h
widgets/RecentPlaylistsModel.h widgets/RecentPlaylistsModel.h
widgets/OverlayButton.h
widgets/overlaywidget.h widgets/overlaywidget.h
widgets/HeaderLabel.h widgets/HeaderLabel.h
widgets/HeaderWidget.h widgets/HeaderWidget.h

View File

@@ -73,12 +73,14 @@ TreeModel::clear()
} }
} }
Tomahawk::collection_ptr Tomahawk::collection_ptr
TreeModel::collection() const TreeModel::collection() const
{ {
return m_collection; return m_collection;
} }
void void
TreeModel::getCover( const QModelIndex& index ) TreeModel::getCover( const QModelIndex& index )
{ {

View File

@@ -64,6 +64,7 @@ TreeProxyModel::setSourceTreeModel( TreeModel* sourceModel )
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( sourceTrackCountChanged( unsigned int ) ) ); connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SIGNAL( sourceTrackCountChanged( unsigned int ) ) );
connect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onRowsInserted( QModelIndex, int, int ) ) ); connect( m_model, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onRowsInserted( QModelIndex, int, int ) ) );
connect( m_model, SIGNAL( modelReset() ), SLOT( onModelReset() ) );
} }
QSortFilterProxyModel::setSourceModel( sourceModel ); QSortFilterProxyModel::setSourceModel( sourceModel );
@@ -93,6 +94,15 @@ TreeProxyModel::onRowsInserted( const QModelIndex& parent, int /* start */, int
} }
void
TreeProxyModel::onModelReset()
{
m_cache.clear();
m_artistsFilter.clear();
m_albumsFilter.clear();
}
void void
TreeProxyModel::setFilter( const QString& pattern ) TreeProxyModel::setFilter( const QString& pattern )
{ {

View File

@@ -92,6 +92,8 @@ private slots:
void onFilterArtists( const QList<Tomahawk::artist_ptr>& artists ); void onFilterArtists( const QList<Tomahawk::artist_ptr>& artists );
void onFilterAlbums( const QList<Tomahawk::album_ptr>& albums ); void onFilterAlbums( const QList<Tomahawk::album_ptr>& albums );
void onModelReset();
private: private:
void filterFinished(); void filterFinished();
QString textForItem( TreeModelItem* item ) const; QString textForItem( TreeModelItem* item ) const;

View File

@@ -30,6 +30,7 @@
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "widgets/OverlayButton.h"
#include "widgets/overlaywidget.h" #include "widgets/overlaywidget.h"
static QString s_aiInfoIdentifier = QString( "AlbumInfoWidget" ); static QString s_aiInfoIdentifier = QString( "AlbumInfoWidget" );
@@ -56,11 +57,21 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* par
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( TreeModel::InfoSystem );
ui->tracksView->setTreeModel( m_tracksModel ); ui->tracksView->setTreeModel( m_tracksModel );
ui->tracksView->setRootIsDecorated( false ); ui->tracksView->setRootIsDecorated( false );
m_pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" ).scaledToWidth( 48, Qt::SmoothTransformation ); m_pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" ).scaledToWidth( 48, Qt::SmoothTransformation );
m_button = new OverlayButton( ui->tracksView );
m_button->setText( tr( "Click to show All Tracks" ) );
m_button->setCheckable( true );
m_button->setChecked( true );
connect( m_button, SIGNAL( clicked() ), SLOT( onModeToggle() ) );
connect( m_tracksModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) );
connect( m_tracksModel, SIGNAL( loadingFinished() ), SLOT( onLoadingFinished() ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) ); SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
@@ -77,6 +88,36 @@ AlbumInfoWidget::~AlbumInfoWidget()
} }
void
AlbumInfoWidget::onModeToggle()
{
m_tracksModel->setMode( m_button->isChecked() ? TreeModel::InfoSystem : TreeModel::Database );
m_tracksModel->clear();
m_tracksModel->addTracks( m_album, QModelIndex() );
if ( m_button->isChecked() )
m_button->setText( tr( "Click to show All Tracks" ) );
else
m_button->setText( tr( "Click to show Official Tracks" ) );
}
void
AlbumInfoWidget::onLoadingStarted()
{
m_button->setEnabled( false );
m_button->hide();
}
void
AlbumInfoWidget::onLoadingFinished()
{
m_button->setEnabled( true );
m_button->show();
}
void void
AlbumInfoWidget::load( const album_ptr& album ) AlbumInfoWidget::load( const album_ptr& album )
{ {

View File

@@ -38,6 +38,7 @@
class AlbumModel; class AlbumModel;
class TreeModel; class TreeModel;
class OverlayButton;
namespace Ui namespace Ui
{ {
@@ -89,6 +90,10 @@ private slots:
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ); void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target ); void infoSystemFinished( QString target );
void onModeToggle();
void onLoadingStarted();
void onLoadingFinished();
private: private:
Ui::AlbumInfoWidget *ui; Ui::AlbumInfoWidget *ui;
@@ -97,6 +102,8 @@ private:
AlbumModel* m_albumsModel; AlbumModel* m_albumsModel;
TreeModel* m_tracksModel; TreeModel* m_tracksModel;
OverlayButton* m_button;
QString m_title; QString m_title;
QString m_description; QString m_description;
QString m_longDescription; QString m_longDescription;

View File

@@ -30,6 +30,7 @@
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "widgets/OverlayButton.h"
#include "widgets/overlaywidget.h" #include "widgets/overlaywidget.h"
using namespace Tomahawk; using namespace Tomahawk;
@@ -68,12 +69,16 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_topHitsModel->setStyle( TrackModel::Short ); m_topHitsModel->setStyle( TrackModel::Short );
ui->topHits->setTrackModel( m_topHitsModel ); ui->topHits->setTrackModel( m_topHitsModel );
ui->albumHeader->setContentsMargins( 0, 0, 4, 0 );
ui->button->setChecked( true );
m_pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" ).scaledToWidth( 48, Qt::SmoothTransformation ); m_pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" ).scaledToWidth( 48, Qt::SmoothTransformation );
connect( ui->button, SIGNAL( clicked() ), SLOT( onModeToggle() ) ); m_button = new OverlayButton( ui->albums );
m_button->setText( tr( "Click to show All Releases" ) );
m_button->setCheckable( true );
m_button->setChecked( true );
connect( m_button, SIGNAL( clicked() ), SLOT( onModeToggle() ) );
connect( m_albumsModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) );
connect( m_albumsModel, SIGNAL( loadingFinished() ), SLOT( onLoadingFinished() ) );
connect( Tomahawk::InfoSystem::InfoSystem::instance(), connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
@@ -94,9 +99,30 @@ ArtistInfoWidget::~ArtistInfoWidget()
void void
ArtistInfoWidget::onModeToggle() ArtistInfoWidget::onModeToggle()
{ {
m_albumsModel->setMode( ui->button->isChecked() ? TreeModel::InfoSystem : TreeModel::Database ); m_albumsModel->setMode( m_button->isChecked() ? TreeModel::InfoSystem : TreeModel::Database );
m_albumsModel->clear(); m_albumsModel->clear();
m_albumsModel->addAlbums( m_artist, QModelIndex() ); m_albumsModel->addAlbums( m_artist, QModelIndex() );
if ( m_button->isChecked() )
m_button->setText( tr( "Click to show All Releases" ) );
else
m_button->setText( tr( "Click to show Official Releases" ) );
}
void
ArtistInfoWidget::onLoadingStarted()
{
m_button->setEnabled( false );
m_button->hide();
}
void
ArtistInfoWidget::onLoadingFinished()
{
m_button->setEnabled( true );
m_button->show();
} }

View File

@@ -40,6 +40,7 @@
class PlaylistModel; class PlaylistModel;
class TreeModel; class TreeModel;
class OverlayButton;
namespace Ui namespace Ui
{ {
@@ -90,6 +91,8 @@ private slots:
void infoSystemFinished( QString target ); void infoSystemFinished( QString target );
void onModeToggle(); void onModeToggle();
void onLoadingStarted();
void onLoadingFinished();
private: private:
Ui::ArtistInfoWidget *ui; Ui::ArtistInfoWidget *ui;
@@ -100,6 +103,8 @@ private:
TreeModel* m_albumsModel; TreeModel* m_albumsModel;
PlaylistModel* m_topHitsModel; PlaylistModel* m_topHitsModel;
OverlayButton* m_button;
QString m_title; QString m_title;
QString m_description; QString m_description;
QString m_longDescription; QString m_longDescription;

View File

@@ -78,13 +78,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="ToggleButton" name="button">
<property name="text">
<string>Official Releases Only</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>