Skip to content

Commit

Permalink
Remove QgsApplication::shortNameRegExp altogether, document API break
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jul 14, 2021
1 parent 03d99a4 commit a580968
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 30 deletions.
10 changes: 10 additions & 0 deletions doc/api_break.dox
Expand Up @@ -16,6 +16,16 @@ with too big impact should be deferred to a major version release.

This page tries to maintain a list with incompatible changes that happened in previous releases.

QGIS 3.22 {#qgis_api_break_3_22}
=========

QgsApplication {#qgis_api_break_3_22_qgsapplication}
--------------

- QgsApplication::shortNameRegExp function was removed as part of a general code migration away from deprecated
QRegExp class. It has been replaced with QgsApplication::shortNameRegularExpression which returns a
QRegularExpression object.

QGIS 3.20 {#qgis_api_break_3_20}
=========

Expand Down
8 changes: 0 additions & 8 deletions python/core/auto_generated/qgsapplication.sip.in
Expand Up @@ -380,14 +380,6 @@ colors are specified then the ``size`` argument also must be set.
Returns the path to user's style.
%End


static QRegExp shortNameRegExp() /Deprecated/;
%Docstring
Returns the short name regular expression for line edit validator

.. deprecated:: QGIS 3.22
%End

static QRegularExpression shortNameRegularExpression();
%Docstring
Returns the short name regular expression for line edit validator
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsprojectproperties.cpp
Expand Up @@ -81,6 +81,7 @@
#include <QDesktopServices>
#include <QAbstractListModel>
#include <QList>
#include <QRegularExpressionValidator>

const char *QgsProjectProperties::GEO_NONE_DESC = QT_TRANSLATE_NOOP( "QgsOptions", "None / Planimetric" );

Expand Down Expand Up @@ -467,7 +468,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mWMSOnlineResourceExpressionButton->setToProperty( QgsProject::instance()->dataDefinedServerProperties().property( QgsProject::DataDefinedServerProperty::WMSOnlineResource ) );

// WMS Name validator
QValidator *shortNameValidator = new QRegExpValidator( QgsApplication::shortNameRegExp(), this );
QValidator *shortNameValidator = new QRegularExpressionValidator( QgsApplication::shortNameRegularExpression(), this );
mWMSName->setValidator( shortNameValidator );

// WMS Contact Position
Expand Down
8 changes: 0 additions & 8 deletions src/core/qgsapplication.cpp
Expand Up @@ -1178,14 +1178,6 @@ QString QgsApplication::userStylePath()
return qgisSettingsDirPath() + QStringLiteral( "symbology-style.db" );
}

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QRegExp QgsApplication::shortNameRegExp()
{
const thread_local QRegExp regexp( QStringLiteral( "^[A-Za-z][A-Za-z0-9\\._-]*" ) );
return regexp;
}
#endif

QRegularExpression QgsApplication::shortNameRegularExpression()
{
const thread_local QRegularExpression regexp( QRegularExpression::anchoredPattern( QStringLiteral( "^[A-Za-z][A-Za-z0-9\\._-]*" ) ) );
Expand Down
9 changes: 0 additions & 9 deletions src/core/qgsapplication.h
Expand Up @@ -404,15 +404,6 @@ class CORE_EXPORT QgsApplication : public QApplication
//! Returns the path to user's style.
static QString userStylePath();

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)

/**
* Returns the short name regular expression for line edit validator
* \deprecated since QGIS 3.22
*/
static QRegExp shortNameRegExp() SIP_DEPRECATED;
#endif

/**
* Returns the short name regular expression for line edit validator
* \since QGIS 3.22
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsgroupwmsdatadialog.cpp
Expand Up @@ -16,14 +16,14 @@
#include "qgsapplication.h"
#include "qgsgroupwmsdatadialog.h"

#include <QRegExpValidator>
#include <QRegularExpressionValidator>

QgsGroupWmsDataDialog::QgsGroupWmsDataDialog( QWidget *parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
{
setupUi( this );
// WMS Name validator
QValidator *shortNameValidator = new QRegExpValidator( QgsApplication::shortNameRegExp(), this );
QValidator *shortNameValidator = new QRegularExpressionValidator( QgsApplication::shortNameRegularExpression(), this );
mShortNameLineEdit->setValidator( shortNameValidator );
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/raster/qgsrasterlayerproperties.cpp
Expand Up @@ -87,6 +87,7 @@
#include <QUrl>
#include <QMenu>
#include <QScreen>
#include <QRegularExpressionValidator>

QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent, Qt::WindowFlags fl )
: QgsOptionsDialogBase( QStringLiteral( "RasterLayerProperties" ), parent, fl )
Expand Down Expand Up @@ -869,7 +870,7 @@ void QgsRasterLayerProperties::sync()
// WMS Name as layer short name
mLayerShortNameLineEdit->setText( mRasterLayer->shortName() );
// WMS Name validator
QValidator *shortNameValidator = new QRegExpValidator( QgsApplication::shortNameRegExp(), this );
QValidator *shortNameValidator = new QRegularExpressionValidator( QgsApplication::shortNameRegularExpression(), this );
mLayerShortNameLineEdit->setValidator( shortNameValidator );

//layer title and abstract
Expand Down
3 changes: 2 additions & 1 deletion src/gui/vector/qgsvectorlayerproperties.cpp
Expand Up @@ -87,6 +87,7 @@
#include <QColorDialog>
#include <QMenu>
#include <QUrl>
#include <QRegularExpressionValidator>

#include "qgsrendererpropertiesdialog.h"
#include "qgsstyle.h"
Expand Down Expand Up @@ -323,7 +324,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
// WMS Name as layer short name
mLayerShortNameLineEdit->setText( mLayer->shortName() );
// WMS Name validator
QValidator *shortNameValidator = new QRegExpValidator( QgsApplication::shortNameRegExp(), this );
QValidator *shortNameValidator = new QRegularExpressionValidator( QgsApplication::shortNameRegularExpression(), this );
mLayerShortNameLineEdit->setValidator( shortNameValidator );

//layer title and abstract
Expand Down

0 comments on commit a580968

Please sign in to comment.