mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +02:00
Pimple Track
This commit is contained in:
37
src/libtomahawk/PlaybackLog.h
Normal file
37
src/libtomahawk/PlaybackLog.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef PLAYBACKLOG_H
|
||||||
|
#define PLAYBACKLOG_H
|
||||||
|
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
struct PlaybackLog
|
||||||
|
{
|
||||||
|
Tomahawk::source_ptr source;
|
||||||
|
unsigned int timestamp;
|
||||||
|
unsigned int secsPlayed;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Tomahawk
|
||||||
|
|
||||||
|
#endif // PLAYBACKLOG_H
|
38
src/libtomahawk/SocialAction.h
Normal file
38
src/libtomahawk/SocialAction.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef SOCIALACTION_H
|
||||||
|
#define SOCIALACTION_H
|
||||||
|
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
struct SocialAction
|
||||||
|
{
|
||||||
|
QVariant action;
|
||||||
|
QVariant value;
|
||||||
|
QVariant timestamp;
|
||||||
|
Tomahawk::source_ptr source;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Tomahawk
|
||||||
|
|
||||||
|
#endif // SOCIALACTION_H
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Track.h"
|
#include "Track_p.h"
|
||||||
|
|
||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "collection/Collection.h"
|
#include "collection/Collection.h"
|
||||||
@@ -102,26 +103,20 @@ Track::get( unsigned int id, const QString& artist, const QString& track, const
|
|||||||
|
|
||||||
|
|
||||||
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 )
|
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 )
|
: d_ptr( new TrackPrivate( this, album, duration, composer, albumpos, discnumber ) )
|
||||||
, m_album( album )
|
|
||||||
, m_duration( duration )
|
|
||||||
, m_albumpos( albumpos )
|
|
||||||
, m_discnumber( discnumber )
|
|
||||||
{
|
{
|
||||||
m_trackData = TrackData::get( id, artist, track );
|
Q_D( Track );
|
||||||
|
d->trackData = TrackData::get( id, artist, track );
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Track::Track( const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber )
|
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 )
|
: d_ptr( new TrackPrivate( this, album, duration, composer, albumpos, discnumber ) )
|
||||||
, m_album( album )
|
|
||||||
, m_duration( duration )
|
|
||||||
, m_albumpos( albumpos )
|
|
||||||
, m_discnumber( discnumber )
|
|
||||||
{
|
{
|
||||||
m_trackData = TrackData::get( 0, artist, track );
|
Q_D( Track );
|
||||||
|
d->trackData = TrackData::get( 0, artist, track );
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -133,25 +128,36 @@ Track::~Track()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Track::setAlbum( const QString& album )
|
||||||
|
{
|
||||||
|
Q_D( Track );
|
||||||
|
d->album = album;
|
||||||
|
updateSortNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::init()
|
Track::init()
|
||||||
{
|
{
|
||||||
|
Q_D( Track );
|
||||||
updateSortNames();
|
updateSortNames();
|
||||||
|
|
||||||
connect( m_trackData.data(), SIGNAL( attributesLoaded() ), SIGNAL( attributesLoaded() ) );
|
connect( d->trackData.data(), SIGNAL( attributesLoaded() ), SIGNAL( attributesLoaded() ) );
|
||||||
connect( m_trackData.data(), SIGNAL( socialActionsLoaded() ), SIGNAL( socialActionsLoaded() ) );
|
connect( d->trackData.data(), SIGNAL( socialActionsLoaded() ), SIGNAL( socialActionsLoaded() ) );
|
||||||
connect( m_trackData.data(), SIGNAL( statsLoaded() ), SIGNAL( statsLoaded() ) );
|
connect( d->trackData.data(), SIGNAL( statsLoaded() ), SIGNAL( statsLoaded() ) );
|
||||||
connect( m_trackData.data(), SIGNAL( similarTracksLoaded() ), SIGNAL( similarTracksLoaded() ) );
|
connect( d->trackData.data(), SIGNAL( similarTracksLoaded() ), SIGNAL( similarTracksLoaded() ) );
|
||||||
connect( m_trackData.data(), SIGNAL( lyricsLoaded() ), SIGNAL( lyricsLoaded() ) );
|
connect( d->trackData.data(), SIGNAL( lyricsLoaded() ), SIGNAL( lyricsLoaded() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::deleteLater()
|
Track::deleteLater()
|
||||||
{
|
{
|
||||||
|
Q_D( Track );
|
||||||
QMutexLocker lock( &s_nameCacheMutex );
|
QMutexLocker lock( &s_nameCacheMutex );
|
||||||
|
|
||||||
const QString key = cacheKey( artist(), track(), m_album, m_duration, m_composer, m_albumpos, m_discnumber );
|
const QString key = cacheKey( artist(), track(), d->album, d->duration, d->composer, d->albumpos, d->discnumber );
|
||||||
if ( s_tracksByName.contains( key ) )
|
if ( s_tracksByName.contains( key ) )
|
||||||
{
|
{
|
||||||
s_tracksByName.remove( key );
|
s_tracksByName.remove( key );
|
||||||
@@ -164,7 +170,24 @@ Track::deleteLater()
|
|||||||
unsigned int
|
unsigned int
|
||||||
Track::trackId() const
|
Track::trackId() const
|
||||||
{
|
{
|
||||||
return m_trackData->trackId();
|
Q_D( const Track );
|
||||||
|
return d->trackData->trackId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QWeakPointer<Track>
|
||||||
|
Track::weakRef()
|
||||||
|
{
|
||||||
|
Q_D( Track );
|
||||||
|
return d->ownRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Track::setWeakRef( QWeakPointer<Track> weakRef )
|
||||||
|
{
|
||||||
|
Q_D( Track );
|
||||||
|
d->ownRef = weakRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -192,6 +215,7 @@ Track::finishPlaying( int timeElapsed )
|
|||||||
void
|
void
|
||||||
Track::markAsListened()
|
Track::markAsListened()
|
||||||
{
|
{
|
||||||
|
Q_D( Track );
|
||||||
if ( !isListened() )
|
if ( !isListened() )
|
||||||
{
|
{
|
||||||
DatabaseCommand_ModifyInboxEntry* cmd = new DatabaseCommand_ModifyInboxEntry( toQuery(), false );
|
DatabaseCommand_ModifyInboxEntry* cmd = new DatabaseCommand_ModifyInboxEntry( toQuery(), false );
|
||||||
@@ -207,9 +231,9 @@ Track::markAsListened()
|
|||||||
it->value = false; //listened!
|
it->value = false; //listened!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_trackData->blockSignals( true );
|
d->trackData->blockSignals( true );
|
||||||
m_trackData->setAllSocialActions( actions ); //emits socialActionsLoaded which gets propagated here
|
d->trackData->setAllSocialActions( actions ); //emits socialActionsLoaded which gets propagated here
|
||||||
m_trackData->blockSignals( false );
|
d->trackData->blockSignals( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,15 +257,17 @@ Track::isListened() const
|
|||||||
void
|
void
|
||||||
Track::updateSortNames()
|
Track::updateSortNames()
|
||||||
{
|
{
|
||||||
m_composerSortname = DatabaseImpl::sortname( m_composer, true );
|
Q_D( Track );
|
||||||
m_albumSortname = DatabaseImpl::sortname( m_album );
|
d->composerSortname = DatabaseImpl::sortname( d->composer, true );
|
||||||
|
d->albumSortname = DatabaseImpl::sortname( d->album );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::setAllSocialActions( const QList< SocialAction >& socialActions )
|
Track::setAllSocialActions( const QList< SocialAction >& socialActions )
|
||||||
{
|
{
|
||||||
m_trackData->setAllSocialActions( socialActions );
|
Q_D( Track );
|
||||||
|
d->trackData->setAllSocialActions( socialActions );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -288,87 +314,114 @@ Track::toString() const
|
|||||||
query_ptr
|
query_ptr
|
||||||
Track::toQuery()
|
Track::toQuery()
|
||||||
{
|
{
|
||||||
if ( m_query.isNull() )
|
Q_D( Track );
|
||||||
|
if ( d->query.isNull() )
|
||||||
{
|
{
|
||||||
query_ptr query = Tomahawk::Query::get( weakRef().toStrongRef() );
|
query_ptr query = Tomahawk::Query::get( weakRef().toStrongRef() );
|
||||||
if ( !query )
|
if ( !query )
|
||||||
return query_ptr();
|
return query_ptr();
|
||||||
|
|
||||||
m_query = query->weakRef();
|
d->query = query->weakRef();
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_query.toStrongRef();
|
return d->query.toStrongRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
Track::composerSortname() const
|
||||||
|
{
|
||||||
|
Q_D( const Track );
|
||||||
|
return d->composerSortname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
Track::albumSortname() const
|
||||||
|
{
|
||||||
|
Q_D( const Track );
|
||||||
|
return d->albumSortname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::loadStats()
|
Track::loadStats()
|
||||||
{
|
{
|
||||||
m_trackData->loadStats();
|
Q_D( Track );
|
||||||
|
d->trackData->loadStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList< Tomahawk::PlaybackLog >
|
QList< Tomahawk::PlaybackLog >
|
||||||
Track::playbackHistory( const Tomahawk::source_ptr& source ) const
|
Track::playbackHistory( const Tomahawk::source_ptr& source ) const
|
||||||
{
|
{
|
||||||
return m_trackData->playbackHistory( source );
|
Q_D( const Track );
|
||||||
|
return d->trackData->playbackHistory( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
Track::playbackCount( const source_ptr& source )
|
Track::playbackCount( const source_ptr& source )
|
||||||
{
|
{
|
||||||
return m_trackData->playbackCount( source );
|
Q_D( Track );
|
||||||
|
return d->trackData->playbackCount( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
Track::chartPosition() const
|
Track::chartPosition() const
|
||||||
{
|
{
|
||||||
return m_trackData->chartPosition();
|
Q_D( const Track );
|
||||||
|
return d->trackData->chartPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
Track::chartCount() const
|
Track::chartCount() const
|
||||||
{
|
{
|
||||||
return m_trackData->chartCount();
|
Q_D( const Track );
|
||||||
|
return d->trackData->chartCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::loadAttributes()
|
Track::loadAttributes()
|
||||||
{
|
{
|
||||||
m_trackData->loadAttributes();
|
Q_D( Track );
|
||||||
|
d->trackData->loadAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::loadSocialActions()
|
Track::loadSocialActions()
|
||||||
{
|
{
|
||||||
m_trackData->loadSocialActions();
|
Q_D( Track );
|
||||||
|
d->trackData->loadSocialActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList< SocialAction >
|
QList< SocialAction >
|
||||||
Track::allSocialActions() const
|
Track::allSocialActions() const
|
||||||
{
|
{
|
||||||
return m_trackData->allSocialActions();
|
Q_D( const Track );
|
||||||
|
return d->trackData->allSocialActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Track::loved()
|
Track::loved()
|
||||||
{
|
{
|
||||||
return m_trackData->loved();
|
Q_D( Track );
|
||||||
|
return d->trackData->loved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::setLoved( bool loved, bool postToInfoSystem )
|
Track::setLoved( bool loved, bool postToInfoSystem )
|
||||||
{
|
{
|
||||||
m_trackData->setLoved( loved );
|
Q_D( Track );
|
||||||
|
d->trackData->setLoved( loved );
|
||||||
|
|
||||||
if ( postToInfoSystem )
|
if ( postToInfoSystem )
|
||||||
{
|
{
|
||||||
@@ -380,7 +433,7 @@ Track::setLoved( bool loved, bool postToInfoSystem )
|
|||||||
|
|
||||||
loveInfo[ "trackinfo" ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
loveInfo[ "trackinfo" ] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPushData pushData ( m_trackData->id(),
|
Tomahawk::InfoSystem::InfoPushData pushData ( d->trackData->id(),
|
||||||
( loved ? Tomahawk::InfoSystem::InfoLove : Tomahawk::InfoSystem::InfoUnLove ),
|
( loved ? Tomahawk::InfoSystem::InfoLove : Tomahawk::InfoSystem::InfoUnLove ),
|
||||||
loveInfo,
|
loveInfo,
|
||||||
Tomahawk::InfoSystem::PushShortUrlFlag );
|
Tomahawk::InfoSystem::PushShortUrlFlag );
|
||||||
@@ -468,38 +521,41 @@ Track::socialActionDescription( const QString& action, DescriptionMode mode ) co
|
|||||||
artist_ptr
|
artist_ptr
|
||||||
Track::artistPtr() const
|
Track::artistPtr() const
|
||||||
{
|
{
|
||||||
if ( !m_artistPtr )
|
Q_D( const Track );
|
||||||
|
if ( !d->artistPtr )
|
||||||
{
|
{
|
||||||
m_artistPtr = Artist::get( artist(), false );
|
d->artistPtr = Artist::get( artist(), false );
|
||||||
connect( m_artistPtr.data(), SIGNAL( updated() ), SIGNAL( updated() ), Qt::UniqueConnection );
|
connect( d->artistPtr.data(), SIGNAL( updated() ), SIGNAL( updated() ), Qt::UniqueConnection );
|
||||||
connect( m_artistPtr.data(), SIGNAL( coverChanged() ), SIGNAL( coverChanged() ), Qt::UniqueConnection );
|
connect( d->artistPtr.data(), SIGNAL( coverChanged() ), SIGNAL( coverChanged() ), Qt::UniqueConnection );
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_artistPtr;
|
return d->artistPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
album_ptr
|
album_ptr
|
||||||
Track::albumPtr() const
|
Track::albumPtr() const
|
||||||
{
|
{
|
||||||
if ( !m_albumPtr )
|
Q_D( const Track );
|
||||||
|
if ( !d->albumPtr )
|
||||||
{
|
{
|
||||||
m_albumPtr = Album::get( artistPtr(), album(), false );
|
d->albumPtr = Album::get( artistPtr(), album(), false );
|
||||||
connect( m_albumPtr.data(), SIGNAL( updated() ), SIGNAL( updated() ), Qt::UniqueConnection );
|
connect( d->albumPtr.data(), SIGNAL( updated() ), SIGNAL( updated() ), Qt::UniqueConnection );
|
||||||
connect( m_albumPtr.data(), SIGNAL( coverChanged() ), SIGNAL( coverChanged() ), Qt::UniqueConnection );
|
connect( d->albumPtr.data(), SIGNAL( coverChanged() ), SIGNAL( coverChanged() ), Qt::UniqueConnection );
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_albumPtr;
|
return d->albumPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
artist_ptr
|
artist_ptr
|
||||||
Track::composerPtr() const
|
Track::composerPtr() const
|
||||||
{
|
{
|
||||||
if ( !m_composerPtr )
|
Q_D( const Track );
|
||||||
m_composerPtr = Artist::get( composer(), false );
|
if ( !d->composerPtr )
|
||||||
|
d->composerPtr = Artist::get( composer(), false );
|
||||||
|
|
||||||
return m_composerPtr;
|
return d->composerPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -523,13 +579,14 @@ Track::cover( const QSize& size, bool forceLoad ) const
|
|||||||
bool
|
bool
|
||||||
Track::coverLoaded() const
|
Track::coverLoaded() const
|
||||||
{
|
{
|
||||||
if ( m_albumPtr.isNull() )
|
Q_D( const Track );
|
||||||
|
if ( d->albumPtr.isNull() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( m_albumPtr->coverLoaded() && !m_albumPtr->cover( QSize( 0, 0 ) ).isNull() )
|
if ( d->albumPtr->coverLoaded() && !d->albumPtr->cover( QSize( 0, 0 ) ).isNull() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return m_artistPtr->coverLoaded();
|
return d->artistPtr->coverLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -538,61 +595,110 @@ Track::coverLoaded() const
|
|||||||
QList<Tomahawk::query_ptr>
|
QList<Tomahawk::query_ptr>
|
||||||
Track::similarTracks() const
|
Track::similarTracks() const
|
||||||
{
|
{
|
||||||
return m_trackData->similarTracks();
|
Q_D( const Track );
|
||||||
|
return d->trackData->similarTracks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
Track::lyrics() const
|
Track::lyrics() const
|
||||||
{
|
{
|
||||||
return m_trackData->lyrics();
|
Q_D( const Track );
|
||||||
|
return d->trackData->lyrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Track::artist() const
|
Track::artist() const
|
||||||
{
|
{
|
||||||
return m_trackData->artist();
|
Q_D( const Track );
|
||||||
|
return d->trackData->artist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Track::track() const
|
Track::track() const
|
||||||
{
|
{
|
||||||
return m_trackData->track();
|
Q_D( const Track );
|
||||||
|
return d->trackData->track();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
Track::composer() const
|
||||||
|
{
|
||||||
|
Q_D( const Track );
|
||||||
|
return d->composer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
Track::album() const
|
||||||
|
{
|
||||||
|
Q_D( const Track );
|
||||||
|
return d->album;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
Track::duration() const
|
||||||
|
{
|
||||||
|
Q_D( const Track );
|
||||||
|
return d->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantMap
|
QVariantMap
|
||||||
Track::attributes() const
|
Track::attributes() const
|
||||||
{
|
{
|
||||||
return m_trackData->attributes();
|
Q_D( const Track );
|
||||||
|
return d->trackData->attributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Track::year() const
|
Track::year() const
|
||||||
{
|
{
|
||||||
return m_trackData->year();
|
Q_D( const Track );
|
||||||
|
return d->trackData->year();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
Track::albumpos() const
|
||||||
|
{
|
||||||
|
Q_D( const Track );
|
||||||
|
return d->albumpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
Track::discnumber() const
|
||||||
|
{
|
||||||
|
Q_D( const Track );
|
||||||
|
return d->discnumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::share( const Tomahawk::source_ptr& source )
|
Track::share( const Tomahawk::source_ptr& source )
|
||||||
{
|
{
|
||||||
m_trackData->share( source );
|
Q_D( Track );
|
||||||
|
d->trackData->share( source );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Track::artistSortname() const
|
Track::artistSortname() const
|
||||||
{
|
{
|
||||||
return m_trackData->artistSortname();
|
Q_D( const Track );
|
||||||
|
return d->trackData->artistSortname();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Track::trackSortname() const
|
Track::trackSortname() const
|
||||||
{
|
{
|
||||||
return m_trackData->trackSortname();
|
Q_D( const Track );
|
||||||
|
return d->trackData->trackSortname();
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,23 +18,24 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#ifndef TRACK_H
|
#ifndef TRACK_H
|
||||||
#define TRACK_H
|
#define TRACK_H
|
||||||
|
|
||||||
#include <QObject>
|
#include "DllMacro.h"
|
||||||
|
#include "PlaybackLog.h"
|
||||||
|
#include "SocialAction.h"
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "Typedefs.h"
|
|
||||||
#include "TrackData.h"
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
class DatabaseCommand_LoadInboxEntries;
|
class DatabaseCommand_LoadInboxEntries;
|
||||||
|
class TrackPrivate;
|
||||||
|
|
||||||
class DLLEXPORT Track : public QObject
|
class DLLEXPORT Track : public QObject
|
||||||
{
|
{
|
||||||
@@ -51,13 +53,13 @@ public:
|
|||||||
|
|
||||||
virtual ~Track();
|
virtual ~Track();
|
||||||
|
|
||||||
// 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 setAlbum( const QString& album );
|
||||||
// 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 setDuration( int duration ) { m_duration = duration; }
|
||||||
void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; }
|
// void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; }
|
||||||
void setDiscNumber( unsigned int discnumber ) { m_discnumber = discnumber; }
|
// void setDiscNumber( unsigned int discnumber ) { m_discnumber = discnumber; }
|
||||||
void setComposer( const QString& composer ) { m_composer = composer; updateSortNames(); }*/
|
// void setComposer( const QString& composer ) { m_composer = composer; updateSortNames(); }
|
||||||
|
|
||||||
bool equals( const Tomahawk::track_ptr& other, bool ignoreCase = false ) const;
|
bool equals( const Tomahawk::track_ptr& other, bool ignoreCase = false ) const;
|
||||||
|
|
||||||
@@ -65,19 +67,19 @@ public:
|
|||||||
QString toString() const;
|
QString toString() const;
|
||||||
Tomahawk::query_ptr toQuery();
|
Tomahawk::query_ptr toQuery();
|
||||||
|
|
||||||
QString composerSortname() const { return m_composerSortname; }
|
QString composerSortname() const;
|
||||||
QString albumSortname() const { return m_albumSortname; }
|
QString albumSortname() const;
|
||||||
QString artistSortname() const;
|
QString artistSortname() const;
|
||||||
QString trackSortname() const;
|
QString trackSortname() const;
|
||||||
|
|
||||||
QString artist() const;
|
QString artist() const;
|
||||||
QString track() const;
|
QString track() const;
|
||||||
QString composer() const { return m_composer; }
|
QString composer() const;
|
||||||
QString album() const { return m_album; }
|
QString album() const;
|
||||||
int duration() const { return m_duration; }
|
int duration() const;
|
||||||
int year() const;
|
int year() const;
|
||||||
unsigned int albumpos() const { return m_albumpos; }
|
unsigned int albumpos() const;
|
||||||
unsigned int discnumber() const { return m_discnumber; }
|
unsigned int discnumber() const;
|
||||||
|
|
||||||
Tomahawk::artist_ptr artistPtr() const;
|
Tomahawk::artist_ptr artistPtr() const;
|
||||||
Tomahawk::album_ptr albumPtr() const;
|
Tomahawk::album_ptr albumPtr() const;
|
||||||
@@ -112,8 +114,8 @@ public:
|
|||||||
|
|
||||||
unsigned int trackId() const;
|
unsigned int trackId() const;
|
||||||
|
|
||||||
QWeakPointer< Tomahawk::Track > weakRef() { return m_ownRef; }
|
QWeakPointer< Tomahawk::Track > weakRef();
|
||||||
void setWeakRef( QWeakPointer< Tomahawk::Track > weakRef ) { m_ownRef = weakRef; }
|
void setWeakRef( QWeakPointer< Tomahawk::Track > weakRef );
|
||||||
|
|
||||||
void startPlaying();
|
void startPlaying();
|
||||||
void finishPlaying( int timeElapsed );
|
void finishPlaying( int timeElapsed );
|
||||||
@@ -134,7 +136,11 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void deleteLater();
|
void deleteLater();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QScopedPointer<TrackPrivate> d_ptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_DECLARE_PRIVATE( Track )
|
||||||
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( 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 );
|
explicit Track( const QString& artist, const QString& track, const QString& album, int duration, const QString& composer, unsigned int albumpos, unsigned int discnumber );
|
||||||
|
|
||||||
@@ -144,29 +150,11 @@ private:
|
|||||||
|
|
||||||
void setAllSocialActions( const QList< SocialAction >& socialActions );
|
void setAllSocialActions( const QList< SocialAction >& socialActions );
|
||||||
|
|
||||||
QString m_composer;
|
|
||||||
QString m_album;
|
|
||||||
QString m_composerSortname;
|
|
||||||
QString m_albumSortname;
|
|
||||||
|
|
||||||
int m_duration;
|
|
||||||
unsigned int m_albumpos;
|
|
||||||
unsigned int m_discnumber;
|
|
||||||
|
|
||||||
mutable Tomahawk::artist_ptr m_artistPtr;
|
|
||||||
mutable Tomahawk::album_ptr m_albumPtr;
|
|
||||||
mutable Tomahawk::artist_ptr m_composerPtr;
|
|
||||||
|
|
||||||
mutable trackdata_ptr m_trackData;
|
|
||||||
|
|
||||||
query_wptr m_query;
|
|
||||||
QWeakPointer< Tomahawk::Track > m_ownRef;
|
|
||||||
|
|
||||||
static QHash< QString, track_wptr > s_tracksByName;
|
static QHash< QString, track_wptr > s_tracksByName;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; //ns
|
} // namespace Tomahawk
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( Tomahawk::track_ptr );
|
Q_DECLARE_METATYPE( Tomahawk::track_ptr )
|
||||||
|
|
||||||
#endif // TRACK_H
|
#endif // TRACK_H
|
||||||
|
@@ -24,10 +24,12 @@
|
|||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "Typedefs.h"
|
|
||||||
#include "infosystem/InfoSystem.h"
|
#include "infosystem/InfoSystem.h"
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
#include "PlaybackLog.h"
|
||||||
|
#include "SocialAction.h"
|
||||||
|
#include "Typedefs.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
@@ -36,21 +38,6 @@ class DatabaseCommand_LogPlayback;
|
|||||||
class DatabaseCommand_PlaybackHistory;
|
class DatabaseCommand_PlaybackHistory;
|
||||||
class IdThreadWorker;
|
class IdThreadWorker;
|
||||||
|
|
||||||
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 DLLEXPORT TrackData : public QObject
|
class DLLEXPORT TrackData : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -173,9 +160,9 @@ private:
|
|||||||
friend class DatabaseCommand_PlaybackHistory;
|
friend class DatabaseCommand_PlaybackHistory;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; //ns
|
} // namespace Tomahawk
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QList<Tomahawk::PlaybackLog> );
|
Q_DECLARE_METATYPE( QList<Tomahawk::PlaybackLog> )
|
||||||
Q_DECLARE_METATYPE( Tomahawk::trackdata_ptr );
|
Q_DECLARE_METATYPE( Tomahawk::trackdata_ptr )
|
||||||
|
|
||||||
#endif // TRACKDATA_H
|
#endif // TRACKDATA_H
|
||||||
|
67
src/libtomahawk/Track_p.h
Normal file
67
src/libtomahawk/Track_p.h
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef TRACK_P_H
|
||||||
|
#define TRACK_P_H
|
||||||
|
|
||||||
|
#include "Track.h"
|
||||||
|
|
||||||
|
namespace Tomahawk {
|
||||||
|
|
||||||
|
class TrackPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TrackPrivate( Track* q, const QString& _album, int _duration, const QString& _composer, unsigned int _albumpos, unsigned int _discnumber )
|
||||||
|
: q_ptr( q )
|
||||||
|
, composer( _composer )
|
||||||
|
, album( _album )
|
||||||
|
, duration( _duration )
|
||||||
|
, albumpos( _albumpos )
|
||||||
|
, discnumber( _discnumber )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Track* q_ptr;
|
||||||
|
Q_DECLARE_PUBLIC( Track )
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString composer;
|
||||||
|
QString album;
|
||||||
|
QString composerSortname;
|
||||||
|
QString albumSortname;
|
||||||
|
|
||||||
|
int duration;
|
||||||
|
uint albumpos;
|
||||||
|
uint discnumber;
|
||||||
|
|
||||||
|
mutable Tomahawk::artist_ptr artistPtr;
|
||||||
|
mutable Tomahawk::album_ptr albumPtr;
|
||||||
|
mutable Tomahawk::artist_ptr composerPtr;
|
||||||
|
|
||||||
|
mutable trackdata_ptr trackData;
|
||||||
|
|
||||||
|
query_wptr query;
|
||||||
|
QWeakPointer< Tomahawk::Track > ownRef;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Tomahawk
|
||||||
|
|
||||||
|
#endif // TRACK_P_H
|
Reference in New Issue
Block a user