add more spacing
[personal-kdebase.git] / runtime / phonon / kcm / qsettingsgroup_p.h
blobb093225ce5dedb76c702e1aa11edbbaccda3f9d8
1 /* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) version 3.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #ifndef PHONON_QSETTINGSGROUP_P_H
22 #define PHONON_QSETTINGSGROUP_P_H
24 #include <QtCore/QSettings>
25 #include <QtCore/QString>
26 #include <QtCore/QVariant>
28 QT_BEGIN_HEADER
29 QT_BEGIN_NAMESPACE
31 namespace Phonon
33 class QSettingsGroup
35 public:
36 inline QSettingsGroup(QSettings *settings, const QString &name)
37 : m_mutableSettings(settings),
38 m_settings(settings),
39 m_group(name + QLatin1Char('/'))
43 inline QSettingsGroup(const QSettings *settings, const QString &name)
44 : m_mutableSettings(0),
45 m_settings(settings),
46 m_group(name + QLatin1Char('/'))
50 template<typename T>
51 inline T value(const QString &key, const T &def) const
53 return qvariant_cast<T>(value(key, qVariantFromValue(def)));
56 inline QVariant value(const QString &key, const QVariant &def) const
58 return m_settings->value(m_group + key, def);
61 template<typename T>
62 inline void setValue(const QString &key, const T &value)
64 Q_ASSERT(m_mutableSettings);
65 m_mutableSettings->setValue(m_group + key, qVariantFromValue(value));
68 inline void removeEntry(const QString &key)
70 Q_ASSERT(m_mutableSettings);
71 m_mutableSettings->remove(m_group + key);
74 bool hasKey(const QString &key) const
76 return m_settings->contains(m_group + key);
79 private:
80 QSettings *const m_mutableSettings;
81 const QSettings *const m_settings;
82 QString m_group;
84 } // namespace Phonon
86 QT_END_NAMESPACE
87 QT_END_HEADER
89 #endif // PHONON_QSETTINGSGROUP_P_H