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