Skip to content
Permalink
Browse files
Handle copy of vextex tool table into clipboard - fixes #46407
  • Loading branch information
Djedouas committed Dec 21, 2021
1 parent dd25b28 commit ec89b1dd43852be72f1700361e64680e3c3cb968
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 ec89b1d

Please sign in to comment.