/src/libtomahawk/SourcePlaylistInterface.h

http://github.com/tomahawk-player/tomahawk · C Header · 89 lines · 50 code · 21 blank · 18 comment · 0 complexity · c294ba38d18e1f35bb29cfb30894ec60 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, 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. #ifndef TOMAHAWKSOURCEPLAYLISTINTERFACE_H
  20. #define TOMAHAWKSOURCEPLAYLISTINTERFACE_H
  21. #include <QObject>
  22. #include <QPointer>
  23. #include "Typedefs.h"
  24. #include "PlaylistInterface.h"
  25. #include "DllMacro.h"
  26. namespace Tomahawk
  27. {
  28. class DLLEXPORT SourcePlaylistInterface : public Tomahawk::PlaylistInterface
  29. {
  30. Q_OBJECT
  31. public:
  32. SourcePlaylistInterface( Tomahawk::Source* source, Tomahawk::PlaylistModes::LatchMode latchMode = PlaylistModes::StayOnSong );
  33. virtual ~SourcePlaylistInterface();
  34. QList<Tomahawk::query_ptr> tracks() const;
  35. virtual int trackCount() const { return 1; }
  36. virtual void setCurrentIndex( qint64 index );
  37. virtual Tomahawk::result_ptr resultAt( qint64 index ) const;
  38. virtual Tomahawk::query_ptr queryAt( qint64 index ) const;
  39. virtual qint64 indexOfResult( const Tomahawk::result_ptr& result ) const;
  40. virtual qint64 indexOfQuery( const Tomahawk::query_ptr& query ) const { Q_UNUSED( query ); Q_ASSERT( false ); return -1; }
  41. virtual qint64 siblingIndex( int itemsAway, qint64 rootIndex = -1 ) const;
  42. virtual bool sourceValid() const;
  43. virtual bool hasNextResult() const;
  44. virtual Tomahawk::result_ptr nextResult() const;
  45. virtual Tomahawk::result_ptr currentItem() const;
  46. virtual PlaylistModes::RepeatMode repeatMode() const { return PlaylistModes::NoRepeat; }
  47. virtual PlaylistModes::SeekRestrictions seekRestrictions() const { return PlaylistModes::NoSeek; }
  48. virtual PlaylistModes::SkipRestrictions skipRestrictions() const { return PlaylistModes::NoSkipBackwards; }
  49. virtual PlaylistModes::RetryMode retryMode() const { return PlaylistModes::Retry; }
  50. virtual quint32 retryInterval() const { return 5000; }
  51. virtual void setLatchMode( PlaylistModes::LatchMode latchMode ) { m_latchMode = latchMode; emit latchModeChanged( latchMode ); }
  52. virtual bool shuffled() const { return false; }
  53. virtual QPointer< Tomahawk::Source > source() const;
  54. virtual void reset();
  55. public slots:
  56. virtual void setRepeatMode( PlaylistModes::RepeatMode ) {}
  57. virtual void setShuffled( bool ) {}
  58. virtual void audioPaused() { setLatchMode( PlaylistModes::StayOnSong ); }
  59. private slots:
  60. void onSourcePlaybackStarted( const Tomahawk::track_ptr& track );
  61. void resolvingFinished( bool hasResults );
  62. private:
  63. QPointer< Tomahawk::Source > m_source;
  64. mutable Tomahawk::result_ptr m_currentItem;
  65. mutable bool m_gotNextItem;
  66. };
  67. }; // ns
  68. #endif