Skip to content

Commit

Permalink
Merge pull request #5291 from nyalldawson/layout_next
Browse files Browse the repository at this point in the history
[layouts] Port most interaction actions from composer
  • Loading branch information
nyalldawson authored Oct 9, 2017
2 parents 5d0f8cd + 3c87fe1 commit 9aa6142
Show file tree
Hide file tree
Showing 86 changed files with 10,481 additions and 304 deletions.
11 changes: 11 additions & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
<file>themes/default/mAction.svg</file>
<file>themes/default/mActionAdd.svg</file>
<file>themes/default/mActionDataSourceManager.svg</file>
<file>themes/default/mActionDistributeBottom.svg</file>
<file>themes/default/mActionDistributeHCenter.svg</file>
<file>themes/default/mActionDistributeLeft.svg</file>
<file>themes/default/mActionDistributeRight.svg</file>
<file>themes/default/mActionDistributeTop.svg</file>
<file>themes/default/mActionDistributeVCenter.svg</file>
<file>themes/default/mActionAddLayer.svg</file>
<file>themes/default/mActionAddAllToOverview.svg</file>
<file>themes/default/mActionAddArrow.svg</file>
Expand Down Expand Up @@ -261,6 +267,10 @@
<file>themes/default/mActionRemoveLayer.svg</file>
<file>themes/default/mActionRemoveSelectedFeature.png</file>
<file>themes/default/mActionReshape.svg</file>
<file>themes/default/mActionResizeNarrowest.svg</file>
<file>themes/default/mActionResizeShortest.svg</file>
<file>themes/default/mActionResizeTallest.svg</file>
<file>themes/default/mActionResizeWidest.svg</file>
<file>themes/default/mActionRollbackAllEdits.svg</file>
<file>themes/default/mActionRollbackEdits.svg</file>
<file>themes/default/mActionRotateFeature.svg</file>
Expand Down Expand Up @@ -572,6 +582,7 @@
<file>themes/default/mActionAddGeoPackageLayer.svg</file>
<file>icons/qgis_icon.svg</file>
<file>themes/default/3d.svg</file>
<file>themes/default/mActionResizeSquare.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
1 change: 1 addition & 0 deletions images/themes/default/mActionDistributeBottom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionDistributeHCenter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionDistributeLeft.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionDistributeRight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionDistributeTop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionDistributeVCenter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionResizeNarrowest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionResizeShortest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionResizeSquare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionResizeTallest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/mActionResizeWidest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions python/core/core_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
%Include composer/qgscomposermultiframecommand.sip
%Include composer/qgscomposertexttable.sip
%Include composer/qgspaperitem.sip
%Include layout/qgslayoutaligner.sip
%Include layout/qgslayoutcontext.sip
%Include layout/qgslayoutgridsettings.sip
%Include layout/qgslayoutmeasurement.sip
Expand Down Expand Up @@ -405,6 +406,7 @@
%Include layout/qgslayoutitempage.sip
%Include layout/qgslayoutitemregistry.sip
%Include layout/qgslayoutitemshape.sip
%Include layout/qgslayoutmodel.sip
%Include layout/qgslayoutpagecollection.sip
%Include layout/qgslayoutobject.sip
%Include symbology/qgscptcityarchive.sip
Expand Down
125 changes: 125 additions & 0 deletions python/core/layout/qgslayout.sip
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
ZItem,
ZGrid,
ZGuide,
ZSmartGuide,
ZMouseHandles,
ZMapTool,
ZSnapIndicator,
};
Expand All @@ -39,6 +41,8 @@ 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 All @@ -52,6 +56,12 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
:rtype: QgsProject
%End

QgsLayoutModel *itemsModel();
%Docstring
Returns the items model attached to the layout.
:rtype: QgsLayoutModel
%End

QString name() const;
%Docstring
Returns the layout's name.
Expand All @@ -66,13 +76,115 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
%End


QList<QgsLayoutItem *> selectedLayoutItems( const bool includeLockedItems = true );
%Docstring
Returns list of selected layout items.

If ``includeLockedItems`` is set to true, then locked items will also be included
in the returned list.
:rtype: list of QgsLayoutItem
%End

void setSelectedItem( QgsLayoutItem *item );
%Docstring
Clears any selected items and sets ``item`` as the current selection.
%End

void deselectAll();
%Docstring
Clears any selected items in the layout.

Call this method rather than QGraphicsScene.clearSelection, as the latter does
not correctly emit signals to allow the layout's model to update.
%End

bool raiseItem( QgsLayoutItem *item, bool deferUpdate = false );
%Docstring
Raises an ``item`` up the z-order.
Returns true if the item was successfully raised.

If ``deferUpdate`` is true, the scene will not be visibly updated
to reflect the new stacking order. This allows multiple
raiseItem() calls to be made in sequence without the cost of
updating the scene for each one.

.. seealso:: lowerItem()
.. seealso:: updateZValues()
:rtype: bool
%End

bool lowerItem( QgsLayoutItem *item, bool deferUpdate = false );
%Docstring
Lowers an ``item`` down the z-order.
Returns true if the item was successfully lowered.

If ``deferUpdate`` is true, the scene will not be visibly updated
to reflect the new stacking order. This allows multiple
raiseItem() calls to be made in sequence without the cost of
updating the scene for each one.

.. seealso:: raiseItem()
.. seealso:: updateZValues()
:rtype: bool
%End

bool moveItemToTop( QgsLayoutItem *item, bool deferUpdate = false );
%Docstring
Raises an ``item`` up to the top of the z-order.
Returns true if the item was successfully raised.

