/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. #ifndef RECENTLYPLAYEDPLAYLISTSMODEL_H
  21. #define RECENTLYPLAYEDPLAYLISTSMODEL_H
  22. #include <QModelIndex>
  23. #include "Playlist.h"
  24. #include "Source.h"
  25. class RecentlyPlayedPlaylistsModel : public QAbstractListModel
  26. {
  27. Q_OBJECT
  28. public:
  29. enum ItemRoles
  30. { ArtistRole = Qt::UserRole, TrackCountRole, PlaylistRole, PlaylistTypeRole, DynamicPlaylistRole };
  31. enum PlaylistTypes
  32. { StaticPlaylist, AutoPlaylist, Station };
  33. explicit RecentlyPlayedPlaylistsModel( QObject* parent = 0 );
  34. void setMaxPlaylists( unsigned int max ) { m_maxPlaylists = max; }
  35. virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
  36. virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
  37. signals:
  38. void emptinessChanged( bool isEmpty );
  39. public slots:
  40. void sourceOnline();
  41. private slots:
  42. void playlistChanged( Tomahawk::playlistinterface_ptr );
  43. void onSourceAdded( const Tomahawk::source_ptr& source );
  44. void onPlaylistsRemoved( QList<Tomahawk::playlist_ptr> );
  45. void loadFromSettings();
  46. void plAdded( const QString& plguid, int sourceId );
  47. void playlistRevisionLoaded();
  48. private:
  49. QList< Tomahawk::playlist_ptr > m_recplaylists;
  50. QHash< QString, Tomahawk::playlist_ptr > m_cached;
  51. mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
  52. unsigned int m_maxPlaylists;
  53. bool m_waitingForSome;
  54. };
  55. #endif // RECENTLYPLAYEDPLAYLISTSMODEL_H