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