PageRenderTime 196ms CodeModel.GetById 74ms app.highlight 6ms RepoModel.GetById 115ms app.codeStats 0ms

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