PageRenderTime 83ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 34ms app.codeStats 0ms

/src/libtomahawk/database/DatabaseCommand_AllAlbums.h

http://github.com/tomahawk-player/tomahawk
C Header | 89 lines | 53 code | 18 blank | 18 comment | 0 complexity | f2eb72bc745953ea61845bb4e0d8aef6 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 2013,      Teo Mrnjavac <teo@kde.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
20#ifndef DATABASECOMMAND_ALLALBUMS_H
21#define DATABASECOMMAND_ALLALBUMS_H
22
23#include <QObject>
24#include <QVariantMap>
25
26#include "Album.h"
27#include "Artist.h"
28#include "collection/Collection.h"
29#include "collection/AlbumsRequest.h"
30#include "Typedefs.h"
31#include "DatabaseCommand.h"
32#include "Database.h"
33#include "DatabaseCollection.h"
34
35#include "DllMacro.h"
36
37namespace Tomahawk
38{
39
40class DLLEXPORT DatabaseCommand_AllAlbums : public DatabaseCommand, public Tomahawk::AlbumsRequest
41{
42Q_OBJECT
43public:
44    enum SortOrder {
45        None = 0,
46        ModificationTime = 1
47    };
48
49    explicit DatabaseCommand_AllAlbums( const Tomahawk::collection_ptr& collection = Tomahawk::collection_ptr(),
50                                        const Tomahawk::artist_ptr& artist = Tomahawk::artist_ptr(),
51                                        QObject* parent = 0 );
52    virtual ~DatabaseCommand_AllAlbums();
53
54    virtual void exec( DatabaseImpl* );
55
56    virtual bool doesMutates() const { return false; }
57    virtual QString commandname() const { return "allalbums"; }
58
59    virtual void enqueue() { Database::instance()->enqueue( Tomahawk::dbcmd_ptr( this ) ); }
60
61    Tomahawk::collection_ptr collection() const { return m_collection; }
62
63    void execForCollection( DatabaseImpl* );
64    void execForArtist( DatabaseImpl* );
65
66    void setArtist( const Tomahawk::artist_ptr& artist );
67    void setLimit( unsigned int amount ) { m_amount = amount; }
68    void setSortOrder( DatabaseCommand_AllAlbums::SortOrder order ) { m_sortOrder = order; }
69    void setSortDescending( bool descending ) { m_sortDescending = descending; }
70    void setFilter( const QString& filter ) { m_filter = filter; }
71
72signals:
73    void albums( const QList<Tomahawk::album_ptr>&, const QVariant& data );
74    void albums( const QList<Tomahawk::album_ptr>& );
75    void done();
76
77private:
78    QSharedPointer< DatabaseCollection > m_collection;
79    Tomahawk::artist_ptr m_artist;
80
81    unsigned int m_amount;
82    DatabaseCommand_AllAlbums::SortOrder m_sortOrder;
83    bool m_sortDescending;
84    QString m_filter;
85};
86
87}
88
89#endif // DATABASECOMMAND_ALLALBUMS_H