PageRenderTime 121ms CodeModel.GetById 40ms app.highlight 9ms RepoModel.GetById 41ms app.codeStats 1ms

/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
 19#ifndef PLAYLIST_ITEM_H
 20#define PLAYLIST_ITEM_H
 21
 22#include "SourceTreeItem.h"
 23#include "playlist/dynamic/DynamicPlaylist.h"
 24
 25class PlaylistItem : public SourceTreeItem
 26{
 27    Q_OBJECT
 28public:
 29    PlaylistItem( SourcesModel* model, SourceTreeItem* parent, const Tomahawk::playlist_ptr& pl, int index = -1 );
 30
 31    virtual QString text() const;
 32    virtual Tomahawk::playlist_ptr playlist() const;
 33    virtual Qt::ItemFlags flags() const;
 34    virtual bool willAcceptDrag( const QMimeData* data ) const;
 35    virtual DropTypes supportedDropTypes( const QMimeData* data ) const;
 36    virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action );
 37    virtual QIcon icon() const;
 38    virtual bool setData(const QVariant& v, bool role);
 39    virtual int peerSortValue() const;
 40    virtual int IDValue() const;
 41    virtual bool isBeingPlayed() const;
 42
 43    virtual SourceTreeItem* activateCurrent();
 44
 45    // subscription management
 46    bool canSubscribe() const;
 47    bool subscribed() const;
 48    QPixmap subscribedIcon() const;
 49    void setSubscribed( bool subscribed );
 50    bool collaborative() const;
 51
 52public slots:
 53    virtual void activate();
 54    virtual void doubleClicked();
 55
 56protected:
 57    void setLoaded( bool loaded );
 58
 59private slots:
 60    void onPlaylistLoaded( Tomahawk::PlaylistRevision revision );
 61    void onPlaylistChanged();
 62    void parsedDroppedTracks( const QList<Tomahawk::query_ptr>& tracks );
 63
 64    void onUpdated();
 65private:
 66    bool createOverlay();
 67
 68    bool m_loaded, m_canSubscribe, m_showSubscribed;
 69    Tomahawk::playlist_ptr m_playlist;
 70    QIcon m_icon, m_overlaidIcon;
 71    QPixmap m_subscribedOnIcon, m_subscribedOffIcon;
 72    QList<Tomahawk::PlaylistUpdaterInterface*> m_overlaidUpdaters;
 73};
 74Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::DropTypes)
 75
 76// can be a station or an auto playlist
 77class DynamicPlaylistItem : public PlaylistItem
 78{
 79    Q_OBJECT
 80public:
 81    DynamicPlaylistItem( SourcesModel* model, SourceTreeItem* parent, const Tomahawk::dynplaylist_ptr& pl, int index = -1 );
 82    virtual ~DynamicPlaylistItem();
 83
 84    virtual QString text() const;
 85    Tomahawk::dynplaylist_ptr dynPlaylist() const;
 86    virtual bool willAcceptDrag( const QMimeData* data ) const;
 87    virtual void activate();
 88    virtual int peerSortValue() const;
 89    virtual int IDValue() const;
 90    virtual QIcon icon() const;
 91
 92    virtual SourceTreeItem* activateCurrent();
 93    virtual bool isBeingPlayed() const;
 94
 95private slots:
 96    void onDynamicPlaylistLoaded( Tomahawk::DynamicPlaylistRevision revision );
 97
 98private:
 99    void checkReparentHackNeeded( const Tomahawk::DynamicPlaylistRevision& rev );
100
101    Tomahawk::dynplaylist_ptr m_dynplaylist;
102
103    QIcon m_stationIcon;
104    QIcon m_automaticPlaylistIcon;
105};
106
107
108#endif