Commit 05707aba authored by Volker Krause's avatar Volker Krause
Browse files

Remove unused CategoryConfig class

The only thing used from this was a string constant, in a single place
internally here.
parent d815b453
Pipeline #155682 passed with stage
in 58 seconds
......@@ -9,7 +9,6 @@ target_sources(KF5CalendarSupport PRIVATE
archivedialog.cpp
attachmenthandler.cpp
calendarsingleton.cpp
categoryconfig.cpp
categoryhierarchyreader.cpp
cellitem.cpp
collectionselection.cpp
......@@ -56,7 +55,6 @@ target_sources(KF5CalendarSupport PRIVATE
printing/calprintdefaultplugins.h
printing/yearprint.h
printing/calprinter.h
categoryconfig.h
kcalprefs.h
urihandler.h
incidenceattachmentmodel.h
......@@ -130,7 +128,6 @@ install(TARGETS
ecm_generate_headers(CalendarSupport_CamelCase_HEADERS
HEADER_NAMES
Utils
CategoryConfig
CellItem
CollectionSelection
KCalPrefs
......
/*
SPDX-FileCopyrightText: 2002 Cornelius Schumacher <schumacher@kde.org>
SPDX-FileCopyrightText: 2005 Rafal Rzepecki <divide@users.sourceforge.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "categoryconfig.h"
#include <KConfigGroup>
#include <KCoreConfigSkeleton>
#include <KLocalizedString>
#include <QColor>
using namespace CalendarSupport;
static QStringList categoryDefaults()
{
QStringList l;
l << i18nc("incidence category: appointment", "Appointment") << i18nc("incidence category", "Business") << i18nc("incidence category", "Meeting")
<< i18nc("incidence category: phone call", "Phone Call") << i18nc("incidence category", "Education")
<< i18nc(
"incidence category: "
"official or unofficial observance of "
"religious/national/cultural/other significance, "
"often accompanied by celebrations or festivities",
"Holiday")
<< i18nc(
"incidence category: "
"a lengthy time away from work or school, a trip abroad, "
"or simply a pleasure trip away from home",
"Vacation")
<< i18nc(
"incidence category: "
"examples: anniversary of historical or personal event; "
"big date; remembrance, etc",
"Special Occasion")
<< i18nc("incidence category", "Personal")
<< i18nc(
"incidence category: "
"typically associated with leaving home for business, "
"and not pleasure",
"Travel")
<< i18nc("incidence category", "Miscellaneous") << i18nc("incidence category", "Birthday");
return l;
}
class CalendarSupport::CategoryConfigPrivate
{
public:
explicit CategoryConfigPrivate(KCoreConfigSkeleton *cfg)
: config(cfg)
{
mDefaultCategoryColor = QColor(151, 235, 121);
}
QColor mDefaultCategoryColor;
KCoreConfigSkeleton *const config;
};
QHash<QString, QColor> CategoryConfig::readColors() const
{
// Category colors
QHash<QString, QColor> categoryColors;
KConfigGroup colorsConfig(d->config->config(), "Category Colors2");
const QStringList cats = customCategories();
for (const QString &category : cats) {
const QColor color = colorsConfig.readEntry(category, d->mDefaultCategoryColor);
if (color != d->mDefaultCategoryColor) {
categoryColors.insert(category, color);
}
}
return categoryColors;
}
void CategoryConfig::setColors(const QHash<QString, QColor> &colors)
{
KConfigGroup colorsConfig(d->config->config(), "Category Colors2");
QHash<QString, QColor>::const_iterator i = colors.constBegin();
QHash<QString, QColor>::const_iterator end = colors.constEnd();
while (i != end) {
colorsConfig.writeEntry(i.key(), i.value());
++i;
}
}
CategoryConfig::CategoryConfig(KCoreConfigSkeleton *cfg, QObject *parent)
: QObject(parent)
, d(new CategoryConfigPrivate(cfg))
{
}
CategoryConfig::~CategoryConfig() = default;
void CategoryConfig::writeConfig()
{
d->config->save();
}
QStringList CategoryConfig::customCategories() const
{
KConfigGroup group(d->config->config(), "General");
QStringList cats = group.readEntry("Custom Categories", categoryDefaults());
cats.sort();
return cats;
}
void CategoryConfig::setCustomCategories(const QStringList &categories)
{
KConfigGroup group(d->config->config(), "General");
group.writeEntry("Custom Categories", categories);
}
const QString CategoryConfig::categorySeparator(QLatin1Char(':'));
/*
SPDX-FileCopyrightText: 2002 Cornelius Schumacher <schumacher@kde.org>
SPDX-FileCopyrightText: 2005 Rafal Rzepecki <divide@users.sourceforge.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include "calendarsupport_export.h"
#include <QHash>
#include <QObject>
#include <memory>
class KCoreConfigSkeleton;
class QColor;
namespace CalendarSupport
{
class CategoryConfigPrivate;
class CALENDARSUPPORT_EXPORT CategoryConfig : public QObject
{
Q_OBJECT
public:
explicit CategoryConfig(KCoreConfigSkeleton *cfg, QObject *parent = nullptr);
~CategoryConfig() override;
Q_REQUIRED_RESULT QStringList customCategories() const;
void setCustomCategories(const QStringList &categories);
Q_REQUIRED_RESULT QHash<QString, QColor> readColors() const;
void setColors(const QHash<QString, QColor> &colors);
void writeConfig();
static const QString categorySeparator;
private:
Q_DISABLE_COPY(CategoryConfig)
std::unique_ptr<CategoryConfigPrivate> const d;
};
}
......@@ -5,12 +5,16 @@
*/
#include "categoryhierarchyreader.h"
#include "categoryconfig.h"
#include <QComboBox>
using namespace CalendarSupport;
namespace CategoryConfig
{
static const QLatin1String categorySeparator(":");
}
inline QString &quote(QString &string)
{
Q_ASSERT(CategoryConfig::categorySeparator != QLatin1String("@"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment