Skip to content

Commit

Permalink
Only enable edit datum transform button when a transform is selected
Browse files Browse the repository at this point in the history
Sponsored by ICSM
  • Loading branch information
nyalldawson committed Mar 19, 2019
1 parent 8a1ba51 commit c8d15d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/app/qgsdatumtransformtablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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();
}
}

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

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

void QgsDatumTransformTableWidget::selectionChanged( const QItemSelection &, const QItemSelection & )
{
mEditButton->setEnabled( !mTableView->selectionModel()->selection().empty() );
}
5 changes: 4 additions & 1 deletion src/app/qgsdatumtransformtablewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class APP_EXPORT QgsDatumTransformTableModel : public QAbstractTableModel
};

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

void setTransformContext( const QgsCoordinateTransformContext &context );

Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit c8d15d6

Please sign in to comment.