Skip to content

Commit

Permalink
Merge pull request #50381 from nirvn/sort_sort_sort
Browse files Browse the repository at this point in the history
New layer tree insertion methods (on top of tree, optimal) and sorting of drag and dropped layers
  • Loading branch information
nirvn committed Oct 26, 2022
2 parents 5700f9e + 09d4b0a commit 087e55d
Show file tree
Hide file tree
Showing 18 changed files with 700 additions and 293 deletions.
7 changes: 7 additions & 0 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2057,3 +2057,10 @@
Qgis.ScriptLanguage.__doc__ = 'Scripting languages.\n\n.. versionadded:: 3.30\n\n' + '* ``Css``: ' + Qgis.ScriptLanguage.Css.__doc__ + '\n' + '* ``QgisExpression``: ' + Qgis.ScriptLanguage.QgisExpression.__doc__ + '\n' + '* ``Html``: ' + Qgis.ScriptLanguage.Html.__doc__ + '\n' + '* ``JavaScript``: ' + Qgis.ScriptLanguage.JavaScript.__doc__ + '\n' + '* ``Json``: ' + Qgis.ScriptLanguage.Json.__doc__ + '\n' + '* ``Python``: ' + Qgis.ScriptLanguage.Python.__doc__ + '\n' + '* ``R``: ' + Qgis.ScriptLanguage.R.__doc__ + '\n' + '* ``Sql``: ' + Qgis.ScriptLanguage.Sql.__doc__ + '\n' + '* ``Unknown``: ' + Qgis.ScriptLanguage.Unknown.__doc__
# --
Qgis.ScriptLanguage.baseClass = Qgis
# monkey patching scoped based enum
Qgis.LayerTreeInsertionMethod.AboveInsertionPoint.__doc__ = "Layers are added in the tree above the insertion point"
Qgis.LayerTreeInsertionMethod.TopOfTree.__doc__ = "Layers are added at the top of the layer tree"
Qgis.LayerTreeInsertionMethod.OptimalInInsertionGroup.__doc__ = "Layers are added at optimal locations across the insertion point's group"
Qgis.LayerTreeInsertionMethod.__doc__ = 'Layer tree insertion methods\n\n.. versionadded:: 3.30\n\n' + '* ``AboveInsertionPoint``: ' + Qgis.LayerTreeInsertionMethod.AboveInsertionPoint.__doc__ + '\n' + '* ``TopOfTree``: ' + Qgis.LayerTreeInsertionMethod.TopOfTree.__doc__ + '\n' + '* ``OptimalInInsertionGroup``: ' + Qgis.LayerTreeInsertionMethod.OptimalInInsertionGroup.__doc__
# --
Qgis.LayerTreeInsertionMethod.baseClass = Qgis
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ Set where the new layers should be inserted - can be used to follow current sele
By default it is root group with zero index.

.. versionadded:: 3.10
%End

void setLayerInsertionMethod( Qgis::LayerTreeInsertionMethod method );
%Docstring
Sets the insertion ``method`` used to add layers to the tree

.. versionadded:: 3.30
%End

Qgis::LayerTreeInsertionMethod layerInsertionMethod() const;
%Docstring
Returns the insertion method used to add layers to the tree

.. versionadded:: 3.30
%End

signals:
Expand Down
19 changes: 19 additions & 0 deletions python/core/auto_generated/layertree/qgslayertreeutils.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,25 @@ or the group itself if it doesn't hold the property
:param property: the property

.. versionadded:: 3.8
%End

static QgsLayerTreeLayer *insertLayerAtOptimalPlacement( QgsLayerTreeGroup *group, QgsMapLayer *layer );
%Docstring
Inserts a ``layer`` within a given ``group`` at an optimal index position by insuring a given layer
type will always sit on top of or below other types. From top to bottom, the stacking logic is
as follow:

- vector points
- vector lines
- vector polygons
- point clouds
- meshes
- rasters
- base maps

A base map is defined as a non-gdal provider raster layer (e.g. XYZ raster layer, vector tile layer, etc.)

.. versionadded:: 3.28
%End
};

Expand Down
7 changes: 7 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,13 @@ The development version
Unknown,
};

enum class LayerTreeInsertionMethod
{
AboveInsertionPoint,
TopOfTree,
OptimalInInsertionGroup,
};

static const double DEFAULT_SEARCH_RADIUS_MM;

static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
Expand Down
10 changes: 10 additions & 0 deletions python/gui/auto_generated/layertree/qgslayertreeview.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ Returns width of contextual menu mark, at right of layer node items.




public slots:
void refreshLayerSymbology( const QString &layerId );
%Docstring
Expand Down Expand Up @@ -351,6 +352,11 @@ Returns the show private layers status
void currentLayerChanged( QgsMapLayer *layer );
%Docstring
Emitted when a current layer is changed
%End

void datasetsDropped( QDropEvent *event );
%Docstring
Emitted when datasets are dropped onto the layer tree view
%End

protected:
Expand All @@ -366,6 +372,10 @@ Emitted when a current layer is changed
virtual void keyPressEvent( QKeyEvent *event );


virtual void dragEnterEvent( QDragEnterEvent *event );

virtual void dragMoveEvent( QDragMoveEvent *event );

virtual void dropEvent( QDropEvent *event );


Expand Down
Loading

0 comments on commit 087e55d

Please sign in to comment.