File indexing completed on 2022-11-29 12:54:54

0001 /*
0002  *  SPDX-FileCopyrightText: 2012 Sebastian Gottfried <sebastiangottfried@web.de>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 
0008 #ifndef COURSECOMMANDS_H
0009 #define COURSECOMMANDS_H
0010 
0011 #include <QUndoCommand>
0012 
0013 class Course;
0014 class Lesson;
0015 
0016 class SetCourseTitleCommand: public QUndoCommand
0017 {
0018 public:
0019     SetCourseTitleCommand(Course* course, const QString& oldTitle, QUndoCommand* parent = nullptr);
0020     void undo() override;
0021     void redo() override;
0022     bool mergeWith(const QUndoCommand* command) override;
0023     int id() const override;
0024 private:
0025     Course* m_course;
0026     QString m_oldTitle;
0027     QString m_newTitle;
0028 };
0029 
0030 class SetCourseKeyboadLayoutNameCommand: public QUndoCommand
0031 {
0032 public:
0033     SetCourseKeyboadLayoutNameCommand(Course* course, const QString& oldKeyboardLayoutName, QUndoCommand* parent = nullptr);
0034     void undo() override;
0035     void redo() override;
0036     bool mergeWith(const QUndoCommand* command) override;
0037     int id() const override;
0038 private:
0039     Course* m_course;
0040     QString m_oldKeyboardLayoutName;
0041     QString m_newKeyboardLayoutName;
0042 };
0043 
0044 class SetCourseDescriptionCommand: public QUndoCommand
0045 {
0046 public:
0047     SetCourseDescriptionCommand(Course* course, const QString& oldDescription, QUndoCommand* parent = nullptr);
0048     void undo() override;
0049     void redo() override;
0050     bool mergeWith(const QUndoCommand* command) override;
0051     int id() const override;
0052 private:
0053     Course* m_course;
0054     QString m_oldDescription;
0055     QString m_newDescription;
0056 };
0057 
0058 class AddLessonCommand: public QUndoCommand
0059 {
0060 public:
0061     AddLessonCommand(Course* course, int lessonIndex, const QString& lessonTitle, QUndoCommand* parent = nullptr);
0062     void undo() override;
0063     void redo() override;
0064     bool mergeWith(const QUndoCommand* command) override;
0065     int id() const override;
0066 private:
0067     Course* m_course;
0068     int m_lessonIndex;
0069     QString m_lessonId;
0070 };
0071 
0072 class RemoveLessonCommand: public QUndoCommand
0073 {
0074 public:
0075     RemoveLessonCommand(Course* course, int lessonIndex, QUndoCommand* parent = nullptr);
0076     ~RemoveLessonCommand() override;
0077     void undo() override;
0078     void redo() override;
0079     bool mergeWith(const QUndoCommand* command) override;
0080     int id() const override;
0081 private:
0082     Course* m_course;
0083     int m_lessonIndex;
0084     Lesson* m_backupLesson;
0085 };
0086 
0087 class MoveLessonCommand: public QUndoCommand
0088 {
0089 public:
0090     MoveLessonCommand(Course* course, int oldLessonIndex, int newLessonIndex, QUndoCommand* parent = nullptr);
0091     void undo() override;
0092     void redo() override;
0093     bool mergeWith(const QUndoCommand* command) override;
0094     int id() const override;
0095 private:
0096     Course* m_course;
0097     int m_oldLessonIndex;
0098     int m_newLessonIndex;
0099 };
0100 
0101 class SetLessonTitleCommand: public QUndoCommand
0102 {
0103 public:
0104     SetLessonTitleCommand(Course* course, int lessonIndex, const QString& oldTitle, QUndoCommand* parent=nullptr);
0105     void undo() override;
0106     void redo() override;
0107     bool mergeWith(const QUndoCommand* command) override;
0108     int id() const override;
0109 private:
0110     Course* m_course;
0111     int m_lessonIndex;
0112     QString m_oldTitle;
0113     QString m_newTitle;
0114 };
0115 
0116 class SetLessonNewCharactersCommand: public QUndoCommand
0117 {
0118 public:
0119     SetLessonNewCharactersCommand(Course* course, int lessonIndex, const QString& oldNewCharacters, QUndoCommand* parent = nullptr);
0120     void undo() override;
0121     void redo() override;
0122     bool mergeWith(const QUndoCommand* command) override;
0123     int id() const override;
0124 private:
0125     Course* m_course;
0126     int m_lessonIndex;
0127     QString m_oldNewCharacters;
0128     QString m_newNewCharacters;
0129 };
0130 
0131 class SetLessonTextCommand: public QUndoCommand
0132 {
0133 public:
0134     SetLessonTextCommand(Course* course, int lessonIndex, const QString& oldText, QUndoCommand* parent = nullptr);
0135     void undo() override;
0136     void redo() override;
0137     bool mergeWith(const QUndoCommand* command) override;
0138     int id() const override;
0139 private:
0140     Course* m_course;
0141     int m_lessonIndex;
0142     QString m_oldText;
0143     QString m_newText;
0144 };
0145 
0146 #endif // COURSECOMMANDS_H