mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
* Made Playlist a proper PlaylistInterface type.
This commit is contained in:
@@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
Tomahawk::collection_ptr collection() const;
|
Tomahawk::collection_ptr collection() const;
|
||||||
|
|
||||||
QList<Tomahawk::query_ptr> tracks();
|
virtual QList<Tomahawk::query_ptr> tracks();
|
||||||
|
|
||||||
virtual int trackCount() const { return 0; }
|
virtual int trackCount() const { return 0; }
|
||||||
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
virtual int unfilteredTrackCount() const { return m_queries.count(); }
|
||||||
|
@@ -32,12 +32,14 @@ PlaylistEntry::queryVariant() const
|
|||||||
return m_query->toVariant();
|
return m_query->toVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistEntry::setQuery( const Tomahawk::query_ptr& q )
|
PlaylistEntry::setQuery( const Tomahawk::query_ptr& q )
|
||||||
{
|
{
|
||||||
m_query = q;
|
m_query = q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Tomahawk::query_ptr&
|
const Tomahawk::query_ptr&
|
||||||
PlaylistEntry::query() const
|
PlaylistEntry::query() const
|
||||||
{
|
{
|
||||||
@@ -51,12 +53,14 @@ PlaylistEntry::lastSource() const
|
|||||||
return m_lastsource;
|
return m_lastsource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistEntry::setLastSource( source_ptr s )
|
PlaylistEntry::setLastSource( source_ptr s )
|
||||||
{
|
{
|
||||||
m_lastsource = s;
|
m_lastsource = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Playlist::Playlist( const source_ptr& author )
|
Playlist::Playlist( const source_ptr& author )
|
||||||
: m_source( author )
|
: m_source( author )
|
||||||
, m_lastmodified( 0 )
|
, m_lastmodified( 0 )
|
||||||
@@ -64,6 +68,7 @@ Playlist::Playlist( const source_ptr& author )
|
|||||||
qDebug() << Q_FUNC_INFO << "JSON";
|
qDebug() << Q_FUNC_INFO << "JSON";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// used when loading from DB:
|
// used when loading from DB:
|
||||||
Playlist::Playlist( const source_ptr& src,
|
Playlist::Playlist( const source_ptr& src,
|
||||||
const QString& currentrevision,
|
const QString& currentrevision,
|
||||||
@@ -107,16 +112,18 @@ Playlist::Playlist( const source_ptr& author,
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
||||||
Playlist::init()
|
Playlist::init()
|
||||||
{
|
{
|
||||||
m_locallyChanged = false;
|
m_locallyChanged = false;
|
||||||
connect( Pipeline::instance(), SIGNAL( idle() ), SLOT( onResolvingFinished() ) );
|
connect( Pipeline::instance(), SIGNAL( idle() ), SLOT( onResolvingFinished() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Playlist::~Playlist() {}
|
Playlist::~Playlist() {}
|
||||||
|
|
||||||
|
|
||||||
playlist_ptr
|
playlist_ptr
|
||||||
Playlist::create( const source_ptr& author,
|
Playlist::create( const source_ptr& author,
|
||||||
const QString& guid,
|
const QString& guid,
|
||||||
@@ -293,6 +300,7 @@ Playlist::setRevision( const QString& rev,
|
|||||||
emit revisionLoaded( pr );
|
emit revisionLoaded( pr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PlaylistRevision
|
PlaylistRevision
|
||||||
Playlist::setNewRevision( const QString& rev,
|
Playlist::setNewRevision( const QString& rev,
|
||||||
const QList<QString>& neworderedguids,
|
const QList<QString>& neworderedguids,
|
||||||
@@ -373,12 +381,14 @@ Playlist::setNewRevision( const QString& rev,
|
|||||||
return pr;
|
return pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const source_ptr&
|
const source_ptr&
|
||||||
Playlist::author()
|
Playlist::author()
|
||||||
{
|
{
|
||||||
return m_source;
|
return m_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Playlist::resolve()
|
Playlist::resolve()
|
||||||
{
|
{
|
||||||
@@ -391,6 +401,7 @@ Playlist::resolve()
|
|||||||
Pipeline::instance()->resolve( qlist );
|
Pipeline::instance()->resolve( qlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Playlist::onResultsFound( const QList<Tomahawk::result_ptr>& results )
|
Playlist::onResultsFound( const QList<Tomahawk::result_ptr>& results )
|
||||||
{
|
{
|
||||||
@@ -409,6 +420,7 @@ Playlist::onResolvingFinished()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Playlist::addEntry( const query_ptr& query, const QString& oldrev )
|
Playlist::addEntry( const query_ptr& query, const QString& oldrev )
|
||||||
{
|
{
|
||||||
@@ -430,6 +442,7 @@ Playlist::addEntries( const QList<query_ptr>& queries, const QString& oldrev )
|
|||||||
createNewRevision( newrev, oldrev, el );
|
createNewRevision( newrev, oldrev, el );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<plentry_ptr>
|
QList<plentry_ptr>
|
||||||
Playlist::addEntriesInternal( const QList<Tomahawk::query_ptr>& queries )
|
Playlist::addEntriesInternal( const QList<Tomahawk::query_ptr>& queries )
|
||||||
{
|
{
|
||||||
@@ -458,15 +471,27 @@ QList< plentry_ptr >
|
|||||||
Playlist::newEntries( const QList< plentry_ptr >& entries )
|
Playlist::newEntries( const QList< plentry_ptr >& entries )
|
||||||
{
|
{
|
||||||
QSet<QString> currentguids;
|
QSet<QString> currentguids;
|
||||||
foreach( plentry_ptr p, m_entries )
|
foreach( const plentry_ptr& p, m_entries )
|
||||||
currentguids.insert( p->guid() ); // could be cached as member?
|
currentguids.insert( p->guid() ); // could be cached as member?
|
||||||
|
|
||||||
// calc list of newly added entries:
|
// calc list of newly added entries:
|
||||||
QList<plentry_ptr> added;
|
QList<plentry_ptr> added;
|
||||||
foreach( plentry_ptr p, entries )
|
foreach( const plentry_ptr& p, entries )
|
||||||
{
|
{
|
||||||
if( !currentguids.contains( p->guid() ) )
|
if( !currentguids.contains( p->guid() ) )
|
||||||
added << p;
|
added << p;
|
||||||
}
|
}
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<Tomahawk::query_ptr>
|
||||||
|
Playlist::tracks()
|
||||||
|
{
|
||||||
|
QList<Tomahawk::query_ptr> queries;
|
||||||
|
foreach( const plentry_ptr& p, m_entries )
|
||||||
|
queries << p->query();
|
||||||
|
|
||||||
|
return queries;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,8 @@
|
|||||||
#include "query.h"
|
#include "query.h"
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
|
|
||||||
|
#include "playlistinterface.h"
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class DatabaseCommand_LoadAllPlaylists;
|
class DatabaseCommand_LoadAllPlaylists;
|
||||||
@@ -79,7 +81,7 @@ struct PlaylistRevision
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT Playlist : public QObject
|
class DLLEXPORT Playlist : public QObject, public PlaylistInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( QString guid READ guid WRITE setGuid )
|
Q_PROPERTY( QString guid READ guid WRITE setGuid )
|
||||||
@@ -137,6 +139,21 @@ public:
|
|||||||
void setShared( bool b ) { m_shared = b; }
|
void setShared( bool b ) { m_shared = b; }
|
||||||
// </IGNORE>
|
// </IGNORE>
|
||||||
|
|
||||||
|
virtual QList<Tomahawk::query_ptr> tracks();
|
||||||
|
|
||||||
|
virtual int unfilteredTrackCount() const { return m_entries.count(); }
|
||||||
|
virtual int trackCount() const { return m_entries.count(); }
|
||||||
|
|
||||||
|
virtual Tomahawk::result_ptr siblingItem( int itemsAway ) { return result_ptr(); }
|
||||||
|
|
||||||
|
virtual PlaylistInterface::RepeatMode repeatMode() const { return PlaylistInterface::NoRepeat; }
|
||||||
|
virtual bool shuffled() const { return false; }
|
||||||
|
|
||||||
|
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||||
|
virtual void setShuffled( bool ) {}
|
||||||
|
|
||||||
|
virtual void setFilter( const QString& pattern ) {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// emitted when the playlist revision changes (whenever the playlist changes)
|
/// emitted when the playlist revision changes (whenever the playlist changes)
|
||||||
void revisionLoaded( Tomahawk::PlaylistRevision );
|
void revisionLoaded( Tomahawk::PlaylistRevision );
|
||||||
@@ -144,6 +161,12 @@ signals:
|
|||||||
/// watch for this to see when newly created playlist is synced to DB (if you care)
|
/// watch for this to see when newly created playlist is synced to DB (if you care)
|
||||||
void created();
|
void created();
|
||||||
|
|
||||||
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
|
void shuffleModeChanged( bool enabled );
|
||||||
|
|
||||||
|
void trackCountChanged( unsigned int tracks );
|
||||||
|
void sourceTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// want to update the playlist from the model?
|
// want to update the playlist from the model?
|
||||||
// generate a newrev using uuid() and call this:
|
// generate a newrev using uuid() and call this:
|
||||||
|
@@ -18,6 +18,8 @@ public:
|
|||||||
virtual AlbumModel* sourceModel() const { return m_model; }
|
virtual AlbumModel* sourceModel() const { return m_model; }
|
||||||
virtual void setSourceModel( AlbumModel* sourceModel );
|
virtual void setSourceModel( AlbumModel* sourceModel );
|
||||||
|
|
||||||
|
virtual QList<Tomahawk::query_ptr> tracks() { Q_ASSERT( FALSE ); QList<Tomahawk::query_ptr> queries; return queries; }
|
||||||
|
|
||||||
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
||||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||||
virtual int albumCount() const { return rowCount( QModelIndex() ); }
|
virtual int albumCount() const { return rowCount( QModelIndex() ); }
|
||||||
|
@@ -45,6 +45,8 @@ public:
|
|||||||
|
|
||||||
bool isSuperCollectionVisible() const { return true; }
|
bool isSuperCollectionVisible() const { return true; }
|
||||||
|
|
||||||
|
PlaylistInterface* currentPlaylistInterface() const { return m_currentInterface; }
|
||||||
|
|
||||||
bool show( const Tomahawk::playlist_ptr& playlist );
|
bool show( const Tomahawk::playlist_ptr& playlist );
|
||||||
bool show( const Tomahawk::dynplaylist_ptr& playlist );
|
bool show( const Tomahawk::dynplaylist_ptr& playlist );
|
||||||
bool show( const Tomahawk::artist_ptr& artist );
|
bool show( const Tomahawk::artist_ptr& artist );
|
||||||
|
@@ -21,6 +21,8 @@ public:
|
|||||||
virtual QPersistentModelIndex currentItem() const { return mapFromSource( m_model->currentItem() ); }
|
virtual QPersistentModelIndex currentItem() const { return mapFromSource( m_model->currentItem() ); }
|
||||||
virtual void setCurrentItem( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
virtual void setCurrentItem( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
|
||||||
|
|
||||||
|
virtual QList<Tomahawk::query_ptr> tracks() { Q_ASSERT( FALSE ); QList<Tomahawk::query_ptr> queries; return queries; }
|
||||||
|
|
||||||
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
virtual int unfilteredTrackCount() const { return sourceModel()->rowCount( QModelIndex() ); }
|
||||||
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
virtual int trackCount() const { return rowCount( QModelIndex() ); }
|
||||||
|
|
||||||
|
@@ -17,6 +17,8 @@ public:
|
|||||||
PlaylistInterface( QObject* parent = 0 ) : m_widget( 0 ), m_object( parent ) {}
|
PlaylistInterface( QObject* parent = 0 ) : m_widget( 0 ), m_object( parent ) {}
|
||||||
virtual ~PlaylistInterface() {}
|
virtual ~PlaylistInterface() {}
|
||||||
|
|
||||||
|
virtual QList< Tomahawk::query_ptr > tracks() = 0;
|
||||||
|
|
||||||
virtual int unfilteredTrackCount() const = 0;
|
virtual int unfilteredTrackCount() const = 0;
|
||||||
virtual int trackCount() const = 0;
|
virtual int trackCount() const = 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user