mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 23:57:34 +02:00
* These DbCmds only want TrackData objects to deal with.
This commit is contained in:
@@ -39,18 +39,12 @@ DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi )
|
||||
|
||||
if ( m_actionOnly.isNull() )
|
||||
{
|
||||
//FIXME!
|
||||
// Load for just specified track
|
||||
int artid = dbi->artistId( m_track->artist(), false );
|
||||
if( artid < 1 )
|
||||
return;
|
||||
|
||||
int trkid = dbi->trackId( artid, m_track->track(), false );
|
||||
if( trkid < 1 )
|
||||
if ( m_track->trackId() == 0 )
|
||||
return;
|
||||
|
||||
QString whereToken;
|
||||
whereToken = QString( "WHERE id IS %1" ).arg( trkid );
|
||||
whereToken = QString( "WHERE id IS %1" ).arg( m_track->trackId() );
|
||||
|
||||
QString sql = QString(
|
||||
"SELECT k, v, timestamp, source "
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
*
|
||||
* Constructor which creates a new database command for loading all social actions.
|
||||
*/
|
||||
explicit DatabaseCommand_LoadSocialActions( const Tomahawk::track_ptr& track, QObject* parent = 0 )
|
||||
explicit DatabaseCommand_LoadSocialActions( const Tomahawk::trackdata_ptr& track, QObject* parent = 0 )
|
||||
: DatabaseCommand( parent ), m_track( track )
|
||||
{
|
||||
setSource( SourceList::instance()->getLocal() );
|
||||
@@ -106,7 +106,7 @@ signals:
|
||||
void done( DatabaseCommand_LoadSocialActions::TrackActions actionsForTracks );
|
||||
|
||||
private:
|
||||
Tomahawk::track_ptr m_track;
|
||||
Tomahawk::trackdata_ptr m_track;
|
||||
QString m_actionOnly;
|
||||
|
||||
};
|
||||
|
@@ -69,7 +69,7 @@ public:
|
||||
*
|
||||
* Constructor which creates a new database command for the specified social action.
|
||||
*/
|
||||
explicit DatabaseCommand_SocialAction( const Tomahawk::track_ptr& track, QString action, QString comment = "", QObject* parent = 0 )
|
||||
explicit DatabaseCommand_SocialAction( const Tomahawk::trackdata_ptr& track, QString action, QString comment = "", QObject* parent = 0 )
|
||||
: DatabaseCommandLoggable( parent ), m_track( track ), m_action( action )
|
||||
{
|
||||
setSource( SourceList::instance()->getLocal() );
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
virtual bool groupable() const { return true; }
|
||||
|
||||
protected:
|
||||
Tomahawk::track_ptr m_track;
|
||||
Tomahawk::trackdata_ptr m_track;
|
||||
|
||||
private:
|
||||
QString m_artist;
|
||||
|
@@ -26,7 +26,7 @@
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
DatabaseCommand_TrackStats::DatabaseCommand_TrackStats( const track_ptr& track, QObject* parent )
|
||||
DatabaseCommand_TrackStats::DatabaseCommand_TrackStats( const trackdata_ptr& track, QObject* parent )
|
||||
: DatabaseCommand( parent )
|
||||
, m_track( track )
|
||||
{
|
||||
@@ -45,23 +45,18 @@ DatabaseCommand_TrackStats::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
|
||||
if ( !m_track.isNull() )
|
||||
if ( m_track )
|
||||
{
|
||||
int artid = dbi->artistId( m_track->artist(), false );
|
||||
if( artid < 1 )
|
||||
return;
|
||||
|
||||
int trkid = dbi->trackId( artid, m_track->track(), false );
|
||||
if( trkid < 1 )
|
||||
if ( m_track->trackId() == 0 )
|
||||
return;
|
||||
|
||||
query.prepare( "SELECT * "
|
||||
"FROM playback_log "
|
||||
"WHERE track = ? ORDER BY playtime ASC" );
|
||||
query.addBindValue( trkid );
|
||||
query.addBindValue( m_track->trackId() );
|
||||
query.exec();
|
||||
}
|
||||
else if ( !m_artist.isNull() )
|
||||
else if ( m_artist )
|
||||
{
|
||||
query.prepare( "SELECT playback_log.* "
|
||||
"FROM playback_log, track "
|
||||
@@ -78,11 +73,11 @@ DatabaseCommand_TrackStats::exec( DatabaseImpl* dbi )
|
||||
log.timestamp = query.value( 3 ).toUInt();
|
||||
log.secsPlayed = query.value( 4 ).toUInt();
|
||||
|
||||
if ( !log.source.isNull() )
|
||||
if ( log.source )
|
||||
playbackData.append( log );
|
||||
}
|
||||
|
||||
if ( !m_track.isNull() )
|
||||
if ( m_track )
|
||||
m_track->setPlaybackHistory( playbackData );
|
||||
else
|
||||
m_artist->setPlaybackHistory( playbackData );
|
||||
|
@@ -31,7 +31,7 @@ class DLLEXPORT DatabaseCommand_TrackStats : public DatabaseCommand
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DatabaseCommand_TrackStats( const Tomahawk::track_ptr& track, QObject* parent = 0 );
|
||||
explicit DatabaseCommand_TrackStats( const Tomahawk::trackdata_ptr& track, QObject* parent = 0 );
|
||||
explicit DatabaseCommand_TrackStats( const Tomahawk::artist_ptr& artist, QObject* parent = 0 );
|
||||
|
||||
virtual void exec( DatabaseImpl* lib );
|
||||
@@ -42,7 +42,7 @@ signals:
|
||||
void done( const QList< Tomahawk::PlaybackLog >& playbackData );
|
||||
|
||||
private:
|
||||
Tomahawk::track_ptr m_track;
|
||||
Tomahawk::trackdata_ptr m_track;
|
||||
Tomahawk::artist_ptr m_artist;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user