mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
Separate out Playlist's interface. PlaylistPlaylistInterface isn't a great name, someone come up with something better.
This commit is contained in:
@@ -286,6 +286,7 @@ set( libSources
|
|||||||
albumplaylistinterface.cpp
|
albumplaylistinterface.cpp
|
||||||
collection.cpp
|
collection.cpp
|
||||||
playlist.cpp
|
playlist.cpp
|
||||||
|
playlistplaylistinterface.cpp
|
||||||
resolver.cpp
|
resolver.cpp
|
||||||
ExternalResolver.cpp
|
ExternalResolver.cpp
|
||||||
query.cpp
|
query.cpp
|
||||||
@@ -419,6 +420,7 @@ set( libHeaders
|
|||||||
album.h
|
album.h
|
||||||
albumplaylistinterface.h
|
albumplaylistinterface.h
|
||||||
playlist.h
|
playlist.h
|
||||||
|
playlistplaylistinterface.h
|
||||||
|
|
||||||
EchonestCatalogSynchronizer.h
|
EchonestCatalogSynchronizer.h
|
||||||
|
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
AlbumPlaylistInterface::AlbumPlaylistInterface() {}
|
AlbumPlaylistInterface::AlbumPlaylistInterface() {}
|
||||||
AlbumPlaylistInterface::~AlbumPlaylistInterface() {}
|
|
||||||
|
|
||||||
AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album *album )
|
AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album *album )
|
||||||
: Tomahawk::PlaylistInterface( this )
|
: Tomahawk::PlaylistInterface( this )
|
||||||
@@ -40,6 +39,12 @@ AlbumPlaylistInterface::AlbumPlaylistInterface( Tomahawk::Album *album )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AlbumPlaylistInterface::~AlbumPlaylistInterface()
|
||||||
|
{
|
||||||
|
m_album.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::result_ptr
|
Tomahawk::result_ptr
|
||||||
AlbumPlaylistInterface::siblingItem( int itemsAway )
|
AlbumPlaylistInterface::siblingItem( int itemsAway )
|
||||||
{
|
{
|
||||||
@@ -100,4 +105,4 @@ void
|
|||||||
AlbumPlaylistInterface::addQueries( const QList< query_ptr >& tracks )
|
AlbumPlaylistInterface::addQueries( const QList< query_ptr >& tracks )
|
||||||
{
|
{
|
||||||
m_queries << tracks;
|
m_queries << tracks;
|
||||||
}
|
}
|
||||||
|
@@ -59,7 +59,9 @@ public:
|
|||||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||||
|
|
||||||
virtual void addQueries( const QList<Tomahawk::query_ptr>& tracks );
|
virtual void addQueries( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
|
virtual void findMoreIfaces() {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
|
@@ -40,6 +40,7 @@ ArtistPlaylistInterface::ArtistPlaylistInterface( Tomahawk::Artist *artist )
|
|||||||
|
|
||||||
ArtistPlaylistInterface::~ArtistPlaylistInterface()
|
ArtistPlaylistInterface::~ArtistPlaylistInterface()
|
||||||
{
|
{
|
||||||
|
m_artist.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ namespace Tomahawk
|
|||||||
{
|
{
|
||||||
|
|
||||||
class Artist;
|
class Artist;
|
||||||
|
|
||||||
class DLLEXPORT ArtistPlaylistInterface : public QObject, public Tomahawk::PlaylistInterface
|
class DLLEXPORT ArtistPlaylistInterface : public QObject, public Tomahawk::PlaylistInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -58,7 +58,9 @@ public:
|
|||||||
virtual void setFilter( const QString& /*pattern*/ ) {}
|
virtual void setFilter( const QString& /*pattern*/ ) {}
|
||||||
|
|
||||||
virtual void addQueries( const QList<Tomahawk::query_ptr>& tracks );
|
virtual void addQueries( const QList<Tomahawk::query_ptr>& tracks );
|
||||||
|
|
||||||
|
virtual void findMoreIfaces() {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
|
|
||||||
#include <QDomDocument>
|
#include <QtXml/QDomDocument>
|
||||||
#include <QDomElement>
|
#include <QtXml/QDomElement>
|
||||||
|
|
||||||
#include "database/database.h"
|
#include "database/database.h"
|
||||||
#include "database/databasecommand_loadplaylistentries.h"
|
#include "database/databasecommand_loadplaylistentries.h"
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "pipeline.h"
|
#include "pipeline.h"
|
||||||
#include "source.h"
|
#include "source.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
|
#include "playlistplaylistinterface.h"
|
||||||
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include "PlaylistUpdaterInterface.h"
|
#include "PlaylistUpdaterInterface.h"
|
||||||
@@ -562,17 +563,6 @@ Playlist::newEntries( const QList< plentry_ptr >& entries )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<Tomahawk::query_ptr>
|
|
||||||
Playlist::tracks()
|
|
||||||
{
|
|
||||||
QList<Tomahawk::query_ptr> queries;
|
|
||||||
foreach( const plentry_ptr& p, m_entries )
|
|
||||||
queries << p->query();
|
|
||||||
|
|
||||||
return queries;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Playlist::setBusy( bool b )
|
Playlist::setBusy( bool b )
|
||||||
{
|
{
|
||||||
@@ -602,3 +592,15 @@ Playlist::checkRevisionQueue()
|
|||||||
createNewRevision( item.newRev, item.oldRev, item.entries );
|
createNewRevision( item.newRev, item.oldRev, item.entries );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::playlistinterface_ptr
|
||||||
|
Playlist::getPlaylistInterface()
|
||||||
|
{
|
||||||
|
if ( m_playlistInterface.isNull() )
|
||||||
|
{
|
||||||
|
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::PlaylistPlaylistInterface( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_playlistInterface;
|
||||||
|
}
|
||||||
|
@@ -114,7 +114,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT Playlist : public QObject, public Tomahawk::PlaylistInterface
|
class DLLEXPORT Playlist : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY( QString guid READ guid WRITE setGuid )
|
Q_PROPERTY( QString guid READ guid WRITE setGuid )
|
||||||
@@ -180,28 +180,13 @@ public:
|
|||||||
void setCreatedOn( uint createdOn ) { m_createdOn = createdOn; }
|
void setCreatedOn( uint createdOn ) { m_createdOn = createdOn; }
|
||||||
// </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 bool hasNextItem() { return false; }
|
|
||||||
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
|
||||||
|
|
||||||
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*/ ) {}
|
|
||||||
|
|
||||||
QList<plentry_ptr> entriesFromQueries( const QList<Tomahawk::query_ptr>& queries, bool clearFirst = false );
|
QList<plentry_ptr> entriesFromQueries( const QList<Tomahawk::query_ptr>& queries, bool clearFirst = false );
|
||||||
void setUpdater( PlaylistUpdaterInterface* interface ) { m_updater = interface; }
|
void setUpdater( PlaylistUpdaterInterface* interface ) { m_updater = interface; }
|
||||||
PlaylistUpdaterInterface* updater() const { return m_updater; }
|
PlaylistUpdaterInterface* updater() const { return m_updater; }
|
||||||
|
|
||||||
|
Tomahawk::playlistinterface_ptr getPlaylistInterface();
|
||||||
|
|
||||||
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 );
|
||||||
@@ -221,13 +206,6 @@ signals:
|
|||||||
/// was deleted, eh?
|
/// was deleted, eh?
|
||||||
void deleted( const Tomahawk::playlist_ptr& pl );
|
void deleted( const Tomahawk::playlist_ptr& pl );
|
||||||
|
|
||||||
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
|
||||||
void shuffleModeChanged( bool enabled );
|
|
||||||
|
|
||||||
void trackCountChanged( unsigned int tracks );
|
|
||||||
void sourceTrackCountChanged( unsigned int tracks );
|
|
||||||
|
|
||||||
void nextTrackReady();
|
|
||||||
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:
|
||||||
@@ -291,8 +269,6 @@ private:
|
|||||||
unsigned int m_createdOn;
|
unsigned int m_createdOn;
|
||||||
bool m_shared;
|
bool m_shared;
|
||||||
|
|
||||||
result_ptr m_currentItem;
|
|
||||||
|
|
||||||
QList< plentry_ptr > m_initEntries;
|
QList< plentry_ptr > m_initEntries;
|
||||||
QList< plentry_ptr > m_entries;
|
QList< plentry_ptr > m_entries;
|
||||||
|
|
||||||
@@ -303,9 +279,11 @@ private:
|
|||||||
bool m_locallyChanged;
|
bool m_locallyChanged;
|
||||||
bool m_deleted;
|
bool m_deleted;
|
||||||
bool m_busy;
|
bool m_busy;
|
||||||
|
|
||||||
|
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QSharedPointer< Tomahawk::Playlist > )
|
Q_DECLARE_METATYPE( QSharedPointer< Tomahawk::Playlist > )
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//virtual void findMoreIfaces() = 0;
|
//virtual void findMoreIfaces() = 0;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setRepeatMode( RepeatMode mode ) = 0;
|
virtual void setRepeatMode( RepeatMode mode ) = 0;
|
||||||
virtual void setShuffled( bool enabled ) = 0;
|
virtual void setShuffled( bool enabled ) = 0;
|
||||||
|
64
src/libtomahawk/playlistplaylistinterface.cpp
Normal file
64
src/libtomahawk/playlistplaylistinterface.cpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "playlistplaylistinterface.h"
|
||||||
|
|
||||||
|
#include "playlist.h"
|
||||||
|
#include "sourcelist.h"
|
||||||
|
|
||||||
|
#include "utils/logger.h"
|
||||||
|
|
||||||
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
|
PlaylistPlaylistInterface::PlaylistPlaylistInterface( Tomahawk::Playlist* playlist )
|
||||||
|
: QObject()
|
||||||
|
, m_playlist( playlist )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlaylistPlaylistInterface::~PlaylistPlaylistInterface()
|
||||||
|
{
|
||||||
|
m_playlist.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
PlaylistPlaylistInterface::unfilteredTrackCount() const
|
||||||
|
{
|
||||||
|
return ( m_playlist.isNull() ? 0 : m_playlist.data()->entries().count() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
PlaylistPlaylistInterface::trackCount() const
|
||||||
|
{
|
||||||
|
return ( m_playlist.isNull() ? 0 : m_playlist.data()->entries().count() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList< Tomahawk::query_ptr >
|
||||||
|
PlaylistPlaylistInterface::tracks()
|
||||||
|
{
|
||||||
|
QList<Tomahawk::query_ptr> queries;
|
||||||
|
foreach( const plentry_ptr& p, ( m_playlist.isNull() ? QList< Tomahawk::plentry_ptr >() : m_playlist.data()->entries() ) )
|
||||||
|
queries << p->query();
|
||||||
|
|
||||||
|
return queries;
|
||||||
|
}
|
85
src/libtomahawk/playlistplaylistinterface.h
Normal file
85
src/libtomahawk/playlistplaylistinterface.h
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PLAYLISTPLAYLISTINTERFACE_H
|
||||||
|
#define PLAYLISTPLAYLISTINTERFACE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QList>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "typedefs.h"
|
||||||
|
#include "result.h"
|
||||||
|
#include "playlistinterface.h"
|
||||||
|
#include "query.h"
|
||||||
|
|
||||||
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class DLLEXPORT PlaylistPlaylistInterface : public QObject, public Tomahawk::PlaylistInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PlaylistPlaylistInterface( Tomahawk::Playlist* playlist );
|
||||||
|
virtual ~PlaylistPlaylistInterface();
|
||||||
|
|
||||||
|
virtual QList<Tomahawk::query_ptr> tracks();
|
||||||
|
|
||||||
|
virtual int unfilteredTrackCount() const;
|
||||||
|
virtual int trackCount() const;
|
||||||
|
|
||||||
|
virtual bool hasNextItem() { return false; }
|
||||||
|
virtual Tomahawk::result_ptr currentItem() const { return m_currentItem; }
|
||||||
|
|
||||||
|
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 setFilter( const QString& /*pattern*/ ) {}
|
||||||
|
|
||||||
|
virtual void findMoreIfaces() {}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void repeatModeChanged( PlaylistInterface::RepeatMode mode );
|
||||||
|
void shuffleModeChanged( bool enabled );
|
||||||
|
|
||||||
|
void trackCountChanged( unsigned int tracks );
|
||||||
|
void sourceTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
|
void nextTrackReady();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||||
|
virtual void setShuffled( bool ) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PlaylistPlaylistInterface();
|
||||||
|
Q_DISABLE_COPY( PlaylistPlaylistInterface )
|
||||||
|
|
||||||
|
QWeakPointer< Tomahawk::Playlist > m_playlist;
|
||||||
|
|
||||||
|
result_ptr m_currentItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PLAYLISTPLAYLISTINTERFACE_H
|
@@ -37,7 +37,9 @@ SourcePlaylistInterface::SourcePlaylistInterface( Tomahawk::source_ptr& source )
|
|||||||
|
|
||||||
|
|
||||||
SourcePlaylistInterface::~SourcePlaylistInterface()
|
SourcePlaylistInterface::~SourcePlaylistInterface()
|
||||||
{}
|
{
|
||||||
|
m_source.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::result_ptr
|
Tomahawk::result_ptr
|
||||||
|
@@ -61,6 +61,8 @@ public:
|
|||||||
|
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
|
virtual void findMoreIfaces() {}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
virtual void setRepeatMode( PlaylistInterface::RepeatMode ) {}
|
||||||
virtual void setShuffled( bool ) {}
|
virtual void setShuffled( bool ) {}
|
||||||
|
Reference in New Issue
Block a user