KConfig

KConfigCommonStructs.h
1 /*
2  This file is part of the KDE libraries.
3 
4  SPDX-FileCopyrightText: 2003 Cornelius Schumacher <[email protected]>
5  SPDX-FileCopyrightText: 2003 Waldo Bastian <[email protected]>
6  SPDX-FileCopyrightText: 2003 Zack Rusin <[email protected]>
7  SPDX-FileCopyrightText: 2006 MichaĆ«l Larouche <[email protected]>
8  SPDX-FileCopyrightText: 2008 Allen Winter <[email protected]>
9  SPDX-FileCopyrightText: 2020 Tomaz Cananbrava <[email protected]>
10 
11  SPDX-License-Identifier: LGPL-2.0-or-later
12 */
13 
14 #ifndef KCONFIGCOMMONSTRUCTS_H
15 #define KCONFIGCOMMONSTRUCTS_H
16 
17 #include <QString>
18 #include <QVector>
19 #include <QList>
20 
21 #include "KConfigParameters.h"
22 
23 struct Param
24 {
25  QString name;
26  QString type;
27 };
28 
29 struct Signal
30 {
31  QString name;
32  QString label;
33  QList<Param> arguments;
34  bool modify = false;
35 };
36 
37 class CfgEntry
38 {
39 public:
40  struct Choice {
41  QString name;
42  QString context;
43  QString label;
44  QString toolTip;
46  QString val;
47 
48  QString value() const
49  {
50  return !val.isEmpty() ? val : name;
51  }
52  };
53  class Choices
54  {
55  public:
56  Choices() {}
57  Choices(const QList<Choice> &d, const QString &n, const QString &p)
58  : prefix(p), choices(d), mName(n)
59  {
60  int i = n.indexOf(QLatin1String("::"));
61  if (i >= 0) {
62  mExternalQual = n.left(i + 2);
63  }
64  }
65  QString prefix;
66  QList<Choice> choices;
67  const QString &name() const
68  {
69  return mName;
70  }
71  const QString &externalQualifier() const
72  {
73  return mExternalQual;
74  }
75  bool external() const
76  {
77  return !mExternalQual.isEmpty();
78  }
79  private:
80  QString mName;
81  QString mExternalQual;
82  };
83 
84 public:
85  QString group;
86  QString parentGroup;
87  QString type;
88  QString key;
89  QString name;
90  QString labelContext;
91  QString label;
92  QString toolTipContext;
93  QString toolTip;
94  QString whatsThisContext;
95  QString whatsThis;
96  QString code;
97  QString defaultValue;
98  QString param;
99  QString paramName;
100  QString paramType;
101  Choices choices;
102  QList<Signal> signalList;
103  QStringList paramValues;
104  QStringList paramDefaultValues;
105  int paramMax;
106  bool hidden;
107  QString min;
108  QString max;
109 };
110 
111 struct ParseResult {
112  QString cfgFileName;
113  bool cfgFileNameArg = false;
114  QList<Param> parameters;
115  QList<Signal> signalList;
116  QStringList includes;
117  QList<CfgEntry *> entries;
118  bool hasNonModifySignals = false;
119 };
120 
121 // TODO: Move those methods
122 QString enumName(const QString &n);
123 QString enumName(const QString &n, const CfgEntry::Choices &c);
124 QString param(const QString &t);
125 QString cppType(const QString &t);
126 QString itemType(const QString &type);
127 QString changeSignalName(const QString &n);
128 
129 QString enumType(const CfgEntry *e, bool globalEnums);
130 
131 QString getDefaultFunction(const QString &n, const QString &className = QString());
132 QString setFunction(const QString &n, const QString &className = QString());
133 QString getFunction(const QString &n, const QString &className = QString());
134 QString immutableFunction(const QString &n, const QString &className = QString());
135 
136 QString itemAccessorBody(const CfgEntry *e, const KConfigParameters &cfg);
137 QString signalEnumName(const QString &signalName);
138 
139 bool isUnsigned(const QString &type);
140 
141 // returns the name of an member variable
142 // use itemPath to know the full path
143 // like using d-> in case of dpointer
144 QString varName(const QString &n, const KConfigParameters &cfg);
145 
146 QString varPath(const QString &n, const KConfigParameters &cfg);
147 
148 // returns the name of an item variable
149 // use itemPath to know the full path
150 // like using d-> in case of dpointer
151 QString itemVar(const CfgEntry *e, const KConfigParameters &cfg);
152 
153 // returns the name of the local inner item if there is one
154 // (before wrapping with KConfigCompilerSignallingItem)
155 // Otherwise return itemVar()
156 QString innerItemVar(const CfgEntry *e, const KConfigParameters &cfg);
157 
158 QString itemPath(const CfgEntry *e, const KConfigParameters &cfg);
159 
160 QString filenameOnly(const QString &path);
161 
162 QString itemDeclaration(const CfgEntry *e, const KConfigParameters &cfg);
163 
164 QString translatedString(
165  const KConfigParameters &cfg,
166  const QString &string,
167  const QString &context = QString(),
168  const QString &param = QString(),
169  const QString &paramValue = QString());
170 
171 // TODO: Sanitize those functions.
172 QString newItem(
173  const CfgEntry *entry,
174  const QString &key,
175  const QString &defaultValue,
176  const KConfigParameters &cfg,
177  const QString &param = QString());
178 
179 QString newInnerItem(
180  const CfgEntry *entry,
181  const QString &key,
182  const QString &defaultValue,
183  const KConfigParameters &cfg,
184  const QString &param = QString());
185 
186 QString userTextsFunctions(
187  const CfgEntry *e,
188  const KConfigParameters &cfg,
189  QString itemVarStr = QString(),
190  const QString &i = QString());
191 
192 QString paramString(const QString &s, const CfgEntry *e, int i);
193 QString paramString(const QString &group, const QList<Param> &parameters);
194 
195 QString defaultValue(const QString &t);
196 QString memberGetDefaultBody(const CfgEntry *e);
197 QString literalString(const QString &s);
198 QString enumTypeQualifier(const QString &n, const CfgEntry::Choices &c);
199 
200 void addQuotes(QString &s);
201 void addDebugMethod(QTextStream &out, const KConfigParameters &cfg, const QString &n);
202 
203 #endif
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
QString name(const QVariant &location)
QString whatsThis(StandardShortcut)
What&#39;s This button.
Type type(const QSqlDatabase &db)
QString label(StandardShortcut id)
Returns a localized label for user-visible display.
bool isEmpty() const const
QString left(int n) const const
Configuration Compiler Configuration.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 5 2020 22:46:15 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.