1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2005-2006 Olivier Goffart <ogoffart at kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-only
6*/
7
8#include "knotifyconfigelement.h"
9
10#include <KConfig>
11#include <KConfigGroup>
12
13KNotifyConfigElement::KNotifyConfigElement(const QString &eventid, KConfig *config)
14 : m_config(new KConfigGroup(config, QStringLiteral("Event/") + eventid))
15 , m_eventId(eventid)
16{
17}
18
19KNotifyConfigElement::~KNotifyConfigElement()
20{
21 delete m_config;
22}
23
24QString KNotifyConfigElement::readEntry(const QString &entry, bool path)
25{
26 if (m_cache.contains(key: entry)) {
27 return m_cache[entry];
28 }
29 return path ? m_config->readPathEntry(pKey: entry, aDefault: QString()) : m_config->readEntry(key: entry, aDefault: QString());
30}
31
32void KNotifyConfigElement::writeEntry(const QString &entry, const QString &data)
33{
34 m_cache[entry] = data;
35}
36
37QString KNotifyConfigElement::eventId() const
38{
39 return m_eventId;
40}
41
42void KNotifyConfigElement::save()
43{
44 QMap<QString, QString>::const_iterator it = m_cache.constBegin();
45 for (; it != m_cache.constEnd(); ++it) {
46 m_config->writeEntry(key: it.key(), value: it.value());
47 }
48}
49

source code of knotifyconfig/src/knotifyconfigelement.cpp