Skip to content

Commit

Permalink
Don't restrict adding crs selections to list of recent CRSes to only
Browse files Browse the repository at this point in the history
a few select dialogs

If the user has gone to the trouble of picking a CRS from the dialog,
it should ALWAYS be pushed to the list of recently used CRS, regardless
of whether they've done it from project properties, layer properties,
some processing algorithm, etc...
  • Loading branch information
nyalldawson committed Jun 16, 2021
1 parent dfe9820 commit 870945c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
Expand Up @@ -147,9 +147,12 @@ by the given Coordinate Reference Systems.
This function's behavior is undefined if it is called after the widget is shown.
%End

void pushProjectionToFront();
void pushProjectionToFront() /Deprecated/;
%Docstring
Marks the current selected projection for push to front of recent projections list.

.. deprecated::
Has no effect since QGIS 3.20
%End

signals:
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -1072,9 +1072,6 @@ void QgsProjectProperties::apply()
{
QgsDebugMsgLevel( QStringLiteral( "CRS set to no projection!" ), 4 );
}

// mark selected projection for push to front
projectionSelector->pushProjectionToFront();
}

mMetadataWidget->acceptMetadata();
Expand Down
25 changes: 4 additions & 21 deletions src/gui/qgsprojectionselectiontreewidget.cpp
Expand Up @@ -51,12 +51,6 @@ QgsProjectionSelectionTreeWidget::QgsProjectionSelectionTreeWidget( QWidget *par

mAreaCanvas->setVisible( mShowMap );

if ( QDialog *dlg = qobject_cast<QDialog *>( parent ) )
{
// mark selected projection for push to front if parent dialog is accepted
connect( dlg, &QDialog::accepted, this, &QgsProjectionSelectionTreeWidget::pushProjectionToFront );
}

// Get the full path name to the sqlite3 spatial reference database.
mSrsDatabaseFileName = QgsApplication::srsDatabaseFilePath();

Expand Down Expand Up @@ -100,20 +94,13 @@ QgsProjectionSelectionTreeWidget::QgsProjectionSelectionTreeWidget( QWidget *par

QgsProjectionSelectionTreeWidget::~QgsProjectionSelectionTreeWidget()
{
if ( !mPushProjectionToFront )
{
return;
}

// Push current projection to front, only if set
long crsId = selectedCrsId();
if ( crsId == 0 )
return;

QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/ProjectionSelector/splitterState" ), mSplitter->saveState() );

QgsCoordinateReferenceSystem::pushRecentCoordinateReferenceSystem( crs() );
// Push current projection to front, only if set
const QgsCoordinateReferenceSystem selectedCrs = crs();
if ( selectedCrs.isValid() )
QgsCoordinateReferenceSystem::pushRecentCoordinateReferenceSystem( selectedCrs );
}

void QgsProjectionSelectionTreeWidget::resizeEvent( QResizeEvent *event )
Expand Down Expand Up @@ -850,14 +837,10 @@ void QgsProjectionSelectionTreeWidget::updateFilter()
filterTreeWidget( lstCoordinateSystems );
}


void QgsProjectionSelectionTreeWidget::pushProjectionToFront()
{
// set flag to push selected projection to front in destructor
mPushProjectionToFront = true;
}


long QgsProjectionSelectionTreeWidget::getLargestCrsIdMatch( const QString &sql )
{
long srsId = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsprojectionselectiontreewidget.h
Expand Up @@ -140,8 +140,10 @@ class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::

/**
* Marks the current selected projection for push to front of recent projections list.
*
* \deprecated Has no effect since QGIS 3.20
*/
void pushProjectionToFront();
Q_DECL_DEPRECATED void pushProjectionToFront() SIP_DEPRECATED;

signals:

Expand Down Expand Up @@ -292,8 +294,6 @@ class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::
int mSearchColumn = QgsProjectionSelectionTreeWidget::None;
QString mSearchValue;

bool mPushProjectionToFront = false;

//! The set of OGC WMS CRSs that want to be applied to this widget
QSet<QString> mCrsFilter;

Expand Down

0 comments on commit 870945c

Please sign in to comment.