Skip to content
Permalink
Browse files

Make custom projections dialog a bit more user friendly

...by updating the list immediately when changes are made to the
current projection's name or definition. Previously the list
was only updated when a new item in the list was clicked, but that
made it appear as though the current changes were not applied
immediately and left users looking for a "save" button to actually
lock-in their changes.

By updating the list immediately we make it obvious that the
changes apply immediately and no further action is required (except
for hitting OK on the dialog!)
  • Loading branch information
nyalldawson committed Nov 7, 2017
1 parent e45c294 commit 2d9b5738424fad68747b2e2afbd38ceaa404fa96
Showing with 26 additions and 4 deletions.
  1. +22 −4 src/app/qgscustomprojectiondialog.cpp
  2. +4 −0 src/app/qgscustomprojectiondialog.h
@@ -185,13 +185,15 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget *parent, Qt::Windo
populateList();
if ( !mCustomCRSnames.empty() )
{
leName->setText( mCustomCRSnames[0] );
teParameters->setPlainText( mCustomCRSparameters[0] );
whileBlocking( leName )->setText( mCustomCRSnames[0] );
whileBlocking( teParameters )->setPlainText( mCustomCRSparameters[0] );
leNameList->setCurrentItem( leNameList->topLevelItem( 0 ) );
}

leNameList->hideColumn( QgisCrsIdColumn );

connect( leName, &QLineEdit::textChanged, this, &QgsCustomProjectionDialog::updateListFromCurrentItem );
connect( teParameters, &QPlainTextEdit::textChanged, this, &QgsCustomProjectionDialog::updateListFromCurrentItem );
}

QgsCustomProjectionDialog::~QgsCustomProjectionDialog()
@@ -451,8 +453,8 @@ void QgsCustomProjectionDialog::leNameList_currentItemChanged( QTreeWidgetItem *
if ( current )
{
currentIndex = leNameList->indexOfTopLevelItem( current );
leName->setText( mCustomCRSnames[currentIndex] );
teParameters->setPlainText( current->text( QgisCrsParametersColumn ) );
whileBlocking( leName )->setText( mCustomCRSnames[currentIndex] );
whileBlocking( teParameters )->setPlainText( current->text( QgisCrsParametersColumn ) );
}
else
{
@@ -541,6 +543,22 @@ void QgsCustomProjectionDialog::buttonBox_accepted()
}
}

void QgsCustomProjectionDialog::updateListFromCurrentItem()
{
QTreeWidgetItem *item = leNameList->currentItem();
if ( !item )
return;

int currentIndex = leNameList->indexOfTopLevelItem( item );
if ( currentIndex < 0 )
return;

mCustomCRSnames[currentIndex] = leName->text();
mCustomCRSparameters[currentIndex] = teParameters->toPlainText();
item->setText( QgisCrsNameColumn, leName->text() );
item->setText( QgisCrsParametersColumn, teParameters->toPlainText() );
}

void QgsCustomProjectionDialog::pbnCalculate_clicked()
{
// We must check the prj def is valid!
@@ -43,6 +43,10 @@ class APP_EXPORT QgsCustomProjectionDialog : public QDialog, private Ui::QgsCust
void leNameList_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
void buttonBox_accepted();

private slots:

void updateListFromCurrentItem();

private:

//helper functions

0 comments on commit 2d9b573

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