mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
Show the same mode as the source when clicking into an album from the collection
This commit is contained in:
parent
ae56d51076
commit
7ab68fb418
@ -158,7 +158,7 @@ ArtistView::onItemActivated( const QModelIndex& index )
|
||||
if ( !item->artist().isNull() )
|
||||
ViewManager::instance()->show( item->artist() );
|
||||
else if ( !item->album().isNull() )
|
||||
ViewManager::instance()->show( item->album() );
|
||||
ViewManager::instance()->show( item->album(), m_model->mode() );
|
||||
else if ( !item->result().isNull() && item->result()->isOnline() )
|
||||
{
|
||||
m_model->setCurrentItem( item->index );
|
||||
|
@ -38,7 +38,7 @@ TreeModel::TreeModel( QObject* parent )
|
||||
, m_rootItem( new TreeModelItem( 0, this ) )
|
||||
, m_infoId( uuid() )
|
||||
, m_columnStyle( AllColumns )
|
||||
, m_mode( Database )
|
||||
, m_mode( DatabaseMode )
|
||||
{
|
||||
setIcon( QPixmap( RESPATH "images/music-icon.png" ) );
|
||||
|
||||
@ -576,7 +576,7 @@ TreeModel::addAlbums( const artist_ptr& artist, const QModelIndex& parent )
|
||||
{
|
||||
emit loadingStarted();
|
||||
|
||||
if ( m_mode == Database )
|
||||
if ( m_mode == DatabaseMode )
|
||||
{
|
||||
DatabaseCommand_AllAlbums* cmd = new DatabaseCommand_AllAlbums( m_collection, artist );
|
||||
cmd->setData( parent.row() );
|
||||
@ -586,7 +586,7 @@ TreeModel::addAlbums( const artist_ptr& artist, const QModelIndex& parent )
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
else if ( m_mode == InfoSystem )
|
||||
else if ( m_mode == InfoSystemMode )
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoStringHash artistInfo;
|
||||
artistInfo["artist"] = artist->name();
|
||||
@ -612,7 +612,7 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent )
|
||||
rows << parent.row();
|
||||
rows << parent.parent().row();
|
||||
|
||||
if ( m_mode == Database )
|
||||
if ( m_mode == DatabaseMode )
|
||||
{
|
||||
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( m_collection );
|
||||
cmd->setAlbum( album.data() );
|
||||
@ -623,7 +623,7 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent )
|
||||
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
else if ( m_mode == InfoSystem )
|
||||
else if ( m_mode == InfoSystemMode )
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoStringHash artistInfo;
|
||||
artistInfo["artist"] = album->artist()->name();
|
||||
@ -850,14 +850,14 @@ TreeModel::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QV
|
||||
{
|
||||
if ( m_receivedInfoData.contains( requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >() ) )
|
||||
break;
|
||||
|
||||
|
||||
QVariantMap returnedData = output.value< QVariantMap >();
|
||||
if ( returnedData.isEmpty() )
|
||||
break;
|
||||
|
||||
|
||||
m_receivedInfoData.insert( requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >() );
|
||||
|
||||
|
||||
|
||||
QStringList tracks = returnedData[ "tracks" ].toStringList();
|
||||
QList<query_ptr> ql;
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "infosystem/infosystem.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
class QMetaData;
|
||||
|
||||
@ -55,9 +56,6 @@ public:
|
||||
enum ColumnStyle
|
||||
{ AllColumns = 0, TrackOnly };
|
||||
|
||||
enum ModelMode
|
||||
{ Database = 0, InfoSystem };
|
||||
|
||||
explicit TreeModel( QObject* parent = 0 );
|
||||
virtual ~TreeModel();
|
||||
|
||||
@ -73,8 +71,8 @@ public:
|
||||
virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
|
||||
virtual int columnCount( const QModelIndex& parent = QModelIndex() ) const;
|
||||
|
||||
virtual ModelMode mode() const { return m_mode; }
|
||||
virtual void setMode( ModelMode mode ) { m_mode = mode; }
|
||||
virtual Tomahawk::ModelMode mode() const { return m_mode; }
|
||||
virtual void setMode( Tomahawk::ModelMode mode ) { m_mode = mode; }
|
||||
|
||||
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
|
||||
virtual QVariant headerData( int section, Qt::Orientation orientation, int role ) const;
|
||||
@ -165,7 +163,7 @@ private:
|
||||
QString m_description;
|
||||
QPixmap m_icon;
|
||||
ColumnStyle m_columnStyle;
|
||||
ModelMode m_mode;
|
||||
Tomahawk::ModelMode m_mode;
|
||||
|
||||
QList<Tomahawk::artist_ptr> m_artistsFilter;
|
||||
|
||||
|
@ -195,7 +195,7 @@ TreeProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent
|
||||
TreeModelItem* pi = sourceModel()->itemFromIndex( sourceModel()->index( sourceRow, 0, sourceParent ) );
|
||||
Q_ASSERT( pi );
|
||||
|
||||
if ( m_model->mode() == TreeModel::Database && !pi->result().isNull() )
|
||||
if ( m_model->mode() == Tomahawk::DatabaseMode && !pi->result().isNull() )
|
||||
{
|
||||
QList< Tomahawk::result_ptr > rl = m_cache.values( sourceParent );
|
||||
foreach ( const Tomahawk::result_ptr& result, rl )
|
||||
|
@ -63,6 +63,12 @@ namespace Tomahawk
|
||||
Static
|
||||
};
|
||||
|
||||
enum ModelMode
|
||||
{
|
||||
DatabaseMode = 0,
|
||||
InfoSystemMode
|
||||
};
|
||||
|
||||
}; // ns
|
||||
|
||||
typedef int AudioErrorCode;
|
||||
|
@ -217,12 +217,12 @@ ViewManager::show( const Tomahawk::artist_ptr& artist )
|
||||
|
||||
|
||||
Tomahawk::ViewPage*
|
||||
ViewManager::show( const Tomahawk::album_ptr& album )
|
||||
ViewManager::show( const Tomahawk::album_ptr& album, Tomahawk::ModelMode initialMode )
|
||||
{
|
||||
AlbumInfoWidget* swidget;
|
||||
if ( !m_albumViews.contains( album ) || m_albumViews.value( album ).isNull() )
|
||||
{
|
||||
swidget = new AlbumInfoWidget( album );
|
||||
swidget = new AlbumInfoWidget( album, initialMode );
|
||||
m_albumViews.insert( album, swidget );
|
||||
}
|
||||
else
|
||||
|
@ -139,7 +139,7 @@ public slots:
|
||||
Tomahawk::ViewPage* show( const Tomahawk::playlist_ptr& playlist );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::dynplaylist_ptr& playlist );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::artist_ptr& artist );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::album_ptr& album );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::album_ptr& album, Tomahawk::ModelMode withInitialMode = Tomahawk::InfoSystemMode );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::collection_ptr& collection );
|
||||
Tomahawk::ViewPage* show( const Tomahawk::source_ptr& source );
|
||||
|
||||
|
@ -39,7 +39,7 @@ static QString s_aiInfoIdentifier = QString( "AlbumInfoWidget" );
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent )
|
||||
AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, ModelMode startingMode, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::AlbumInfoWidget )
|
||||
{
|
||||
@ -58,16 +58,19 @@ 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 );
|
||||
m_tracksModel->setMode( startingMode );
|
||||
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 Super Collection Tracks" ) );
|
||||
m_button->setCheckable( true );
|
||||
m_button->setChecked( true );
|
||||
m_button->setChecked( m_tracksModel->mode() == InfoSystemMode );
|
||||
if ( m_button->isChecked() )
|
||||
m_button->setText( tr( "Click to show Super Collection Tracks" ) );
|
||||
else
|
||||
m_button->setText( tr( "Click to show Official Tracks" ) );
|
||||
|
||||
connect( m_button, SIGNAL( clicked() ), SLOT( onModeToggle() ) );
|
||||
connect( m_tracksModel, SIGNAL( loadingStarted() ), SLOT( onLoadingStarted() ) );
|
||||
@ -94,11 +97,18 @@ AlbumInfoWidget::playlistInterface() const
|
||||
return ui->tracksView->playlistInterface();
|
||||
}
|
||||
|
||||
void
|
||||
AlbumInfoWidget::setMode( ModelMode mode )
|
||||
{
|
||||
if ( m_tracksModel->mode() != mode )
|
||||
onModeToggle();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AlbumInfoWidget::onModeToggle()
|
||||
{
|
||||
m_tracksModel->setMode( m_button->isChecked() ? TreeModel::InfoSystem : TreeModel::Database );
|
||||
m_tracksModel->setMode( m_button->isChecked() ? InfoSystemMode : DatabaseMode );
|
||||
m_tracksModel->clear();
|
||||
m_tracksModel->addTracks( m_album, QModelIndex() );
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "infosystem/infosystem.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
class AlbumModel;
|
||||
class TreeModel;
|
||||
@ -50,7 +51,7 @@ class DLLEXPORT AlbumInfoWidget : public QWidget, public Tomahawk::ViewPage
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent = 0 );
|
||||
AlbumInfoWidget( const Tomahawk::album_ptr& album, Tomahawk::ModelMode startingMode = Tomahawk::InfoSystemMode, QWidget* parent = 0 );
|
||||
~AlbumInfoWidget();
|
||||
|
||||
virtual QWidget* widget() { return this; }
|
||||
@ -63,6 +64,8 @@ public:
|
||||
virtual QString longDescription() const { return m_longDescription; }
|
||||
virtual QPixmap pixmap() const { if ( m_pixmap.isNull() ) return Tomahawk::ViewPage::pixmap(); else return m_pixmap; }
|
||||
|
||||
void setMode( Tomahawk::ModelMode mode );
|
||||
|
||||
virtual bool isTemporaryPage() const { return true; }
|
||||
virtual bool showStatsBar() const { return false; }
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "ui_ArtistInfoWidget.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "viewmanager.h"
|
||||
#include "playlist/treemodel.h"
|
||||
#include "playlist/playlistmodel.h"
|
||||
#include "playlist/treeproxymodel.h"
|
||||
@ -63,7 +62,7 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
||||
TomahawkUtils::unmarginLayout( ui->albumHeader->layout() );
|
||||
|
||||
m_albumsModel = new TreeModel( ui->albums );
|
||||
m_albumsModel->setMode( TreeModel::InfoSystem );
|
||||
m_albumsModel->setMode( InfoSystemMode );
|
||||
ui->albums->setTreeModel( m_albumsModel );
|
||||
|
||||
m_relatedModel = new TreeModel( ui->relatedArtists );
|
||||
@ -111,7 +110,7 @@ ArtistInfoWidget::playlistInterface() const
|
||||
void
|
||||
ArtistInfoWidget::onModeToggle()
|
||||
{
|
||||
m_albumsModel->setMode( m_button->isChecked() ? TreeModel::InfoSystem : TreeModel::Database );
|
||||
m_albumsModel->setMode( m_button->isChecked() ? InfoSystemMode : DatabaseMode );
|
||||
m_albumsModel->clear();
|
||||
m_albumsModel->addAlbums( m_artist, QModelIndex() );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user