/src/libtomahawk/database/DatabaseCommand_SetDynamicPlaylistRevision.h

http://github.com/tomahawk-player/tomahawk · C Header · 92 lines · 57 code · 18 blank · 17 comment · 0 complexity · 49c49c5b63ba8682a443e8483afbe812 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. #ifndef DATABASECOMMAND_SETDYNAMICPLAYLISTREVISION_H
  19. #define DATABASECOMMAND_SETDYNAMICPLAYLISTREVISION_H
  20. #include "DatabaseCommand_SetPlaylistRevision.h"
  21. #include "playlist/dynamic/GeneratorInterface.h"
  22. namespace Tomahawk
  23. {
  24. class DatabaseCommand_SetDynamicPlaylistRevision : public DatabaseCommand_SetPlaylistRevision
  25. {
  26. Q_OBJECT
  27. Q_PROPERTY( QString type READ type WRITE setType )
  28. Q_PROPERTY( int mode READ mode WRITE setMode )
  29. Q_PROPERTY( QVariantList controls READ controlsV WRITE setControlsV )
  30. public:
  31. explicit DatabaseCommand_SetDynamicPlaylistRevision( QObject* parent = 0 )
  32. : DatabaseCommand_SetPlaylistRevision( parent )
  33. {}
  34. explicit DatabaseCommand_SetDynamicPlaylistRevision( const source_ptr& s,
  35. const QString& playlistguid,
  36. const QString& newrev,
  37. const QString& oldrev,
  38. const QStringList& orderedguids,
  39. const QList<Tomahawk::plentry_ptr>& addedentries,
  40. const QList<plentry_ptr>& entries,
  41. const QString& type,
  42. GeneratorMode mode,
  43. const QList< dyncontrol_ptr >& controls );
  44. explicit DatabaseCommand_SetDynamicPlaylistRevision( const source_ptr& s,
  45. const QString& playlistguid,
  46. const QString& newrev,
  47. const QString& oldrev,
  48. const QString& type,
  49. GeneratorMode mode,
  50. const QList< dyncontrol_ptr >& controls );
  51. QString commandname() const { return "setdynamicplaylistrevision"; }
  52. virtual void exec( DatabaseImpl* lib );
  53. virtual void postCommitHook();
  54. virtual bool doesMutates() const { return true; }
  55. virtual bool groupable() const { return true; }
  56. void setControlsV( const QVariantList& vlist )
  57. {
  58. m_controlsV = vlist;
  59. }
  60. QVariantList controlsV();
  61. QString type() const { return m_type; }
  62. int mode() const { return (int)m_mode; }
  63. void setType( const QString& type ) { m_type = type; }
  64. void setMode( int mode ) { m_mode = (GeneratorMode)mode; }
  65. void setPlaylist( QWeakPointer<DynamicPlaylist> pl ); // raw pointer b/c we don't have the shared pointer from inside the shared pointer
  66. private:
  67. QString m_type;
  68. GeneratorMode m_mode;
  69. QList< dyncontrol_ptr > m_controls;
  70. QList< QVariant > m_controlsV;
  71. QSharedPointer<DynamicPlaylist> m_playlist; // Only used if setting revision of a non-autoloaded playlist, as those aren't able to be looked up by guid
  72. };
  73. }
  74. #endif // DATABASECOMMAND_SETDYNAMICPLAYLISTREVISION_H