PageRenderTime 163ms CodeModel.GetById 80ms app.highlight 9ms RepoModel.GetById 72ms app.codeStats 0ms

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