Skip to content

Commit

Permalink
Rename editCopy/editPaste to copySelectionToClipboard/pasteFromClipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
gacarrillor committed Nov 15, 2017
1 parent 829915e commit a00ce9e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 28 deletions.
10 changes: 6 additions & 4 deletions python/gui/qgisinterface.sip
Expand Up @@ -767,14 +767,16 @@ Start a blank project
:rtype: bool
%End

virtual void editCopy( QgsMapLayer * ) = 0;
virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;
%Docstring
Copy selected features from the layer to clipboard
Copy selected features from the layer to clipboard
.. versionadded:: 3.0
%End

virtual void editPaste( QgsMapLayer * ) = 0;
virtual void pasteFromClipboard( QgsMapLayer * ) = 0;
%Docstring
Paste features from clipboard to the layer
Paste features from clipboard to the layer
.. versionadded:: 3.0
%End

virtual int addToolBarIcon( QAction *qAction ) = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgisapp.cpp
Expand Up @@ -1805,9 +1805,9 @@ void QgisApp::createActions()

connect( mActionUndo, &QAction::triggered, mUndoWidget, &QgsUndoWidget::undo );
connect( mActionRedo, &QAction::triggered, mUndoWidget, &QgsUndoWidget::redo );
connect( mActionCutFeatures, &QAction::triggered, this, [ = ] { editCut(); } );
connect( mActionCopyFeatures, &QAction::triggered, this, [ = ] { editCopy(); } );
connect( mActionPasteFeatures, &QAction::triggered, this, [ = ] { editPaste(); } );
connect( mActionCutFeatures, &QAction::triggered, this, [ = ] { cutSelectionToClipboard(); } );
connect( mActionCopyFeatures, &QAction::triggered, this, [ = ] { copySelectionToClipboard(); } );
connect( mActionPasteFeatures, &QAction::triggered, this, [ = ] { pasteFromClipboard(); } );
connect( mActionPasteAsNewVector, &QAction::triggered, this, &QgisApp::pasteAsNewVector );
connect( mActionPasteAsNewMemoryVector, &QAction::triggered, this, [ = ] { pasteAsNewMemoryVector(); } );
connect( mActionCopyStyle, &QAction::triggered, this, [ = ] { copyStyle(); } );
Expand Down Expand Up @@ -8054,7 +8054,7 @@ void QgisApp::addPart()
}


void QgisApp::editCut( QgsMapLayer *layerContainingSelection )
void QgisApp::cutSelectionToClipboard( QgsMapLayer *layerContainingSelection )
{
// Test for feature support in this layer
QgsVectorLayer *selectionVectorLayer = qobject_cast<QgsVectorLayer *>( layerContainingSelection ? layerContainingSelection : activeLayer() );
Expand All @@ -8068,7 +8068,7 @@ void QgisApp::editCut( QgsMapLayer *layerContainingSelection )
selectionVectorLayer->endEditCommand();
}

void QgisApp::editCopy( QgsMapLayer *layerContainingSelection )
void QgisApp::copySelectionToClipboard( QgsMapLayer *layerContainingSelection )
{
QgsVectorLayer *selectionVectorLayer = qobject_cast<QgsVectorLayer *>( layerContainingSelection ? layerContainingSelection : activeLayer() );
if ( !selectionVectorLayer )
Expand All @@ -8083,7 +8083,7 @@ void QgisApp::clipboardChanged()
activateDeactivateLayerRelatedActions( activeLayer() );
}

void QgisApp::editPaste( QgsMapLayer *destinationLayer )
void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer )
{
QgsVectorLayer *pasteVectorLayer = qobject_cast<QgsVectorLayer *>( destinationLayer ? destinationLayer : activeLayer() );
if ( !pasteVectorLayer )
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgisapp.h
Expand Up @@ -745,21 +745,21 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
\param layerContainingSelection The layer that the selection will be taken from
(defaults to the active layer on the legend)
*/
void editCut( QgsMapLayer *layerContainingSelection = nullptr );
void cutSelectionToClipboard( QgsMapLayer *layerContainingSelection = nullptr );
//! copies selected features on the active layer to the clipboard

/**
\param layerContainingSelection The layer that the selection will be taken from
(defaults to the active layer on the legend)
*/
void editCopy( QgsMapLayer *layerContainingSelection = nullptr );
void copySelectionToClipboard( QgsMapLayer *layerContainingSelection = nullptr );
//! copies features on the clipboard to the active layer

/**
\param destinationLayer The layer that the clipboard will be pasted to
(defaults to the active layer on the legend)
*/
void editPaste( QgsMapLayer *destinationLayer = nullptr );
void pasteFromClipboard( QgsMapLayer *destinationLayer = nullptr );
//! copies features on the clipboard to a new vector layer
void pasteAsNewVector();
//! copies features on the clipboard to a new memory vector layer
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgisappinterface.cpp
Expand Up @@ -186,14 +186,14 @@ bool QgisAppInterface::setActiveLayer( QgsMapLayer *layer )
return qgis->setActiveLayer( layer );
}

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

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

void QgisAppInterface::addPluginToMenu( const QString &name, QAction *action )
Expand Down
14 changes: 10 additions & 4 deletions src/app/qgisappinterface.h
Expand Up @@ -96,11 +96,17 @@ 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 editCopy( QgsMapLayer *layer ) override;
/**
* Copy selected features from the layer to clipboard
* \since QGIS 3.0
*/
virtual void copySelectionToClipboard( QgsMapLayer *layer ) override;

//! Paste features from clipboard to the layer
virtual void editPaste( QgsMapLayer *layer ) override;
/**
* Paste features from clipboard to the layer
* \since QGIS 3.0
*/
virtual void pasteFromClipboard( QgsMapLayer *layer ) override;

//! Add an icon to the plugins toolbar
int addToolBarIcon( QAction *qAction ) override;
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -730,12 +730,12 @@ void QgsAttributeTableDialog::mActionExpressionSelect_triggered()

void QgsAttributeTableDialog::mActionCopySelectedRows_triggered()
{
QgisApp::instance()->editCopy( mLayer );
QgisApp::instance()->copySelectionToClipboard( mLayer );
}

void QgsAttributeTableDialog::mActionPasteFeatures_triggered()
{
QgisApp::instance()->editPaste( mLayer );
QgisApp::instance()->pasteFromClipboard( mLayer );
}


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

//! Copy selected features from the layer to clipboard
virtual void editCopy( QgsMapLayer * ) = 0;
/**
* Copy selected features from the layer to clipboard
* \since QGIS 3.0
*/
virtual void copySelectionToClipboard( QgsMapLayer * ) = 0;

//! Paste features from clipboard to the layer
virtual void editPaste( QgsMapLayer * ) = 0;
/**
* Paste features from clipboard to the layer
* \since QGIS 3.0
*/
virtual void pasteFromClipboard( QgsMapLayer * ) = 0;

//! Add an icon to the plugins toolbar
virtual int addToolBarIcon( QAction *qAction ) = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/app/testqgisappclipboard.cpp
Expand Up @@ -103,7 +103,7 @@ void TestQgisAppClipboard::copyPaste()

// copy all features to clipboard
inputLayer->selectAll();
mQgisApp->editCopy( inputLayer );
mQgisApp->copySelectionToClipboard( inputLayer );

QgsFeatureList features = mQgisApp->clipboard()->copyOf();
qDebug() << features.size() << " features copied to clipboard";
Expand Down

0 comments on commit a00ce9e

Please sign in to comment.