swift
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"
15 #include "misc/propertyindexref.h"
16 #include "misc/swiftmiscexport.h"
17 #include "misc/valueobject.h"
18 
19 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::network, CRole)
20 
21 namespace 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 
79 Q_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.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Class from which a derived class can inherit datastore-related functions.
Definition: datastore.h:70
CRole()=default
Constructor.
const QString & getName() const
Name.
Definition: role.h:43
void setName(const QString &name)
Name.
Definition: role.h:46
const QString & getDescription() const
Description.
Definition: role.h:49
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:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
#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