1 | /* |
2 | SPDX-FileCopyrightText: 2007-2008 Aaron Seigo <aseigo@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KCONFIGLOADER_P_H |
8 | #define KCONFIGLOADER_P_H |
9 | |
10 | #include <QUrl> |
11 | |
12 | class ConfigLoaderPrivate |
13 | { |
14 | public: |
15 | ConfigLoaderPrivate() |
16 | : saveDefaults(false) |
17 | { |
18 | } |
19 | |
20 | ~ConfigLoaderPrivate() |
21 | { |
22 | clearData(); |
23 | } |
24 | |
25 | void clearData() |
26 | { |
27 | qDeleteAll(c: bools); |
28 | qDeleteAll(c: strings); |
29 | qDeleteAll(c: stringlists); |
30 | qDeleteAll(c: colors); |
31 | qDeleteAll(c: fonts); |
32 | qDeleteAll(c: ints); |
33 | qDeleteAll(c: uints); |
34 | qDeleteAll(c: urls); |
35 | qDeleteAll(c: dateTimes); |
36 | qDeleteAll(c: doubles); |
37 | qDeleteAll(c: intlists); |
38 | qDeleteAll(c: longlongs); |
39 | qDeleteAll(c: points); |
40 | qDeleteAll(c: pointfs); |
41 | qDeleteAll(c: rects); |
42 | qDeleteAll(c: rectfs); |
43 | qDeleteAll(c: sizes); |
44 | qDeleteAll(c: sizefs); |
45 | qDeleteAll(c: ulonglongs); |
46 | qDeleteAll(c: urllists); |
47 | } |
48 | |
49 | bool *newBool() |
50 | { |
51 | bool *v = new bool; |
52 | bools.append(t: v); |
53 | return v; |
54 | } |
55 | |
56 | QString *newString() |
57 | { |
58 | QString *v = new QString; |
59 | strings.append(t: v); |
60 | return v; |
61 | } |
62 | |
63 | QStringList *newStringList() |
64 | { |
65 | QStringList *v = new QStringList; |
66 | stringlists.append(t: v); |
67 | return v; |
68 | } |
69 | |
70 | QColor *newColor() |
71 | { |
72 | QColor *v = new QColor; |
73 | colors.append(t: v); |
74 | return v; |
75 | } |
76 | |
77 | QFont *newFont() |
78 | { |
79 | QFont *v = new QFont; |
80 | fonts.append(t: v); |
81 | return v; |
82 | } |
83 | |
84 | qint32 *newInt() |
85 | { |
86 | qint32 *v = new qint32; |
87 | ints.append(t: v); |
88 | return v; |
89 | } |
90 | |
91 | quint32 *newUint() |
92 | { |
93 | quint32 *v = new quint32; |
94 | uints.append(t: v); |
95 | return v; |
96 | } |
97 | |
98 | QUrl *newUrl() |
99 | { |
100 | QUrl *v = new QUrl; |
101 | urls.append(t: v); |
102 | return v; |
103 | } |
104 | |
105 | QDateTime *newDateTime() |
106 | { |
107 | QDateTime *v = new QDateTime; |
108 | dateTimes.append(t: v); |
109 | return v; |
110 | } |
111 | |
112 | double *newDouble() |
113 | { |
114 | double *v = new double; |
115 | doubles.append(t: v); |
116 | return v; |
117 | } |
118 | |
119 | QList<qint32> *newIntList() |
120 | { |
121 | QList<qint32> *v = new QList<qint32>; |
122 | intlists.append(t: v); |
123 | return v; |
124 | } |
125 | |
126 | qint64 *newLongLong() |
127 | { |
128 | qint64 *v = new qint64; |
129 | longlongs.append(t: v); |
130 | return v; |
131 | } |
132 | |
133 | QPoint *newPoint() |
134 | { |
135 | QPoint *v = new QPoint; |
136 | points.append(t: v); |
137 | return v; |
138 | } |
139 | |
140 | QPointF *newPointF() |
141 | { |
142 | QPointF *v = new QPointF; |
143 | pointfs.append(t: v); |
144 | return v; |
145 | } |
146 | |
147 | QRect *newRect() |
148 | { |
149 | QRect *v = new QRect; |
150 | rects.append(t: v); |
151 | return v; |
152 | } |
153 | |
154 | QRectF *newRectF() |
155 | { |
156 | QRectF *v = new QRectF; |
157 | rectfs.append(t: v); |
158 | return v; |
159 | } |
160 | |
161 | QSize *newSize() |
162 | { |
163 | QSize *v = new QSize; |
164 | sizes.append(t: v); |
165 | return v; |
166 | } |
167 | |
168 | QSizeF *newSizeF() |
169 | { |
170 | QSizeF *v = new QSizeF; |
171 | sizefs.append(t: v); |
172 | return v; |
173 | } |
174 | |
175 | quint64 *newULongLong() |
176 | { |
177 | quint64 *v = new quint64; |
178 | ulonglongs.append(t: v); |
179 | return v; |
180 | } |
181 | |
182 | QList<QUrl> *newUrlList() |
183 | { |
184 | QList<QUrl> *v = new QList<QUrl>(); |
185 | urllists.append(t: v); |
186 | return v; |
187 | } |
188 | |
189 | void parse(KConfigLoader *loader, QIODevice *xml); |
190 | |
191 | /** |
192 | * Whether or not to write out default values. |
193 | * |
194 | * @param writeDefaults true if defaults should be written out |
195 | */ |
196 | void setWriteDefaults(bool writeDefaults) |
197 | { |
198 | saveDefaults = writeDefaults; |
199 | } |
200 | |
201 | /** |
202 | * @return true if default values will also be written out |
203 | */ |
204 | bool writeDefaults() const |
205 | { |
206 | return saveDefaults; |
207 | } |
208 | |
209 | QList<bool *> bools; |
210 | QList<QString *> strings; |
211 | QList<QStringList *> stringlists; |
212 | QList<QColor *> colors; |
213 | QList<QFont *> fonts; |
214 | QList<qint32 *> ints; |
215 | QList<quint32 *> uints; |
216 | QList<QUrl *> urls; |
217 | QList<QDateTime *> dateTimes; |
218 | QList<double *> doubles; |
219 | QList<QList<qint32> *> intlists; |
220 | QList<qint64 *> longlongs; |
221 | QList<QPoint *> points; |
222 | QList<QPointF *> pointfs; |
223 | QList<QRect *> rects; |
224 | QList<QRectF *> rectfs; |
225 | QList<QSize *> sizes; |
226 | QList<QSizeF *> sizefs; |
227 | QList<quint64 *> ulonglongs; |
228 | QList<QList<QUrl> *> urllists; |
229 | QString baseGroup; |
230 | QStringList groups; |
231 | QHash<QString, QString> keysToNames; |
232 | bool saveDefaults; |
233 | }; |
234 | |
235 | #endif |
236 | |