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