diff --git a/src/gui/proj/qgscoordinatereferencesystemmodel.cpp b/src/gui/proj/qgscoordinatereferencesystemmodel.cpp index 5be20f7c07df..daf8fba5b3b1 100644 --- a/src/gui/proj/qgscoordinatereferencesystemmodel.cpp +++ b/src/gui/proj/qgscoordinatereferencesystemmodel.cpp @@ -716,7 +716,15 @@ bool QgsCoordinateReferenceSystemProxyModel::filterAcceptsRow( int sourceRow, co if ( !mFilterString.trimmed().isEmpty() ) { const QString name = sourceModel()->data( sourceIndex, static_cast( QgsCoordinateReferenceSystemModel::CustomRole::Name ) ).toString(); - if ( !( QgsStringUtils::containsByWord( name, mFilterString ) + QString candidate = name; + const QString groupName = sourceModel()->data( sourceIndex, static_cast( QgsCoordinateReferenceSystemModel::CustomRole::Group ) ).toString(); + if ( !groupName.isEmpty() ) + candidate += ' ' + groupName; + const QString projectionName = sourceModel()->data( sourceIndex, static_cast( QgsCoordinateReferenceSystemModel::CustomRole::Projection ) ).toString(); + if ( !projectionName.isEmpty() ) + candidate += ' ' + projectionName; + + if ( !( QgsStringUtils::containsByWord( candidate, mFilterString ) || authid.contains( mFilterString, Qt::CaseInsensitive ) ) ) return false; } diff --git a/tests/src/python/test_qgscoordinatereferencesystemmodel.py b/tests/src/python/test_qgscoordinatereferencesystemmodel.py index 292728664095..909d6369d999 100644 --- a/tests/src/python/test_qgscoordinatereferencesystemmodel.py +++ b/tests/src/python/test_qgscoordinatereferencesystemmodel.py @@ -775,6 +775,35 @@ def test_proxy_model(self): ][0] self.assertTrue(epsg_4347_index.isValid()) + model.setFilterString("equal gda2020 Area") + projected_index = [ + model.index(row, 0, QModelIndex()) + for row in range(model.rowCount(QModelIndex())) + if model.data( + model.index(row, 0, QModelIndex()), + QgsCoordinateReferenceSystemModel.Roles.RoleGroupId, + ) + == "Projected" + ][0] + aae_index = [ + model.index(row, 0, projected_index) + for row in range(model.rowCount(projected_index)) + if model.data( + model.index(row, 0, projected_index), + Qt.DisplayRole, + ) + == "Albers Equal Area" + ][0] + epsg_9473_index = [ + model.index(row, 0, aae_index) + for row in range(model.rowCount(aae_index)) + if model.data( + model.index(row, 0, aae_index), + QgsCoordinateReferenceSystemModel.Roles.RoleAuthId, + ) + == "EPSG:9473" + ][0] + model.setFilterString("") # set filtered list of crs to show