Skip to content
Permalink
Browse files

Only enable edit datum transform button when a transform is selected

Sponsored by ICSM
  • Loading branch information
nyalldawson committed Mar 12, 2019
1 parent 8a1ba51 commit c8d15d61cee03d8a679432302592054524579e0b
Showing with 14 additions and 1 deletion.
  1. +10 −0 src/app/qgsdatumtransformtablewidget.cpp
  2. +4 −1 src/app/qgsdatumtransformtablewidget.h
@@ -188,6 +188,9 @@ QgsDatumTransformTableWidget::QgsDatumTransformTableWidget( QWidget *parent )
connect( mAddButton, &QToolButton::clicked, this, &QgsDatumTransformTableWidget::addDatumTransform );
connect( mRemoveButton, &QToolButton::clicked, this, &QgsDatumTransformTableWidget::removeDatumTransform );
connect( mEditButton, &QToolButton::clicked, this, &QgsDatumTransformTableWidget::editDatumTransform );

connect( mTableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsDatumTransformTableWidget::selectionChanged );
mEditButton->setEnabled( false );
}

void QgsDatumTransformTableWidget::addDatumTransform()
@@ -199,6 +202,7 @@ void QgsDatumTransformTableWidget::addDatumTransform()
QgsCoordinateTransformContext context = mModel->transformContext();
context.addSourceDestinationDatumTransform( dt.first.first, dt.second.first, dt.first.second, dt.second.second );
mModel->setTransformContext( context );
selectionChanged();
}
}

@@ -208,6 +212,7 @@ void QgsDatumTransformTableWidget::removeDatumTransform()
if ( selectedIndexes.count() > 0 )
{
mModel->removeTransform( selectedIndexes );
selectionChanged();
}
}

@@ -255,3 +260,8 @@ void QgsDatumTransformTableWidget::editDatumTransform()
}
}
}

void QgsDatumTransformTableWidget::selectionChanged( const QItemSelection &, const QItemSelection & )
{
mEditButton->setEnabled( !mTableView->selectionModel()->selection().empty() );
}
@@ -44,7 +44,6 @@ class APP_EXPORT QgsDatumTransformTableModel : public QAbstractTableModel
};

QgsDatumTransformTableModel( QObject *parent = nullptr );
~QgsDatumTransformTableModel() {}

void setTransformContext( const QgsCoordinateTransformContext &context );

@@ -96,6 +95,10 @@ class APP_EXPORT QgsDatumTransformTableWidget : public QWidget, private Ui::QgsD
//! edit currently selected datum transform
void editDatumTransform();

private slots:

void selectionChanged( const QItemSelection &selected = QItemSelection(), const QItemSelection &deselected = QItemSelection() );

private:
QgsDatumTransformTableModel *mModel = nullptr;
};

0 comments on commit c8d15d6

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