KConfig

KConfigParameters.cpp
1/*
2 This file is part of the KDE libraries.
3
4 SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org>
5 SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org>
6 SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org>
7 SPDX-FileCopyrightText: 2006 Michaƫl Larouche <michael.larouche@kdemail.net>
8 SPDX-FileCopyrightText: 2008 Allen Winter <winter@kde.org>
9 SPDX-FileCopyrightText: 2020 Tomaz Cananbrava <tcanabrava@kde.org>
10
11 SPDX-License-Identifier: LGPL-2.0-or-later
12*/
13
14#include "KConfigParameters.h"
15
16#include <QDebug>
17#include <QFileInfo>
18
19#include <iostream>
20
21KConfigParameters::KConfigParameters(const QString &codegenFilename)
22{
23 if (!codegenFilename.endsWith(QLatin1String(".kcfgc"))) {
24 std::cerr << "Codegen options file must have extension .kcfgc" << std::endl;
25 exit(1);
26 }
27
28 baseName = QFileInfo(codegenFilename).fileName();
29 baseName = baseName.left(baseName.length() - 6);
30
31 // Configure the compiler with some settings
32 QSettings codegenConfig(codegenFilename, QSettings::IniFormat);
33
34 nameSpace = codegenConfig.value(QStringLiteral("NameSpace")).toString();
35 className = codegenConfig.value(QStringLiteral("ClassName")).toString();
36 if (className.isEmpty()) {
37 std::cerr << "Class name missing" << std::endl;
38 exit(1);
39 }
40 inherits = codegenConfig.value(QStringLiteral("Inherits")).toString();
41 if (inherits.isEmpty()) {
42 inherits = QStringLiteral("KConfigSkeleton");
43 }
44 visibility = codegenConfig.value(QStringLiteral("Visibility")).toString();
45 if (!visibility.isEmpty()) {
46 visibility += QLatin1Char(' ');
47 }
48 parentInConstructor = codegenConfig.value(QStringLiteral("ParentInConstructor"), false).toBool();
49 forceStringFilename = codegenConfig.value(QStringLiteral("ForceStringFilename"), false).toBool();
50 singleton = codegenConfig.value(QStringLiteral("Singleton"), false).toBool();
51 staticAccessors = singleton;
52 customAddons = codegenConfig.value(QStringLiteral("CustomAdditions"), false).toBool();
53 memberVariables = codegenConfig.value(QStringLiteral("MemberVariables")).toString();
54 dpointer = (memberVariables == QLatin1String("dpointer"));
55 headerIncludes = codegenConfig.value(QStringLiteral("IncludeFiles"), QStringList()).toStringList();
56 sourceIncludes = codegenConfig.value(QStringLiteral("SourceIncludeFiles"), QStringList()).toStringList();
57 mutators = codegenConfig.value(QStringLiteral("Mutators"), QStringList()).toStringList();
58 allMutators = ((mutators.count() == 1) && (mutators.at(0).toLower() == QLatin1String("true")));
59 itemAccessors = codegenConfig.value(QStringLiteral("ItemAccessors"), false).toBool();
60 setUserTexts = codegenConfig.value(QStringLiteral("SetUserTexts"), false).toBool();
61 defaultGetters = codegenConfig.value(QStringLiteral("DefaultValueGetters"), QStringList()).toStringList();
62 allDefaultGetters = (defaultGetters.count() == 1) && (defaultGetters.at(0).toLower() == QLatin1String("true"));
63 notifiers = codegenConfig.value(QStringLiteral("Notifiers"), QStringList()).toStringList();
64 allNotifiers = ((notifiers.count() == 1) && (notifiers.at(0).toLower() == QLatin1String("true")));
65 globalEnums = codegenConfig.value(QStringLiteral("GlobalEnums"), false).toBool();
66 useEnumTypes = codegenConfig.value(QStringLiteral("UseEnumTypes"), false).toBool();
67 const QString trString = codegenConfig.value(QStringLiteral("TranslationSystem")).toString().toLower();
68 generateProperties = codegenConfig.value(QStringLiteral("GenerateProperties"), false).toBool();
69 if (trString == QLatin1String("kde")) {
70 translationSystem = KdeTranslation;
71 translationDomain = codegenConfig.value(QStringLiteral("TranslationDomain")).toString();
72 } else {
73 if (!trString.isEmpty() && trString != QLatin1String("qt")) {
74 std::cerr << "Unknown translation system, falling back to Qt tr()" << std::endl;
75 }
76 translationSystem = QtTranslation;
77 }
78 qCategoryLoggingName = codegenConfig.value(QStringLiteral("CategoryLoggingName"), QString()).toString();
79 headerExtension = codegenConfig.value(QStringLiteral("HeaderExtension"), QStringLiteral("h")).toString();
80 qmlRegistration = codegenConfig.value(QStringLiteral("QmlRegistration")).toBool();
81}
QString fileName() const const
const_reference at(qsizetype i) const const
qsizetype count() const const
T value(qsizetype i) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QString left(qsizetype n) const const
qsizetype length() const const
QString toLower() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.