File indexing completed on 2022-11-23 10:35:59

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2005-2006 Olivier Goffart <ogoffart at kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "knotifyconfigelement.h"
0009 
0010 #include <KConfig>
0011 #include <KConfigGroup>
0012 
0013 KNotifyConfigElement::KNotifyConfigElement(const QString &eventid, KConfig *config)
0014     : m_config(new KConfigGroup(config, QStringLiteral("Event/") + eventid))
0015     , m_eventId(eventid)
0016 {
0017 }
0018 
0019 KNotifyConfigElement::~KNotifyConfigElement()
0020 {
0021     delete m_config;
0022 }
0023 
0024 QString KNotifyConfigElement::readEntry(const QString &entry, bool path)
0025 {
0026     if (m_cache.contains(entry)) {
0027         return m_cache[entry];
0028     }
0029     return path ? m_config->readPathEntry(entry, QString()) : m_config->readEntry(entry, QString());
0030 }
0031 
0032 void KNotifyConfigElement::writeEntry(const QString &entry, const QString &data)
0033 {
0034     m_cache[entry] = data;
0035 }
0036 
0037 QString KNotifyConfigElement::eventId() const
0038 {
0039     return m_eventId;
0040 }
0041 
0042 void KNotifyConfigElement::save()
0043 {
0044     QMap<QString, QString>::const_iterator it = m_cache.constBegin();
0045     for (; it != m_cache.constEnd(); ++it) {
0046         m_config->writeEntry(it.key(), it.value());
0047     }
0048 }
0049 
0050 bool KNotifyConfigElement::have_tts() //[static]
0051 {
0052     // TODO: Add a runtime check to see if the status is not BackendError
0053 #ifdef HAVE_SPEECH
0054     return true;
0055 #else
0056     return false;
0057 #endif
0058 }