PageRenderTime 223ms CodeModel.GetById 81ms app.highlight 8ms RepoModel.GetById 132ms app.codeStats 1ms

/src/libtomahawk/database/DatabaseCommand_SetPlaylistRevision.h

http://github.com/tomahawk-player/tomahawk
C Header | 112 lines | 70 code | 23 blank | 19 comment | 0 complexity | 20f43199d6ce97fbeaa99c7598a40908 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_SETPLAYLISTREVISION_H
 20#define DATABASECOMMAND_SETPLAYLISTREVISION_H
 21
 22#include "DatabaseCommandLoggable.h"
 23#include "Playlist.h"
 24
 25#include "DllMacro.h"
 26
 27#include <QStringList>
 28
 29namespace Tomahawk
 30{
 31
 32class DLLEXPORT DatabaseCommand_SetPlaylistRevision : public DatabaseCommandLoggable
 33{
 34Q_OBJECT
 35Q_PROPERTY( QString playlistguid      READ playlistguid  WRITE setPlaylistguid )
 36Q_PROPERTY( QString newrev            READ newrev        WRITE setNewrev )
 37Q_PROPERTY( QString oldrev            READ oldrev        WRITE setOldrev )
 38Q_PROPERTY( QVariantList orderedguids READ orderedguids  WRITE setOrderedguids )
 39Q_PROPERTY( QVariantList addedentries READ addedentriesV WRITE setAddedentriesV )
 40Q_PROPERTY( bool metadataUpdate       READ metadataUpdate WRITE setMetadataUpdate )
 41
 42public:
 43    explicit DatabaseCommand_SetPlaylistRevision( QObject* parent = 0 )
 44        : DatabaseCommandLoggable( parent )
 45        , m_failed( false )
 46        , m_applied( false )
 47        , m_localOnly( false )
 48        , m_metadataUpdate( false )
 49    {}
 50
 51    // Constructor for inserting or removing entries
 52    DatabaseCommand_SetPlaylistRevision( const source_ptr& s,
 53                                                  const QString& playlistguid,
 54                                                  const QString& newrev,
 55                                                  const QString& oldrev,
 56                                                  const QStringList& orderedguids,
 57                                                  const QList<Tomahawk::plentry_ptr>& addedentries,
 58                                                  const QList<Tomahawk::plentry_ptr>& entries );
 59
 60    // constructor for updating metadata only
 61    DatabaseCommand_SetPlaylistRevision( const source_ptr& s,
 62                                                  const QString& playlistguid,
 63                                                  const QString& newrev,
 64                                                  const QString& oldrev,
 65                                                  const QStringList& orderedguids,
 66                                                  const QList<Tomahawk::plentry_ptr>& entriesToUpdate );
 67
 68
 69    QString commandname() const { return "setplaylistrevision"; }
 70
 71    virtual void exec( DatabaseImpl* lib );
 72    virtual void postCommitHook();
 73
 74    virtual bool doesMutates() const { return true; }
 75    virtual bool localOnly() const { return m_localOnly; }
 76    virtual bool groupable() const { return true; }
 77
 78    void setAddedentriesV( const QVariantList& vlist );
 79
 80    QVariantList addedentriesV() const;
 81
 82    void setPlaylistguid( const QString& s ) { m_playlistguid = s; }
 83
 84    void setNewrev( const QString& s ) { m_newrev = s; }
 85    void setOldrev( const QString& s ) { m_oldrev = s; }
 86    QString newrev() const { return m_newrev; }
 87    QString oldrev() const { return m_oldrev; }
 88    QString playlistguid() const { return m_playlistguid; }
 89    bool metadataUpdate() const { return m_metadataUpdate; }
 90    void setMetadataUpdate( bool metadataUpdate ) { m_metadataUpdate = metadataUpdate; }
 91
 92    void setOrderedguids( const QVariantList& l ) { m_orderedguids = l; }
 93    QVariantList orderedguids() const { return m_orderedguids; }
 94
 95protected:
 96    bool m_failed;
 97    bool m_applied;
 98    QStringList m_previous_rev_orderedguids;
 99    QString m_playlistguid;
100    QString m_newrev, m_oldrev;
101    QMap<QString, Tomahawk::plentry_ptr> m_addedmap;
102
103private:
104    QVariantList m_orderedguids;
105    QList<Tomahawk::plentry_ptr> m_addedentries, m_entries;
106
107    bool m_localOnly, m_metadataUpdate;
108};
109
110}
111
112#endif // DATABASECOMMAND_SETPLAYLISTREVISION_H