1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01: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/RecentlyPlayedPlaylistsModel.cpp
widgets/RecentPlaylistsModel.cpp
widgets/OverlayButton.cpp
widgets/overlaywidget.cpp
widgets/HeaderLabel.cpp
widgets/HeaderWidget.cpp
@ -436,6 +437,7 @@ set( libHeaders
widgets/whatshotwidget.h
widgets/RecentlyPlayedPlaylistsModel.h
widgets/RecentPlaylistsModel.h
widgets/OverlayButton.h
widgets/overlaywidget.h
widgets/HeaderLabel.h
widgets/HeaderWidget.h

View File

@ -73,12 +73,14 @@ TreeModel::clear()
}
}
Tomahawk::collection_ptr
TreeModel::collection() const
{
return m_collection;
}
void
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( rowsInserted( QModelIndex, int, int ) ), SLOT( onRowsInserted( QModelIndex, int, int ) ) );
connect( m_model, SIGNAL( modelReset() ), SLOT( onModelReset() ) );
}
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
TreeProxyModel::setFilter( const QString& pattern )
{

View File

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

View File

@ -30,6 +30,7 @@
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
#include "widgets/OverlayButton.h"
#include "widgets/overlaywidget.h"
static QString s_aiInfoIdentifier = QString( "AlbumInfoWidget" );
@ -56,11 +57,21 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* par
ui->albumsView->setAlbumModel( m_albumsModel );
m_tracksModel = new TreeModel( ui->tracksView );
m_tracksModel->setMode( TreeModel::InfoSystem );
ui->tracksView->setTreeModel( m_tracksModel );
ui->tracksView->setRootIsDecorated( false );
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(),
SIGNAL( info( 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
AlbumInfoWidget::load( const album_ptr& album )
{

View File

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

View File

@ -30,6 +30,7 @@
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
#include "widgets/OverlayButton.h"
#include "widgets/overlaywidget.h"
using namespace Tomahawk;
@ -68,12 +69,16 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_topHitsModel->setStyle( TrackModel::Short );
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 );
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(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
@ -94,9 +99,30 @@ ArtistInfoWidget::~ArtistInfoWidget()
void
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->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 TreeModel;
class OverlayButton;
namespace Ui
{
@ -90,6 +91,8 @@ private slots:
void infoSystemFinished( QString target );
void onModeToggle();
void onLoadingStarted();
void onLoadingFinished();
private:
Ui::ArtistInfoWidget *ui;
@ -100,6 +103,8 @@ private:
TreeModel* m_albumsModel;
PlaylistModel* m_topHitsModel;
OverlayButton* m_button;
QString m_title;
QString m_description;
QString m_longDescription;

View File

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