swift
Loading...
Searching...
No Matches
distribution.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_DB_DISTRIBUTION_H
7#define SWIFT_MISC_DB_DISTRIBUTION_H
8
9#include <QMetaType>
10#include <QString>
11#include <QVersionNumber>
12
13#include "config/buildconfig.h"
14#include "misc/db/datastore.h"
15#include "misc/dictionary.h"
16#include "misc/network/url.h"
17#include "misc/settingscache.h"
19#include "misc/valueobject.h"
20
21SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::db, CDistribution)
22
23namespace swift::misc::db
24{
27 {
28 public:
31 {
32 IndexChannel = CPropertyIndexRef::GlobalIndexCDistribution,
33 IndexStability,
34 IndexRestricted,
35 IndexDownloadUrl
36 };
37
39 CDistribution() = default;
40
42 CDistribution(const QString &channel, int stability, bool restricted);
43
45 const QString &getChannel() const { return m_channel; }
46
48 void setChannel(const QString &channel);
49
51 int getStability() const { return m_stability; }
52
54 void setStability(int stability) { m_stability = stability; }
55
57 const network::CUrl &getDownloadUrl() const { return m_downloadUrl; }
58
60 void setDownloadUrl(const swift::misc::network::CUrl &url);
61
63 bool hasDownloadUrl() const;
64
66 bool isRestricted() const { return m_restricted; }
67
69 void setRestricted(bool r) { m_restricted = r; }
70
72 CIcons::IconIndex getRestrictionIcon() const;
73
75 bool isStabilitySameOrBetter(const CDistribution &otherDistribution) const;
76
78 bool isStabilityBetter(const CDistribution &otherDistribution) const;
79
81 bool isEmpty() const { return m_channel.isEmpty(); }
82
84 QString convertToQString(bool i18n = false) const;
85
87 QString convertToQString(const QString &separator, bool i18n = false) const;
88
90 CIcons::IconIndex toIcon() const;
91
93 QVariant propertyByIndex(CPropertyIndexRef index) const;
94
96 void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
97
99 const static CDistribution &localDeveloperBuild();
100
102 static CDistribution fromDatabaseJson(const QJsonObject &json, const QString &prefix = {});
103
104 private:
105 QString m_channel;
106 int m_stability;
107 bool m_restricted = false;
108 network::CUrl m_downloadUrl;
109
111 CDistribution,
112 SWIFT_METAMEMBER(dbKey),
113 SWIFT_METAMEMBER(timestampMSecsSinceEpoch),
114 SWIFT_METAMEMBER(channel),
115 SWIFT_METAMEMBER(stability),
116 SWIFT_METAMEMBER(downloadUrl));
117 };
118} // namespace swift::misc::db
119
120Q_DECLARE_METATYPE(swift::misc::db::CDistribution)
121
122#endif // SWIFT_MISC_DB_DISTRIBUTION_H
IconIndex
Index for each icon, allows to send them via DBus, efficiently store them, etc.
Definition icons.h:32
Non-owning reference to a CPropertyIndex with a subset of its features.
Distributions for channel.
bool isRestricted() const
Restricted channel?
const QString & getChannel() const
Version channel (Alpha, Beta, Stable ..).
int getStability() const
Stability (higher is more stable).
CDistribution()=default
Default constructor.
void setStability(int stability)
Order.
ColumnIndex
Properties by index.
const network::CUrl & getDownloadUrl() const
Download URL, i.e. here one can download installer.
void setRestricted(bool r)
Restricted channel.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
Definition url.h:27
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition metaclass.h:72
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition metaclass.h:52
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition valueobject.h:65