mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Use proper sort order for Top Hits & Related Artists.
This commit is contained in:
@@ -489,15 +489,26 @@ LastFmPlugin::similarArtistsReturned()
|
||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
|
||||
|
||||
QMap< int, QString > similarArtists = lastfm::Artist::getSimilar( reply );
|
||||
|
||||
QStringList sortedArtists;
|
||||
QStringList sortedScores;
|
||||
QStringList al;
|
||||
QStringList sl;
|
||||
|
||||
foreach ( const QString& a, similarArtists.values() )
|
||||
al << a;
|
||||
foreach ( const QString& artist, similarArtists.values() )
|
||||
al << artist;
|
||||
foreach ( int score, similarArtists.keys() )
|
||||
sl << QString::number( score );
|
||||
|
||||
for ( int i = al.count() - 1; i >= 0; i-- )
|
||||
{
|
||||
sortedArtists << al.at( i );
|
||||
sortedScores << sl.at( i );
|
||||
}
|
||||
|
||||
QVariantMap returnedData;
|
||||
returnedData["artists"] = al;
|
||||
returnedData["score"] = sl;
|
||||
returnedData["artists"] = sortedArtists;
|
||||
returnedData["score"] = sortedScores;
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||
|
||||
@@ -780,7 +791,8 @@ QList<lastfm::Track>
|
||||
LastFmPlugin::parseTrackList( QNetworkReply* reply )
|
||||
{
|
||||
QList<lastfm::Track> tracks;
|
||||
try {
|
||||
try
|
||||
{
|
||||
lastfm::XmlQuery lfm = reply->readAll();
|
||||
foreach ( lastfm::XmlQuery xq, lfm.children( "track" ) )
|
||||
{
|
||||
|
@@ -132,9 +132,6 @@ TrackView::setTrackModel( TrackModel* model )
|
||||
m_proxyModel->setSourceTrackModel( m_model );
|
||||
}
|
||||
|
||||
if ( m_model && m_model->metaObject()->indexOfSignal( "itemSizeChanged(QModelIndex)" ) > -1 )
|
||||
connect( m_model, SIGNAL( itemSizeChanged( QModelIndex ) ), SLOT( onItemResized( QModelIndex ) ) );
|
||||
|
||||
connect( m_model, SIGNAL( loadingStarted() ), m_loadingSpinner, SLOT( fadeIn() ) );
|
||||
connect( m_model, SIGNAL( loadingFinished() ), m_loadingSpinner, SLOT( fadeOut() ) );
|
||||
|
||||
|
@@ -294,18 +294,14 @@ TreeModel::data( const QModelIndex& index, int role ) const
|
||||
return TomahawkUtils::timeToString( result->duration() );
|
||||
|
||||
case Bitrate:
|
||||
if ( result->bitrate() == 0 )
|
||||
return QString();
|
||||
else
|
||||
if ( result->bitrate() > 0 )
|
||||
return result->bitrate();
|
||||
|
||||
case Age:
|
||||
return TomahawkUtils::ageToString( QDateTime::fromTime_t( result->modificationTime() ) );
|
||||
|
||||
case Year:
|
||||
if ( result->year() == 0 )
|
||||
return QString();
|
||||
else
|
||||
if ( result->year() != 0 )
|
||||
return result->year();
|
||||
|
||||
case Filesize:
|
||||
@@ -318,6 +314,7 @@ TreeModel::data( const QModelIndex& index, int role ) const
|
||||
return result->albumpos();
|
||||
|
||||
case Composer:
|
||||
if ( !result->composer().isNull() )
|
||||
return result->composer()->name();
|
||||
|
||||
default:
|
||||
|
@@ -41,6 +41,7 @@ TreeProxyModel::TreeProxyModel( QObject* parent )
|
||||
setSourceTreeModel( 0 );
|
||||
}
|
||||
|
||||
|
||||
QPersistentModelIndex
|
||||
TreeProxyModel::currentIndex() const
|
||||
{
|
||||
@@ -109,6 +110,7 @@ TreeProxyModel::onModelReset()
|
||||
m_albumsFilter.clear();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeProxyModel::newFilterFromPlaylistInterface( const QString &pattern )
|
||||
{
|
||||
@@ -142,6 +144,7 @@ TreeProxyModel::newFilterFromPlaylistInterface( const QString &pattern )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeProxyModel::onFilterArtists( const QList<Tomahawk::artist_ptr>& artists )
|
||||
{
|
||||
|
@@ -140,13 +140,16 @@ ViewManager::createPageForPlaylist( const playlist_ptr& pl )
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
playlist_ptr
|
||||
ViewManager::playlistForPage( ViewPage* page ) const
|
||||
{
|
||||
playlist_ptr p;
|
||||
if ( dynamic_cast< PlaylistView* >( page ) && dynamic_cast< PlaylistView* >( page )->playlistModel() &&
|
||||
!dynamic_cast< PlaylistView* >( page )->playlistModel()->playlist().isNull() )
|
||||
{
|
||||
p = dynamic_cast< PlaylistView* >( page )->playlistModel()->playlist();
|
||||
}
|
||||
else if ( dynamic_cast< DynamicWidget* >( page ) )
|
||||
p = dynamic_cast< DynamicWidget* >( page )->playlist();
|
||||
|
||||
@@ -484,13 +487,15 @@ ViewManager::historyBack()
|
||||
delete oldPage;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::removeFromHistory ( ViewPage* p )
|
||||
{
|
||||
if ( currentPage() == p )
|
||||
{
|
||||
historyBack();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pageHistory.removeAll( p );
|
||||
delete p;
|
||||
@@ -498,6 +503,7 @@ ViewManager::removeFromHistory ( ViewPage* p )
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::setFilter( const QString& filter )
|
||||
{
|
||||
@@ -717,12 +723,17 @@ ViewManager::loadCurrentPlaylistSettings()
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
|
||||
if ( !pl.isNull() ) {
|
||||
|
||||
if ( !pl.isNull() )
|
||||
{
|
||||
currentPlaylistInterface()->setShuffled( s->shuffleState( pl->guid() ));
|
||||
currentPlaylistInterface()->setRepeatMode( s->repeatMode( pl->guid() ));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
|
||||
if ( !dynPl.isNull() ) {
|
||||
if ( !dynPl.isNull() )
|
||||
{
|
||||
currentPlaylistInterface()->setShuffled( s->shuffleState( dynPl->guid() ));
|
||||
}
|
||||
}
|
||||
@@ -783,8 +794,7 @@ ViewManager::setShuffled( bool enabled )
|
||||
|
||||
|
||||
void
|
||||
ViewManager::createPlaylist( const Tomahawk::source_ptr& src,
|
||||
const QVariant& contents )
|
||||
ViewManager::createPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents )
|
||||
{
|
||||
Tomahawk::playlist_ptr p = Tomahawk::playlist_ptr( new Tomahawk::Playlist( src ) );
|
||||
QJson::QObjectHelper::qvariant2qobject( contents.toMap(), p.data() );
|
||||
@@ -793,8 +803,7 @@ ViewManager::createPlaylist( const Tomahawk::source_ptr& src,
|
||||
|
||||
|
||||
void
|
||||
ViewManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
|
||||
const QVariant& contents )
|
||||
ViewManager::createDynamicPlaylist( const Tomahawk::source_ptr& src, const QVariant& contents )
|
||||
{
|
||||
Tomahawk::dynplaylist_ptr p = Tomahawk::dynplaylist_ptr( new Tomahawk::DynamicPlaylist( src, contents.toMap().value( "type", QString() ).toString() ) );
|
||||
QJson::QObjectHelper::qvariant2qobject( contents.toMap(), p.data() );
|
||||
@@ -838,6 +847,7 @@ ViewManager::pageForInterface( Tomahawk::playlistinterface_ptr interface ) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlistinterface_ptr
|
||||
ViewManager::currentPlaylistInterface() const
|
||||
{
|
||||
@@ -854,6 +864,7 @@ ViewManager::currentPage() const
|
||||
return m_pageHistory.isEmpty() ? 0 : m_pageHistory.front();
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::playlist_ptr
|
||||
ViewManager::playlistForInterface( Tomahawk::playlistinterface_ptr interface ) const
|
||||
{
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "ui_ArtistInfoWidget.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "playlist/trackheader.h"
|
||||
#include "playlist/treemodel.h"
|
||||
#include "playlist/playlistmodel.h"
|
||||
#include "playlist/treeproxymodel.h"
|
||||
@@ -68,10 +69,13 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
||||
m_relatedModel = new TreeModel( ui->relatedArtists );
|
||||
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
|
||||
ui->relatedArtists->setTreeModel( m_relatedModel );
|
||||
ui->relatedArtists->setSortingEnabled( false );
|
||||
ui->relatedArtists->proxyModel()->sort( -1 );
|
||||
|
||||
m_topHitsModel = new PlaylistModel( ui->topHits );
|
||||
m_topHitsModel->setStyle( TrackModel::Short );
|
||||
ui->topHits->setTrackModel( m_topHitsModel );
|
||||
ui->topHits->setSortingEnabled( false );
|
||||
|
||||
m_pixmap = QPixmap( RESPATH "images/no-album-no-case.png" ).scaledToWidth( 48, Qt::SmoothTransformation );
|
||||
|
||||
@@ -252,15 +256,17 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
|
||||
{
|
||||
const QStringList tracks = returnedData["tracks"].toStringList();
|
||||
|
||||
QList< query_ptr > queries;
|
||||
int i = 0;
|
||||
foreach ( const QString& track, tracks )
|
||||
{
|
||||
query_ptr query = Query::get( m_artist->name(), track, QString(), uuid() );
|
||||
m_topHitsModel->append( query );
|
||||
queries << Query::get( m_artist->name(), track, QString(), uuid() );
|
||||
|
||||
if ( ++i == 15 )
|
||||
break;
|
||||
}
|
||||
|
||||
m_topHitsModel->append( queries );
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user