QGIS API Documentation 3.99.0-Master (1d785854362)
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
24class QgsProcessingModelAlgorithm;
25
26#define SIP_NO_FILE
27
29
36class GUI_EXPORT QgsModelUndoCommand : public QUndoCommand
37{
38 public:
39 enum class CommandOperation
40 {
41 Unknown = 0,
42 NameChanged = 1,
43 GroupChanged = 2,
44 };
45
51 QgsModelUndoCommand( QgsProcessingModelAlgorithm *model, const QString &text, CommandOperation operation = CommandOperation::Unknown, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );
52
58 QgsModelUndoCommand( QgsProcessingModelAlgorithm *model, const QString &text, const QString &idString, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );
59
63 void saveAfterState();
64
65 int id() const override;
66 void undo() override;
67 void redo() override;
68 bool mergeWith( const QUndoCommand *other ) override;
69
73 CommandOperation operation() const { return mOperation; }
74
78 QString idString() const { return mIdString; }
79
80 private:
82 bool mFirstRun = true;
83
84 QgsProcessingModelAlgorithm *mModel = nullptr;
85 QVariant mBeforeState;
86 QVariant mAfterState;
87 CommandOperation mOperation = CommandOperation::Unknown;
88 QString mIdString;
89};
90
92
93#endif // QGSMODELUNDOCOMMAND_H
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53