1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
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.
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.
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/>.
19
#ifndef DATABASECOMMAND_SETPLAYLISTREVISION_H
20
#define DATABASECOMMAND_SETPLAYLISTREVISION_H
22
#include "DatabaseCommandLoggable.h"
24
#include "qjson/qobjecthelper.h"
28
using namespace Tomahawk;
30
class DLLEXPORT DatabaseCommand_SetPlaylistRevision : public DatabaseCommandLoggable
33
Q_PROPERTY( QString playlistguid READ playlistguid WRITE setPlaylistguid )
34
Q_PROPERTY( QString newrev READ newrev WRITE setNewrev )
35
Q_PROPERTY( QString oldrev READ oldrev WRITE setOldrev )
36
Q_PROPERTY( QVariantList orderedguids READ orderedguids WRITE setOrderedguids )
37
Q_PROPERTY( QVariantList addedentries READ addedentriesV WRITE setAddedentriesV )
38
Q_PROPERTY( bool metadataUpdate READ metadataUpdate WRITE setMetadataUpdate )
41
explicit DatabaseCommand_SetPlaylistRevision( QObject* parent = 0 )
42
: DatabaseCommandLoggable( parent )
44
, m_localOnly( false )
45
, m_metadataUpdate( false )
48
// Constructor for inserting or removing entries
49
DatabaseCommand_SetPlaylistRevision( const source_ptr& s,
50
const QString& playlistguid,
51
const QString& newrev,
52
const QString& oldrev,
53
const QStringList& orderedguids,
54
const QList<Tomahawk::plentry_ptr>& addedentries,
55
const QList<Tomahawk::plentry_ptr>& entries );
57
// constructor for updating metadata only
58
DatabaseCommand_SetPlaylistRevision( const source_ptr& s,
59
const QString& playlistguid,
60
const QString& newrev,
61
const QString& oldrev,
62
const QStringList& orderedguids,
63
const QList<Tomahawk::plentry_ptr>& entriesToUpdate );
66
QString commandname() const { return "setplaylistrevision"; }
68
virtual void exec( DatabaseImpl* lib );
69
virtual void postCommitHook();
71
virtual bool doesMutates() const { return true; }
72
virtual bool localOnly() const { return m_localOnly; }
73
virtual bool groupable() const { return true; }
75
void setAddedentriesV( const QVariantList& vlist )
77
m_addedentries.clear();
78
foreach( const QVariant& v, vlist )
80
PlaylistEntry* pep = new PlaylistEntry;
81
QJson::QObjectHelper::qvariant2qobject( v.toMap(), pep );
84
m_addedentries << plentry_ptr( pep );
88
QVariantList addedentriesV() const
91
foreach( const plentry_ptr& pe, m_addedentries )
96
QVariant v = QJson::QObjectHelper::qobject2qvariant( pe.data() );
102
void setPlaylistguid( const QString& s ) { m_playlistguid = s; }
104
void setNewrev( const QString& s ) { m_newrev = s; }
105
void setOldrev( const QString& s ) { m_oldrev = s; }
106
QString newrev() const { return m_newrev; }
107
QString oldrev() const { return m_oldrev; }
108
QString playlistguid() const { return m_playlistguid; }
109
bool metadataUpdate() const { return m_metadataUpdate; }
110
void setMetadataUpdate( bool metadataUpdate ) { m_metadataUpdate = metadataUpdate; }
112
void setOrderedguids( const QVariantList& l ) { m_orderedguids = l; }
113
QVariantList orderedguids() const { return m_orderedguids; }
117
QStringList m_previous_rev_orderedguids;
118
QString m_playlistguid;
119
QString m_newrev, m_oldrev;
120
QMap<QString, Tomahawk::plentry_ptr> m_addedmap;
122
QString m_currentRevision;
125
QString hintFromQuery( const query_ptr& query ) const;
127
QVariantList m_orderedguids;
128
QList<Tomahawk::plentry_ptr> m_addedentries, m_entries;
130
bool m_localOnly, m_metadataUpdate;
133
#endif // DATABASECOMMAND_SETPLAYLISTREVISION_H