/src/libtomahawk/widgets/RecentPlaylistsModel.h

http://github.com/tomahawk-player/tomahawk · 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. #ifndef RECENTLPLAYLISTSMODEL_H
  20. #define RECENTLPLAYLISTSMODEL_H
  21. #include "Playlist.h"
  22. #include "Source.h"
  23. #include "database/DatabaseCommand_LoadAllSortedPlaylists.h"
  24. #include <QModelIndex>
  25. #include <QTimer>
  26. #include "DllMacro.h"
  27. class DLLEXPORT RecentPlaylistsModel : public QAbstractListModel
  28. {
  29. Q_OBJECT
  30. public:
  31. explicit RecentPlaylistsModel( unsigned int maxPlaylists, QObject* parent = 0 );
  32. virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
  33. virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
  34. public slots:
  35. void refresh();
  36. void onReady();
  37. signals:
  38. void emptinessChanged( bool isEmpty );
  39. void loadingStarted();
  40. void loadingFinished();
  41. private slots:
  42. void onRefresh();
  43. void playlistsLoaded( const QList<Tomahawk::DatabaseCommand_LoadAllSortedPlaylists::SourcePlaylistPair>& playlistGuids );
  44. void onPlaylistsRemoved( QList< Tomahawk::playlist_ptr > playlists );
  45. void onDynPlaylistsRemoved( QList< Tomahawk::dynplaylist_ptr > playlists );
  46. void updatePlaylist();
  47. void sourceOnline();
  48. void onSourceAdded( const Tomahawk::source_ptr& source );
  49. private:
  50. QList< Tomahawk::playlist_ptr > m_playlists;
  51. mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
  52. unsigned int m_maxPlaylists;
  53. QTimer* m_timer;
  54. };
  55. #endif // RECENTLPLAYLISTSMODEL_H