PageRenderTime 72ms CodeModel.GetById 30ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/src/libtomahawk/widgets/RecentlyPlayedPlaylistsModel.h

http://github.com/tomahawk-player/tomahawk
C Header | 69 lines | 36 code | 14 blank | 19 comment | 0 complexity | 05d92071e79dcf37e544d90723ff0f80 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2011, Leo Franchi <lfranchi@kde.org>
 4 *   Copyright 2011, Jeff Mitchell <jeff@tomahawk-player.org>
 5 *   Copyright 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 6 *
 7 *   Tomahawk is free software: you can redistribute it and/or modify
 8 *   it under the terms of the GNU General Public License as published by
 9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (at your option) any later version.
11 *
12 *   Tomahawk is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef RECENTLYPLAYEDPLAYLISTSMODEL_H
22#define RECENTLYPLAYEDPLAYLISTSMODEL_H
23
24#include <QModelIndex>
25
26#include "Playlist.h"
27#include "Source.h"
28
29class RecentlyPlayedPlaylistsModel : public QAbstractListModel
30{
31    Q_OBJECT
32public:
33    enum ItemRoles
34    { ArtistRole = Qt::UserRole, TrackCountRole, PlaylistRole, PlaylistTypeRole, DynamicPlaylistRole };
35    enum PlaylistTypes
36    { StaticPlaylist, AutoPlaylist, Station };
37
38    explicit RecentlyPlayedPlaylistsModel( QObject* parent = 0 );
39
40    void setMaxPlaylists( unsigned int max ) { m_maxPlaylists = max; }
41
42    virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
43    virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
44
45signals:
46    void emptinessChanged( bool isEmpty );
47
48public slots:
49    void sourceOnline();
50
51private slots:
52    void playlistChanged( Tomahawk::playlistinterface_ptr );
53    void onSourceAdded( const Tomahawk::source_ptr& source );
54    void onPlaylistsRemoved( QList<Tomahawk::playlist_ptr> );
55    void loadFromSettings();
56
57    void plAdded( const QString& plguid, int sourceId );
58    void playlistRevisionLoaded();
59
60private:
61    QList< Tomahawk::playlist_ptr > m_recplaylists;
62    QHash< QString, Tomahawk::playlist_ptr > m_cached;
63    mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
64
65    unsigned int m_maxPlaylists;
66    bool m_waitingForSome;
67};
68
69#endif // RECENTLYPLAYEDPLAYLISTSMODEL_H