mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-14 18:14:50 +02:00
Sort by rank if possible
This commit is contained in:
committed by
Michael Zanetti
parent
c2f3cff83a
commit
c3995a0cc8
@@ -48,23 +48,29 @@ using namespace Tomahawk::InfoSystem;
|
||||
bool
|
||||
newReleaseSort( const InfoStringHash& left, const InfoStringHash& right )
|
||||
{
|
||||
if ( !left.contains( "date" ) || !right.contains( "date" ) )
|
||||
if ( left.contains( "rank" ) && right.contains( "rank" ) )
|
||||
{
|
||||
return true;
|
||||
const int lRank = left[ "rank" ].toInt();
|
||||
const int rRank = right[ "rank" ].toInt();
|
||||
return lRank < rRank;
|
||||
}
|
||||
|
||||
if ( left.contains( "date" ) && right.contains( "date" ) )
|
||||
{
|
||||
const QDate lDate = QDate::fromString( left[ "date" ], "yyyy-MM-dd" );
|
||||
const QDate rDate = QDate::fromString( right[ "date" ], "yyyy-MM-dd" );
|
||||
|
||||
return lDate > rDate;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
NewReleasesPlugin::NewReleasesPlugin()
|
||||
: InfoPlugin()
|
||||
, m_nrFetchJobs( 0 )
|
||||
{
|
||||
m_nrVersion = "0.5.1";
|
||||
m_nrVersion = "0.5.2";
|
||||
m_supportedGetTypes << InfoNewReleaseCapabilities << InfoNewRelease;
|
||||
}
|
||||
|
||||
@@ -685,11 +691,12 @@ NewReleasesPlugin::nrReturned()
|
||||
const QString album = albumMap.value( "album" ).toString();
|
||||
const QString artist = albumMap.value( "artist" ).toString();
|
||||
const QString date = albumMap.value( "date" ).toString();
|
||||
|
||||
const QString rank = albumMap.value( "rank" ).toString();
|
||||
Tomahawk::InfoSystem::InfoStringHash pair;
|
||||
pair[ "artist" ] = artist;
|
||||
pair[ "album" ] = album;
|
||||
pair[ "date" ] = date;
|
||||
pair[ "rank" ] = rank;
|
||||
newreleases.append( pair );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user