PageRenderTime 188ms CodeModel.GetById 100ms app.highlight 19ms RepoModel.GetById 62ms app.codeStats 0ms

/src/libtomahawk/database/DatabaseCommand_SetCollectionAttributes.h

http://github.com/tomahawk-player/tomahawk
C Header | 68 lines | 38 code | 12 blank | 18 comment | 0 complexity | 9bc0208b556a2e8631ed64aa15a0a789 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Leo Franchi <lfranchi@kde.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_SETCOLLECTIONATTRIBUTES
20#define DATABASECOMMAND_SETCOLLECTIONATTRIBUTES
21
22#include "Typedefs.h"
23#include "DatabaseCommandLoggable.h"
24#include <QByteArray>
25
26namespace Tomahawk
27{
28
29class DatabaseCommand_SetCollectionAttributes : public DatabaseCommandLoggable
30{
31    Q_OBJECT
32    Q_PROPERTY( QByteArray     id                    READ id          WRITE setId )
33    Q_PROPERTY( int           type                   READ type        WRITE setType )
34    Q_PROPERTY( bool          del                    READ del         WRITE setDel )
35
36public:
37    enum AttributeType {
38        EchonestSongCatalog = 0,
39        EchonestArtistCatalog = 1
40    };
41
42    DatabaseCommand_SetCollectionAttributes( AttributeType type, const QByteArray& id );
43    // Delete all attributes for the source+type
44    DatabaseCommand_SetCollectionAttributes( AttributeType type, bool toDelete );
45    DatabaseCommand_SetCollectionAttributes() : m_delete( false ) {} // JSON
46    virtual void exec( DatabaseImpl* lib );
47    virtual bool doesMutates() const { return true; }
48    virtual void postCommitHook();
49
50    virtual QString commandname() const { return "setcollectionattributes"; }
51
52    void setId( const QByteArray& id ) { m_id = id; }
53    QByteArray id() const { return m_id; }
54
55    void setType( int type ) { m_type = (AttributeType)type; }
56    int type() const { return (int)m_type; }
57
58    void setDel( bool del ) { m_delete = del; }
59    bool del() const { return m_delete; }
60private:
61    bool m_delete;
62    AttributeType m_type;
63    QByteArray m_id;
64};
65
66}
67
68#endif // DATABASECOMMAND_SETCOLLECTIONATTRIBUTES