forked from qt-creator/qt-creator
ExtensionSystem: Port PluginSpec to QRegularExpression
Task-number: 24098 Change-Id: I8dcdc736962eef949c54e457f06d9dbdb4efb054 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
#include <QDir>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
/*!
|
||||
\class ExtensionSystem::PluginDetailsView
|
||||
@@ -101,8 +101,8 @@ void PluginDetailsView::update(PluginSpec *spec)
|
||||
m_ui->description->setText(spec->description());
|
||||
m_ui->copyright->setText(spec->copyright());
|
||||
m_ui->license->setText(spec->license());
|
||||
const QRegExp platforms = spec->platformSpecification();
|
||||
const QString pluginPlatformString = platforms.isEmpty() ? tr("All") : platforms.pattern();
|
||||
const QRegularExpression platforms = spec->platformSpecification();
|
||||
const QString pluginPlatformString = platforms.pattern().isEmpty() ? tr("All") : platforms.pattern();
|
||||
const QString platformString = tr("%1 (current: \"%2\")").arg(pluginPlatformString,
|
||||
PluginManager::platformName());
|
||||
m_ui->platforms->setText(platformString);
|
||||
|
@@ -44,7 +44,6 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QPluginLoader>
|
||||
#include <QRegExp>
|
||||
|
||||
/*!
|
||||
\class ExtensionSystem::PluginDependency
|
||||
@@ -283,12 +282,12 @@ QString PluginSpec::category() const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a QRegExp matching the platforms this plugin works on. An empty
|
||||
pattern implies all platforms.
|
||||
Returns a QRegularExpression matching the platforms this plugin works on.
|
||||
An empty pattern implies all platforms.
|
||||
\since 3.0
|
||||
*/
|
||||
|
||||
QRegExp PluginSpec::platformSpecification() const
|
||||
QRegularExpression PluginSpec::platformSpecification() const
|
||||
{
|
||||
return d->platformSpecification;
|
||||
}
|
||||
@@ -298,8 +297,8 @@ QRegExp PluginSpec::platformSpecification() const
|
||||
*/
|
||||
bool PluginSpec::isAvailableForHostPlatform() const
|
||||
{
|
||||
return d->platformSpecification.isEmpty()
|
||||
|| d->platformSpecification.indexIn(PluginManager::platformName()) >= 0;
|
||||
return d->platformSpecification.pattern().isEmpty()
|
||||
|| d->platformSpecification.match(PluginManager::platformName()).hasMatch();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -894,9 +893,9 @@ bool PluginSpecPrivate::provides(const QString &pluginName, const QString &plugi
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
const QRegExp &PluginSpecPrivate::versionRegExp()
|
||||
const QRegularExpression &PluginSpecPrivate::versionRegExp()
|
||||
{
|
||||
static const QRegExp reg(QLatin1String("([0-9]+)(?:[.]([0-9]+))?(?:[.]([0-9]+))?(?:_([0-9]+))?"));
|
||||
static const QRegularExpression reg("^([0-9]+)(?:[.]([0-9]+))?(?:[.]([0-9]+))?(?:_([0-9]+))?$");
|
||||
return reg;
|
||||
}
|
||||
/*!
|
||||
@@ -904,7 +903,7 @@ const QRegExp &PluginSpecPrivate::versionRegExp()
|
||||
*/
|
||||
bool PluginSpecPrivate::isValidVersion(const QString &version)
|
||||
{
|
||||
return versionRegExp().exactMatch(version);
|
||||
return versionRegExp().match(version).hasMatch();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -912,17 +911,15 @@ bool PluginSpecPrivate::isValidVersion(const QString &version)
|
||||
*/
|
||||
int PluginSpecPrivate::versionCompare(const QString &version1, const QString &version2)
|
||||
{
|
||||
QRegExp reg1 = versionRegExp();
|
||||
QRegExp reg2 = versionRegExp();
|
||||
if (!reg1.exactMatch(version1))
|
||||
const QRegularExpressionMatch match1 = versionRegExp().match(version1);
|
||||
const QRegularExpressionMatch match2 = versionRegExp().match(version2);
|
||||
if (!match1.hasMatch())
|
||||
return 0;
|
||||
if (!reg2.exactMatch(version2))
|
||||
if (!match2.hasMatch())
|
||||
return 0;
|
||||
int number1;
|
||||
int number2;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
number1 = reg1.cap(i+1).toInt();
|
||||
number2 = reg2.cap(i+1).toInt();
|
||||
const int number1 = match1.captured(i + 1).toInt();
|
||||
const int number2 = match2.captured(i + 1).toInt();
|
||||
if (number1 < number2)
|
||||
return -1;
|
||||
if (number1 > number2)
|
||||
|
@@ -33,7 +33,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QStringList;
|
||||
class QRegExp;
|
||||
class QRegularExpression;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ExtensionSystem {
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
QString description() const;
|
||||
QString url() const;
|
||||
QString category() const;
|
||||
QRegExp platformSpecification() const;
|
||||
QRegularExpression platformSpecification() const;
|
||||
bool isAvailableForHostPlatform() const;
|
||||
bool isRequired() const;
|
||||
bool isHiddenByDefault() const;
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
#include <QPluginLoader>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <QXmlStreamReader>
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
QString description;
|
||||
QString url;
|
||||
QString category;
|
||||
QRegExp platformSpecification;
|
||||
QRegularExpression platformSpecification;
|
||||
QVector<PluginDependency> dependencies;
|
||||
QJsonObject metaData;
|
||||
bool enabledBySettings = true;
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
PluginSpec *q;
|
||||
|
||||
bool reportError(const QString &err);
|
||||
static const QRegExp &versionRegExp();
|
||||
static const QRegularExpression &versionRegExp();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user