7 #include <QStringBuilder>
12 namespace swift::misc::network
14 CRole::CRole(
const QString &name,
const QString &description) : m_name(name), m_description(description) {}
24 if (index.
isMyself()) {
return QVariant::fromValue(*
this); }
25 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
27 return IDatastoreObjectWithIntegerKey::propertyByIndex(index);
32 case IndexName:
return QVariant::fromValue(m_name);
33 case IndexDescription:
return QVariant::fromValue(m_description);
43 (*this) = variant.value<
CRole>();
46 if (IDatastoreObjectWithIntegerKey::canHandleIndex(index))
48 IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant);
54 case IndexName: this->
setName(variant.value<QString>());
break;
55 case IndexDescription: this->
setDescription(variant.value<QString>());
break;
64 role.
setName(json.value(
"name").toString());
66 role.
setDbKey(json.value(
"idrole").toInt(-1));
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.
ColumnIndex
Property index.
void setDbKey(int key)
Set the DB key.
QString getDbKeyAsStringInParentheses(const QString &prefix={}) const
Db key in parentheses, e.g. "(3)".
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString convertToQString(bool i18n=false) const
Cast as QString.
static CRole fromDatabaseJson(const QJsonObject &json)
Role from DB JSON.
CRole()=default
Constructor.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
void setName(const QString &name)
Name.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setDescription(const QString &description)
Description.
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.