Redesign Version class

PR #17484.
This commit is contained in:
Chocobo1 2022-08-06 11:06:16 +08:00 committed by GitHub
parent 54b50c3a8a
commit 33e6ca6778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 178 additions and 178 deletions

View file

@ -52,25 +52,21 @@ namespace
{
bool isVersionMoreRecent(const QString &remoteVersion)
{
using Version = Utils::Version<int, 4, 3>;
using Version = Utils::Version<4, 3>;
try
{
const Version newVersion {remoteVersion};
const Version currentVersion {QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD};
if (newVersion == currentVersion)
{
const bool isDevVersion = QStringLiteral(QBT_VERSION_STATUS).contains(
QRegularExpression(u"(alpha|beta|rc)"_qs));
if (isDevVersion)
return true;
}
return (newVersion > currentVersion);
}
catch (const RuntimeError &)
{
const auto newVersion = Version::fromString(remoteVersion);
if (!newVersion.isValid())
return false;
const Version currentVersion {QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD};
if (newVersion == currentVersion)
{
const bool isDevVersion = QStringLiteral(QBT_VERSION_STATUS).contains(
QRegularExpression(u"(alpha|beta|rc)"_qs));
if (isDevVersion)
return true;
}
return (newVersion > currentVersion);
}
}