/src/libtomahawk/widgets/RecentPlaylistsModel.h
C Header | 69 lines | 37 code | 14 blank | 18 comment | 0 complexity | df034404d684b53e3169ceac439e56b4 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 2013, Christian Muehlhaeuser <muesli@tomahawk-player.org> 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#ifndef RECENTLPLAYLISTSMODEL_H 21#define RECENTLPLAYLISTSMODEL_H 22 23#include "Playlist.h" 24#include "Source.h" 25#include "database/DatabaseCommand_LoadAllSortedPlaylists.h" 26 27#include <QModelIndex> 28#include <QTimer> 29 30#include "DllMacro.h" 31 32class DLLEXPORT RecentPlaylistsModel : public QAbstractListModel 33{ 34 Q_OBJECT 35public: 36 explicit RecentPlaylistsModel( unsigned int maxPlaylists, QObject* parent = 0 ); 37 38 virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; 39 virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const; 40 41public slots: 42 void refresh(); 43 void onReady(); 44 45signals: 46 void emptinessChanged( bool isEmpty ); 47 48 void loadingStarted(); 49 void loadingFinished(); 50 51private slots: 52 void onRefresh(); 53 void playlistsLoaded( const QList<Tomahawk::DatabaseCommand_LoadAllSortedPlaylists::SourcePlaylistPair>& playlistGuids ); 54 55 void onPlaylistsRemoved( QList< Tomahawk::playlist_ptr > playlists ); 56 void onDynPlaylistsRemoved( QList< Tomahawk::dynplaylist_ptr > playlists ); 57 void updatePlaylist(); 58 59 void sourceOnline(); 60 void onSourceAdded( const Tomahawk::source_ptr& source ); 61 62private: 63 QList< Tomahawk::playlist_ptr > m_playlists; 64 mutable QHash< Tomahawk::playlist_ptr, QString > m_artists; 65 unsigned int m_maxPlaylists; 66 QTimer* m_timer; 67}; 68 69#endif // RECENTLPLAYLISTSMODEL_H