fix logic
[personal-kdelibs.git] / kdecore / config / kconfig_p.h
blobcdf13c0aacf0c71480d64e15f5213a5e1da08011
1 /*
2 This file is part of the KDE libraries
3 Copyright (c) 2006, 2007 Thomas Braxton <kde.braxton@gmail.com>
4 Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
5 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
6 Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
24 #ifndef KCONFIG_P_H
25 #define KCONFIG_P_H
27 #include "kconfigdata.h"
28 #include <kglobal.h>
29 #include "kconfigbackend.h"
30 #include "kconfiggroup.h"
31 #include "kcomponentdata.h"
32 #include "kstandarddirs.h"
33 #include "klocale.h"
35 #include <QtCore/QStringList>
36 #include <QtCore/QStack>
37 #include <QtCore/QFile>
38 #include <QtCore/QDir>
40 #include <unistd.h>
42 class KConfigPrivate
44 friend class KConfig;
45 public:
46 KConfig::OpenFlags openFlags;
47 const char* resourceType;
49 void changeFileName(const QString& fileName, const char* resourceType);
51 // functions for KConfigGroup
52 bool canWriteEntry(const QByteArray& group, const char* key, bool isDefault=false) const;
53 QString lookupData(const QByteArray& group, const char* key, KEntryMap::SearchFlags flags,
54 bool* expand) const;
55 QByteArray lookupData(const QByteArray& group, const char* key, KEntryMap::SearchFlags flags) const;
57 void putData(const QByteArray& group, const char* key, const QByteArray& value,
58 KConfigBase::WriteConfigFlags flags, bool expand=false);
59 QStringList groupList(const QByteArray& group) const;
60 // copies the entries from @p source to @p otherGroup changing all occurrences
61 // of @p source with @p destination
62 void copyGroup(const QByteArray& source, const QByteArray& destination,
63 KConfigGroup *otherGroup, KConfigBase::WriteConfigFlags flags) const;
65 protected:
66 KSharedPtr<KConfigBackend> mBackend;
68 KConfigPrivate(const KComponentData &componentData_, KConfig::OpenFlags flags,
69 const char* resource);
71 virtual ~KConfigPrivate()
75 bool bDynamicBackend:1; // do we own the backend?
76 private:
77 bool bDirty:1;
78 bool bLocaleInitialized:1;
79 bool bReadDefaults:1;
80 bool bFileImmutable:1;
81 bool bForceGlobal:1;
83 QString sGlobalFileName;
84 static bool mappingsRegistered;
87 KEntryMap entryMap;
88 QString backendType;
89 QStringList globalFiles;
90 QStack<QString> extraFiles;
92 QString locale;
93 QString fileName;
94 KComponentData componentData;
95 KConfigBase::AccessMode configState;
97 bool wantGlobals() const { return openFlags&KConfig::IncludeGlobals; }
98 bool wantDefaults() const { return openFlags&KConfig::CascadeConfig; }
99 bool isSimple() const { return openFlags == KConfig::SimpleConfig; }
100 bool isReadOnly() const { return configState == KConfig::ReadOnly; }
102 bool setLocale(const QString& aLocale);
103 void parseGlobalFiles();
104 void parseConfigFiles();
105 void initCustomized(KConfig*);
106 bool lockLocal();
109 #endif // KCONFIG_P_H