mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +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(
|
||||
const QString &name, const QString &version, const QString &md5,
|
||||
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_platform(platform)
|
||||
{
|
||||
this->setVersion(trimVersionString(version));
|
||||
if (!name.isEmpty() && version.isEmpty())
|
||||
{
|
||||
m_version = versionNumberFromFilename(name);
|
||||
@@ -84,15 +85,10 @@ namespace BlackMisc
|
||||
return rf;
|
||||
}
|
||||
|
||||
QVersionNumber CArtifact::getQVersion() const
|
||||
{
|
||||
return QVersionNumber::fromString(getVersionString());
|
||||
}
|
||||
|
||||
bool CArtifact::isNewerThanCurrentBuild() const
|
||||
{
|
||||
if (this->isUnknown()) { return false; }
|
||||
if (this->getVersionString().isEmpty()) { return false; }
|
||||
if (!this->hasVersion()) { return false; }
|
||||
return this->getQVersion() > CBuildConfig::getVersion();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "blackmisc/platform.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/network/remotefile.h"
|
||||
#include <QVersionNumber>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -59,9 +58,6 @@ namespace BlackMisc
|
||||
CArtifact(const QString &name, const QString &version, const QString &md5,
|
||||
ArtifactType type, int size, bool existing, const CPlatform &platform);
|
||||
|
||||
//! Destructor.
|
||||
~CArtifact() {}
|
||||
|
||||
//! Having name?
|
||||
bool hasName() const { return !m_name.isEmpty(); }
|
||||
|
||||
@@ -74,12 +70,6 @@ namespace BlackMisc
|
||||
//! Matching name?
|
||||
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
|
||||
ArtifactType getType() const { return static_cast<ArtifactType>(m_type); }
|
||||
|
||||
@@ -132,9 +122,6 @@ namespace BlackMisc
|
||||
//! \note requires distributions
|
||||
Network::CRemoteFile asRemoteFile() const;
|
||||
|
||||
//! Version as QVersion
|
||||
QVersionNumber getQVersion() const;
|
||||
|
||||
//! Newer tahn the current build
|
||||
bool isNewerThanCurrentBuild() const;
|
||||
|
||||
@@ -158,7 +145,6 @@ namespace BlackMisc
|
||||
|
||||
private:
|
||||
QString m_name; //!< channel the files belong to
|
||||
QString m_version; //!< version string
|
||||
QString m_md5; //!< MD5 checksum
|
||||
int m_type = static_cast<int>(UnknownArtifact); //!< artifact type
|
||||
int m_size = -1; //!< size
|
||||
|
||||
@@ -150,9 +150,9 @@ namespace BlackMisc
|
||||
return rfs;
|
||||
}
|
||||
|
||||
QString CArtifactList::getLatestVersionString() const
|
||||
QString CArtifactList::getLatestVersion() const
|
||||
{
|
||||
return this->getLatestArtifactOrDefault().getVersionString();
|
||||
return this->getLatestArtifactOrDefault().getVersion();
|
||||
}
|
||||
|
||||
QVersionNumber CArtifactList::getLatestQVersion() const
|
||||
@@ -182,9 +182,9 @@ namespace BlackMisc
|
||||
QStringList versions;
|
||||
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;
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace BlackMisc
|
||||
Network::CRemoteFileList asRemoteFiles() const;
|
||||
|
||||
//! Latest version
|
||||
QString getLatestVersionString() const;
|
||||
QString getLatestVersion() const;
|
||||
|
||||
//! Latest version
|
||||
QVersionNumber getLatestQVersion() const;
|
||||
|
||||
@@ -19,6 +19,11 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Db
|
||||
{
|
||||
QVersionNumber IDatastoreObject::getQVersion() const
|
||||
{
|
||||
return QVersionNumber::fromString(this->getVersion());
|
||||
}
|
||||
|
||||
void IDatastoreObject::setTimestampVersionFromDatabaseJson(const QJsonObject &json, const QString &prefix)
|
||||
{
|
||||
// we check 2 formats, the DB format and the backend object format
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QObject>
|
||||
#include <QVersionNumber>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -52,6 +53,12 @@ namespace BlackMisc
|
||||
//! Version info
|
||||
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
|
||||
void setVersion(const QString &version) { m_version = version; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user