/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. #ifndef DATABASECOMMAND_SETPLAYLISTREVISION_H
  19. #define DATABASECOMMAND_SETPLAYLISTREVISION_H
  20. #include "DatabaseCommandLoggable.h"
  21. #include "Playlist.h"
  22. #include "DllMacro.h"
  23. #include <QStringList>
  24. namespace Tomahawk
  25. {
  26. class DLLEXPORT DatabaseCommand_SetPlaylistRevision : public DatabaseCommandLoggable
  27. {
  28. Q_OBJECT
  29. Q_PROPERTY( QString playlistguid READ playlistguid WRITE setPlaylistguid )
  30. Q_PROPERTY( QString newrev READ newrev WRITE setNewrev )
  31. Q_PROPERTY( QString oldrev READ oldrev WRITE setOldrev )
  32. Q_PROPERTY( QVariantList orderedguids READ orderedguids WRITE setOrderedguids )
  33. Q_PROPERTY( QVariantList addedentries READ addedentriesV WRITE setAddedentriesV )
  34. Q_PROPERTY( bool metadataUpdate READ metadataUpdate WRITE setMetadataUpdate )
  35. public:
  36. explicit DatabaseCommand_SetPlaylistRevision( QObject* parent = 0 )
  37. : DatabaseCommandLoggable( parent )
  38. , m_failed( false )
  39. , m_applied( false )
  40. , m_localOnly( false )
  41. , m_metadataUpdate( false )
  42. {}
  43. // Constructor for inserting or removing entries
  44. DatabaseCommand_SetPlaylistRevision( const source_ptr& s,
  45. const QString& playlistguid,
  46. const QString& newrev,
  47. const QString& oldrev,
  48. const QStringList& orderedguids,
  49. const QList<Tomahawk::plentry_ptr>& addedentries,
  50. const QList<Tomahawk::plentry_ptr>& entries );
  51. // constructor for updating metadata only
  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>& entriesToUpdate );
  58. QString commandname() const { return "setplaylistrevision"; }
  59. virtual void exec( DatabaseImpl* lib );
  60. virtual void postCommitHook();
  61. virtual bool doesMutates() const { return true; }
  62. virtual bool localOnly() const { return m_localOnly; }
  63. virtual bool groupable() const { return true; }
  64. void setAddedentriesV( const QVariantList& vlist );
  65. QVariantList addedentriesV() const;
  66. void setPlaylistguid( const QString& s ) { m_playlistguid = s; }
  67. void setNewrev( const QString& s ) { m_newrev = s; }
  68. void setOldrev( const QString& s ) { m_oldrev = s; }
  69. QString newrev() const { return m_newrev; }
  70. QString oldrev() const { return m_oldrev; }
  71. QString playlistguid() const { return m_playlistguid; }
  72. bool metadataUpdate() const { return m_metadataUpdate; }
  73. void setMetadataUpdate( bool metadataUpdate ) { m_metadataUpdate = metadataUpdate; }
  74. void setOrderedguids( const QVariantList& l ) { m_orderedguids = l; }
  75. QVariantList orderedguids() const { return m_orderedguids; }
  76. protected:
  77. bool m_failed;
  78. bool m_applied;
  79. QStringList m_previous_rev_orderedguids;
  80. QString m_playlistguid;
  81. QString m_newrev, m_oldrev;
  82. QMap<QString, Tomahawk::plentry_ptr> m_addedmap;
  83. private:
  84. QVariantList m_orderedguids;
  85. QList<Tomahawk::plentry_ptr> m_addedentries, m_entries;
  86. bool m_localOnly, m_metadataUpdate;
  87. };
  88. }
  89. #endif // DATABASECOMMAND_SETPLAYLISTREVISION_H