/src/sourcetree/items/playlistitems.h

http://github.com/tomahawk-player/tomahawk · C Header · 108 lines · 69 code · 20 blank · 19 comment · 0 complexity · d134379df5826adf907a0cfe0901db7c MD5 · raw file

  1. /*
  2. * Copyright 2010-2012, Leo Franchi <lfranchi@kde.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef PLAYLIST_ITEM_H
  19. #define PLAYLIST_ITEM_H
  20. #include "SourceTreeItem.h"
  21. #include "playlist/dynamic/DynamicPlaylist.h"
  22. class PlaylistItem : public SourceTreeItem
  23. {
  24. Q_OBJECT
  25. public:
  26. PlaylistItem( SourcesModel* model, SourceTreeItem* parent, const Tomahawk::playlist_ptr& pl, int index = -1 );
  27. virtual QString text() const;
  28. virtual Tomahawk::playlist_ptr playlist() const;
  29. virtual Qt::ItemFlags flags() const;
  30. virtual bool willAcceptDrag( const QMimeData* data ) const;
  31. virtual DropTypes supportedDropTypes( const QMimeData* data ) const;
  32. virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action );
  33. virtual QIcon icon() const;
  34. virtual bool setData(const QVariant& v, bool role);
  35. virtual int peerSortValue() const;
  36. virtual int IDValue() const;
  37. virtual bool isBeingPlayed() const;
  38. virtual SourceTreeItem* activateCurrent();
  39. // subscription management
  40. bool canSubscribe() const;
  41. bool subscribed() const;
  42. QPixmap subscribedIcon() const;
  43. void setSubscribed( bool subscribed );
  44. bool collaborative() const;
  45. public slots:
  46. virtual void activate();
  47. virtual void doubleClicked();
  48. protected:
  49. void setLoaded( bool loaded );
  50. private slots:
  51. void onPlaylistLoaded( Tomahawk::PlaylistRevision revision );
  52. void onPlaylistChanged();
  53. void parsedDroppedTracks( const QList<Tomahawk::query_ptr>& tracks );
  54. void onUpdated();
  55. private:
  56. bool createOverlay();
  57. bool m_loaded, m_canSubscribe, m_showSubscribed;
  58. Tomahawk::playlist_ptr m_playlist;
  59. QIcon m_icon, m_overlaidIcon;
  60. QPixmap m_subscribedOnIcon, m_subscribedOffIcon;
  61. QList<Tomahawk::PlaylistUpdaterInterface*> m_overlaidUpdaters;
  62. };
  63. Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::DropTypes)
  64. // can be a station or an auto playlist
  65. class DynamicPlaylistItem : public PlaylistItem
  66. {
  67. Q_OBJECT
  68. public:
  69. DynamicPlaylistItem( SourcesModel* model, SourceTreeItem* parent, const Tomahawk::dynplaylist_ptr& pl, int index = -1 );
  70. virtual ~DynamicPlaylistItem();
  71. virtual QString text() const;
  72. Tomahawk::dynplaylist_ptr dynPlaylist() const;
  73. virtual bool willAcceptDrag( const QMimeData* data ) const;
  74. virtual void activate();
  75. virtual int peerSortValue() const;
  76. virtual int IDValue() const;
  77. virtual QIcon icon() const;
  78. virtual SourceTreeItem* activateCurrent();
  79. virtual bool isBeingPlayed() const;
  80. private slots:
  81. void onDynamicPlaylistLoaded( Tomahawk::DynamicPlaylistRevision revision );
  82. private:
  83. void checkReparentHackNeeded( const Tomahawk::DynamicPlaylistRevision& rev );
  84. Tomahawk::dynplaylist_ptr m_dynplaylist;
  85. QIcon m_stationIcon;
  86. QIcon m_automaticPlaylistIcon;
  87. };
  88. #endif