Akonadi

nodetree.h
1 /*
2  SPDX-FileCopyrightText: 2017 Daniel Vr├ítil <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QMultiMap>
10 #include <QVector>
11 
12 class Node
13 {
14 public:
15  enum NodeType {
16  Document,
17  Class,
18  Ctor,
19  Enum,
20  EnumValue,
21  Property,
22  };
23 
24  Node(NodeType type, Node *parent);
25  Node(const Node &) = delete;
26  Node(Node &&) = delete;
27  virtual ~Node();
28 
29  Node &operator=(const Node &) = delete;
30  Node &operator=(Node &&) = delete;
31 
32  NodeType type() const;
33  Node *parent() const;
34 
35  void appendNode(Node *child);
36 
37  const QVector<Node const *> &children() const;
38 
39 protected:
40  Node *mParent;
41  QVector<Node const *> mChildren;
42  NodeType mType;
43 };
44 
45 class DocumentNode : public Node
46 {
47 public:
48  DocumentNode(int version);
49 
50  int version() const;
51 
52 private:
53  int mVersion;
54 };
55 
56 class PropertyNode;
57 class ClassNode : public Node
58 {
59 public:
60  enum ClassType {
61  Invalid,
62  Class,
63  Command,
64  Response,
65  Notification,
66  };
67 
68  ClassNode(const QString &name, ClassType type, DocumentNode *parent);
69  QString name() const;
70  ClassType classType() const;
71  QString className() const;
72  QString parentClassName() const;
74 
75 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
76  static ClassType elementNameToType(const QStringRef &name);
77 #else
78  static ClassType elementNameToType(QStringView name);
79 #endif
80 
81 private:
82  QString mName;
83  ClassType mClassType;
84 };
85 
86 class CtorNode : public Node
87 {
88 public:
89  struct Argument {
90  QString name;
91  QString type;
92  QString defaultValue;
93 
94  QString mVariableName() const
95  {
96  return QStringLiteral("m") + name[0].toUpper() +
97  QStringView(name).mid(1);
98  }
99  };
100 
101  CtorNode(const QVector<Argument> &args, ClassNode *parent);
102  ~CtorNode() override;
103 
104  QVector<Argument> arguments() const;
105  void setArgumentType(const QString &name, const QString &type);
106 
107 private:
108  QVector<Argument> mArgs;
109 };
110 
111 class EnumNode : public Node
112 {
113 public:
114  enum EnumType {
115  TypeInvalid,
116  TypeEnum,
117  TypeFlag,
118  };
119 
120  EnumNode(const QString &name, EnumType type, ClassNode *parent);
121 
122  QString name() const;
123  EnumType enumType() const;
124 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
125  static EnumType elementNameToType(const QStringRef &name);
126 #else
127  static EnumType elementNameToType(QStringView name);
128 #endif
129 private:
130  QString mName;
131  EnumType mEnumType;
132 };
133 
134 class EnumValueNode : public Node
135 {
136 public:
137  EnumValueNode(const QString &name, EnumNode *parent);
138 
139  QString name() const;
140  void setValue(const QString &value);
141  QString value() const;
142 
143 private:
144  QString mName;
145  QString mValue;
146 };
147 
148 class PropertyNode : public Node
149 {
150 public:
151  struct Setter {
152  QString name;
153  QString type;
154  QString append;
155  QString remove;
156  };
157 
158  PropertyNode(const QString &name, const QString &type, ClassNode *parent);
159  ~PropertyNode() override;
160 
161  QString type() const;
162  QString name() const;
163 
164  void setDefaultValue(const QString &defaultValue);
165  QString defaultValue() const;
166 
167  bool readOnly() const;
168  void setReadOnly(bool readOnly);
169 
170  bool asReference() const;
171  void setAsReference(bool asReference);
172 
173  bool isPointer() const;
174 
175  QMultiMap<QString, QString> dependencies() const;
176  void addDependency(const QString &enumVar, const QString &enumValue);
177 
178  Setter *setter() const;
179  void setSetter(Setter *setter);
180 
181  QString mVariableName() const;
182  QString setterName() const;
183 
184 private:
185  QString mName;
186  QString mType;
187  QString mDefaultValue;
189  Setter *mSetter;
190  bool mReadOnly;
191  bool mAsReference;
192 };
193 
virtual QString type() const
Definition: nodetree.cpp:25
QString toUpper() const const
QStringView mid(qsizetype start) const const
KGuiItem remove()
Property
KGuiItem properties()
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
Definition: nodetree.h:12
unsigned int version()
QString name(StandardShortcut id)
QString name() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.