/src/libtomahawk/playlist/dynamic/DynamicModel.h

http://github.com/tomahawk-player/tomahawk · C Header · 107 lines · 56 code · 27 blank · 24 comment · 0 complexity · 381ec1081542293b26af8bbb3a0a6e1f MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  4. * Copyright 2010-2011, 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 DYNAMIC_MODEL_H
  20. #define DYNAMIC_MODEL_H
  21. #include "playlist/PlaylistModel.h"
  22. #include "Query.h"
  23. namespace Tomahawk
  24. {
  25. class StationModelItem;
  26. /**
  27. * Extends PlaylistModel with support for handling stations
  28. */
  29. class DynamicModel : public PlaylistModel
  30. {
  31. Q_OBJECT
  32. public:
  33. DynamicModel( QObject* parent = 0 );
  34. virtual ~DynamicModel();
  35. void startOnDemand();
  36. void stopOnDemand( bool stopPlaying = true );
  37. void changeStation();
  38. virtual QString description() const;
  39. void loadPlaylist( const dynplaylist_ptr& playlist, bool loadEntries = true );
  40. virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
  41. bool searchingForNext() const { return m_searchingForNext; }
  42. void setFilterUnresolvable( bool filter ) { m_filterUnresolvable = filter; }
  43. bool filterUnresolvable() const { return m_filterUnresolvable; }
  44. // a batchof static tracks wre generated
  45. void tracksGenerated( const QList< query_ptr > entries, int limitResolvedTo = -1 );
  46. using PlaylistModel::loadPlaylist;
  47. bool ignoreRevision( const QString& revisionguid ) const { return waitForRevision( revisionguid ); }
  48. void removeRevisionFromIgnore( const QString& revisionguid ) { removeFromWaitList( revisionguid ); }
  49. signals:
  50. void collapseFromTo( int startRow, int num );
  51. void checkForOverflow();
  52. void trackGenerationFailure( const QString& msg );
  53. void tracksAdded();
  54. private slots:
  55. void newTrackGenerated( const Tomahawk::query_ptr& query );
  56. void trackResolveFinished( bool );
  57. void newTrackLoading();
  58. void filteringTrackResolved( bool successful );
  59. private:
  60. void filterUnresolved( const QList< query_ptr >& entries );
  61. void addToPlaylist( const QList< query_ptr >& entries, bool clearFirst );
  62. dynplaylist_ptr m_playlist;
  63. // for filtering unresolvable
  64. int m_limitResolvedTo;
  65. QList< query_ptr > m_toResolveList;
  66. QList< query_ptr > m_resolvedList;
  67. // for managing upcoming queue
  68. QList< Query* > m_waitingFor;
  69. QList< QPair< QString, QString > > m_deduper;
  70. bool m_onDemandRunning;
  71. bool m_changeOnNext;
  72. bool m_searchingForNext;
  73. bool m_firstTrackGenerated;
  74. bool m_filterUnresolvable;
  75. bool m_startingAfterFailed;
  76. int m_currentAttempts;
  77. int m_lastResolvedRow;
  78. };
  79. };
  80. #endif