File indexing completed on 2024-05-12 05:55:42

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2023 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_CASESENSITIVITYCONFIGENTRY_HPP
0010 #define KASTEN_CASESENSITIVITYCONFIGENTRY_HPP
0011 
0012 // KF
0013 #include <KConfigGroup>
0014 // Qt
0015 #include <Qt>
0016 
0017 template <>
0018 inline Qt::CaseSensitivity KConfigGroup::readEntry(const char *key, const Qt::CaseSensitivity &defaultValue) const
0019 {
0020     const QString entry = readEntry(key, QString());
0021     const Qt::CaseSensitivity caseSensitivity =
0022         (entry == QLatin1String("Sensitive")) ?   Qt::CaseSensitive :
0023         (entry == QLatin1String("Insensitive")) ? Qt::CaseInsensitive :
0024         /* else */                                defaultValue;
0025     return caseSensitivity;
0026 }
0027 
0028 template <>
0029 inline void KConfigGroup::writeEntry(const char *key, const Qt::CaseSensitivity &value,
0030                                      KConfigBase::WriteConfigFlags flags)
0031 {
0032     const QString valueString =
0033         (value == Qt::CaseSensitive) ? QLatin1String("Sensitive") : QLatin1String("Insensitive");
0034     writeEntry(key, valueString, flags);
0035 }
0036 
0037 #endif