Skip to content
Permalink
Browse files

allow to copy all line measurements at once (fix #20498)

  • Loading branch information
alexbruy authored and nyalldawson committed Jul 30, 2020
1 parent 0348ab0 commit c942185947c688eff9fa68eaac27e40898f51b6d
Showing with 23 additions and 0 deletions.
  1. +20 −0 src/app/qgsmeasuredialog.cpp
  2. +3 −0 src/app/qgsmeasuredialog.h
@@ -27,6 +27,7 @@
#include "qgssettings.h"
#include "qgsgui.h"

#include <QClipboard>
#include <QCloseEvent>
#include <QLocale>
#include <QPushButton>
@@ -55,6 +56,13 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool *tool, Qt::WindowFlags f )
buttonBox->addButton( cb, QDialogButtonBox::ActionRole );
connect( cb, &QAbstractButton::clicked, this, &QgsMeasureDialog::openConfigTab );

if ( !mMeasureArea )
{
QPushButton *cpb = new QPushButton( tr( "Copy &All" ) );
buttonBox->addButton( cpb, QDialogButtonBox::ActionRole );
connect( cpb, &QAbstractButton::clicked, this, &QgsMeasureDialog::copyMeasurements );
}

repopulateComboBoxUnits( mMeasureArea );
if ( mMeasureArea )
{
@@ -646,6 +654,18 @@ double QgsMeasureDialog::convertArea( double area, QgsUnitTypes::AreaUnit toUnit
return mDa.convertAreaMeasurement( area, toUnit );
}

void QgsMeasureDialog::copyMeasurements()
{
QClipboard *clipboard = QApplication::clipboard();
QString text;
QTreeWidgetItemIterator it( mTable );
while ( *it )
{
text += ( *it )->text( 0 ) + QStringLiteral( "\n" );
it++;
}
clipboard->setText( text );
}

void QgsMeasureDialog::reject()
{
@@ -70,6 +70,9 @@ class APP_EXPORT QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase
//! Open configuration tab
void openConfigTab();

//! Copy measurements to the clipboard
void copyMeasurements();

void crsChanged();

void projChanged();

0 comments on commit c942185

Please sign in to comment.
You can’t perform that action at this time.