/src/libtomahawk/playlist/PlaylistModel.h

http://github.com/tomahawk-player/tomahawk · C Header · 107 lines · 64 code · 25 blank · 18 comment · 0 complexity · d6e104e7687bea079525bfd6d3081099 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 2013, Uwe L. Korn <uwelk@xhochy.com>
  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. #pragma once
  20. #ifndef PLAYLISTMODEL_H
  21. #define PLAYLISTMODEL_H
  22. #include <QList>
  23. #include <QHash>
  24. #include "collection/Collection.h"
  25. #include "Playlist.h"
  26. #include "Query.h"
  27. #include "PlaylistInterface.h"
  28. #include "DllMacro.h"
  29. #include "PlayableModel.h"
  30. #include "Typedefs.h"
  31. class QMimeData;
  32. class QMetaData;
  33. class PlaylistModelPrivate;
  34. class DLLEXPORT PlaylistModel : public PlayableModel
  35. {
  36. Q_OBJECT
  37. typedef struct {
  38. int row;
  39. QPersistentModelIndex parent;
  40. Qt::DropAction action;
  41. } DropStorageData;
  42. public:
  43. explicit PlaylistModel( QObject* parent = 0 );
  44. virtual ~PlaylistModel();
  45. virtual QString guid() const;
  46. virtual QMimeData* mimeData( const QModelIndexList& indexes ) const;
  47. virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
  48. Tomahawk::playlist_ptr playlist() const;
  49. virtual void loadPlaylist( const Tomahawk::playlist_ptr& playlist, bool loadEntries = true );
  50. bool isTemporary() const;
  51. bool acceptPlayableQueriesOnly() const;
  52. void setAcceptPlayableQueriesOnly( bool b );
  53. public slots:
  54. virtual void clear();
  55. virtual void appendEntries( const QList< Tomahawk::plentry_ptr >& entries );
  56. virtual void insertAlbums( const QList< Tomahawk::album_ptr >& album, int row = 0 );
  57. virtual void insertAlbums( const Tomahawk::collection_ptr&, int row = 0 ) { Q_UNUSED( row ); }
  58. virtual void insertArtists( const QList< Tomahawk::artist_ptr >& artist, int row = 0 );
  59. virtual void insertQueries( const QList< Tomahawk::query_ptr >& queries, int row = 0, const QList< Tomahawk::PlaybackLog >& logs = QList< Tomahawk::PlaybackLog >(), const QModelIndex& parent = QModelIndex() );
  60. virtual void insertEntries( const QList< Tomahawk::plentry_ptr >& entries, int row = 0, const QModelIndex& parent = QModelIndex(), const QList< Tomahawk::PlaybackLog >& logs = QList< Tomahawk::PlaybackLog >() );
  61. virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
  62. signals:
  63. void repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode mode );
  64. void shuffleModeChanged( bool enabled );
  65. void playlistDeleted();
  66. protected:
  67. PlaylistModel( QObject* parent, PlaylistModelPrivate* d );
  68. bool waitForRevision( const QString& revisionguid ) const;
  69. void removeFromWaitList( const QString& revisionguid );
  70. QList<Tomahawk::plentry_ptr> playlistEntries() const;
  71. private slots:
  72. void onRevisionLoaded( Tomahawk::PlaylistRevision revision );
  73. void parsedDroppedTracks( QList<Tomahawk::query_ptr> );
  74. void trackResolved( bool );
  75. void onPlaylistChanged();
  76. private:
  77. void beginPlaylistChanges();
  78. void endPlaylistChanges();
  79. void init();
  80. Q_DECLARE_PRIVATE( PlaylistModel )
  81. };
  82. #endif // PLAYLISTMODEL_H