/src/libtomahawk/playlist/TreeModel.h

http://github.com/tomahawk-player/tomahawk · C Header · 93 lines · 51 code · 22 blank · 20 comment · 0 complexity · b0004f49c0bb0de2fad980c1d65e9ded 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 2010-2011, Jeff Mitchell <jeff@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 TREEMODEL_H
  20. #define TREEMODEL_H
  21. #include <QAbstractItemModel>
  22. #include <QPixmap>
  23. #include "Artist.h"
  24. #include "Album.h"
  25. #include "Query.h"
  26. #include "Result.h"
  27. #include "PlayableModel.h"
  28. #include "PlaylistInterface.h"
  29. #include "database/DatabaseCommand_AllArtists.h"
  30. #include "DllMacro.h"
  31. #include "Typedefs.h"
  32. class QMetaData;
  33. class PlayableItem;
  34. class DLLEXPORT TreeModel : public PlayableModel
  35. {
  36. Q_OBJECT
  37. public:
  38. explicit TreeModel( QObject* parent = 0 );
  39. virtual ~TreeModel();
  40. virtual Tomahawk::ModelMode mode() const { return m_mode; }
  41. virtual void setMode( Tomahawk::ModelMode mode );
  42. Tomahawk::collection_ptr collection() const;
  43. void addCollection( const Tomahawk::collection_ptr& collection );
  44. //TODO: Unused, but will be useful for supporting filtered queries. - Teo 1/2013
  45. //void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllArtists::SortOrder order );
  46. void addArtists( const Tomahawk::artist_ptr& artist );
  47. void fetchAlbums( const Tomahawk::artist_ptr& artist );
  48. void getCover( const QModelIndex& index );
  49. virtual PlayableItem* itemFromResult( const Tomahawk::result_ptr& result ) const;
  50. virtual QModelIndex indexFromArtist( const Tomahawk::artist_ptr& artist ) const;
  51. virtual QModelIndex indexFromAlbum( const Tomahawk::album_ptr& album ) const;
  52. virtual QModelIndex indexFromResult( const Tomahawk::result_ptr& result ) const;
  53. virtual QModelIndex indexFromQuery( const Tomahawk::query_ptr& query ) const;
  54. public slots:
  55. void addAlbums( const QModelIndex& parent, const QList<Tomahawk::album_ptr>& albums );
  56. void addTracks( const Tomahawk::album_ptr& album, const QModelIndex& parent );
  57. signals:
  58. void modeChanged( Tomahawk::ModelMode mode );
  59. protected:
  60. bool canFetchMore( const QModelIndex& parent ) const;
  61. void fetchMore( const QModelIndex& parent );
  62. private slots:
  63. void onArtistsAdded( const QList<Tomahawk::artist_ptr>& artists );
  64. void onAlbumsFound( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
  65. void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModelIndex& index );
  66. private:
  67. Tomahawk::ModelMode m_mode;
  68. Tomahawk::collection_ptr m_collection;
  69. QList<Tomahawk::artist_ptr> m_artistsFilter;
  70. };
  71. #endif // ALBUMMODEL_H