Commit a7d069f2 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove duplicate code

parent 919451b1
Pipeline #50348 passed with stage
in 41 minutes and 54 seconds
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
set(PIM_VERSION "5.16.43")
set(PIM_VERSION "5.16.44")
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
......
......@@ -150,6 +150,10 @@ set(messagecomposer_plugineditorgrammar_SRCS
plugineditorgrammar/plugineditorgrammarmanager.cpp
plugineditorgrammar/plugineditorgrammarcustomtoolsviewinterface.cpp
)
set(messagecomposer_plugineditorbase_SRCS
plugineditorbase/plugineditorbase.cpp
)
set(messagecomposer_sendlater_SRCS
sendlater/sendlaterinfo.cpp
sendlater/sendlaterjob.cpp
......@@ -184,6 +188,7 @@ set( messagecomposer_src
${messagecomposer_plugineditorcheckbeforesend_SRCS}
${messagecomposer_plugineditorgrammar_SRCS}
${messagecomposer_sendlater_SRCS}
${messagecomposer_plugineditorbase_SRCS}
utils/util.cpp
settings/messagecomposersettings.cpp
)
......@@ -302,6 +307,14 @@ ecm_generate_headers(MessageComposer_Camelplugineditorinit_HEADERS
RELATIVE plugineditorinit
)
ecm_generate_headers(MessageComposer_CamelPluginEditorBase_HEADERS
HEADER_NAMES
PluginEditorBase
REQUIRED_HEADERS MessageComposer_PluginEditorBase_HEADERS
PREFIX MessageComposer
RELATIVE plugineditorbase
)
ecm_generate_headers(MessageComposer_Camelplugineditorconverttext_HEADERS
HEADER_NAMES
PluginEditorConvertTextConfigureWidget
......@@ -487,8 +500,8 @@ ecm_generate_pri_file(BASE_NAME MessageComposer
DEPS "KMime MessageCore PimCommon Akonadi KIdentityManagement AkonadiMime Libkleo" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/MessageComposer
)
install(FILES
${MessageComposer_CamelPluginEditorBase_HEADERS}
${MessageComposer_Camelsnippet_HEADERS}
${MessageComposer_Camelplugineditorconverttext_HEADERS}
${MessageComposer_Camelplugineditorinit_HEADERS}
......@@ -515,6 +528,7 @@ install(FILES
install(FILES
${MessageComposer_HEADERS}
${MessageComposer_PluginEditorBase_HEADERS}
${MessageComposer_snippet_HEADERS}
${MessageComposer_plugineditorconverttext_HEADERS}
${MessageComposer_plugineditorinit_HEADERS}
......
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "plugineditorbase.h"
using namespace MessageComposer;
class MessageComposer::PluginEditorBasePrivate
{
public:
PluginEditorBasePrivate()
{
}
bool mIsEnabled = false;
};
PluginEditorBase::PluginEditorBase(QObject *parent)
: QObject(parent)
, d(new MessageComposer::PluginEditorBasePrivate)
{
}
PluginEditorBase::~PluginEditorBase()
{
delete d;
}
bool PluginEditorBase::hasConfigureDialog() const
{
return false;
}
void PluginEditorBase::showConfigureDialog(QWidget *parent)
{
Q_UNUSED(parent)
}
void PluginEditorBase::emitConfigChanged()
{
Q_EMIT configChanged();
}
QString PluginEditorBase::description() const
{
return {};
}
void PluginEditorBase::setIsEnabled(bool enabled)
{
d->mIsEnabled = enabled;
}
bool PluginEditorBase::isEnabled() const
{
return d->mIsEnabled;
}
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef PLUGINEDITORBASE_H
#define PLUGINEDITORBASE_H
#include "messagecomposer_export.h"
#include <QObject>
namespace MessageComposer
{
class PluginEditorBasePrivate;
class PluginEditorBaseInterface;
/**
* @brief The PluginEditorBase class
* @author Laurent Montel <montel@kde.org>
*/
class MESSAGECOMPOSER_EXPORT PluginEditorBase : public QObject
{
Q_OBJECT
public:
explicit PluginEditorBase(QObject *parent = nullptr);
~PluginEditorBase() override;
Q_REQUIRED_RESULT virtual bool hasConfigureDialog() const;
virtual void showConfigureDialog(QWidget *parent = nullptr);
void emitConfigChanged();
Q_REQUIRED_RESULT virtual QString description() const;
void setIsEnabled(bool enabled);
Q_REQUIRED_RESULT bool isEnabled() const;
Q_SIGNALS:
void configChanged();
private:
PluginEditorBasePrivate *const d;
};
}
#endif // PLUGINEDITORBASE_H
......@@ -8,53 +8,11 @@
using namespace MessageComposer;
class MessageComposer::PluginEditorCheckBeforeSendPrivate
{
public:
PluginEditorCheckBeforeSendPrivate()
{
}
bool mIsEnabled = false;
};
PluginEditorCheckBeforeSend::PluginEditorCheckBeforeSend(QObject *parent)
: QObject(parent)
, d(new MessageComposer::PluginEditorCheckBeforeSendPrivate)
: PluginEditorBase(parent)
{
}
PluginEditorCheckBeforeSend::~PluginEditorCheckBeforeSend()
{
delete d;
}
bool PluginEditorCheckBeforeSend::hasConfigureDialog() const
{
return false;
}
void PluginEditorCheckBeforeSend::showConfigureDialog(QWidget *parent)
{
Q_UNUSED(parent)
}
void PluginEditorCheckBeforeSend::emitConfigChanged()
{
Q_EMIT configChanged();
}
QString PluginEditorCheckBeforeSend::description() const
{
return {};
}
void PluginEditorCheckBeforeSend::setIsEnabled(bool enabled)
{
d->mIsEnabled = enabled;
}
bool PluginEditorCheckBeforeSend::isEnabled() const
{
return d->mIsEnabled;
}
......@@ -8,17 +8,16 @@
#define PLUGINEDITORCHECKBEFORESEND_H
#include "messagecomposer_export.h"
#include <QObject>
#include <MessageComposer/PluginEditorBase>
namespace MessageComposer
{
class PluginEditorCheckBeforeSendPrivate;
class PluginEditorCheckBeforeSendInterface;
/**
* @brief The PluginEditorCheckBeforeSend class
* @author Laurent Montel <montel@kde.org>
*/
class MESSAGECOMPOSER_EXPORT PluginEditorCheckBeforeSend : public QObject
class MESSAGECOMPOSER_EXPORT PluginEditorCheckBeforeSend : public PluginEditorBase
{
Q_OBJECT
public:
......@@ -26,23 +25,6 @@ public:
~PluginEditorCheckBeforeSend() override;
virtual PluginEditorCheckBeforeSendInterface *createInterface(QObject *parent) = 0;
Q_REQUIRED_RESULT virtual bool hasConfigureDialog() const;
virtual void showConfigureDialog(QWidget *parent = nullptr);
void emitConfigChanged();
Q_REQUIRED_RESULT virtual QString description() const;
void setIsEnabled(bool enabled);
Q_REQUIRED_RESULT bool isEnabled() const;
Q_SIGNALS:
void configChanged();
private:
PluginEditorCheckBeforeSendPrivate *const d;
};
}
#endif // PLUGINEDITORCHECKBEFORESEND_H
......@@ -32,11 +32,12 @@ public:
void emitConfigChanged();
Q_REQUIRED_RESULT virtual QString description() const;
void setIsEnabled(bool enabled);
Q_REQUIRED_RESULT bool isEnabled() const;
Q_REQUIRED_RESULT virtual QString description() const;
Q_REQUIRED_RESULT virtual bool canWorkOnHtml() const;
Q_REQUIRED_RESULT virtual bool hasStatusBarSupport() const;
......
......@@ -8,53 +8,11 @@
using namespace MessageComposer;
class MessageComposer::PluginEditorInitPrivate
{
public:
PluginEditorInitPrivate()
{
}
bool mIsEnabled = false;
};
PluginEditorInit::PluginEditorInit(QObject *parent)
: QObject(parent)
, d(new MessageComposer::PluginEditorInitPrivate)
: PluginEditorBase(parent)
{
}
PluginEditorInit::~PluginEditorInit()
{
delete d;
}
bool PluginEditorInit::hasConfigureDialog() const
{
return false;
}
void PluginEditorInit::showConfigureDialog(QWidget *parent)
{
Q_UNUSED(parent)
}
void PluginEditorInit::emitConfigChanged()
{
Q_EMIT configChanged();
}
QString PluginEditorInit::description() const
{
return {};
}
void PluginEditorInit::setIsEnabled(bool enabled)
{
d->mIsEnabled = enabled;
}
bool PluginEditorInit::isEnabled() const
{
return d->mIsEnabled;
}
......@@ -8,17 +8,17 @@
#define PLUGINEDITORINIT_H
#include "messagecomposer_export.h"
#include <MessageComposer/PluginEditorBase>
#include <QObject>
namespace MessageComposer
{
class PluginEditorInitPrivate;
class PluginEditorInitInterface;
/**
* @brief The PluginEditorInit class
* @author Laurent Montel <montel@kde.org>
*/
class MESSAGECOMPOSER_EXPORT PluginEditorInit : public QObject
class MESSAGECOMPOSER_EXPORT PluginEditorInit : public PluginEditorBase
{
Q_OBJECT
public:
......@@ -26,23 +26,6 @@ public:
~PluginEditorInit() override;
virtual PluginEditorInitInterface *createInterface(QObject *parent) = 0;
Q_REQUIRED_RESULT virtual bool hasConfigureDialog() const;
virtual void showConfigureDialog(QWidget *parent = nullptr);
void emitConfigChanged();
Q_REQUIRED_RESULT virtual QString description() const;
void setIsEnabled(bool enabled);
Q_REQUIRED_RESULT bool isEnabled() const;
Q_SIGNALS:
void configChanged();
private:
PluginEditorInitPrivate *const d;
};
}
#endif // PLUGINEDITORINIT_H
Markdown is supported
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