Skip to content
Permalink
Browse files

Add units selector to measure dialog. Add info text to dialog

  • Loading branch information
NathanW2 committed Jan 1, 2015
1 parent 246de9f commit 53c4c8f0aa41d4674f540bdb3829177cb00641de
Showing with 60 additions and 17 deletions.
  1. +19 −1 src/app/qgsmeasuredialog.cpp
  2. +3 −0 src/app/qgsmeasuredialog.h
  3. +38 −16 src/ui/qgsmeasurebase.ui
@@ -43,7 +43,15 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WindowFlags f )
mMeasureArea = tool->measureArea();
mTotal = 0.;

mUnitsCombo->addItem( "Meters");
mUnitsCombo->addItem( "Feet");
mUnitsCombo->addItem( "Degrees");
mUnitsCombo->addItem( "Nautical Miles");
mUnitsCombo->setCurrentIndex( 0 );

updateSettings();

connect( mUnitsCombo, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( unitsChanged( const QString & ) ) );
}

void QgsMeasureDialog::updateSettings()
@@ -52,7 +60,7 @@ void QgsMeasureDialog::updateSettings()

mDecimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();
mCanvasUnits = mTool->canvas()->mapUnits();
mDisplayUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );
mDisplayUnits = QGis::fromLiteral( mUnitsCombo->currentText().toLower() );
// Configure QgsDistanceArea
mDa.setSourceCrs( mTool->canvas()->mapSettings().destinationCrs().srsid() );
mDa.setEllipsoid( QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ) );
@@ -77,6 +85,14 @@ void QgsMeasureDialog::updateSettings()
updateUi();
}

void QgsMeasureDialog::unitsChanged(const QString &units)
{
mDisplayUnits = QGis::fromLiteral( units.toLower() );
mTable->clear();
mTotal = 0.;
updateUi();
}

void QgsMeasureDialog::restart()
{
mTool->restart();
@@ -221,6 +237,7 @@ QString QgsMeasureDialog::formatDistance( double distance )
QSettings settings;
bool baseUnit = settings.value( "/qgis/measure/keepbaseunit", false ).toBool();

QgsDebugMsg( mUnitsCombo->currentText().toLower() );
QGis::UnitType newDisplayUnits;
convertMeasurement( distance, newDisplayUnits, false );
return QgsDistanceArea::textUnit( distance, mDecimalPlaces, newDisplayUnits, false, baseUnit );
@@ -269,6 +286,7 @@ void QgsMeasureDialog::updateUi()

editTotal->setToolTip( toolTip );
mTable->setToolTip( toolTip );
mNotesLabel->setText( toolTip );

QGis::UnitType newDisplayUnits;
double dummy = 1.0;
@@ -66,6 +66,9 @@ class APP_EXPORT QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase
//! When any external settings change
void updateSettings();

private slots:
void unitsChanged( const QString &units );

private:

//! formats distance to most appropriate units
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>281</width>
<height>272</height>
<width>359</width>
<height>301</height>
</rect>
</property>
<property name="baseSize">
@@ -25,13 +25,32 @@
</iconset>
</property>
<layout class="QGridLayout">
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="2" column="2">
<item row="4" column="0">
<widget class="QLabel" name="textLabel2">
<property name="text">
<string>Total</string>
</property>
<property name="buddy">
<cstring>editTotal</cstring>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="editTotal">
<property name="font">
<font>
@@ -47,7 +66,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="4" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -63,17 +82,10 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="textLabel2">
<property name="text">
<string>Total</string>
</property>
<property name="buddy">
<cstring>editTotal</cstring>
</property>
</widget>
<item row="4" column="3">
<widget class="QComboBox" name="mUnitsCombo"/>
</item>
<item row="1" column="0" colspan="3">
<item row="2" column="0" colspan="4">
<widget class="QTreeWidget" name="mTable">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
@@ -91,7 +103,17 @@
</column>
</widget>
</item>
<item row="3" column="2">
<item row="5" column="0" colspan="4">
<widget class="QLabel" name="mNotesLabel">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="4">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>

0 comments on commit 53c4c8f

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