Skip to content

Commit

Permalink
Handle copy of vextex tool table into clipboard - fixes #46407
Browse files Browse the repository at this point in the history
  • Loading branch information
Djedouas authored and m-kuhn committed Jan 3, 2022
1 parent c40d32a commit b81c83a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/app/vertextool/qgsvertexeditor.cpp
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************/

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

#include <QClipboard>
#include <QLabel>
#include <QTableWidget>
#include <QHeaderView>
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit b81c83a

Please sign in to comment.