Skip to content

Commit

Permalink
Expose through iface methods to copy/paste features between given layers
Browse files Browse the repository at this point in the history
That is, no need to load layers into the layer tree nor make them active.
  • Loading branch information
gacarrillor committed Nov 9, 2017
1 parent 75c41f5 commit 9aa1f21
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/gui/qgisinterface.sip
Expand Up @@ -767,6 +767,16 @@ Start a blank project
:rtype: bool
%End

virtual void copyFeatures( QgsMapLayer * ) = 0;
%Docstring
Copy selected features from the layer to clipboard
%End

virtual void pasteFeatures( QgsMapLayer * ) = 0;
%Docstring
Paste features from clipboard to the layer
%End

virtual int addToolBarIcon( QAction *qAction ) = 0;
%Docstring
Add an icon to the plugins toolbar
Expand Down
10 changes: 10 additions & 0 deletions src/app/qgisappinterface.cpp
Expand Up @@ -186,6 +186,16 @@ bool QgisAppInterface::setActiveLayer( QgsMapLayer *layer )
return qgis->setActiveLayer( layer );
}

void QgisAppInterface::copyFeatures( QgsMapLayer *layer )
{
return qgis->editCopy( layer );
}

void QgisAppInterface::pasteFeatures( QgsMapLayer *layer )
{
return qgis->editPaste( layer );
}

void QgisAppInterface::addPluginToMenu( const QString &name, QAction *action )
{
qgis->addPluginToMenu( name, action );
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgisappinterface.h
Expand Up @@ -96,6 +96,12 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
//! set the active layer (layer selected in the legend)
bool setActiveLayer( QgsMapLayer *layer ) override;

//! Copy selected features from the layer to clipboard
virtual void copyFeatures( QgsMapLayer *layer ) override;

//! Paste features from clipboard to the layer
virtual void pasteFeatures( QgsMapLayer *layer ) override;

//! Add an icon to the plugins toolbar
int addToolBarIcon( QAction *qAction ) override;

Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgisinterface.h
Expand Up @@ -422,6 +422,12 @@ class GUI_EXPORT QgisInterface : public QObject
*/
virtual bool setActiveLayer( QgsMapLayer * ) = 0;

//! Copy selected features from the layer to clipboard
virtual void copyFeatures( QgsMapLayer * ) = 0;

//! Paste features from clipboard to the layer
virtual void pasteFeatures( QgsMapLayer * ) = 0;

//! Add an icon to the plugins toolbar
virtual int addToolBarIcon( QAction *qAction ) = 0;

Expand Down

0 comments on commit 9aa1f21

Please sign in to comment.