swift
Loading...
Searching...
No Matches
role.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2015 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_NETWORK_ROLE_H
7#define SWIFT_MISC_NETWORK_ROLE_H
8
9#include <QJsonObject>
10#include <QMetaType>
11#include <QString>
12
13#include "misc/db/datastore.h"
14#include "misc/metaclass.h"
17#include "misc/valueobject.h"
18
19SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::network, CRole)
20
21namespace swift::misc::network
22{
27 {
28 public:
31 {
32 IndexName = CPropertyIndexRef::GlobalIndexCRole,
33 IndexDescription
34 };
35
37 CRole() = default;
38
40 CRole(const QString &name, const QString &description);
41
43 const QString &getName() const { return m_name; }
44
46 void setName(const QString &name) { m_name = name.trimmed().toUpper(); }
47
49 const QString &getDescription() const { return m_description; }
50
52 void setDescription(const QString &description) { m_description = description.trimmed(); }
53
55 QString convertToQString(bool i18n = false) const;
56
58 QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
59
61 void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
62
64 static CRole fromDatabaseJson(const QJsonObject &json);
65
66 private:
67 QString m_name;
68 QString m_description;
69
71 CRole,
72 SWIFT_METAMEMBER(dbKey),
73 SWIFT_METAMEMBER(name),
74 SWIFT_METAMEMBER(description));
75 };
76
77} // namespace swift::misc::network
78
79Q_DECLARE_METATYPE(swift::misc::network::CRole)
80
81#endif // SWIFT_MISC_NETWORK_ROLE_H
Non-owning reference to a CPropertyIndex with a subset of its features.
Class from which a derived class can inherit datastore-related functions.
Definition datastore.h:70
const QString & getName() const
Name.
Definition role.h:43
const QString & getDescription() const
Description.
Definition role.h:49
ColumnIndex
Properties by index.
Definition role.h:31
CRole()=default
Constructor.
void setName(const QString &name)
Name.
Definition role.h:46
void setDescription(const QString &description)
Description.
Definition role.h:52
#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
QString toUpper() const const
QString trimmed() const const
#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