/src/libtomahawk/PlaylistInterface.h
C Header | 137 lines | 82 code | 34 blank | 21 comment | 0 complexity | fb4a6e6c00775e158a33d38e6542ec5b MD5 | raw file
1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === 2 * 3 * Copyright 2010-2012, Christian Muehlhaeuser <muesli@tomahawk-player.org> 4 * Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org> 5 * 6 * Tomahawk is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Tomahawk is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20#ifndef PLAYLISTINTERFACE_H 21#define PLAYLISTINTERFACE_H 22 23#include <QtCore/QModelIndex> 24 25#include "playlist/PlayableItem.h" 26#include "Typedefs.h" 27#include "DllMacro.h" 28 29namespace Tomahawk 30{ 31 32class DLLEXPORT PlaylistInterface : public QObject 33{ 34Q_OBJECT 35 36public: 37 explicit PlaylistInterface(); 38 virtual ~PlaylistInterface(); 39 40 const QString id() const { return m_id; } 41 42 virtual QList< Tomahawk::query_ptr > tracks() const = 0; 43 bool isFinished() const { return m_finished; } 44 bool hasFirstPlayableTrack() const { return m_foundFirstTrack; } 45 46 virtual int trackCount() const = 0; 47 48 virtual Tomahawk::result_ptr currentItem() const = 0; 49 virtual void setCurrentIndex( qint64 index ); 50 51 virtual bool hasNextResult() const; 52 virtual bool hasPreviousResult() const; 53 virtual Tomahawk::result_ptr nextResult() const; 54 virtual Tomahawk::result_ptr previousResult() const; 55 56 virtual qint64 siblingIndex( int itemsAway, qint64 rootIndex = -1 ) const = 0; 57 virtual qint64 siblingResultIndex( int itemsAway, qint64 rootIndex = -1 ) const; 58 virtual Tomahawk::result_ptr siblingResult( int itemsAway, qint64 rootIndex = -1 ) const; 59 virtual Tomahawk::result_ptr setSiblingResult( int itemsAway, qint64 rootIndex = -1 ); 60 61 virtual Tomahawk::result_ptr resultAt( qint64 index ) const = 0; 62 virtual Tomahawk::query_ptr queryAt( qint64 index ) const = 0; 63 virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const = 0; 64 virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const = 0; 65 66 virtual int posOfResult( const Tomahawk::result_ptr& result ) const; 67 virtual int posOfQuery( const Tomahawk::query_ptr& query ) const; 68 69 virtual PlaylistModes::RepeatMode repeatMode() const = 0; 70 virtual bool shuffled() const = 0; 71 72 virtual PlaylistModes::ViewMode viewMode() const { return PlaylistModes::Unknown; } 73 74 virtual PlaylistModes::SeekRestrictions seekRestrictions() const { return PlaylistModes::NoSeekRestrictions; } 75 virtual PlaylistModes::SkipRestrictions skipRestrictions() const { return PlaylistModes::NoSkipRestrictions; } 76 77 virtual PlaylistModes::RetryMode retryMode() const { return PlaylistModes::NoRetry; } 78 virtual quint32 retryInterval() const { return 30000; } 79 80 virtual PlaylistModes::LatchMode latchMode() const { return m_latchMode; } 81 virtual void setLatchMode( PlaylistModes::LatchMode latchMode ) { m_latchMode = latchMode; } 82 83 virtual bool setCurrentTrack( unsigned int albumpos ) { Q_UNUSED( albumpos ); return false; } 84 85 virtual void reset() {} 86 87 //TODO: Get rid of the next two functions once all playlsitinterfaces are factored out 88 // Some playlist interfaces can wrap other interfaces. When checking for top-level 89 // equality (say, to compare the currently playing interface) this might be needed 90 virtual bool hasChildInterface( const Tomahawk::playlistinterface_ptr& ) { return false; } 91 92public slots: 93 virtual void setRepeatMode( PlaylistModes::RepeatMode mode ) = 0; 94 virtual void setShuffled( bool enabled ) = 0; 95 96signals: 97 void itemCountChanged( unsigned int tracks ); 98 void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode ); 99 void shuffleModeChanged( bool enabled ); 100 void latchModeChanged( Tomahawk::PlaylistModes::LatchMode mode ); 101 102 void previousTrackAvailable( bool available ); 103 void nextTrackAvailable( bool available ); 104 105 void currentIndexChanged(); 106 void finishedLoading(); 107 void foundFirstPlayableTrack(); 108 109protected slots: 110 virtual void onItemsChanged(); 111 void startLoading(); 112 void finishLoading(); 113 void onQueryResolved(); 114 115protected: 116 virtual QList<Tomahawk::query_ptr> filterTracks( const QList<Tomahawk::query_ptr>& queries ); 117 118 PlaylistModes::LatchMode m_latchMode; 119 mutable bool m_prevAvail; 120 mutable bool m_nextAvail; 121 mutable qint64 m_currentIndex; 122 123private: 124 Q_DISABLE_COPY( PlaylistInterface ) 125 126private: 127 QString m_id; 128 QString m_filter; 129 bool m_finished; 130 bool m_foundFirstTrack; 131}; 132 133} 134 135Q_DECLARE_METATYPE( Tomahawk::playlistinterface_ptr ) 136 137#endif // PLAYLISTINTERFACE_H