mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-16 02:54:33 +02:00
* Cleaned up PlaylistInterface.
This commit is contained in:
@@ -41,16 +41,41 @@ PlaylistInterface::~PlaylistInterface()
|
|||||||
|
|
||||||
|
|
||||||
result_ptr
|
result_ptr
|
||||||
PlaylistInterface::previousItem()
|
PlaylistInterface::previousResult() const
|
||||||
{
|
{
|
||||||
return siblingItem( -1 );
|
return siblingResult( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
result_ptr
|
result_ptr
|
||||||
PlaylistInterface::nextItem()
|
PlaylistInterface::nextResult() const
|
||||||
{
|
{
|
||||||
return siblingItem( 1 );
|
return siblingResult( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::result_ptr
|
||||||
|
PlaylistInterface::siblingResult( int itemsAway ) const
|
||||||
|
{
|
||||||
|
qint64 idx = siblingIndex( itemsAway );
|
||||||
|
|
||||||
|
while ( idx >= 0 )
|
||||||
|
{
|
||||||
|
Tomahawk::query_ptr query = queryAt( idx );
|
||||||
|
if ( query->numResults() )
|
||||||
|
{
|
||||||
|
return query->results().first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( itemsAway < 0 )
|
||||||
|
itemsAway--;
|
||||||
|
else
|
||||||
|
itemsAway++;
|
||||||
|
|
||||||
|
idx = siblingIndex( itemsAway );
|
||||||
|
}
|
||||||
|
|
||||||
|
return Tomahawk::result_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -89,3 +114,17 @@ PlaylistInterface::filterTracks( const QList<Tomahawk::query_ptr>& queries )
|
|||||||
Pipeline::instance()->resolve( result );
|
Pipeline::instance()->resolve( result );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PlaylistInterface::hasNextResult() const
|
||||||
|
{
|
||||||
|
return !( siblingResult( 1 ).isNull() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PlaylistInterface::hasPreviousResult() const
|
||||||
|
{
|
||||||
|
return !( siblingResult( -1 ).isNull() );
|
||||||
|
}
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <QtCore/QModelIndex>
|
#include <QtCore/QModelIndex>
|
||||||
|
|
||||||
|
#include "playlist/PlayableItem.h"
|
||||||
#include "Typedefs.h"
|
#include "Typedefs.h"
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
@@ -45,20 +46,22 @@ public:
|
|||||||
virtual int trackCount() const = 0;
|
virtual int trackCount() const = 0;
|
||||||
|
|
||||||
virtual Tomahawk::result_ptr currentItem() const = 0;
|
virtual Tomahawk::result_ptr currentItem() const = 0;
|
||||||
|
virtual void setCurrentIndex( qint64 index ) = 0;
|
||||||
|
|
||||||
virtual bool hasNextItem() { return true; }
|
virtual bool hasNextResult() const;
|
||||||
virtual bool hasPreviousItem() { return true; }
|
virtual bool hasPreviousResult() const;
|
||||||
virtual Tomahawk::result_ptr nextItem();
|
virtual Tomahawk::result_ptr nextResult() const;
|
||||||
virtual Tomahawk::result_ptr previousItem();
|
virtual Tomahawk::result_ptr previousResult() const;
|
||||||
|
|
||||||
virtual Tomahawk::result_ptr siblingItem( int itemsAway, bool readOnly = false ) = 0;
|
virtual qint64 siblingIndex( int itemsAway ) const = 0;
|
||||||
|
virtual Tomahawk::result_ptr siblingResult( int itemsAway ) const;
|
||||||
|
|
||||||
virtual Tomahawk::query_ptr itemAt( unsigned int position ) const = 0;
|
virtual Tomahawk::result_ptr resultAt( qint64 index ) const = 0;
|
||||||
virtual int indexOfResult( const Tomahawk::result_ptr& result ) const = 0;
|
virtual Tomahawk::query_ptr queryAt( qint64 index ) const = 0;
|
||||||
virtual int indexOfQuery( const Tomahawk::query_ptr& query ) const = 0;
|
virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const = 0;
|
||||||
|
virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const = 0;
|
||||||
|
|
||||||
virtual PlaylistModes::RepeatMode repeatMode() const = 0;
|
virtual PlaylistModes::RepeatMode repeatMode() const = 0;
|
||||||
|
|
||||||
virtual bool shuffled() const = 0;
|
virtual bool shuffled() const = 0;
|
||||||
|
|
||||||
virtual PlaylistModes::ViewMode viewMode() const { return PlaylistModes::Unknown; }
|
virtual PlaylistModes::ViewMode viewMode() const { return PlaylistModes::Unknown; }
|
||||||
@@ -90,7 +93,9 @@ signals:
|
|||||||
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
|
||||||
void shuffleModeChanged( bool enabled );
|
void shuffleModeChanged( bool enabled );
|
||||||
void latchModeChanged( Tomahawk::PlaylistModes::LatchMode mode );
|
void latchModeChanged( Tomahawk::PlaylistModes::LatchMode mode );
|
||||||
void nextTrackReady();
|
|
||||||
|
void previousTrackAvailable();
|
||||||
|
void nextTrackAvailable();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QList<Tomahawk::query_ptr> filterTracks( const QList<Tomahawk::query_ptr>& queries );
|
virtual QList<Tomahawk::query_ptr> filterTracks( const QList<Tomahawk::query_ptr>& queries );
|
||||||
|
Reference in New Issue
Block a user