7 #include <QStringBuilder>
16 namespace swift::misc::network
21 : IDatastoreObjectWithIntegerKey(id), m_realname(realname.trimmed())
25 const QString &password)
26 : IDatastoreObjectWithIntegerKey(id), m_realname(realname.trimmed()), m_email(email.trimmed()),
27 m_password(password.trimmed())
39 if (m_realname.isEmpty()) {
return QStringLiteral(
"<no realname>"); }
46 user.
setDbKey(json.value(
"id").toInt(-1));
49 user.
setUsername(json.value(
"username").toString());
50 user.
setEmail(json.value(
"email").toString(
""));
51 user.
setCountry(
CCountry(json.value(
"country").toString(), json.value(
"countryname").toString()));
52 user.
setEnabled(json.value(
"enabled").toBool());
61 const QString rn(realname.trimmed().simplified());
67 const QString un(username.trimmed().simplified().toUpper());
107 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
108 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
110 return IDatastoreObjectWithIntegerKey::propertyByIndex(index);
115 case IndexVatsimId:
return QVariant::fromValue(m_vatsimId);
116 case IndexEmail:
return QVariant::fromValue(m_email);
117 case IndexPassword:
return QVariant::fromValue(m_password);
118 case IndexRealName:
return QVariant::fromValue(m_realname);
119 case IndexUsername:
return QVariant::fromValue(m_username);
131 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
133 IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant);
139 case IndexVatsimId: this->
setVatsimId(variant.toInt());
break;
140 case IndexEmail: this->
setEmail(variant.value<QString>());
break;
141 case IndexPassword: this->
setPassword(variant.value<QString>());
break;
142 case IndexRealName: this->
setRealName(variant.value<QString>());
break;
143 case IndexUsername: this->
setUsername(variant.value<QString>());
break;
IconIndex
Index for each icon, allows to send them via DBus, efficiently store them, etc.
A sequence of log categories.
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.
void push_back(const T &value)
Appends an element at the end of the sequence.
Streamable status message, e.g.
constexpr static auto SeverityWarning
Status severities.
Status messages, e.g. from Core -> GUI.
QString getDbKeyAsString() const
DB key as string.
ColumnIndex
Property index.
void setDbKey(int key)
Set the DB key.
QString getDbKeyAsStringInParentheses(const QString &prefix={}) const
Db key in parentheses, e.g. "(3)".
bool hasValidDbKey() const
Has valid DB key.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Value object encapsulating information of an authentiated user.
void setVatsimId(int id)
Set id.
bool isAuthenticated() const
Authenticated.
QString convertToQString(bool i18n=false) const
Cast as QString.
void setRealName(const QString &realname)
Set real name.
bool canDirectlyWriteModels() const
Entitled to directly update models.
QString getRealNameAndId() const
Full name + id.
bool hasRole(const QString &roleName) const
Has role?
static CAuthenticatedUser fromDatabaseJson(const QJsonObject &json)
From our database JSON format.
void setAuthenticated(bool authenticated)
Authenticated.
bool hasValidRealName() const
Valid real name?
swift::misc::CIcons::IconIndex toIcon() const
As icon, not implemented by all classes.
bool hasBulkRole() const
Has bulk role?
void setEmail(const QString &email)
Set email.
bool hasValidCredentials() const
Valid credentials?
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
void setCountry(const swift::misc::CCountry &country)
Country.
bool isEnabled() const
Enabled.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setRoles(const CRoleList &roles)
Roles.
CAuthenticatedUser()
Default constructor.
swift::misc::CStatusMessageList validate() const
Validate, provide details about issues.
bool hasMappingAdminRole() const
Admin?
void setEnabled(bool enabled)
Enabled.
bool hasAdminRole() const
Admin?
void setPassword(const QString &pw)
Set password.
bool hasBulkAddRole() const
Has bulk add role?
void setUsername(const QString &username)
Set username.
bool isValid() const
Valid user object?
Value object encapsulating a list of servers.
static CRoleList fromDatabaseJson(const QJsonArray &array)
From our database JSON format.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.