/src/libtomahawk/database/DatabaseCommand_AllTracks.h

http://github.com/tomahawk-player/tomahawk · C Header · 93 lines · 58 code · 18 blank · 17 comment · 0 complexity · 3f3b57c2f2dc30e039e52ead428715cf 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 DATABASECOMMAND_ALLTRACKS_H
  19. #define DATABASECOMMAND_ALLTRACKS_H
  20. #include <QObject>
  21. #include <QVariantMap>
  22. #include "DatabaseCommand.h"
  23. #include "Database.h"
  24. #include "DatabaseCollection.h"
  25. #include "collection/Collection.h"
  26. #include "collection/TracksRequest.h"
  27. #include "Typedefs.h"
  28. #include "Query.h"
  29. #include "Artist.h"
  30. #include "Album.h"
  31. #include "DllMacro.h"
  32. namespace Tomahawk
  33. {
  34. class DLLEXPORT DatabaseCommand_AllTracks : public DatabaseCommand, public Tomahawk::TracksRequest
  35. {
  36. Q_OBJECT
  37. public:
  38. enum SortOrder {
  39. None = 0,
  40. Album = 1,
  41. ModificationTime = 2,
  42. AlbumPosition = 3
  43. };
  44. explicit DatabaseCommand_AllTracks( const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr(), QObject* parent = nullptr )
  45. : DatabaseCommand( parent )
  46. , m_collection( collection.objectCast< DatabaseCollection >() )
  47. , m_artist( nullptr )
  48. , m_album( nullptr )
  49. , m_amount( 0 )
  50. , m_sortOrder( DatabaseCommand_AllTracks::None )
  51. , m_sortDescending( false )
  52. {}
  53. void exec( DatabaseImpl* ) override;
  54. bool doesMutates() const override { return false; }
  55. QString commandname() const override { return "alltracks"; }
  56. void enqueue() override { Database::instance()->enqueue( Tomahawk::dbcmd_ptr( this ) ); }
  57. void setArtist( const Tomahawk::artist_ptr& artist ) { m_artist = artist; }
  58. void setAlbum( const Tomahawk::album_ptr& album ) { m_album = album; }
  59. void setLimit( unsigned int amount ) { m_amount = amount; }
  60. void setSortOrder( DatabaseCommand_AllTracks::SortOrder order ) { m_sortOrder = order; }
  61. void setSortDescending( bool descending ) { m_sortDescending = descending; }
  62. signals:
  63. void tracks( const QList<Tomahawk::query_ptr>&, const QVariant& data );
  64. void tracks( const QList<Tomahawk::query_ptr>& ) override;
  65. void done( const Tomahawk::collection_ptr& );
  66. private:
  67. QSharedPointer< DatabaseCollection > m_collection;
  68. Tomahawk::artist_ptr m_artist;
  69. Tomahawk::album_ptr m_album;
  70. unsigned int m_amount;
  71. DatabaseCommand_AllTracks::SortOrder m_sortOrder;
  72. bool m_sortDescending;
  73. };
  74. }
  75. #endif // DATABASECOMMAND_ALLTRACKS_H