Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Start work on undo/redo support for layouts
- Loading branch information
1 parent
1589b4e
commit 62dcd0d
Showing
37 changed files
with
1,292 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutitemundocommand.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsLayoutItemUndoCommand: QgsAbstractLayoutUndoCommand | ||
{ | ||
%Docstring | ||
************************************************************************* | ||
* | ||
This program is free software; you can redistribute it and/or modify * | ||
it under the terms of the GNU General Public License as published by * | ||
the Free Software Foundation; either version 2 of the License, or * | ||
(at your option) any later version. * | ||
* | ||
************************************************************************** | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutitemundocommand.h" | ||
%End | ||
public: | ||
|
||
QgsLayoutItemUndoCommand( QgsLayoutItem *item, const QString &text, int id = 0, QUndoCommand *parent /TransferThis/ = 0 ); | ||
|
||
virtual bool mergeWith( const QUndoCommand *command ); | ||
|
||
|
||
QgsLayout *layout() const; | ||
%Docstring | ||
:rtype: QgsLayout | ||
%End | ||
|
||
QString itemUuid() const; | ||
%Docstring | ||
:rtype: str | ||
%End | ||
|
||
protected: | ||
|
||
virtual void saveState( QDomDocument &stateDoc ) const; | ||
|
||
virtual void restoreState( QDomDocument &stateDoc ); | ||
|
||
|
||
virtual QgsLayoutItem *recreateItem( int itemType, QgsLayout *layout ) /Factory/; | ||
%Docstring | ||
:rtype: QgsLayoutItem | ||
%End | ||
|
||
}; | ||
|
||
class QgsLayoutItemDeleteUndoCommand: QgsLayoutItemUndoCommand | ||
{ | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutitemundocommand.h" | ||
%End | ||
public: | ||
|
||
QgsLayoutItemDeleteUndoCommand( QgsLayoutItem *item, const QString &text, int id = 0, QUndoCommand *parent /TransferThis/ = 0 ); | ||
virtual bool mergeWith( const QUndoCommand *command ); | ||
|
||
virtual void redo(); | ||
|
||
|
||
}; | ||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutitemundocommand.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutundocommand.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsAbstractLayoutUndoCommand: QUndoCommand | ||
{ | ||
%Docstring | ||
Base class for commands to undo/redo layout and layout object changes. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutundocommand.h" | ||
%End | ||
public: | ||
|
||
QgsAbstractLayoutUndoCommand( const QString &text, int id = 0, QUndoCommand *parent /TransferThis/ = 0 ); | ||
%Docstring | ||
Constructor for QgsLayoutUndoCommand. | ||
The ``id`` argument can be used to specify an id number for the source event - this is used to determine whether QUndoCommand | ||
command compression can apply to the command. | ||
%End | ||
|
||
virtual void undo(); | ||
|
||
virtual void redo(); | ||
|
||
virtual int id() const; | ||
|
||
void saveBeforeState(); | ||
%Docstring | ||
Saves current layout state as before state. | ||
.. seealso:: beforeState() | ||
.. seealso:: saveAfterState() | ||
%End | ||
|
||
void saveAfterState(); | ||
%Docstring | ||
Saves current layout state as after state. | ||
.. seealso:: afterState() | ||
.. seealso:: saveBeforeState() | ||
%End | ||
|
||
QDomDocument beforeState() const; | ||
%Docstring | ||
Returns the before state for the layout. | ||
.. seealso:: saveBeforeState() | ||
.. seealso:: afterState() | ||
:rtype: QDomDocument | ||
%End | ||
|
||
QDomDocument afterState() const; | ||
%Docstring | ||
Returns the after state for the layout. | ||
.. seealso:: saveAfterState() | ||
.. seealso:: beforeState() | ||
:rtype: QDomDocument | ||
%End | ||
|
||
virtual bool containsChange() const; | ||
%Docstring | ||
Returns true if both the before and after states are valid and different. | ||
:rtype: bool | ||
%End | ||
|
||
protected: | ||
|
||
virtual void saveState( QDomDocument &stateDoc ) const = 0; | ||
%Docstring | ||
Saves the state of the object to the specified ``stateDoc``. | ||
|
||
Subclasses must implement this to handle encapsulating their current state into a DOM document. | ||
|
||
.. seealso:: restoreState() | ||
%End | ||
|
||
virtual void restoreState( QDomDocument &stateDoc ) = 0; | ||
%Docstring | ||
Restores the state of the object from the specified ``stateDoc``. | ||
|
||
Subclasses must implement this to handle restoring their current state from the encapsulated state. | ||
|
||
.. seealso:: saveState() | ||
%End | ||
|
||
void setAfterState( const QDomDocument &stateDoc ); | ||
%Docstring | ||
Manually sets the after state for the command. Generally this should not be called directly. | ||
%End | ||
|
||
|
||
}; | ||
|
||
class QgsLayoutUndoObjectInterface | ||
{ | ||
%Docstring | ||
Interface for layout objects which support undo/redo commands. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutundocommand.h" | ||
%End | ||
public: | ||
|
||
virtual QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id = 0, QUndoCommand *parent = 0 ) = 0 /Factory/; | ||
%Docstring | ||
Creates a new layout undo command with the specified ``text`` and ``parent``. | ||
|
||
The ``id`` argument can be used to specify an id number for the source event - this is used to determine whether QUndoCommand | ||
command compression can apply to the command. | ||
:rtype: QgsAbstractLayoutUndoCommand | ||
%End | ||
}; | ||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutundocommand.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutundostack.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsLayoutUndoStack | ||
{ | ||
%Docstring | ||
An undo stack for QgsLayouts. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutundostack.h" | ||
%End | ||
public: | ||
|
||
QgsLayoutUndoStack( QgsLayout *layout ); | ||
%Docstring | ||
Constructor for QgsLayoutUndoStack, for the specified parent ``layout``. | ||
%End | ||
|
||
void beginMacro( const QString &commandText ); | ||
|
||
void endMacro(); | ||
|
||
void beginCommand( QgsLayoutUndoObjectInterface *object, const QString &commandText, int id = 0 ); | ||
%Docstring | ||
Begins a new undo command for the specified ``object``. | ||
|
||
This must be followed by a call to endCommand() or cancelCommand() after the desired changes | ||
have been made to ``object``. | ||
|
||
The ``id`` argument can be used to specify an id number for the source event - this is used to determine whether QUndoCommand | ||
command compression can apply to the command. | ||
|
||
.. seealso:: endCommand() | ||
.. seealso:: cancelCommand() | ||
%End | ||
|
||
void endCommand(); | ||
%Docstring | ||
Saves final state of an object and pushes the active command to the undo history. | ||
.. seealso:: beginCommand() | ||
.. seealso:: cancelCommand() | ||
%End | ||
|
||
void cancelCommand(); | ||
%Docstring | ||
Cancels the active command, discarding it without pushing to the undo history. | ||
.. seealso:: endCommand() | ||
.. seealso:: cancelCommand() | ||
%End | ||
|
||
QUndoStack *stack(); | ||
%Docstring | ||
Returns a pointer to the internal QUndoStack. | ||
:rtype: QUndoStack | ||
%End | ||
|
||
private: | ||
QgsLayoutUndoStack( const QgsLayoutUndoStack &other ); | ||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutundostack.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
Oops, something went wrong.