Skip to content
Permalink
Browse files

allow editing transform in project properties

  • Loading branch information
3nids authored and nyalldawson committed Nov 29, 2017
1 parent eb71750 commit 8798cf068067e0a99663438f2802b03897b00763
@@ -99,6 +99,16 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
break;
}
break;
case Qt::UserRole:
switch ( index.column() )
{
case SourceTransformColumn:
return sourceTransform;
case DestinationTransformColumn:
return destinationTransform;
default:
break;
}
default:
break;
}
@@ -165,6 +165,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mDatumTransformTableView->setSelectionBehavior( QAbstractItemView::SelectRows );
connect( mDatumTransformAddButton, &QToolButton::clicked, this, &QgsProjectProperties::addDatumTransform );
connect( mDatumTransformRemoveButton, &QToolButton::clicked, this, &QgsProjectProperties::removeDatumTransform );
connect( mDatumTransformEditButton, &QToolButton::clicked, this, &QgsProjectProperties::editDatumTransform );

bool show = settings.value( QStringLiteral( "/Projections/showDatumTransformDialog" ), false ).toBool();
mShowDatumTransformDialogCheckBox->setChecked( show );
@@ -1254,6 +1255,51 @@ void QgsProjectProperties::removeDatumTransform()
}
}

void QgsProjectProperties::editDatumTransform()
{
QModelIndexList selectedIndexes = mDatumTransformTableView->selectionModel()->selectedIndexes();
if ( selectedIndexes.count() > 0 )
{
QgsCoordinateReferenceSystem sourceCrs;
QgsCoordinateReferenceSystem destinationCrs;
int sourceTransform = -1;
int destinationTransform = -1;
for ( QModelIndexList::const_iterator it = selectedIndexes.constBegin(); it != selectedIndexes.constEnd(); it ++ )
{
if ( it->column() == QgsDatumTransformTableModel::SourceCrsColumn )
{
sourceCrs = QgsCoordinateReferenceSystem( mDatumTransformTableModel->data( *it, Qt::DisplayRole ).toString() );
}
if ( it->column() == QgsDatumTransformTableModel::DestinationCrsColumn )
{
destinationCrs = QgsCoordinateReferenceSystem( mDatumTransformTableModel->data( *it, Qt::DisplayRole ).toString() );
}
if ( it->column() == QgsDatumTransformTableModel::SourceTransformColumn )
{
sourceTransform = mDatumTransformTableModel->data( *it, Qt::UserRole ).toInt();
}
if ( it->column() == QgsDatumTransformTableModel::DestinationTransformColumn )
{
destinationTransform = mDatumTransformTableModel->data( *it, Qt::UserRole ).toInt();
}
}
if ( sourceCrs.isValid() && destinationCrs.isValid() &&
( sourceTransform != -1 || destinationTransform != -1 ) )
{
QgsDatumTransformDialog *dlg = new QgsDatumTransformDialog( sourceCrs, destinationCrs, qMakePair( sourceTransform, destinationTransform ) );
if ( dlg->exec() )
{
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg->selectedDatumTransforms();
QgsCoordinateTransformContext context = mDatumTransformTableModel->transformContext();
// QMap::insert takes care of replacing existing value
context.addSourceDestinationDatumTransform( sourceCrs, destinationCrs, dt.first.second, dt.second.second );
mDatumTransformTableModel->setTransformContext( context );
}
}
}

}

void QgsProjectProperties::cbxWFSPubliedStateChanged( int aIdx )
{
QCheckBox *cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 1 ) );
@@ -76,6 +76,9 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
//! remove currently selected datum transform
void removeDatumTransform();

//! edit currently selected datum transform
void editDatumTransform();

/**
* Let the user add a scale to the list of project scales
* used in scale combobox instead of global ones */
@@ -25,13 +25,18 @@
#include <QDir>
#include <QPushButton>

QgsDatumTransformDialog::QgsDatumTransformDialog( QgsCoordinateReferenceSystem sourceCrs,
QgsCoordinateReferenceSystem destinationCrs,
QWidget *parent, Qt::WindowFlags f )
QgsDatumTransformDialog::QgsDatumTransformDialog( const QgsCoordinateReferenceSystem &sourceCrs,
const QgsCoordinateReferenceSystem &destinationCrs,
QPair<int, int> selectedDatumTransforms,
QWidget *parent,
Qt::WindowFlags f )
: QDialog( parent, f )
{
setupUi( this );

mSourceProjectionSelectionWidget->setCrs( sourceCrs );
mDestinationProjectionSelectionWidget->setCrs( destinationCrs );

connect( mHideDeprecatedCheckBox, &QCheckBox::stateChanged, this, &QgsDatumTransformDialog::mHideDeprecatedCheckBox_stateChanged );
connect( mDatumTransformTreeWidget, &QTreeWidget::currentItemChanged, this, &QgsDatumTransformDialog::mDatumTransformTreeWidget_currentItemChanged );

@@ -59,10 +64,10 @@ QgsDatumTransformDialog::QgsDatumTransformDialog( QgsCoordinateReferenceSystem s
mDatumTransformTreeWidget->setColumnWidth( i, settings.value( QStringLiteral( "Windows/DatumTransformDialog/columnWidths/%1" ).arg( i ), mDatumTransformTreeWidget->columnWidth( i ) ).toInt() );
}

load();
load( selectedDatumTransforms );
}

void QgsDatumTransformDialog::load()
void QgsDatumTransformDialog::load( const QPair<int, int> &selectedDatumTransforms )
{
QgsDebugMsg( "Entered." );

@@ -128,6 +133,11 @@ void QgsDatumTransformDialog::load()
{
item->setDisabled( itemDisabled );
mDatumTransformTreeWidget->addTopLevelItem( item );
if ( it->at( 0 ) == selectedDatumTransforms.first &&
it->at( 1 ) == selectedDatumTransforms.second )
{
mDatumTransformTreeWidget->setCurrentItem( item );
}
}
else
{
@@ -37,9 +37,11 @@ class GUI_EXPORT QgsDatumTransformDialog : public QDialog, private Ui::QgsDatumT
/**
* Constructor for QgsDatumTransformDialog.
*/
QgsDatumTransformDialog( QgsCoordinateReferenceSystem sourceCrs = QgsCoordinateReferenceSystem(),
QgsCoordinateReferenceSystem destinationCrs = QgsCoordinateReferenceSystem(),
QWidget *parent = nullptr, Qt::WindowFlags f = nullptr );
QgsDatumTransformDialog( const QgsCoordinateReferenceSystem &sourceCrs = QgsCoordinateReferenceSystem(),
const QgsCoordinateReferenceSystem &destinationCrs = QgsCoordinateReferenceSystem(),
QPair<int, int> selectedDatumTransforms = qMakePair( -1, -1 ),
QWidget *parent = nullptr,
Qt::WindowFlags f = nullptr );
~QgsDatumTransformDialog();

/**
@@ -64,7 +66,7 @@ class GUI_EXPORT QgsDatumTransformDialog : public QDialog, private Ui::QgsDatumT
bool gridShiftTransformation( const QString &itemText ) const;
//! Returns false if the location of the grid shift files is known (PROJ_LIB) and the shift file is not there
bool testGridShiftFileAvailability( QTreeWidgetItem *item, int col ) const;
void load();
void load( const QPair<int, int> &selectedDatumTransforms = qMakePair( -1, -1 ) );
void setOKButtonEnabled();


0 comments on commit 8798cf0

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