mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-03 20:57:52 +02:00
Sort new releases by date, show newest release first.
This commit is contained in:
@@ -24,6 +24,20 @@
|
|||||||
|
|
||||||
using namespace Tomahawk::InfoSystem;
|
using namespace Tomahawk::InfoSystem;
|
||||||
|
|
||||||
|
bool newReleaseSort( const InfoStringHash& left, const InfoStringHash& right )
|
||||||
|
{
|
||||||
|
if ( !left.contains( "date" ) || !right.contains( "date" ) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QDate lDate = QDate::fromString( left[ "date" ], "yyyy-MM-dd" );
|
||||||
|
const QDate rDate = QDate::fromString( right[ "date" ], "yyyy-MM-dd" );
|
||||||
|
|
||||||
|
return lDate > rDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NewReleasesPlugin::NewReleasesPlugin()
|
NewReleasesPlugin::NewReleasesPlugin()
|
||||||
: InfoPlugin()
|
: InfoPlugin()
|
||||||
, m_nrFetchJobs ( 0 )
|
, m_nrFetchJobs ( 0 )
|
||||||
@@ -274,6 +288,7 @@ void NewReleasesPlugin::nrList()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !albumNRs.isEmpty() )
|
if ( !albumNRs.isEmpty() )
|
||||||
newreleases.insert ( tr ( "Albums" ), QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > > ( albumNRs ) );
|
newreleases.insert ( tr ( "Albums" ), QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > > ( albumNRs ) );
|
||||||
|
|
||||||
@@ -334,11 +349,14 @@ void NewReleasesPlugin::nrReturned()
|
|||||||
Tomahawk::InfoSystem::InfoStringHash pair;
|
Tomahawk::InfoSystem::InfoStringHash pair;
|
||||||
pair["artist"] = artist;
|
pair["artist"] = artist;
|
||||||
pair["album"] = album;
|
pair["album"] = album;
|
||||||
|
pair["date"] = date;
|
||||||
newreleases.append( pair );
|
newreleases.append( pair );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tDebug() << "NewReleasesPlugin:" << "\tgot " << newreleases.size() << " albums";
|
qSort( newreleases.begin(), newreleases.end(), newReleaseSort );
|
||||||
|
|
||||||
|
// tDebug() << "NewReleasesPlugin:" << "\tgot " << newreleases.size() << " albums";
|
||||||
returnedData[ "albums" ] = QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( newreleases );
|
returnedData[ "albums" ] = QVariant::fromValue< QList< Tomahawk::InfoSystem::InfoStringHash > >( newreleases );
|
||||||
returnedData[ "type" ] = "albums";
|
returnedData[ "type" ] = "albums";
|
||||||
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();
|
||||||
|
Reference in New Issue
Block a user