File indexing completed on 2024-12-01 13:46:37

0001 // clang-format off
0002 /*
0003  *  This file is part of KDiff3.
0004  *
0005  * SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de
0006  * SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com
0007  * SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 // clang-format on
0010 
0011 #ifndef CONFIGVALUEMAP_H
0012 #define CONFIGVALUEMAP_H
0013 
0014 #include "common.h"
0015 
0016 #include <KConfigGroup>
0017 #include <QColor>
0018 #include <QFont>
0019 #include <QString>
0020 #include <QSize>
0021 #include <QPoint>
0022 
0023 class ConfigValueMap : public ValueMap
0024 {
0025   private:
0026     KConfigGroup m_config;
0027 
0028   public:
0029     explicit ConfigValueMap(const KConfigGroup& config) : m_config(config) {}
0030 
0031     void writeEntry(const QString& s, const QFont& v) override
0032     {
0033         m_config.writeEntry(s, v);
0034     }
0035     void writeEntry(const QString& s, const QColor& v) override
0036     {
0037         m_config.writeEntry(s, v);
0038     }
0039     void writeEntry(const QString& s, const QSize& v) override
0040     {
0041         m_config.writeEntry(s, v);
0042     }
0043     void writeEntry(const QString& s, const QPoint& v) override
0044     {
0045         m_config.writeEntry(s, v);
0046     }
0047     void writeEntry(const QString& s, qint32 v) override
0048     {
0049         m_config.writeEntry(s, v);
0050     }
0051     void writeEntry(const QString& s, bool v) override
0052     {
0053         m_config.writeEntry(s, v);
0054     }
0055     void writeEntry(const QString& s, const QString& v) override
0056     {
0057         m_config.writeEntry(s, v);
0058     }
0059     void writeEntry(const QString& s, const char* v) override
0060     {
0061         m_config.writeEntry(s, v);
0062     }
0063 private:
0064     QFont readFontEntry(const QString& s, const QFont* defaultVal) override
0065     {
0066         return m_config.readEntry(s, *defaultVal);
0067     }
0068     QColor readColorEntry(const QString& s, const QColor* defaultVal) override
0069     {
0070         return m_config.readEntry(s, *defaultVal);
0071     }
0072     QSize readSizeEntry(const QString& s, const QSize* defaultVal) override
0073     {
0074         return m_config.readEntry(s, *defaultVal);
0075     }
0076     QPoint readPointEntry(const QString& s, const QPoint* defaultVal) override
0077     {
0078         return m_config.readEntry(s, *defaultVal);
0079     }
0080     bool readBoolEntry(const QString& s, bool defaultVal) override
0081     {
0082         return m_config.readEntry(s, defaultVal);
0083     }
0084     qint32 readNumEntry(const QString& s, qint32 defaultVal) override
0085     {
0086         return m_config.readEntry(s, defaultVal);
0087     }
0088     QString readStringEntry(const QString& s, const QString& defaultVal) override
0089     {
0090         return m_config.readEntry(s, defaultVal);
0091     }
0092 
0093     void writeEntry(const QString& s, const QStringList& v) override
0094     {
0095         m_config.writeEntry(s, v);
0096     }
0097     QStringList readListEntry(const QString& s, const QStringList& def) override
0098     {
0099         return m_config.readEntry(s, def);
0100     }
0101 };
0102 
0103 #endif // !CONFIGVALUEMAP_H