Skip to content

Commit

Permalink
Option to remember selected datum transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Nov 11, 2013
1 parent 3278114 commit 7c98970
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/gui/qgsdatumtransformdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ QList< int > QgsDatumTransformDialog::selectedDatumTransform()
}
return list;
}

bool QgsDatumTransformDialog::rememberSelection() const
{
return mRememberSelectionCheckBox->isChecked();
}
3 changes: 3 additions & 0 deletions src/gui/qgsdatumtransformdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class GUI_EXPORT QgsDatumTransformDialog: public QDialog, private Ui::QgsDatumTr
~QgsDatumTransformDialog();

QList< int > selectedDatumTransform();

bool rememberSelection() const;

private:
QgsDatumTransformDialog();
};
Expand Down
17 changes: 17 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ email : sherman at mrcc.com
#include <QPaintEvent>
#include <QPixmap>
#include <QRect>
#include <QSettings>
#include <QTextStream>
#include <QResizeEvent>
#include <QString>
Expand Down Expand Up @@ -1555,6 +1556,17 @@ void QgsMapCanvas::getDatumTransformInfo( const QgsMapLayer* ml, const QString&
return;
}

//check if default datum transformation available
QSettings s;
QString settingsString = "/Projections/" + srcAuthId + "//" + destAuthId;
QVariant defaultSrcTransform = s.value( settingsString + "_srcTransform" );
QVariant defaultDestTransform = s.value( settingsString + "_destTransform" );
if ( defaultSrcTransform.isValid() && defaultDestTransform.isValid() )
{
mMapRenderer->addLayerCoordinateTransform( ml->id(), srcAuthId, destAuthId, defaultSrcTransform.toInt(), defaultDestTransform.toInt() );
return;
}

const QgsCoordinateReferenceSystem& srcCRS = QgsCRSCache::instance()->crsByAuthId( srcAuthId );
const QgsCoordinateReferenceSystem& destCRS = QgsCRSCache::instance()->crsByAuthId( destAuthId );

Expand All @@ -1581,6 +1593,11 @@ void QgsMapCanvas::getDatumTransformInfo( const QgsMapLayer* ml, const QString&
destTransform = t.at( 1 );
}
mMapRenderer->addLayerCoordinateTransform( ml->id(), srcAuthId, destAuthId, srcTransform, destTransform );
if ( d.rememberSelection() )
{
s.setValue( settingsString + "_srcTransform", srcTransform );
s.setValue( settingsString + "_destTransform", destTransform );
}
}
else
{
Expand Down
19 changes: 13 additions & 6 deletions src/ui/qgsdatumtransformdialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
<string>Select datum transformations</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTreeWidget" name="mDatumTransformTreeWidget">
<column>
Expand All @@ -34,12 +44,9 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<widget class="QCheckBox" name="mRememberSelectionCheckBox">
<property name="text">
<string>Remember selection</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 7c98970

Please sign in to comment.