Skip to content
Permalink
Browse files
Merge pull request #46536 from Djedouas/copy-paste-vertex-editor
  • Loading branch information
m-kuhn committed Dec 23, 2021
2 parents df41a58 + ec89b1d commit 668a1fedce64b545079ab817b1df8afdaf3eeb1a
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/app/vertextool/qgsvertexeditor.cpp
@@ -16,6 +16,7 @@
* *
***************************************************************************/

#include "qgsapplication.h"
#include "qgsvertexeditor.h"
#include "qgscoordinateutils.h"
#include "qgsmapcanvas.h"
@@ -27,6 +28,7 @@
#include "qgscoordinatetransform.h"
#include "qgsdoublevalidator.h"

#include <QClipboard>
#include <QLabel>
#include <QTableWidget>
#include <QHeaderView>
@@ -457,6 +459,22 @@ void QgsVertexEditor::keyPressEvent( QKeyEvent *e )
// Override default shortcut management in MapCanvas
e->ignore();
}
else if ( e->matches( QKeySequence::Copy ) )
{
if ( !mTableView->selectionModel()->hasSelection() )
return;
QString text;
QItemSelectionRange range = mTableView->selectionModel()->selection().first();
for ( int i = range.top(); i <= range.bottom(); ++i )
{
QStringList rowContents;
for ( int j = range.left(); j <= range.right(); ++j )
rowContents << mVertexModel->index( i, j ).data().toString();
text += rowContents.join( '\t' );
text += '\n';
}
QApplication::clipboard()->setText( text );
}
}

void QgsVertexEditor::closeEvent( QCloseEvent *event )

0 comments on commit 668a1fe

Please sign in to comment.