mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
* DbCmd_PlaybackHistory can now deal with date ranges.
This commit is contained in:
parent
80cc6b45dd
commit
99e331d8cd
@ -30,11 +30,17 @@ void
|
||||
DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
QString whereToken;
|
||||
QString whereToken( "WHERE 1" );
|
||||
|
||||
if ( !source().isNull() )
|
||||
{
|
||||
whereToken = QString( "WHERE source %1" ).arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) );
|
||||
whereToken += QString( " AND source %1" ).arg( source()->isLocal() ? "IS NULL" : QString( "= %1" ).arg( source()->id() ) );
|
||||
}
|
||||
if ( m_dateFrom.year() > 1900 && m_dateTo.year() > 1900 )
|
||||
{
|
||||
whereToken += QString( " AND playtime >= %1 AND playtime <= %2" )
|
||||
.arg( QDateTime( m_dateFrom ).toUTC().toTime_t() )
|
||||
.arg( QDateTime( m_dateTo.addDays( 1 ) ).toUTC().toTime_t() );
|
||||
}
|
||||
|
||||
QString sql = QString(
|
||||
|
@ -44,12 +44,16 @@ public:
|
||||
virtual QString commandname() const { return "playbackhistory"; }
|
||||
|
||||
void setLimit( unsigned int amount ) { m_amount = amount; }
|
||||
void setDateFrom( const QDate& date ) { m_dateFrom = date; }
|
||||
void setDateTo( const QDate& date ) { m_dateTo = date; }
|
||||
|
||||
signals:
|
||||
void tracks( const QList<Tomahawk::track_ptr>& tracks, QList<Tomahawk::PlaybackLog> logs );
|
||||
|
||||
private:
|
||||
unsigned int m_amount;
|
||||
QDate m_dateFrom;
|
||||
QDate m_dateTo;
|
||||
};
|
||||
|
||||
#endif // DATABASECOMMAND_PLAYBACKHISTORY_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user