6 #include <QRegularExpression>
7 #include <QStringBuilder>
9 using namespace swift::config;
11 using namespace swift::misc::network;
15 namespace swift::misc::db
17 CDistribution::CDistribution() {}
19 CDistribution::CDistribution(
const QString &channel,
int stability,
bool restricted)
20 : m_channel(channel.trimmed().toUpper()), m_stability(stability), m_restricted(restricted)
36 return m_restricted ? CIcons::StandardIconLockClosed16 : CIcons::StandardIconGlobe16;
41 return m_stability >= otherDistribution.m_stability;
46 return m_stability > otherDistribution.m_stability;
61 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
70 case IndexChannel:
return QVariant::fromValue(m_channel);
71 case IndexStability:
return QVariant::fromValue(m_stability);
72 case IndexDownloadUrl:
return QVariant::fromValue(m_downloadUrl);
73 case IndexRestricted:
return QVariant::fromValue(m_restricted);
94 case IndexChannel: this->
setChannel(variant.value<QString>());
break;
95 case IndexStability: m_stability = variant.toInt();
break;
96 case IndexDownloadUrl: m_downloadUrl = variant.value<
CUrl>();
break;
97 case IndexRestricted: m_restricted = variant.toBool();
break;
116 const QString channel(json.value(
"channel").toString());
117 const bool restricted = json.value(
"restricted").toBool();
118 const int stability = json.value(
"stability").toInt();
123 for (
int i = 0; i < 5; i++)
125 const QString key =
"url" + QString::number(i);
126 const QString url = json.value(key).toString();
127 if (url.isEmpty()) {
continue; }
IconIndex
Index for each icon, allows to send them via DBus, efficiently store them, etc.
Non-owning reference to a CPropertyIndex with a subset of its features.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
QString getFormattedUtcTimestampYmdhms() const
As yyyy MM dd HH mm ss.
void setCurrentUtcTime()
Set the current time as timestamp.
Distributions for channel.
bool isStabilityBetter(const CDistribution &otherDistribution) const
"this" having better stability than other distribution?
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
CIcons::IconIndex toIcon() const
Representing icon.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
CIcons::IconIndex getRestrictionIcon() const
Get the restrict icon.
const QString & getChannel() const
Version channel (Alpha, Beta, Stable ..)
QString convertToQString(bool i18n=false) const
Cast as QString.
void setChannel(const QString &channel)
Set the channel.
static const CDistribution & localDeveloperBuild()
Pseudo distribution for local builds.
bool isStabilitySameOrBetter(const CDistribution &otherDistribution) const
"this" having same or better stability than other distribution?
void setDownloadUrl(const swift::misc::network::CUrl &url)
Set URL, ignored if empty.
static CDistribution fromDatabaseJson(const QJsonObject &json, const QString &prefix={})
Object from database JSON format.
bool hasDownloadUrl() const
Has a download URL?
const network::CUrl & getDownloadUrl() const
Download URL, i.e. here one can download installer.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
ColumnIndex
Property index.
static bool canHandleIndex(swift::misc::CPropertyIndexRef index)
Can given index be handled?
void setKeyVersionTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
Set key and timestamp values.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString toQString(bool i18n=false) const
Cast as QString.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
bool isEmpty() const
Empty.
Free functions in swift::misc.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.