QGIS API Documentation 3.99.0-Master (0c964c3d988)
Loading...
Searching...
No Matches
qgsmodelundocommand.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelundocommand.h
3 ----------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMODELUNDOCOMMAND_H
17#define QGSMODELUNDOCOMMAND_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21
22#include <QUndoCommand>
23
24#define SIP_NO_FILE
25
26class QgsProcessingModelAlgorithm;
27
28
30
37class GUI_EXPORT QgsModelUndoCommand : public QUndoCommand
38{
39 public:
40 enum class CommandOperation
41 {
42 Unknown = 0,
43 NameChanged = 1,
44 GroupChanged = 2,
45 };
46
52 QgsModelUndoCommand( QgsProcessingModelAlgorithm *model, const QString &text, CommandOperation operation = CommandOperation::Unknown, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );
53
59 QgsModelUndoCommand( QgsProcessingModelAlgorithm *model, const QString &text, const QString &idString, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );
60
64 void saveAfterState();
65
66 int id() const override;
67 void undo() override;
68 void redo() override;
69 bool mergeWith( const QUndoCommand *other ) override;
70
74 CommandOperation operation() const { return mOperation; }
75
79 QString idString() const { return mIdString; }
80
81 private:
83 bool mFirstRun = true;
84
85 QgsProcessingModelAlgorithm *mModel = nullptr;
86 QVariant mBeforeState;
87 QVariant mAfterState;
88 CommandOperation mOperation = CommandOperation::Unknown;
89 QString mIdString;
90};
91
93
94#endif // QGSMODELUNDOCOMMAND_H
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52