Skip to content

Commit

Permalink
Make custom projections dialog a bit more user friendly
Browse files Browse the repository at this point in the history
...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 2d9b573
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/app/qgscustomprojectiondialog.cpp
Expand Up @@ -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()
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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!
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgscustomprojectiondialog.h
Expand Up @@ -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
Expand Down

0 comments on commit 2d9b573

Please sign in to comment.