Skip to content

Commit

Permalink
SIP, indentation and documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 4, 2017
1 parent 44a8a51 commit a77950c
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 86 deletions.
1 change: 1 addition & 0 deletions python/console/console_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@


class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole):

def __init__(self, parent):
QDialog.__init__(self, parent)
self.setWindowTitle(QCoreApplication.translate(
Expand Down
1 change: 0 additions & 1 deletion python/core/core_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
%Include composer/qgspaperitem.sip
%Include layout/qgslayoutcontext.sip
%Include layout/qgslayoutgridsettings.sip
%Include layout/qgslayoutitemundocommand.sip
%Include layout/qgslayoutmeasurement.sip
%Include layout/qgslayoutmeasurementconverter.sip
%Include layout/qgspagesizeregistry.sip
Expand Down
2 changes: 0 additions & 2 deletions python/core/layout/qgslayout.sip
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
called on the new layout.
%End

~QgsLayout();

void initializeDefaults();
%Docstring
Initializes an empty layout, e.g. by adding a default page to the layout. This should be called after creating
Expand Down
83 changes: 0 additions & 83 deletions python/core/layout/qgslayoutitemundocommand.sip

This file was deleted.

7 changes: 7 additions & 0 deletions python/core/layout/qgslayoutpagecollection.sip
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ class QgsLayoutPageCollection : QObject, QgsLayoutSerializableObject
:rtype: bool
%End

QgsLayoutGuideCollection &guides();
%Docstring
Returns a reference to the collection's guide collection, which manages page snap guides.
:rtype: QgsLayoutGuideCollection
%End


public slots:

void redraw();
Expand Down
21 changes: 21 additions & 0 deletions python/core/layout/qgslayoutundostack.sip
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,29 @@ class QgsLayoutUndoStack
%End

void beginMacro( const QString &commandText );
%Docstring
Starts a macro command, with the given descriptive ``commandText``.

Any commands added to the stack (either via direct manipulation of
stack() or via beginCommand()/endCommand() calls) between a
beginMacro() and endMacro() block are collapsed into a single
undo command, which will be applied or rolled back in a single step.

.. seealso:: endMacro()
%End

void endMacro();
%Docstring
Ends a macro command. This must be called after beginMacro(), when
all child undo commands which form part of the macro have been completed.

Any commands added to the stack (either via direct manipulation of
stack() or via beginCommand()/endCommand() calls) between a
beginMacro() and endMacro() block are collapsed into a single
undo command, which will be applied or rolled back in a single step.

.. seealso:: beginMacro()
%End

void beginCommand( QgsLayoutUndoObjectInterface *object, const QString &commandText, int id = 0 );
%Docstring
Expand Down
3 changes: 3 additions & 0 deletions src/core/layout/qgslayoutitemundocommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qgslayout.h"
#include "qgsproject.h"

///@cond PRIVATE
QgsLayoutItemUndoCommand::QgsLayoutItemUndoCommand( QgsLayoutItem *item, const QString &text, int id, QUndoCommand *parent )
: QgsAbstractLayoutUndoCommand( text, id, parent )
, mItemUuid( item->uuid() )
Expand Down Expand Up @@ -118,3 +119,5 @@ void QgsLayoutItemDeleteUndoCommand::redo()
layout()->removeItem( item );
item->deleteLater();
}

///@endcond
47 changes: 47 additions & 0 deletions src/core/layout/qgslayoutitemundocommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,45 @@
class QgsLayout;
class QgsLayoutItem;

SIP_NO_FILE

///@cond PRIVATE

/**
* \ingroup core
* An undo command subclass for layout item undo commands.
*
* QgsLayoutItemUndoCommand is a specific layout undo command which is
* designed for use with QgsLayoutItems. It automatically handles
* recreating a deleted item when the undo stack rolls back past
* the item deletion command.
*
* \since QGIS 3.0
*/
class CORE_EXPORT QgsLayoutItemUndoCommand: public QgsAbstractLayoutUndoCommand
{
public:

/**
* Constructor for QgsLayoutItemUndoCommand.
* \param item associated layout item
* \param text undo command descriptive text
* \param id optional undo command id, used for automatic command merging
* \param parent command
*/
QgsLayoutItemUndoCommand( QgsLayoutItem *item, const QString &text, int id = 0, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );

bool mergeWith( const QUndoCommand *command ) override;

/**
* Returns the layout associated with this command.
*/
QgsLayout *layout() const;

/**
* Returns the associated item's UUID, which uniquely identifies the item
* within the layout.
*/
QString itemUuid() const;

protected:
Expand All @@ -51,15 +80,33 @@ class CORE_EXPORT QgsLayoutItemUndoCommand: public QgsAbstractLayoutUndoCommand

};

/**
* \ingroup core
* An undo command subclass for layout item deletion undo commands.
*
* QgsLayoutItemDeleteUndoCommand is a specific layout undo command which handles
* layout item deletion. When applied (e.g. as a result of a 'redo' action),
* the associated layout item is deleted and removed from the layout.
*
* \since QGIS 3.0
*/
class CORE_EXPORT QgsLayoutItemDeleteUndoCommand: public QgsLayoutItemUndoCommand
{
public:

/**
* Constructor for QgsLayoutItemDeleteUndoCommand.
* \param item associated layout item
* \param text undo command descriptive text
* \param id optional undo command id, used for automatic command merging
* \param parent command
*/
QgsLayoutItemDeleteUndoCommand( QgsLayoutItem *item, const QString &text, int id = 0, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );
bool mergeWith( const QUndoCommand *command ) override;
void redo() override;

};

///@endcond

#endif
21 changes: 21 additions & 0 deletions src/core/layout/qgslayoutundostack.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,29 @@ class CORE_EXPORT QgsLayoutUndoStack
*/
QgsLayoutUndoStack( QgsLayout *layout );

/**
* Starts a macro command, with the given descriptive \a commandText.
*
* Any commands added to the stack (either via direct manipulation of
* stack() or via beginCommand()/endCommand() calls) between a
* beginMacro() and endMacro() block are collapsed into a single
* undo command, which will be applied or rolled back in a single step.
*
* \see endMacro()
*/
void beginMacro( const QString &commandText );

/**
* Ends a macro command. This must be called after beginMacro(), when
* all child undo commands which form part of the macro have been completed.
*
* Any commands added to the stack (either via direct manipulation of
* stack() or via beginCommand()/endCommand() calls) between a
* beginMacro() and endMacro() block are collapsed into a single
* undo command, which will be applied or rolled back in a single step.
*
* \see beginMacro()
*/
void endMacro();

/**
Expand Down

0 comments on commit a77950c

Please sign in to comment.