mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
* Moved social actions from Result into Query. Added contextual menu entry for (un)loving.
This commit is contained in:
parent
60b746c430
commit
11c6d4cdca
@ -26,7 +26,6 @@
|
||||
#include "audio/audioengine.h"
|
||||
#include "playlist/playlistview.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_socialaction.h"
|
||||
#include "widgets/imagebutton.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
@ -37,8 +36,6 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
static QString s_acInfoIdentifier = QString( "AUDIOCONTROLS" );
|
||||
|
||||
|
||||
AudioControls::AudioControls( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
@ -226,12 +223,12 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
if ( !m_currentTrack.isNull() )
|
||||
{
|
||||
disconnect( m_currentTrack->album().data(), SIGNAL( updated() ), this, SLOT( onAlbumCoverUpdated() ) );
|
||||
disconnect( m_currentTrack.data(), SIGNAL( socialActionsLoaded() ), this, SLOT( socialActionsLoaded() ) );
|
||||
disconnect( m_currentTrack->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( onSocialActionsLoaded() ) );
|
||||
}
|
||||
|
||||
m_currentTrack = result;
|
||||
connect( m_currentTrack->album().data(), SIGNAL( updated() ), SLOT( onAlbumCoverUpdated() ) );
|
||||
connect( m_currentTrack.data(), SIGNAL( socialActionsLoaded() ), SLOT( socialActionsLoaded() ) );
|
||||
connect( m_currentTrack->toQuery().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) );
|
||||
|
||||
ui->artistTrackLabel->setResult( result );
|
||||
ui->albumLabel->setResult( result );
|
||||
@ -249,7 +246,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
ui->loveButton->setVisible( true );
|
||||
|
||||
setAlbumCover();
|
||||
result->loadSocialActions();
|
||||
setSocialActions();
|
||||
}
|
||||
|
||||
|
||||
@ -277,23 +274,28 @@ AudioControls::setAlbumCover()
|
||||
|
||||
|
||||
void
|
||||
AudioControls::socialActionsLoaded()
|
||||
AudioControls::onSocialActionsLoaded()
|
||||
{
|
||||
Result* r = qobject_cast< Result* >( sender() );
|
||||
Q_ASSERT( r );
|
||||
Query* query = qobject_cast< Query* >( sender() );
|
||||
if ( !query || query != m_currentTrack->toQuery().data() )
|
||||
return;
|
||||
|
||||
if ( m_currentTrack.data() == r )
|
||||
setSocialActions();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::setSocialActions()
|
||||
{
|
||||
if ( m_currentTrack->toQuery()->loved() )
|
||||
{
|
||||
if ( m_currentTrack->loved() )
|
||||
{
|
||||
ui->loveButton->setPixmap( RESPATH "images/loved.png" );
|
||||
ui->loveButton->setChecked( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
|
||||
ui->loveButton->setChecked( false );
|
||||
}
|
||||
ui->loveButton->setPixmap( RESPATH "images/loved.png" );
|
||||
ui->loveButton->setChecked( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
|
||||
ui->loveButton->setChecked( false );
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,30 +585,17 @@ AudioControls::droppedTracks( QList< query_ptr > tracks )
|
||||
void
|
||||
AudioControls::onLoveButtonClicked( bool checked )
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["title"] = m_currentTrack->track();
|
||||
trackInfo["artist"] = m_currentTrack->artist()->name();
|
||||
trackInfo["album"] = m_currentTrack->album()->name();
|
||||
|
||||
if ( checked )
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_acInfoIdentifier, Tomahawk::InfoSystem::InfoLove,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
|
||||
|
||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( m_currentTrack, QString( "Love" ), QString( "true") );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
ui->loveButton->setPixmap( RESPATH "images/loved.png" );
|
||||
|
||||
m_currentTrack->toQuery()->setLoved( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_acInfoIdentifier, Tomahawk::InfoSystem::InfoUnLove,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
|
||||
|
||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( m_currentTrack, QString( "Love" ), QString( "false" ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
|
||||
|
||||
m_currentTrack->toQuery()->setLoved( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,11 @@ private slots:
|
||||
|
||||
void droppedTracks( QList<Tomahawk::query_ptr> );
|
||||
|
||||
void socialActionsLoaded();
|
||||
void onSocialActionsLoaded();
|
||||
|
||||
private:
|
||||
void setAlbumCover();
|
||||
void setSocialActions();
|
||||
|
||||
Ui::AudioControls *ui;
|
||||
|
||||
|
@ -32,11 +32,12 @@ using namespace Tomahawk;
|
||||
|
||||
ContextMenu::ContextMenu( QWidget* parent )
|
||||
: QMenu( parent )
|
||||
, m_loveAction( 0 )
|
||||
{
|
||||
m_sigmap = new QSignalMapper( this );
|
||||
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( onTriggered( int ) ) );
|
||||
|
||||
m_supportedActions = ActionPlay | ActionQueue | ActionCopyLink;
|
||||
m_supportedActions = ActionPlay | ActionQueue | ActionCopyLink | ActionLove;
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +60,7 @@ ContextMenu::clear()
|
||||
unsigned int
|
||||
ContextMenu::itemCount() const
|
||||
{
|
||||
return m_queries.count() + m_artists.count() + m_albums.count();
|
||||
return m_queries.count() + m_artists.count() + m_albums.count();
|
||||
}
|
||||
|
||||
|
||||
@ -81,8 +82,17 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& queries )
|
||||
|
||||
addSeparator();
|
||||
|
||||
if ( m_supportedActions & ActionLove && itemCount() == 1 )
|
||||
{
|
||||
m_loveAction = addAction( tr( "&Love" ) );
|
||||
m_sigmap->setMapping( m_loveAction, ActionLove );
|
||||
|
||||
connect( queries.first().data(), SIGNAL( socialActionsLoaded() ), SLOT( onSocialActionsLoaded() ) );
|
||||
onSocialActionsLoaded();
|
||||
}
|
||||
|
||||
if ( m_supportedActions & ActionCopyLink && itemCount() == 1 )
|
||||
m_sigmap->setMapping( addAction( tr( "Copy Track &Link" ) ), ActionCopyLink );
|
||||
m_sigmap->setMapping( addAction( tr( "&Copy Track Link" ) ), ActionCopyLink );
|
||||
|
||||
addSeparator();
|
||||
|
||||
@ -197,6 +207,10 @@ ContextMenu::onTriggered( int action )
|
||||
copyLink();
|
||||
break;
|
||||
|
||||
case ActionLove:
|
||||
m_queries.first()->setLoved( !m_queries.first()->loved() );
|
||||
break;
|
||||
|
||||
default:
|
||||
emit triggered( action );
|
||||
}
|
||||
@ -232,3 +246,19 @@ ContextMenu::copyLink()
|
||||
GlobalActionManager::instance()->copyToClipboard( m_queries.first() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ContextMenu::onSocialActionsLoaded()
|
||||
{
|
||||
if ( m_queries.first()->loved() )
|
||||
{
|
||||
m_loveAction->setText( tr( "Un-&Love" ) );
|
||||
m_loveAction->setIcon( QIcon( RESPATH "images/not-loved.png" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_loveAction->setText( tr( "&Love" ) );
|
||||
m_loveAction->setIcon( QIcon( RESPATH "images/loved.png" ) );
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ public:
|
||||
ActionPlay = 1,
|
||||
ActionQueue = 2,
|
||||
ActionDelete = 4,
|
||||
ActionCopyLink = 8
|
||||
ActionCopyLink = 8,
|
||||
ActionLove = 16
|
||||
};
|
||||
|
||||
explicit ContextMenu( QWidget* parent = 0 );
|
||||
@ -68,10 +69,14 @@ private slots:
|
||||
void copyLink();
|
||||
void addToQueue();
|
||||
|
||||
void onSocialActionsLoaded();
|
||||
|
||||
private:
|
||||
QSignalMapper* m_sigmap;
|
||||
int m_supportedActions;
|
||||
|
||||
QAction* m_loveAction;
|
||||
|
||||
QList<Tomahawk::query_ptr> m_queries;
|
||||
QList<Tomahawk::artist_ptr> m_artists;
|
||||
QList<Tomahawk::album_ptr> m_albums;
|
||||
|
@ -39,13 +39,11 @@ DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi )
|
||||
|
||||
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
|
||||
|
||||
bool autoCreate = false;
|
||||
int artid = dbi->artistId( m_artist, autoCreate );
|
||||
int artid = dbi->artistId( m_artist, false );
|
||||
if( artid < 1 )
|
||||
return;
|
||||
|
||||
autoCreate = false; // artistId overwrites autoCreate (reference)
|
||||
int trkid = dbi->trackId( artid, m_track, autoCreate );
|
||||
int trkid = dbi->trackId( artid, m_track, false );
|
||||
if( trkid < 1 )
|
||||
return;
|
||||
|
||||
@ -72,6 +70,6 @@ DatabaseCommand_LoadSocialActions::exec( DatabaseImpl* dbi )
|
||||
allSocialActions.append( action );
|
||||
}
|
||||
|
||||
m_result->setAllSocialActions( allSocialActions );
|
||||
m_query->setAllSocialActions( allSocialActions );
|
||||
}
|
||||
|
||||
|
@ -56,17 +56,17 @@ public:
|
||||
|
||||
/**
|
||||
* \brief Overloaded constructor for DatabaseCommand_LoadSocialAction.
|
||||
* \param result Pointer to a Tomahawk::Result.
|
||||
* \param result A Tomahawk Query object.
|
||||
* \param parent Parent class.
|
||||
*
|
||||
* Constructor which creates a new database command for loading all social actions.
|
||||
*/
|
||||
explicit DatabaseCommand_LoadSocialActions( Tomahawk::Result* result, QObject* parent = 0 )
|
||||
: DatabaseCommand( parent ), m_result( result )
|
||||
explicit DatabaseCommand_LoadSocialActions( const Tomahawk::query_ptr& query, QObject* parent = 0 )
|
||||
: DatabaseCommand( parent ), m_query( query )
|
||||
{
|
||||
setSource( SourceList::instance()->getLocal() );
|
||||
setArtist( result->artist()->name() );
|
||||
setTrack( result->track() );
|
||||
setArtist( query->artist() );
|
||||
setTrack( query->track() );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ signals:
|
||||
void done( QList< Tomahawk::SocialAction >& allSocialActions );
|
||||
|
||||
private:
|
||||
Tomahawk::Result* m_result;
|
||||
Tomahawk::query_ptr m_query;
|
||||
QString m_artist;
|
||||
QString m_track;
|
||||
|
||||
|
@ -61,20 +61,20 @@ public:
|
||||
|
||||
/**
|
||||
* \brief Overloaded constructor for DatabaseCommand_SocialAction.
|
||||
* \param result Pointer to a Tomahawk::Result.
|
||||
* \param query A Tomahawk Query object.
|
||||
* \param action Name of the social action to be written to the database.
|
||||
* \param comment Comment associated with this social action.
|
||||
* \param parent Parent class.
|
||||
*
|
||||
* Constructor which creates a new database command for the specified social action.
|
||||
*/
|
||||
explicit DatabaseCommand_SocialAction( const Tomahawk::result_ptr& result, QString action, QString comment="", QObject* parent = 0 )
|
||||
: DatabaseCommandLoggable( parent ), m_result( result ), m_action( action )
|
||||
explicit DatabaseCommand_SocialAction( const Tomahawk::query_ptr& query, QString action, QString comment = "", QObject* parent = 0 )
|
||||
: DatabaseCommandLoggable( parent ), m_query( query ), m_action( action )
|
||||
{
|
||||
setSource( SourceList::instance()->getLocal() );
|
||||
|
||||
setArtist( result->artist()->name() );
|
||||
setTrack( result->track() );
|
||||
setArtist( query->artist() );
|
||||
setTrack( query->track() );
|
||||
setComment( comment );
|
||||
setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||
}
|
||||
@ -173,7 +173,7 @@ public:
|
||||
virtual bool groupable() const { return true; }
|
||||
|
||||
private:
|
||||
Tomahawk::result_ptr m_result;
|
||||
Tomahawk::query_ptr m_query;
|
||||
|
||||
QString m_artist;
|
||||
QString m_track;
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "database/databasecommand_logplayback.h"
|
||||
#include "database/databasecommand_playbackhistory.h"
|
||||
#include "database/databasecommand_loadplaylistentries.h"
|
||||
#include "database/databasecommand_loadsocialactions.h"
|
||||
#include "database/databasecommand_socialaction.h"
|
||||
#include "album.h"
|
||||
#include "collection.h"
|
||||
#include "pipeline.h"
|
||||
@ -71,6 +73,7 @@ Query::Query( const QString& artist, const QString& track, const QString& album,
|
||||
, m_artist( artist )
|
||||
, m_album( album )
|
||||
, m_track( track )
|
||||
, m_socialActionsLoaded( false )
|
||||
{
|
||||
init();
|
||||
|
||||
@ -475,6 +478,97 @@ Query::playedBy() const
|
||||
return m_playedBy;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Query::loadSocialActions()
|
||||
{
|
||||
m_socialActionsLoaded = true;
|
||||
query_ptr q = m_ownRef.toStrongRef();
|
||||
|
||||
DatabaseCommand_LoadSocialActions* cmd = new DatabaseCommand_LoadSocialActions( q );
|
||||
connect( cmd, SIGNAL( finished() ), SLOT( onSocialActionsLoaded() ));
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Query::onSocialActionsLoaded()
|
||||
{
|
||||
parseSocialActions();
|
||||
|
||||
emit socialActionsLoaded();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Query::setAllSocialActions( const QList< SocialAction >& socialActions )
|
||||
{
|
||||
m_allSocialActions = socialActions;
|
||||
}
|
||||
|
||||
|
||||
QList< SocialAction >
|
||||
Query::allSocialActions()
|
||||
{
|
||||
return m_allSocialActions;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Query::parseSocialActions()
|
||||
{
|
||||
QListIterator< Tomahawk::SocialAction > it( m_allSocialActions );
|
||||
unsigned int highestTimestamp = 0;
|
||||
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Tomahawk::SocialAction socialAction;
|
||||
socialAction = it.next();
|
||||
if ( socialAction.timestamp.toUInt() > highestTimestamp && socialAction.source.toInt() == SourceList::instance()->getLocal()->id() )
|
||||
{
|
||||
m_currentSocialActions[ socialAction.action.toString() ] = socialAction.value.toBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Query::loved()
|
||||
{
|
||||
if ( m_socialActionsLoaded )
|
||||
{
|
||||
return m_currentSocialActions[ "Love" ].toBool();
|
||||
}
|
||||
else
|
||||
{
|
||||
loadSocialActions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Query::setLoved( bool loved )
|
||||
{
|
||||
query_ptr q = m_ownRef.toStrongRef();
|
||||
if ( q )
|
||||
{
|
||||
m_currentSocialActions[ "Loved" ] = loved;
|
||||
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["title"] = track();
|
||||
trackInfo["artist"] = artist();
|
||||
trackInfo["album"] = album();
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
id(), Tomahawk::InfoSystem::InfoLove,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ) );
|
||||
|
||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( q, QString( "Love" ), loved ? QString( "true" ) : QString( "false" ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Query::levenshtein( const QString& source, const QString& target )
|
||||
{
|
||||
|
@ -102,6 +102,13 @@ public:
|
||||
void setResolveFinished( bool resolved ) { m_resolveFinished = resolved; }
|
||||
void setPlayedBy( const Tomahawk::source_ptr& source, unsigned int playtime );
|
||||
|
||||
void setLoved( bool loved );
|
||||
bool loved();
|
||||
|
||||
void loadSocialActions();
|
||||
QList< Tomahawk::SocialAction > allSocialActions();
|
||||
void setAllSocialActions( const QList< Tomahawk::SocialAction >& socialActions );
|
||||
|
||||
QWeakPointer< Tomahawk::Query > weakRef() { return m_ownRef; }
|
||||
void setWeakRef( QWeakPointer< Tomahawk::Query > weakRef ) { m_ownRef = weakRef; }
|
||||
|
||||
@ -117,6 +124,9 @@ signals:
|
||||
void playableStateChanged( bool state );
|
||||
void resolvingFinished( bool hasResults );
|
||||
|
||||
// emitted when social actions are loaded
|
||||
void socialActionsLoaded();
|
||||
|
||||
public slots:
|
||||
/// (indirectly) called by resolver plugins when results are found
|
||||
void addResults( const QList< Tomahawk::result_ptr >& );
|
||||
@ -134,6 +144,7 @@ public slots:
|
||||
private slots:
|
||||
void onResultStatusChanged();
|
||||
void refreshResults();
|
||||
void onSocialActionsLoaded();
|
||||
|
||||
private:
|
||||
Query();
|
||||
@ -149,6 +160,8 @@ private:
|
||||
void updateSortNames();
|
||||
static int levenshtein( const QString& source, const QString& target );
|
||||
|
||||
void parseSocialActions();
|
||||
|
||||
QList< Tomahawk::artist_ptr > m_artists;
|
||||
QList< Tomahawk::album_ptr > m_albums;
|
||||
QList< Tomahawk::result_ptr > m_results;
|
||||
@ -176,6 +189,10 @@ private:
|
||||
mutable QMutex m_mutex;
|
||||
|
||||
QWeakPointer< Tomahawk::Query > m_ownRef;
|
||||
|
||||
bool m_socialActionsLoaded;
|
||||
QHash< QString, QVariant > m_currentSocialActions;
|
||||
QList< SocialAction > m_allSocialActions;
|
||||
};
|
||||
|
||||
}; //ns
|
||||
|
@ -20,11 +20,11 @@
|
||||
|
||||
#include "album.h"
|
||||
#include "collection.h"
|
||||
#include "source.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_resolve.h"
|
||||
#include "database/databasecommand_alltracks.h"
|
||||
#include "database/databasecommand_addfiles.h"
|
||||
#include "database/databasecommand_loadsocialactions.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
@ -164,15 +164,19 @@ Result::toString() const
|
||||
|
||||
|
||||
Tomahawk::query_ptr
|
||||
Result::toQuery() const
|
||||
Result::toQuery()
|
||||
{
|
||||
Tomahawk::query_ptr query = Tomahawk::Query::get( artist()->name(), track(), album()->name() );
|
||||
QList<Tomahawk::result_ptr> rl;
|
||||
rl << Result::get( m_url );
|
||||
if ( m_query.isNull() )
|
||||
{
|
||||
m_query = Tomahawk::Query::get( artist()->name(), track(), album()->name() );
|
||||
QList<Tomahawk::result_ptr> rl;
|
||||
rl << Result::get( m_url );
|
||||
|
||||
query->addResults( rl );
|
||||
query->setResolveFinished( true );
|
||||
return query;
|
||||
m_query->addResults( rl );
|
||||
m_query->setResolveFinished( true );
|
||||
}
|
||||
|
||||
return m_query;
|
||||
}
|
||||
|
||||
|
||||
@ -200,55 +204,6 @@ Result::onOffline()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Result::loadSocialActions()
|
||||
{
|
||||
DatabaseCommand_LoadSocialActions* cmd = new DatabaseCommand_LoadSocialActions( this );
|
||||
connect( cmd, SIGNAL( finished() ), SLOT( onSocialActionsLoaded() ));
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
}
|
||||
|
||||
|
||||
void Result::onSocialActionsLoaded()
|
||||
{
|
||||
parseSocialActions();
|
||||
|
||||
emit socialActionsLoaded();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Result::setAllSocialActions(QList< SocialAction > socialActions)
|
||||
{
|
||||
m_allSocialActions = socialActions;
|
||||
}
|
||||
|
||||
|
||||
QList< SocialAction >
|
||||
Result::allSocialActions()
|
||||
{
|
||||
return m_allSocialActions;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Result::parseSocialActions()
|
||||
{
|
||||
QListIterator< Tomahawk::SocialAction > it( m_allSocialActions );
|
||||
unsigned int highestTimestamp = 0;
|
||||
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Tomahawk::SocialAction socialAction;
|
||||
socialAction = it.next();
|
||||
if ( socialAction.timestamp.toUInt() > highestTimestamp && socialAction.source.toInt() == SourceList::instance()->getLocal()->id() )
|
||||
{
|
||||
m_currentSocialActions[ socialAction.action.toString() ] = socialAction.value.toBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Result::setArtist( const Tomahawk::artist_ptr& artist )
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
|
||||
QVariant toVariant() const;
|
||||
QString toString() const;
|
||||
Tomahawk::query_ptr toQuery() const;
|
||||
Tomahawk::query_ptr toQuery();
|
||||
|
||||
float score() const;
|
||||
RID id() const;
|
||||
@ -80,8 +80,6 @@ public:
|
||||
unsigned int albumpos() const { return m_albumpos; }
|
||||
unsigned int modificationTime() const { return m_modtime; }
|
||||
int year() const { return m_year; }
|
||||
bool loved() { return m_currentSocialActions[ "Love" ].toBool(); }
|
||||
QList< Tomahawk::SocialAction > allSocialActions();
|
||||
|
||||
void setScore( float score ) { m_score = score; }
|
||||
void setTrackId( unsigned int id ) { m_trackId = id; }
|
||||
@ -99,26 +97,17 @@ public:
|
||||
void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; }
|
||||
void setModificationTime( unsigned int modtime ) { m_modtime = modtime; }
|
||||
void setYear( unsigned int year ) { m_year = year; }
|
||||
void setLoved( bool loved ) { m_currentSocialActions[ "Loved" ] = loved; }
|
||||
void setAllSocialActions( QList< Tomahawk::SocialAction > socialActions );
|
||||
|
||||
void loadSocialActions();
|
||||
QVariantMap attributes() const { return m_attributes; }
|
||||
void setAttributes( const QVariantMap& map ) { m_attributes = map; updateAttributes(); }
|
||||
|
||||
unsigned int trackId() const { return m_trackId; }
|
||||
unsigned int fileId() const { return m_fileId; }
|
||||
|
||||
public slots:
|
||||
void onSocialActionsLoaded();
|
||||
|
||||
signals:
|
||||
// emitted when the collection this result comes from is going offline/online:
|
||||
void statusChanged();
|
||||
|
||||
// emitted when social actions are loaded
|
||||
void socialActionsLoaded();
|
||||
|
||||
private slots:
|
||||
void onOffline();
|
||||
void onOnline();
|
||||
@ -129,10 +118,10 @@ private:
|
||||
explicit Result();
|
||||
|
||||
void updateAttributes();
|
||||
void parseSocialActions();
|
||||
|
||||
mutable RID m_rid;
|
||||
collection_ptr m_collection;
|
||||
Tomahawk::query_ptr m_query;
|
||||
|
||||
Tomahawk::artist_ptr m_artist;
|
||||
Tomahawk::album_ptr m_album;
|
||||
@ -150,11 +139,7 @@ private:
|
||||
float m_score;
|
||||
|
||||
QVariantMap m_attributes;
|
||||
|
||||
unsigned int m_trackId, m_fileId;
|
||||
|
||||
QHash< QString, QVariant > m_currentSocialActions;
|
||||
QList< SocialAction > m_allSocialActions;
|
||||
};
|
||||
|
||||
} //ns
|
||||
|
Loading…
x
Reference in New Issue
Block a user