Skip to content

Commit

Permalink
allow to copy all line measurements at once (fix #20498)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and nyalldawson committed Jul 30, 2020
1 parent 0348ab0 commit c942185
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/app/qgsmeasuredialog.cpp
Expand Up @@ -27,6 +27,7 @@
#include "qgssettings.h"
#include "qgsgui.h"

#include <QClipboard>
#include <QCloseEvent>
#include <QLocale>
#include <QPushButton>
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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()
{
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsmeasuredialog.h
Expand Up @@ -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();
Expand Down

0 comments on commit c942185

Please sign in to comment.