File indexing completed on 2024-12-08 04:25:56

0001 /*
0002     SPDX-FileCopyrightText: 2017 Jean-Baptiste Mardelle
0003     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #pragma once
0007 
0008 #include "assetparametermodel.hpp"
0009 #include <QPersistentModelIndex>
0010 #include <QTime>
0011 #include <QUndoCommand>
0012 
0013 /** @class AssetCommand
0014     @brief \@todo Describe class AssetCommand
0015     @todo Describe class AssetCommand
0016  */
0017 class AssetCommand : public QUndoCommand
0018 {
0019 public:
0020     AssetCommand(const std::shared_ptr<AssetParameterModel> &model, const QModelIndex &index, QString value, QUndoCommand *parent = nullptr);
0021     void undo() override;
0022     void redo() override;
0023     int id() const override;
0024     bool mergeWith(const QUndoCommand *other) override;
0025 
0026 private:
0027     std::shared_ptr<AssetParameterModel> m_model;
0028     QPersistentModelIndex m_index;
0029     QString m_value;
0030     QString m_name;
0031     QString m_oldValue;
0032     bool m_updateView;
0033     QTime m_stamp;
0034 };
0035 
0036 /** @class AssetMultiCommand
0037     @brief \@todo Describe class AssetMultiCommand
0038     @todo Describe class AssetMultiCommand
0039  */
0040 class AssetMultiCommand : public QUndoCommand
0041 {
0042 public:
0043     AssetMultiCommand(const std::shared_ptr<AssetParameterModel> &model, const QList<QModelIndex> &indexes, const QStringList &values,
0044                       QUndoCommand *parent = nullptr);
0045     void undo() override;
0046     void redo() override;
0047     int id() const override;
0048     bool mergeWith(const QUndoCommand *other) override;
0049 
0050 private:
0051     std::shared_ptr<AssetParameterModel> m_model;
0052     QList<QModelIndex> m_indexes;
0053     QStringList m_values;
0054     QString m_name;
0055     QStringList m_oldValues;
0056     bool m_updateView;
0057     QTime m_stamp;
0058 };
0059 
0060 /** @class AssetKeyframeCommand
0061     @brief \@todo Describe class AssetKeyframeCommand
0062     @todo Describe class AssetKeyframeCommand
0063  */
0064 class AssetKeyframeCommand : public QUndoCommand
0065 {
0066 public:
0067     AssetKeyframeCommand(const std::shared_ptr<AssetParameterModel> &model, const QModelIndex &index, QVariant value, GenTime pos,
0068                          QUndoCommand *parent = nullptr);
0069     void undo() override;
0070     void redo() override;
0071     int id() const override;
0072     bool mergeWith(const QUndoCommand *other) override;
0073 
0074 private:
0075     std::shared_ptr<AssetParameterModel> m_model;
0076     QPersistentModelIndex m_index;
0077     QVariant m_value;
0078     QVariant m_oldValue;
0079     GenTime m_pos;
0080     bool m_updateView;
0081     QTime m_stamp;
0082 };
0083 
0084 /** @class AssetMultiKeyframeCommand
0085     @brief \@todo Describe class AssetKeyframeCommand
0086     @todo Describe class AssetKeyframeCommand
0087  */
0088 class AssetMultiKeyframeCommand : public QUndoCommand
0089 {
0090 public:
0091     AssetMultiKeyframeCommand(const std::shared_ptr<AssetParameterModel> &model, const QList<QModelIndex> &indexes, const QStringList &sourceValues,
0092                               const QStringList &values, GenTime pos, QUndoCommand *parent = nullptr);
0093     void undo() override;
0094     void redo() override;
0095     int id() const override;
0096     bool mergeWith(const QUndoCommand *other) override;
0097 
0098 private:
0099     std::shared_ptr<AssetParameterModel> m_model;
0100     QList<QModelIndex> m_indexes;
0101     QStringList m_values;
0102     QStringList m_oldValues;
0103     GenTime m_pos;
0104     QTime m_stamp;
0105 };
0106 
0107 /** @class AssetUpdateCommand
0108     @brief \@todo Describe class AssetUpdateCommand
0109     @todo Describe class AssetUpdateCommand
0110  */
0111 class AssetUpdateCommand : public QUndoCommand
0112 {
0113 public:
0114     AssetUpdateCommand(const std::shared_ptr<AssetParameterModel> &model, QVector<QPair<QString, QVariant>> parameters, QUndoCommand *parent = nullptr);
0115     void undo() override;
0116     void redo() override;
0117     int id() const override;
0118 
0119 private:
0120     std::shared_ptr<AssetParameterModel> m_model;
0121     QVector<QPair<QString, QVariant>> m_value;
0122     QVector<QPair<QString, QVariant>> m_oldValue;
0123 };