mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 17:29:42 +01:00
* Fixed TWK-537: Adding social actions for remote sources was broken.
This commit is contained in:
parent
6c2ed4baed
commit
b46af3405e
@ -50,7 +50,7 @@ DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi )
|
||||
return;
|
||||
|
||||
QString whereToken;
|
||||
whereToken = QString( "WHERE id IS %1" ).arg( trkid );
|
||||
whereToken = QString( "WHERE id IS %1" ).arg( trkid );
|
||||
|
||||
QString sql = QString(
|
||||
"SELECT k, v, timestamp, source "
|
||||
@ -66,7 +66,7 @@ DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi )
|
||||
Tomahawk::SocialAction action;
|
||||
action.action = query.value( 0 ); // action
|
||||
action.value = query.value( 1 ); // comment
|
||||
action.timestamp = query.value( 2 ); // timestamp
|
||||
action.timestamp = query.value( 2 ); // timestamp
|
||||
action.source = query.value( 3 ); // source
|
||||
|
||||
allSocialActions.append( action );
|
||||
|
@ -49,22 +49,17 @@ DatabaseCommand_SocialAction::exec( DatabaseImpl* dbi )
|
||||
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
|
||||
|
||||
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
|
||||
|
||||
int trkid = -2;
|
||||
if ( !m_result.isNull() && !m_artist.isNull() && !m_track.isEmpty() )
|
||||
{
|
||||
bool autoCreate = true;
|
||||
int artid = dbi->artistId( m_artist, autoCreate );
|
||||
if ( artid < 1 )
|
||||
return;
|
||||
if ( m_artist.isNull() || m_track.isEmpty() )
|
||||
return;
|
||||
|
||||
autoCreate = true; // artistId overwrites autoCreate (reference)
|
||||
trkid = dbi->trackId( artid, m_track, autoCreate );
|
||||
if ( trkid < 1 )
|
||||
return;
|
||||
}
|
||||
int artid = dbi->artistId( m_artist, true );
|
||||
if ( artid < 1 )
|
||||
return;
|
||||
int trkid = dbi->trackId( artid, m_track, true );
|
||||
if ( trkid < 1 )
|
||||
return;
|
||||
|
||||
// update if it already exists
|
||||
TomahawkSqlQuery find = dbi->newquery();
|
||||
@ -80,12 +75,13 @@ DatabaseCommand_SocialAction::exec( DatabaseImpl* dbi )
|
||||
.arg( trkid )
|
||||
.arg( source()->isLocal() ? "IS NULL" : QString( "=%1" ).arg( source()->id() ) )
|
||||
.arg( m_action ) );
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
query.prepare( "INSERT INTO social_attributes(id, source, k, v, timestamp) "
|
||||
query.prepare( "INSERT INTO social_attributes(id, source, k, v, timestamp) "
|
||||
"VALUES (?, ?, ?, ?, ?)" );
|
||||
|
||||
query.bindValue( 0, trkid >= -1 ? trkid : QVariant() );
|
||||
query.bindValue( 0, trkid );
|
||||
query.bindValue( 1, srcid );
|
||||
query.bindValue( 2, m_action );
|
||||
query.bindValue( 3, m_comment );
|
||||
|
@ -52,8 +52,11 @@ CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, c
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CustomPlaylistView::~CustomPlaylistView()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CustomPlaylistView::isBeingPlayed() const
|
||||
@ -61,6 +64,7 @@ CustomPlaylistView::isBeingPlayed() const
|
||||
return AudioEngine::instance()->currentTrackPlaylist() == playlistInterface();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CustomPlaylistView::jumpToCurrentTrack()
|
||||
{
|
||||
@ -80,7 +84,7 @@ CustomPlaylistView::generateTracks()
|
||||
"FROM social_attributes, track, artist "
|
||||
"WHERE social_attributes.id = track.id AND artist.id = track.artist AND social_attributes.k = 'Love' AND social_attributes.v = 'true' AND social_attributes.source %1 "
|
||||
"GROUP BY track.id "
|
||||
"ORDER BY counter DESC, social_attributes.timestamp DESC " ).arg( m_source->isLocal() ? "IS NULL" : QString( "=%1" ).arg( m_source->id() ) );
|
||||
"ORDER BY counter DESC, social_attributes.timestamp DESC " ).arg( m_source->isLocal() ? "IS NULL" : QString( "= %1" ).arg( m_source->id() ) );
|
||||
break;
|
||||
case AllLovedTracks:
|
||||
sql = QString( "SELECT track.name, artist.name, source, COUNT(*) as counter "
|
||||
@ -96,6 +100,7 @@ CustomPlaylistView::generateTracks()
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks )
|
||||
{
|
||||
@ -103,6 +108,7 @@ CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks )
|
||||
m_model->append( q );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
CustomPlaylistView::title() const
|
||||
{
|
||||
@ -132,18 +138,21 @@ CustomPlaylistView::description() const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
CustomPlaylistView::longDescription() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
QPixmap
|
||||
CustomPlaylistView::pixmap() const
|
||||
{
|
||||
return QPixmap( RESPATH "images/loved_playlist.png" );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CustomPlaylistView::reload()
|
||||
{
|
||||
@ -153,7 +162,7 @@ CustomPlaylistView::reload()
|
||||
|
||||
|
||||
void
|
||||
CustomPlaylistView::sourceAdded( const source_ptr& s)
|
||||
CustomPlaylistView::sourceAdded( const source_ptr& s )
|
||||
{
|
||||
connect( s.data(), SIGNAL( socialAttributesChanged() ), this, SLOT( reload() ) );
|
||||
}
|
||||
|
@ -115,8 +115,11 @@ SourceTreeView::SourceTreeView( QWidget* parent )
|
||||
connect( this, SIGNAL( catchUpRequest() ), m_latchManager, SLOT( catchUpRequest() ) );
|
||||
}
|
||||
|
||||
|
||||
SourceTreeView::~SourceTreeView()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::setupMenus()
|
||||
@ -151,7 +154,7 @@ SourceTreeView::setupMenus()
|
||||
m_latchOnAction->setText( tr( "&Catch Up" ) );
|
||||
m_latchMenu.addSeparator();
|
||||
m_latchOffAction = m_latchMenu.addAction( tr( "&Stop Listening Along" ) );
|
||||
connect( m_latchOffAction, SIGNAL( triggered() ), SLOT( latchOff() ) );
|
||||
connect( m_latchOffAction, SIGNAL( triggered() ), SLOT( latchOff() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,6 +234,7 @@ SourceTreeView::selectRequest( const QPersistentModelIndex& idx )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::expandRequest( const QPersistentModelIndex &idx )
|
||||
{
|
||||
@ -245,6 +249,7 @@ SourceTreeView::loadPlaylist()
|
||||
onItemActivated( m_contextMenuIndex );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::deletePlaylist( const QModelIndex& idxIn )
|
||||
{
|
||||
@ -353,6 +358,7 @@ SourceTreeView::latchOnOrCatchUp()
|
||||
emit latchRequest( source );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SourceTreeView::latchOff()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user