/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. #ifndef DATABASECOMMAND_DELETEFILES_H
  20. #define DATABASECOMMAND_DELETEFILES_H
  21. #include <QtCore/QObject>
  22. #include <QtCore/QDir>
  23. #include <QtCore/QVariantMap>
  24. #include "database/DatabaseCommandLoggable.h"
  25. #include "Typedefs.h"
  26. #include "DllMacro.h"
  27. namespace Tomahawk
  28. {
  29. class DLLEXPORT DatabaseCommand_DeleteFiles : public DatabaseCommandLoggable
  30. {
  31. Q_OBJECT
  32. Q_PROPERTY( QVariantList ids READ ids WRITE setIds )
  33. Q_PROPERTY( bool deleteAll READ deleteAll WRITE setDeleteAll )
  34. public:
  35. explicit DatabaseCommand_DeleteFiles( QObject* parent = 0 )
  36. : DatabaseCommandLoggable( parent )
  37. {}
  38. explicit DatabaseCommand_DeleteFiles( const Tomahawk::source_ptr& source, QObject* parent = 0 )
  39. : DatabaseCommandLoggable( parent ), m_deleteAll( true )
  40. {
  41. setSource( source );
  42. }
  43. explicit DatabaseCommand_DeleteFiles( const QDir& dir, const Tomahawk::source_ptr& source, QObject* parent = 0 )
  44. : DatabaseCommandLoggable( parent ), m_dir( dir ), m_deleteAll( false )
  45. {
  46. setSource( source );
  47. }
  48. explicit DatabaseCommand_DeleteFiles( const QVariantList& ids, const Tomahawk::source_ptr& source, QObject* parent = 0 )
  49. : DatabaseCommandLoggable( parent ), m_ids( ids ), m_deleteAll( false )
  50. {
  51. setSource( source );
  52. }
  53. virtual QString commandname() const { return "deletefiles"; }
  54. virtual void exec( DatabaseImpl* );
  55. virtual bool doesMutates() const { return true; }
  56. virtual bool localOnly() const { return false; }
  57. virtual bool groupable() const { return true; }
  58. virtual void postCommitHook();
  59. QVariantList ids() const { return m_ids; }
  60. void setIds( const QVariantList& i ) { m_ids = i; }
  61. bool deleteAll() const { return m_deleteAll; }
  62. void setDeleteAll( const bool deleteAll ) { m_deleteAll = deleteAll; }
  63. signals:
  64. void done( const QList<unsigned int>&, const Tomahawk::collection_ptr& );
  65. void notify( const QList<unsigned int>& ids );
  66. private:
  67. QDir m_dir;
  68. QVariantList m_ids;
  69. QList<unsigned int> m_idList;
  70. bool m_deleteAll;
  71. };
  72. }
  73. #endif // DATABASECOMMAND_DELETEFILES_H