If ``deferUpdate`` is true, the scene will not be visibly updated
to reflect the new stacking order. This allows multiple
raiseItem() calls to be made in sequence without the cost of
updating the scene for each one.

.. seealso:: moveItemToBottom()
.. seealso:: updateZValues()
:rtype: bool
%End

bool moveItemToBottom( QgsLayoutItem *item, bool deferUpdate = false );
%Docstring
Lowers an ``item`` down to the bottom of the z-order.
Returns true if the item was successfully lowered.
If ``deferUpdate`` is true, the scene will not be visibly updated
to reflect the new stacking order. This allows multiple
raiseItem() calls to be made in sequence without the cost of
updating the scene for each one.

.. seealso:: moveItemToTop()
.. seealso:: updateZValues()
:rtype: bool
%End

void updateZValues( const bool addUndoCommands = true );
%Docstring
Resets the z-values of items based on their position in the internal
z order list. This should be called after any stacking changes
which deferred z-order updates.
%End

QgsLayoutItem *itemByUuid( const QString &uuid );
%Docstring
Returns the layout item with matching ``uuid`` unique identifier, or a None
if a matching item could not be found.
:rtype: QgsLayoutItem
%End

QgsLayoutItem *layoutItemAt( QPointF position, const bool ignoreLocked = false ) const;
%Docstring
Returns the topmost layout item at a specified ``position``. Ignores paper items.
If ``ignoreLocked`` is set to true any locked items will be ignored.
:rtype: QgsLayoutItem
%End

QgsLayoutItem *layoutItemAt( QPointF position, const QgsLayoutItem *belowItem, const bool ignoreLocked = false ) const;
%Docstring
Returns the topmost composer item at a specified ``position`` which is below a specified ``item``. Ignores paper items.
If ``ignoreLocked`` is set to true any locked items will be ignored.
:rtype: QgsLayoutItem
%End

void setUnits( QgsUnitTypes::LayoutUnit units );
%Docstring
Sets the native measurement ``units`` for the layout. These also form the default unit
Expand Down Expand Up @@ -253,6 +365,13 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
method. Ownership of the item is transferred to the layout.
%End

void removeLayoutItem( QgsLayoutItem *item );
%Docstring
Removes an ``item`` from the layout. This should be called instead of the base class removeItem()
method.
The item will also be deleted.
%End

QDomElement writeXml( QDomDocument &document, const QgsReadWriteContext &context ) const;
%Docstring
Returns the layout's state encapsulated in a DOM element.
Expand Down Expand Up @@ -293,6 +412,12 @@ class QgsLayout : QGraphicsScene, QgsExpressionContextGenerator, QgsLayoutUndoOb
Emitted whenever the expression variables stored in the layout have been changed.
%End

void selectedItemChanged( QgsLayoutItem *selected );
%Docstring
Emitted whenever the selected item changes.
If None, no item is selected.
%End

};


Expand Down
85 changes: 85 additions & 0 deletions python/core/layout/qgslayoutaligner.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutaligner.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsLayoutAligner
{
%Docstring
Handles aligning and distributing sets of layout items.

QgsLayoutAligner contains methods for automatically aligning and distributing
sets of layout items, e.g. aligning a group of items to top or left sides.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgslayoutaligner.h"
%End
public:

enum Alignment
{
AlignLeft,
AlignHCenter,
AlignRight,
AlignTop,
AlignVCenter,
AlignBottom,
};

enum Distribution
{
DistributeLeft,
DistributeHCenter,
DistributeRight,
DistributeTop,
DistributeVCenter,
DistributeBottom,
};

enum Resize
{
ResizeNarrowest,
ResizeWidest,
ResizeShortest,
ResizeTallest,
ResizeToSquare,
};

static void alignItems( QgsLayout *layout, const QList< QgsLayoutItem * > &items, Alignment alignment );
%Docstring
Aligns a set of ``items`` from a ``layout`` in place.

The ``alignment`` argument specifies the method to use when aligning the items.
%End

static void distributeItems( QgsLayout *layout, const QList< QgsLayoutItem * > &items, Distribution distribution );
%Docstring
Distributes a set of ``items`` from a ``layout`` in place.

The ``distribution`` argument specifies the method to use when distributing the items.
%End

static void resizeItems( QgsLayout *layout, const QList< QgsLayoutItem * > &items, Resize resize );
%Docstring
Resizes a set of ``items`` from a ``layout`` in place.

The ``resize`` argument specifies the method to use when resizing the items.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layout/qgslayoutaligner.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
30 changes: 30 additions & 0 deletions python/core/layout/qgslayoutcontext.sip
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,36 @@ class QgsLayoutContext
.. seealso:: gridVisible()
%End

bool boundingBoxesVisible() const;
%Docstring
Returns true if the item bounding boxes should be drawn.
.. seealso:: setBoundingBoxesVisible()
:rtype: bool
%End

void setBoundingBoxesVisible( bool visible );
%Docstring
Sets whether the item bounding boxes should be ``visible``.
.. seealso:: boundingBoxesVisible()
%End

void setPagesVisible( bool visible );
%Docstring
Sets whether the page items should be ``visible`` in the layout. Removing
them will prevent both display of the page boundaries in layout views and
will also prevent them from being rendered in layout exports.
.. seealso:: pagesVisible()
%End

bool pagesVisible() const;
%Docstring
Returns whether the page items are be visible in the layout. This setting
effects both display of the page boundaries in layout views and
whether they will be rendered in layout exports.
.. seealso:: setPagesVisible()
:rtype: bool
%End

};


Expand Down
Loading

0 comments on commit 9aa6142

Please sign in to comment.