PageRenderTime 103ms CodeModel.GetById 61ms app.highlight 6ms RepoModel.GetById 34ms app.codeStats 0ms

/src/libtomahawk/database/DatabaseCommand_DeleteFiles.h

http://github.com/tomahawk-player/tomahawk
C Header | 92 lines | 55 code | 19 blank | 18 comment | 0 complexity | 2c88037c1752c223926a932d9121af25 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 2010-2012, Jeff Mitchell <jeff@tomahawk-player.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_DELETEFILES_H
21#define DATABASECOMMAND_DELETEFILES_H
22
23#include <QtCore/QObject>
24#include <QtCore/QDir>
25#include <QtCore/QVariantMap>
26
27#include "database/DatabaseCommandLoggable.h"
28#include "Typedefs.h"
29
30#include "DllMacro.h"
31
32
33namespace Tomahawk
34{
35
36class DLLEXPORT DatabaseCommand_DeleteFiles : public DatabaseCommandLoggable
37{
38Q_OBJECT
39Q_PROPERTY( QVariantList ids READ ids WRITE setIds )
40Q_PROPERTY( bool deleteAll READ deleteAll WRITE setDeleteAll )
41
42public:
43    explicit DatabaseCommand_DeleteFiles( QObject* parent = 0 )
44        : DatabaseCommandLoggable( parent )
45    {}
46
47    explicit DatabaseCommand_DeleteFiles( const Tomahawk::source_ptr& source, QObject* parent = 0 )
48    : DatabaseCommandLoggable( parent ), m_deleteAll( true )
49    {
50        setSource( source );
51    }
52
53    explicit DatabaseCommand_DeleteFiles( const QDir& dir, const Tomahawk::source_ptr& source, QObject* parent = 0 )
54    : DatabaseCommandLoggable( parent ), m_dir( dir ), m_deleteAll( false )
55    {
56        setSource( source );
57    }
58
59    explicit DatabaseCommand_DeleteFiles( const QVariantList& ids, const Tomahawk::source_ptr& source, QObject* parent = 0 )
60    : DatabaseCommandLoggable( parent ), m_ids( ids ), m_deleteAll( false )
61    {
62        setSource( source );
63    }
64
65    virtual QString commandname() const { return "deletefiles"; }
66
67    virtual void exec( DatabaseImpl* );
68    virtual bool doesMutates() const { return true; }
69    virtual bool localOnly() const { return false; }
70    virtual bool groupable() const { return true; }
71    virtual void postCommitHook();
72
73    QVariantList ids() const { return m_ids; }
74    void setIds( const QVariantList& i ) { m_ids = i; }
75
76    bool deleteAll() const { return m_deleteAll; }
77    void setDeleteAll( const bool deleteAll ) { m_deleteAll = deleteAll; }
78
79signals:
80    void done( const QList<unsigned int>&, const Tomahawk::collection_ptr& );
81    void notify( const QList<unsigned int>& ids );
82
83private:
84    QDir m_dir;
85    QVariantList m_ids;
86    QList<unsigned int> m_idList;
87    bool m_deleteAll;
88};
89
90}
91
92#endif // DATABASECOMMAND_DELETEFILES_H