Changeset View
Changeset View
Standalone View
Standalone View
src/core/kcoreconfigskeleton.h
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | 55 | public: | |||
---|---|---|---|---|---|
128 | void setWhatsThis(const QString &w); | 128 | void setWhatsThis(const QString &w); | ||
129 | 129 | | |||
130 | /** | 130 | /** | ||
131 | Return WhatsThis description of item. See setWhatsThis(). | 131 | Return WhatsThis description of item. See setWhatsThis(). | ||
132 | */ | 132 | */ | ||
133 | QString whatsThis() const; | 133 | QString whatsThis() const; | ||
134 | 134 | | |||
135 | /** | 135 | /** | ||
136 | The write flags to be used when writing configuration. | ||||
137 | @since 5.58 | ||||
138 | */ | ||||
139 | void setWriteFlags(KConfigBase::WriteConfigFlags flags); | ||||
140 | | ||||
141 | /** | ||||
142 | Return write flags to be used when writing configuration. | ||||
143 | They should be passed to every call of writeEntry() and revertToDefault(). | ||||
144 | @since 5.58 | ||||
145 | */ | ||||
146 | KConfigBase::WriteConfigFlags writeFlags() const; | ||||
147 | | ||||
148 | /** | ||||
136 | * This function is called by @ref KCoreConfigSkeleton to read the value for this setting | 149 | * This function is called by @ref KCoreConfigSkeleton to read the value for this setting | ||
137 | * from a config file. | 150 | * from a config file. | ||
138 | */ | 151 | */ | ||
139 | virtual void readConfig(KConfig *) = 0; | 152 | virtual void readConfig(KConfig *) = 0; | ||
140 | 153 | | |||
141 | /** | 154 | /** | ||
142 | * This function is called by @ref KCoreConfigSkeleton to write the value of this setting | 155 | * This function is called by @ref KCoreConfigSkeleton to write the value of this setting | ||
143 | * to a config file. | 156 | * to a config file. | ||
157 | * Make sure to pass writeFlags() to every call of writeEntry() and revertToDefault(). | ||||
144 | */ | 158 | */ | ||
145 | virtual void writeConfig(KConfig *) = 0; | 159 | virtual void writeConfig(KConfig *) = 0; | ||
146 | 160 | | |||
147 | /** | 161 | /** | ||
148 | * Read global default value. | 162 | * Read global default value. | ||
149 | */ | 163 | */ | ||
150 | virtual void readDefault(KConfig *) = 0; | 164 | virtual void readDefault(KConfig *) = 0; | ||
151 | 165 | | |||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
209 | 223 | | |||
210 | private: | 224 | private: | ||
211 | KConfigSkeletonItemPrivate *const d; | 225 | KConfigSkeletonItemPrivate *const d; | ||
212 | }; | 226 | }; | ||
213 | 227 | | |||
214 | /** | 228 | /** | ||
215 | * \class KConfigSkeletonGenericItem kcoreconfigskeleton.h <KConfigSkeletonGenericItem> | 229 | * \class KConfigSkeletonGenericItem kcoreconfigskeleton.h <KConfigSkeletonGenericItem> | ||
216 | */ | 230 | */ | ||
217 | template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeletonItem | 231 | template < typename T > class KConfigSkeletonGenericItem: public KConfigSkeletonItem | ||
davidedmundson: Can you move the new flag into KConfigSkeletonItem which is d-pointered and expose write flags… | |||||
218 | { | 232 | { | ||
219 | public: | 233 | public: | ||
220 | /** @copydoc KConfigSkeletonItem(const QString&, const QString&) | 234 | /** @copydoc KConfigSkeletonItem(const QString&, const QString&) | ||
221 | @param reference The initial value to hold in the item | 235 | @param reference The initial value to hold in the item | ||
222 | @param defaultValue The default value for the item | 236 | @param defaultValue The default value for the item | ||
223 | */ | 237 | */ | ||
224 | KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, | 238 | KConfigSkeletonGenericItem(const QString &_group, const QString &_key, T &reference, | ||
225 | T defaultValue) | 239 | T defaultValue) | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
269 | } | 283 | } | ||
270 | 284 | | |||
271 | /** @copydoc KConfigSkeletonItem::writeConfig(KConfig *) */ | 285 | /** @copydoc KConfigSkeletonItem::writeConfig(KConfig *) */ | ||
272 | void writeConfig(KConfig *config) override | 286 | void writeConfig(KConfig *config) override | ||
273 | { | 287 | { | ||
274 | if (mReference != mLoadedValue) { // Is this needed? | 288 | if (mReference != mLoadedValue) { // Is this needed? | ||
275 | KConfigGroup cg(config, mGroup); | 289 | KConfigGroup cg(config, mGroup); | ||
276 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | 290 | if ((mDefault == mReference) && !cg.hasDefault(mKey)) { | ||
277 | cg.revertToDefault(mKey); | 291 | cg.revertToDefault(mKey, writeFlags()); | ||
278 | } else { | 292 | } else { | ||
279 | cg.writeEntry(mKey, mReference); | 293 | cg.writeEntry(mKey, mReference, writeFlags()); | ||
280 | } | 294 | } | ||
281 | mLoadedValue = mReference; | 295 | mLoadedValue = mReference; | ||
282 | } | 296 | } | ||
283 | } | 297 | } | ||
284 | 298 | | |||
285 | /** @copydoc KConfigSkeletonItem::readDefault(KConfig*) */ | 299 | /** @copydoc KConfigSkeletonItem::readDefault(KConfig*) */ | ||
286 | void readDefault(KConfig *config) override | 300 | void readDefault(KConfig *config) override | ||
287 | { | 301 | { | ||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |
Can you move the new flag into KConfigSkeletonItem which is d-pointered and expose write flags with a protected accessor?