Skip to content
Permalink
Browse files

Use QgsCoordinateOperationWidget in QgsDatumTransformDialog

  • Loading branch information
nyalldawson committed Dec 19, 2019
1 parent 0cd49ca commit f0f63d3802a1f8bd0be59f2e7e508f3f01fcef4b
@@ -30,6 +30,8 @@ a source and destination coordinate reference system.
int destinationTransformId;

QString proj;

bool isAvailable;
};

QgsCoordinateOperationWidget( QWidget *parent = 0 );
@@ -84,6 +86,21 @@ the current canvas state.
void setShowMakeDefault( bool show );
%Docstring
Sets whether the "make default" checkbox should be shown.
%End

bool makeDefaultSelected() const;
%Docstring
Returns ``True`` if the "make default" option is selected.
%End

bool hasSelection() const;
%Docstring
Returns ``True`` if there is a valid selection in the widget.
%End

QList< QgsCoordinateOperationWidget::OperationDetails > availableOperations() const;
%Docstring
Returns a list of the available operations shown in the widget.
%End

QgsCoordinateOperationWidget::OperationDetails defaultOperation() const;
@@ -122,6 +122,42 @@ void QgsCoordinateOperationWidget::setShowMakeDefault( bool show )
mMakeDefaultCheckBox->setVisible( show );
}

bool QgsCoordinateOperationWidget::makeDefaultSelected() const
{
return mMakeDefaultCheckBox->isChecked();
}

bool QgsCoordinateOperationWidget::hasSelection() const
{
return !mCoordinateOperationTableWidget->selectedItems().isEmpty();
}

QList<QgsCoordinateOperationWidget::OperationDetails> QgsCoordinateOperationWidget::availableOperations() const
{
QList<QgsCoordinateOperationWidget::OperationDetails> res;
res.reserve( mDatumTransforms.size() );
#if PROJ_VERSION_MAJOR>=6
for ( const QgsDatumTransform::TransformDetails &details : mDatumTransforms )
{
OperationDetails op;
op.proj = details.proj;
op.sourceTransformId = -1;
op.destinationTransformId = -1;
op.isAvailable = details.isAvailable;
res << op;
}
#else
for ( const QgsDatumTransform::TransformPair &details : mDatumTransforms )
{
OperationDetails op;
op.sourceTransformId = details.sourceTransformId;
op.destinationTransformId = details.destinationTransformId;
res << op;
}
#endif
return res;
}

void QgsCoordinateOperationWidget::loadAvailableOperations()
{
mCoordinateOperationTableWidget->setRowCount( 0 );
@@ -442,6 +478,7 @@ QgsCoordinateOperationWidget::OperationDetails QgsCoordinateOperationWidget::def
if ( transform.isAvailable )
{
preferred.proj = transform.proj;
preferred.isAvailable = transform.isAvailable;
break;
}
}
@@ -532,6 +569,7 @@ QgsCoordinateOperationWidget::OperationDetails QgsCoordinateOperationWidget::sel
QTableWidgetItem *destItem = mCoordinateOperationTableWidget->item( row, 1 );
op.destinationTransformId = destItem ? destItem->data( TransformIdRole ).toInt() : -1;
op.proj = srcItem ? srcItem->data( ProjRole ).toString() : QString();
op.isAvailable = srcItem ? srcItem->data( AvailableRole ).toBool() : true;
}
else
{
@@ -46,6 +46,9 @@ class GUI_EXPORT QgsCoordinateOperationWidget : public QWidget, private Ui::QgsC

//! Proj coordinate operation description, for Proj >= 6.0 builds only
QString proj;

//! TRUE if operation is available
bool isAvailable = true;
};

/**
@@ -98,6 +101,21 @@ class GUI_EXPORT QgsCoordinateOperationWidget : public QWidget, private Ui::QgsC
*/
void setShowMakeDefault( bool show );

/**
* Returns TRUE if the "make default" option is selected.
*/
bool makeDefaultSelected() const;

/**
* Returns TRUE if there is a valid selection in the widget.
*/
bool hasSelection() const;

/**
* Returns a list of the available operations shown in the widget.
*/
QList< QgsCoordinateOperationWidget::OperationDetails > availableOperations() const;

/**
* Returns the details of the default operation suggested by the widget.
*/

0 comments on commit f0f63d3

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