/src/libtomahawk/playlist/collectionflatmodel.h

http://github.com/tomahawk-player/tomahawk · C Header · 73 lines · 39 code · 16 blank · 18 comment · 0 complexity · 3268a391d0a80ae51498bc03f6341f45 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. *
  5. * Tomahawk is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Tomahawk is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef COLLECTIONFLATMODEL_H
  19. #define COLLECTIONFLATMODEL_H
  20. #include <QAbstractItemModel>
  21. #include <QList>
  22. #include <QHash>
  23. #include "typedefs.h"
  24. #include "trackmodel.h"
  25. #include "query.h"
  26. #include "source.h"
  27. #include "playlistinterface.h"
  28. #include "database/databasecommand_alltracks.h"
  29. #include "dllmacro.h"
  30. class QMetaData;
  31. class DLLEXPORT CollectionFlatModel : public TrackModel
  32. {
  33. Q_OBJECT
  34. public:
  35. explicit CollectionFlatModel( QObject* parent = 0 );
  36. ~CollectionFlatModel();
  37. virtual int trackCount() const { return rowCount( QModelIndex() ) + m_tracksToAdd.count(); }
  38. void addCollections( const QList< Tomahawk::collection_ptr >& collections );
  39. void addCollection( const Tomahawk::collection_ptr& collection, bool sendNotifications = true );
  40. void addFilteredCollection( const Tomahawk::collection_ptr& collection, unsigned int amount, DatabaseCommand_AllTracks::SortOrder order );
  41. signals:
  42. void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
  43. void shuffleModeChanged( bool enabled );
  44. void loadingStarted();
  45. void loadingFinished();
  46. void trackCountChanged( unsigned int tracks );
  47. private slots:
  48. void onDataChanged();
  49. void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
  50. void onTracksRemoved( const QList<Tomahawk::query_ptr>& tracks );
  51. private:
  52. QMap< Tomahawk::collection_ptr, QPair< int, int > > m_collectionRows;
  53. QList<Tomahawk::query_ptr> m_tracksToAdd;
  54. // just to keep track of what we are waiting to be loaded
  55. QList<Tomahawk::Collection*> m_loadingCollections;
  56. };
  57. #endif // COLLECTIONFLATMODEL_H