mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
Ref T419, use version from IDatastoreObject in CArtifact
* add QVersion * remove version parts from CArtifact
This commit is contained in:
committed by
Mat Sutcliffe
parent
aabc975889
commit
b9c233802f
@@ -25,10 +25,11 @@ namespace BlackMisc
|
|||||||
CArtifact::CArtifact(
|
CArtifact::CArtifact(
|
||||||
const QString &name, const QString &version, const QString &md5,
|
const QString &name, const QString &version, const QString &md5,
|
||||||
CArtifact::ArtifactType type, int size, bool existing, const CPlatform &platform):
|
CArtifact::ArtifactType type, int size, bool existing, const CPlatform &platform):
|
||||||
m_name(name.trimmed()), m_version(trimVersionString(version)),
|
m_name(name.trimmed()),
|
||||||
m_md5(md5), m_type(static_cast<int>(type)), m_size(size), m_existing(existing),
|
m_md5(md5), m_type(static_cast<int>(type)), m_size(size), m_existing(existing),
|
||||||
m_platform(platform)
|
m_platform(platform)
|
||||||
{
|
{
|
||||||
|
this->setVersion(trimVersionString(version));
|
||||||
if (!name.isEmpty() && version.isEmpty())
|
if (!name.isEmpty() && version.isEmpty())
|
||||||
{
|
{
|
||||||
m_version = versionNumberFromFilename(name);
|
m_version = versionNumberFromFilename(name);
|
||||||
@@ -84,15 +85,10 @@ namespace BlackMisc
|
|||||||
return rf;
|
return rf;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVersionNumber CArtifact::getQVersion() const
|
|
||||||
{
|
|
||||||
return QVersionNumber::fromString(getVersionString());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CArtifact::isNewerThanCurrentBuild() const
|
bool CArtifact::isNewerThanCurrentBuild() const
|
||||||
{
|
{
|
||||||
if (this->isUnknown()) { return false; }
|
if (this->isUnknown()) { return false; }
|
||||||
if (this->getVersionString().isEmpty()) { return false; }
|
if (!this->hasVersion()) { return false; }
|
||||||
return this->getQVersion() > CBuildConfig::getVersion();
|
return this->getQVersion() > CBuildConfig::getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#include "blackmisc/platform.h"
|
#include "blackmisc/platform.h"
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
#include "blackmisc/network/remotefile.h"
|
#include "blackmisc/network/remotefile.h"
|
||||||
#include <QVersionNumber>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -59,9 +58,6 @@ namespace BlackMisc
|
|||||||
CArtifact(const QString &name, const QString &version, const QString &md5,
|
CArtifact(const QString &name, const QString &version, const QString &md5,
|
||||||
ArtifactType type, int size, bool existing, const CPlatform &platform);
|
ArtifactType type, int size, bool existing, const CPlatform &platform);
|
||||||
|
|
||||||
//! Destructor.
|
|
||||||
~CArtifact() {}
|
|
||||||
|
|
||||||
//! Having name?
|
//! Having name?
|
||||||
bool hasName() const { return !m_name.isEmpty(); }
|
bool hasName() const { return !m_name.isEmpty(); }
|
||||||
|
|
||||||
@@ -74,12 +70,6 @@ namespace BlackMisc
|
|||||||
//! Matching name?
|
//! Matching name?
|
||||||
bool matchesName(const QString &name, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
bool matchesName(const QString &name, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||||
|
|
||||||
//! Having a version string?
|
|
||||||
bool hasVersionString() const { return !m_version.isEmpty(); }
|
|
||||||
|
|
||||||
//! Version for platform
|
|
||||||
const QString &getVersionString() const { return m_version; }
|
|
||||||
|
|
||||||
//! Get type
|
//! Get type
|
||||||
ArtifactType getType() const { return static_cast<ArtifactType>(m_type); }
|
ArtifactType getType() const { return static_cast<ArtifactType>(m_type); }
|
||||||
|
|
||||||
@@ -132,9 +122,6 @@ namespace BlackMisc
|
|||||||
//! \note requires distributions
|
//! \note requires distributions
|
||||||
Network::CRemoteFile asRemoteFile() const;
|
Network::CRemoteFile asRemoteFile() const;
|
||||||
|
|
||||||
//! Version as QVersion
|
|
||||||
QVersionNumber getQVersion() const;
|
|
||||||
|
|
||||||
//! Newer tahn the current build
|
//! Newer tahn the current build
|
||||||
bool isNewerThanCurrentBuild() const;
|
bool isNewerThanCurrentBuild() const;
|
||||||
|
|
||||||
@@ -158,7 +145,6 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name; //!< channel the files belong to
|
QString m_name; //!< channel the files belong to
|
||||||
QString m_version; //!< version string
|
|
||||||
QString m_md5; //!< MD5 checksum
|
QString m_md5; //!< MD5 checksum
|
||||||
int m_type = static_cast<int>(UnknownArtifact); //!< artifact type
|
int m_type = static_cast<int>(UnknownArtifact); //!< artifact type
|
||||||
int m_size = -1; //!< size
|
int m_size = -1; //!< size
|
||||||
|
|||||||
@@ -150,9 +150,9 @@ namespace BlackMisc
|
|||||||
return rfs;
|
return rfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CArtifactList::getLatestVersionString() const
|
QString CArtifactList::getLatestVersion() const
|
||||||
{
|
{
|
||||||
return this->getLatestArtifactOrDefault().getVersionString();
|
return this->getLatestArtifactOrDefault().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVersionNumber CArtifactList::getLatestQVersion() const
|
QVersionNumber CArtifactList::getLatestQVersion() const
|
||||||
@@ -182,9 +182,9 @@ namespace BlackMisc
|
|||||||
QStringList versions;
|
QStringList versions;
|
||||||
for (const CArtifact &artifact : as_const(copy))
|
for (const CArtifact &artifact : as_const(copy))
|
||||||
{
|
{
|
||||||
if (artifact.hasVersionString())
|
if (artifact.hasVersion())
|
||||||
{
|
{
|
||||||
versions.push_back(artifact.getVersionString());
|
versions.push_back(artifact.getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return versions;
|
return versions;
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace BlackMisc
|
|||||||
Network::CRemoteFileList asRemoteFiles() const;
|
Network::CRemoteFileList asRemoteFiles() const;
|
||||||
|
|
||||||
//! Latest version
|
//! Latest version
|
||||||
QString getLatestVersionString() const;
|
QString getLatestVersion() const;
|
||||||
|
|
||||||
//! Latest version
|
//! Latest version
|
||||||
QVersionNumber getLatestQVersion() const;
|
QVersionNumber getLatestQVersion() const;
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Db
|
namespace Db
|
||||||
{
|
{
|
||||||
|
QVersionNumber IDatastoreObject::getQVersion() const
|
||||||
|
{
|
||||||
|
return QVersionNumber::fromString(this->getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
void IDatastoreObject::setTimestampVersionFromDatabaseJson(const QJsonObject &json, const QString &prefix)
|
void IDatastoreObject::setTimestampVersionFromDatabaseJson(const QJsonObject &json, const QString &prefix)
|
||||||
{
|
{
|
||||||
// we check 2 formats, the DB format and the backend object format
|
// we check 2 formats, the DB format and the backend object format
|
||||||
|
|||||||
@@ -19,8 +19,9 @@
|
|||||||
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QObject>
|
#include <QVersionNumber>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -52,6 +53,12 @@ namespace BlackMisc
|
|||||||
//! Version info
|
//! Version info
|
||||||
const QString &getVersion() const { return m_version; }
|
const QString &getVersion() const { return m_version; }
|
||||||
|
|
||||||
|
//! Version as QVersion
|
||||||
|
QVersionNumber getQVersion() const;
|
||||||
|
|
||||||
|
//! Having a version?s
|
||||||
|
bool hasVersion() const { return !m_version.isEmpty(); }
|
||||||
|
|
||||||
//! Version info
|
//! Version info
|
||||||
void setVersion(const QString &version) { m_version = version; }
|
void setVersion(const QString &version) { m_version = version; }
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ void CSwiftLauncher::setHeaderInfo(const CArtifact &latestArtifact)
|
|||||||
{
|
{
|
||||||
static const QString t("New version '%1' ['%2'/'%3']");
|
static const QString t("New version '%1' ['%2'/'%3']");
|
||||||
ui->lbl_HeaderInfo->setText(
|
ui->lbl_HeaderInfo->setText(
|
||||||
t.arg(latestArtifact.getVersionString(), latestArtifact.getPlatform().getPlatformName(),
|
t.arg(latestArtifact.getVersion(), latestArtifact.getPlatform().getPlatformName(),
|
||||||
latestArtifact.getMostStableDistribution().getChannel()));
|
latestArtifact.getMostStableDistribution().getChannel()));
|
||||||
ui->lbl_HeaderInfo->setStyleSheet("background: red; color: yellow;");
|
ui->lbl_HeaderInfo->setStyleSheet("background: red; color: yellow;");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user