mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 08:21:54 +02:00
* Track is now proxying a TrackData object (which is cached and only loaded once per track-id).
This commit is contained in:
parent
1e1bdb29d4
commit
84c219105e
@ -19,14 +19,10 @@
|
||||
#include "Track.h"
|
||||
|
||||
#include <QtAlgorithms>
|
||||
#include <QReadWriteLock>
|
||||
|
||||
#include "database/Database.h"
|
||||
#include "database/DatabaseImpl.h"
|
||||
#include "database/DatabaseCommand_LogPlayback.h"
|
||||
#include "database/DatabaseCommand_LoadPlaylistEntries.h"
|
||||
#include "database/DatabaseCommand_LoadSocialActions.h"
|
||||
#include "database/DatabaseCommand_SocialAction.h"
|
||||
#include "database/DatabaseCommand_TrackStats.h"
|
||||
#include "Album.h"
|
||||
#include "collection/Collection.h"
|
||||
#include "Pipeline.h"
|
||||
@ -38,8 +34,10 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
static QHash< QString, track_wptr > s_tracks;
|
||||
static QMutex s_mutex;
|
||||
QHash< QString, track_wptr > Track::s_tracksByName = QHash< QString, track_wptr >();
|
||||
|
||||
static QMutex s_nameCacheMutex;
|
||||
|
||||
|
||||
inline QString
|
||||
cacheKey( const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber )
|
||||
@ -60,35 +58,66 @@ Track::get( const QString& artist, const QString& track, const QString& album, i
|
||||
return track_ptr();
|
||||
}
|
||||
|
||||
QMutexLocker lock( &s_mutex );
|
||||
QMutexLocker lock( &s_nameCacheMutex );
|
||||
const QString key = cacheKey( artist, track, album, duration, composer, albumpos, discnumber );
|
||||
if ( s_tracks.contains( key ) )
|
||||
if ( s_tracksByName.contains( key ) )
|
||||
{
|
||||
return s_tracks.value( key );
|
||||
track_wptr track = s_tracksByName.value( key );
|
||||
if ( track )
|
||||
return track.toStrongRef();
|
||||
}
|
||||
|
||||
track_ptr t = track_ptr( new Track( artist, track, album, duration, composer, albumpos, discnumber ), &Track::deleteLater );
|
||||
t->setWeakRef( t.toWeakRef() );
|
||||
s_tracks.insert( key, t );
|
||||
s_tracksByName.insert( key, t );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Track::Track( const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber )
|
||||
: m_artist( artist )
|
||||
, m_composer( composer )
|
||||
track_ptr
|
||||
Track::get( unsigned int id, const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber )
|
||||
{
|
||||
QMutexLocker lock( &s_nameCacheMutex );
|
||||
const QString key = cacheKey( artist, track, album, duration, composer, albumpos, discnumber );
|
||||
if ( s_tracksByName.contains( key ) )
|
||||
{
|
||||
track_wptr track = s_tracksByName.value( key );
|
||||
if ( track )
|
||||
return track;
|
||||
}
|
||||
|
||||
track_ptr t = track_ptr( new Track( id, artist, track, album, duration, composer, albumpos, discnumber ), &Track::deleteLater );
|
||||
t->setWeakRef( t.toWeakRef() );
|
||||
s_tracksByName.insert( key, t );
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Track::Track( unsigned int id, const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber )
|
||||
: m_composer( composer )
|
||||
, m_album( album )
|
||||
, m_track( track )
|
||||
, m_duration( duration )
|
||||
, m_albumpos( albumpos )
|
||||
, m_discnumber( discnumber )
|
||||
, m_socialActionsLoaded( false )
|
||||
, m_simTracksLoaded( false )
|
||||
, m_lyricsLoaded( false )
|
||||
, m_infoJobs( 0 )
|
||||
{
|
||||
updateSortNames();
|
||||
m_trackData = TrackData::get( id, artist, track );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
Track::Track( const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber )
|
||||
: m_composer( composer )
|
||||
, m_album( album )
|
||||
, m_duration( duration )
|
||||
, m_albumpos( albumpos )
|
||||
, m_discnumber( discnumber )
|
||||
{
|
||||
m_trackData = TrackData::get( 0, artist, track );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@ -98,28 +127,48 @@ Track::~Track()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::init()
|
||||
{
|
||||
updateSortNames();
|
||||
|
||||
connect( m_trackData.data(), SIGNAL( attributesLoaded() ), SIGNAL( attributesLoaded() ) );
|
||||
connect( m_trackData.data(), SIGNAL( socialActionsLoaded() ), SIGNAL( socialActionsLoaded() ) );
|
||||
connect( m_trackData.data(), SIGNAL( statsLoaded() ), SIGNAL( statsLoaded() ) );
|
||||
connect( m_trackData.data(), SIGNAL( similarTracksLoaded() ), SIGNAL( similarTracksLoaded() ) );
|
||||
connect( m_trackData.data(), SIGNAL( lyricsLoaded() ), SIGNAL( lyricsLoaded() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::deleteLater()
|
||||
{
|
||||
QMutexLocker lock( &s_mutex );
|
||||
QMutexLocker lock( &s_nameCacheMutex );
|
||||
|
||||
const QString key = cacheKey( m_artist, m_track, m_album, m_duration, m_composer, m_albumpos, m_discnumber );
|
||||
if ( s_tracks.contains( key ) )
|
||||
const QString key = cacheKey( artist(), track(), m_album, m_duration, m_composer, m_albumpos, m_discnumber );
|
||||
if ( s_tracksByName.contains( key ) )
|
||||
{
|
||||
s_tracks.remove( key );
|
||||
s_tracksByName.remove( key );
|
||||
}
|
||||
|
||||
QObject::deleteLater();
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
Track::trackId() const
|
||||
{
|
||||
return m_trackData->trackId();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::updateSortNames()
|
||||
{
|
||||
m_artistSortname = DatabaseImpl::sortname( m_artist, true );
|
||||
m_artistSortname = DatabaseImpl::sortname( artist(), true );
|
||||
m_composerSortname = DatabaseImpl::sortname( m_composer, true );
|
||||
m_albumSortname = DatabaseImpl::sortname( m_album );
|
||||
m_trackSortname = DatabaseImpl::sortname( m_track );
|
||||
m_trackSortname = DatabaseImpl::sortname( track() );
|
||||
}
|
||||
|
||||
|
||||
@ -183,138 +232,74 @@ Track::toQuery()
|
||||
void
|
||||
Track::loadStats()
|
||||
{
|
||||
DatabaseCommand_TrackStats* cmd = new DatabaseCommand_TrackStats( m_ownRef.toStrongRef() );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
m_trackData->loadStats();
|
||||
}
|
||||
|
||||
|
||||
QList< Tomahawk::PlaybackLog >
|
||||
Track::playbackHistory( const Tomahawk::source_ptr& source ) const
|
||||
{
|
||||
QList< Tomahawk::PlaybackLog > history;
|
||||
|
||||
foreach ( const PlaybackLog& log, m_playbackHistory )
|
||||
{
|
||||
if ( source.isNull() || log.source == source )
|
||||
{
|
||||
history << log;
|
||||
}
|
||||
}
|
||||
|
||||
return history;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::setPlaybackHistory( const QList< Tomahawk::PlaybackLog >& playbackData )
|
||||
{
|
||||
m_playbackHistory = playbackData;
|
||||
emit statsLoaded();
|
||||
return m_trackData->playbackHistory( source );
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
Track::playbackCount( const source_ptr& source )
|
||||
{
|
||||
unsigned int count = 0;
|
||||
foreach ( const PlaybackLog& log, m_playbackHistory )
|
||||
{
|
||||
if ( source.isNull() || log.source == source )
|
||||
count++;
|
||||
}
|
||||
return m_trackData->playbackCount( source );
|
||||
}
|
||||
|
||||
return count;
|
||||
|
||||
void
|
||||
Track::loadAttributes()
|
||||
{
|
||||
m_trackData->loadAttributes();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::loadSocialActions()
|
||||
{
|
||||
if ( m_socialActionsLoaded )
|
||||
return;
|
||||
|
||||
m_socialActionsLoaded = true;
|
||||
|
||||
DatabaseCommand_LoadSocialActions* cmd = new DatabaseCommand_LoadSocialActions( m_ownRef.toStrongRef() );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::setAllSocialActions( const QList< SocialAction >& socialActions )
|
||||
{
|
||||
m_allSocialActions = socialActions;
|
||||
parseSocialActions();
|
||||
|
||||
emit socialActionsLoaded();
|
||||
m_trackData->loadSocialActions();
|
||||
}
|
||||
|
||||
|
||||
QList< SocialAction >
|
||||
Track::allSocialActions() const
|
||||
{
|
||||
return m_allSocialActions;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::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->isLocal() )
|
||||
{
|
||||
m_currentSocialActions[ socialAction.action.toString() ] = socialAction.value.toBool();
|
||||
}
|
||||
}
|
||||
return m_trackData->allSocialActions();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Track::loved()
|
||||
{
|
||||
if ( m_socialActionsLoaded )
|
||||
{
|
||||
return m_currentSocialActions[ "Love" ].toBool();
|
||||
}
|
||||
else
|
||||
{
|
||||
loadSocialActions();
|
||||
}
|
||||
|
||||
return false;
|
||||
return m_trackData->loved();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::setLoved( bool loved )
|
||||
Track::setLoved( bool loved, bool postToInfoSystem )
|
||||
{
|
||||
m_currentSocialActions[ "Love" ] = loved;
|
||||
m_trackData->setLoved( loved );
|
||||
|
||||
QVariantMap loveInfo;
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["title"] = track();
|
||||
trackInfo["artist"] = artist();
|
||||
trackInfo["album"] = album();
|
||||
if ( postToInfoSystem )
|
||||
{
|
||||
QVariantMap loveInfo;
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["title"] = track();
|
||||
trackInfo["artist"] = artist();
|
||||
trackInfo["album"] = album();
|
||||
|
||||
loveInfo[ "trackinfo" ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||
loveInfo[ "trackinfo" ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||
|
||||
Tomahawk::InfoSystem::InfoPushData pushData ( id(),
|
||||
( loved ? Tomahawk::InfoSystem::InfoLove : Tomahawk::InfoSystem::InfoUnLove ),
|
||||
loveInfo,
|
||||
Tomahawk::InfoSystem::PushShortUrlFlag );
|
||||
Tomahawk::InfoSystem::InfoPushData pushData ( m_trackData->id(),
|
||||
( loved ? Tomahawk::InfoSystem::InfoLove : Tomahawk::InfoSystem::InfoUnLove ),
|
||||
loveInfo,
|
||||
Tomahawk::InfoSystem::PushShortUrlFlag );
|
||||
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
||||
|
||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction( m_ownRef.toStrongRef(), QString( "Love" ), loved ? QString( "true" ) : QString( "false" ) );
|
||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||
|
||||
emit socialActionsLoaded();
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -466,136 +451,47 @@ Track::coverLoaded() const
|
||||
QList<Tomahawk::query_ptr>
|
||||
Track::similarTracks() const
|
||||
{
|
||||
if ( !m_simTracksLoaded )
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["artist"] = artist();
|
||||
trackInfo["track"] = track();
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||
requestData.caller = id();
|
||||
requestData.customData = QVariantMap();
|
||||
|
||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||
requestData.type = Tomahawk::InfoSystem::InfoTrackSimilars;
|
||||
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( finished( QString ) ),
|
||||
SLOT( infoSystemFinished( QString ) ), Qt::UniqueConnection );
|
||||
|
||||
m_infoJobs++;
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||
}
|
||||
|
||||
return m_similarTracks;
|
||||
return m_trackData->similarTracks();
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
Track::lyrics() const
|
||||
{
|
||||
if ( !m_lyricsLoaded )
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoStringHash trackInfo;
|
||||
trackInfo["artist"] = artist();
|
||||
trackInfo["track"] = track();
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||
requestData.caller = id();
|
||||
requestData.customData = QVariantMap();
|
||||
|
||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||
requestData.type = Tomahawk::InfoSystem::InfoTrackLyrics;
|
||||
requestData.requestId = TomahawkUtils::infosystemRequestId();
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ), Qt::UniqueConnection );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( finished( QString ) ),
|
||||
SLOT( infoSystemFinished( QString ) ), Qt::UniqueConnection );
|
||||
|
||||
m_infoJobs++;
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||
}
|
||||
|
||||
return m_lyrics;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
if ( requestData.caller != id() )
|
||||
return;
|
||||
|
||||
QVariantMap returnedData = output.value< QVariantMap >();
|
||||
switch ( requestData.type )
|
||||
{
|
||||
case InfoSystem::InfoTrackLyrics:
|
||||
{
|
||||
m_lyrics = output.value< QVariant >().toString().split( "\n" );
|
||||
|
||||
m_lyricsLoaded = true;
|
||||
emit lyricsLoaded();
|
||||
break;
|
||||
}
|
||||
|
||||
case InfoSystem::InfoTrackSimilars:
|
||||
{
|
||||
const QStringList artists = returnedData["artists"].toStringList();
|
||||
const QStringList tracks = returnedData["tracks"].toStringList();
|
||||
|
||||
for ( int i = 0; i < tracks.count() && i < 50; i++ )
|
||||
{
|
||||
m_similarTracks << Query::get( artists.at( i ), tracks.at( i ), QString(), uuid(), false );
|
||||
}
|
||||
Pipeline::instance()->resolve( m_similarTracks );
|
||||
|
||||
m_simTracksLoaded = true;
|
||||
emit similarTracksLoaded();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::infoSystemFinished( QString target )
|
||||
{
|
||||
if ( target != id() )
|
||||
return;
|
||||
|
||||
if ( --m_infoJobs == 0 )
|
||||
{
|
||||
disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
this, SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||
|
||||
disconnect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ),
|
||||
this, SLOT( infoSystemFinished( QString ) ) );
|
||||
}
|
||||
|
||||
emit updated();
|
||||
return m_trackData->lyrics();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
Track::id() const
|
||||
Track::artist() const
|
||||
{
|
||||
if ( m_uuid.isEmpty() )
|
||||
{
|
||||
m_uuid = uuid();
|
||||
}
|
||||
|
||||
return m_uuid;
|
||||
return m_trackData->artist();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
Track::track() const
|
||||
{
|
||||
return m_trackData->track();
|
||||
}
|
||||
|
||||
|
||||
QVariantMap
|
||||
Track::attributes() const
|
||||
{
|
||||
return m_trackData->attributes();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Track::year() const
|
||||
{
|
||||
return m_trackData->year();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Track::share( const Tomahawk::source_ptr& source )
|
||||
{
|
||||
m_trackData->share( source );
|
||||
}
|
||||
|
@ -24,39 +24,18 @@
|
||||
#include <QVariant>
|
||||
|
||||
#include "Typedefs.h"
|
||||
#include "TrackData.h"
|
||||
#include "infosystem/InfoSystem.h"
|
||||
|
||||
#include "DllMacro.h"
|
||||
|
||||
class DatabaseCommand_LogPlayback;
|
||||
class DatabaseCommand_PlaybackHistory;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
struct SocialAction
|
||||
{
|
||||
QVariant action;
|
||||
QVariant value;
|
||||
QVariant timestamp;
|
||||
Tomahawk::source_ptr source;
|
||||
};
|
||||
|
||||
struct PlaybackLog
|
||||
{
|
||||
Tomahawk::source_ptr source;
|
||||
unsigned int timestamp;
|
||||
unsigned int secsPlayed;
|
||||
};
|
||||
|
||||
class TrackPrivate;
|
||||
|
||||
class DLLEXPORT Track : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class ::DatabaseCommand_LogPlayback;
|
||||
friend class ::DatabaseCommand_PlaybackHistory;
|
||||
friend class Pipeline;
|
||||
|
||||
public:
|
||||
@ -64,14 +43,13 @@ public:
|
||||
{ Detailed = 0, Short = 1 };
|
||||
|
||||
static track_ptr get( const QString& artist, const QString& track, const QString& album = QString(), int duration = 0, const QString& composer = QString(), unsigned int albumpos = 0, unsigned int discnumber = 0 );
|
||||
static track_ptr get( unsigned int id, const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber );
|
||||
|
||||
virtual ~Track();
|
||||
|
||||
QString id() const;
|
||||
|
||||
void setArtist( const QString& artist ) { m_artist = artist; updateSortNames(); }
|
||||
// void setArtist( const QString& artist ) { m_artist = artist; updateSortNames(); }
|
||||
void setAlbum( const QString& album ) { m_album = album; updateSortNames(); }
|
||||
void setTrack( const QString& track ) { m_track = track; updateSortNames(); }
|
||||
// void setTrack( const QString& track ) { m_track = track; updateSortNames(); }
|
||||
/* void setDuration( int duration ) { m_duration = duration; }
|
||||
void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; }
|
||||
void setDiscNumber( unsigned int discnumber ) { m_discnumber = discnumber; }
|
||||
@ -88,11 +66,12 @@ public:
|
||||
QString albumSortname() const { return m_albumSortname; }
|
||||
QString trackSortname() const { return m_trackSortname; }
|
||||
|
||||
QString artist() const { return m_artist; }
|
||||
QString artist() const;
|
||||
QString track() const;
|
||||
QString composer() const { return m_composer; }
|
||||
QString album() const { return m_album; }
|
||||
QString track() const { return m_track; }
|
||||
int duration() const { return m_duration; }
|
||||
int year() const;
|
||||
unsigned int albumpos() const { return m_albumpos; }
|
||||
unsigned int discnumber() const { return m_discnumber; }
|
||||
|
||||
@ -105,28 +84,34 @@ public:
|
||||
#endif
|
||||
bool coverLoaded() const;
|
||||
|
||||
void setLoved( bool loved );
|
||||
void setLoved( bool loved, bool postToInfoSystem = true );
|
||||
bool loved();
|
||||
|
||||
void share( const Tomahawk::source_ptr& source );
|
||||
|
||||
void loadAttributes();
|
||||
QVariantMap attributes() const;
|
||||
|
||||
void loadStats();
|
||||
QList< Tomahawk::PlaybackLog > playbackHistory( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() ) const;
|
||||
void setPlaybackHistory( const QList< Tomahawk::PlaybackLog >& playbackData );
|
||||
unsigned int playbackCount( const Tomahawk::source_ptr& source = Tomahawk::source_ptr() );
|
||||
|
||||
void loadSocialActions();
|
||||
QList< Tomahawk::SocialAction > allSocialActions() const;
|
||||
void setAllSocialActions( const QList< Tomahawk::SocialAction >& socialActions );
|
||||
QString socialActionDescription( const QString& action, DescriptionMode mode ) const;
|
||||
|
||||
QList<Tomahawk::query_ptr> similarTracks() const;
|
||||
QStringList lyrics() const;
|
||||
|
||||
unsigned int trackId() const;
|
||||
|
||||
QWeakPointer< Tomahawk::Track > weakRef() { return m_ownRef; }
|
||||
void setWeakRef( QWeakPointer< Tomahawk::Track > weakRef ) { m_ownRef = weakRef; }
|
||||
|
||||
signals:
|
||||
void coverChanged();
|
||||
void socialActionsLoaded();
|
||||
void attributesLoaded();
|
||||
void statsLoaded();
|
||||
void similarTracksLoaded();
|
||||
void lyricsLoaded();
|
||||
@ -136,25 +121,21 @@ signals:
|
||||
public slots:
|
||||
void deleteLater();
|
||||
|
||||
private slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
private:
|
||||
explicit Track( unsigned int id, const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber );
|
||||
explicit Track( const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber );
|
||||
|
||||
void init();
|
||||
|
||||
void updateSortNames();
|
||||
void parseSocialActions();
|
||||
|
||||
QString m_artistSortname;
|
||||
QString m_composerSortname;
|
||||
QString m_albumSortname;
|
||||
QString m_trackSortname;
|
||||
|
||||
QString m_artist;
|
||||
QString m_composer;
|
||||
QString m_album;
|
||||
QString m_track;
|
||||
|
||||
int m_duration;
|
||||
unsigned int m_albumpos;
|
||||
@ -164,29 +145,16 @@ private:
|
||||
mutable Tomahawk::album_ptr m_albumPtr;
|
||||
mutable Tomahawk::artist_ptr m_composerPtr;
|
||||
|
||||
bool m_playbackHistoryLoaded;
|
||||
QList< PlaybackLog > m_playbackHistory;
|
||||
|
||||
bool m_socialActionsLoaded;
|
||||
QHash< QString, QVariant > m_currentSocialActions;
|
||||
QList< SocialAction > m_allSocialActions;
|
||||
|
||||
bool m_simTracksLoaded;
|
||||
QList<Tomahawk::query_ptr> m_similarTracks;
|
||||
|
||||
bool m_lyricsLoaded;
|
||||
QStringList m_lyrics;
|
||||
|
||||
mutable int m_infoJobs;
|
||||
mutable QString m_uuid;
|
||||
mutable trackdata_ptr m_trackData;
|
||||
|
||||
query_wptr m_query;
|
||||
QWeakPointer< Tomahawk::Track > m_ownRef;
|
||||
|
||||
static QHash< QString, track_wptr > s_tracksByName;
|
||||
};
|
||||
|
||||
}; //ns
|
||||
|
||||
Q_DECLARE_METATYPE( QList<Tomahawk::PlaybackLog> );
|
||||
Q_DECLARE_METATYPE( Tomahawk::track_ptr );
|
||||
|
||||
#endif // TRACK_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user