Commit 58dd7d58 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Improve plugin

parent 890724f2
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(PIM_VERSION "5.17.52")
set(PIM_VERSION "5.17.53")
project(Messagelib VERSION ${PIM_VERSION})
......
......@@ -5,6 +5,7 @@
*/
#include "messageviewercheckbeforedeletinginterface.h"
#include "messageviewercheckbeforedeletingparameters.h"
using namespace MessageViewer;
......@@ -15,6 +16,7 @@ public:
{
}
MessageViewer::MessageViewerCheckBeforeDeletingParameters parameters;
QWidget *mParentWidget = nullptr;
};
......@@ -43,3 +45,13 @@ void MessageViewerCheckBeforeDeletingInterface::reloadConfig()
{
// Reimplement it
}
void MessageViewerCheckBeforeDeletingInterface::setParameters(const MessageViewer::MessageViewerCheckBeforeDeletingParameters &params)
{
d->parameters = params;
}
MessageViewer::MessageViewerCheckBeforeDeletingParameters MessageViewerCheckBeforeDeletingInterface::parameters() const
{
return d->parameters;
}
......@@ -11,6 +11,7 @@
namespace MessageViewer
{
class MessageViewerCheckBeforeDeletingParameters;
class MessageViewerCheckBeforeDeletingInterfacePrivate;
/**
* @brief The MessageViewerCheckBeforeDeletingInterface class
......@@ -26,7 +27,10 @@ public:
void setParentWidget(QWidget *parent);
Q_REQUIRED_RESULT QWidget *parentWidget() const;
// TODO add virtual method
virtual bool exec() = 0;
void setParameters(const MessageViewer::MessageViewerCheckBeforeDeletingParameters &params);
Q_REQUIRED_RESULT MessageViewer::MessageViewerCheckBeforeDeletingParameters parameters() const;
public Q_SLOTS:
virtual void reloadConfig();
......
......@@ -13,6 +13,7 @@ public:
MessageViewerCheckBeforeDeletingParametersPrivate()
{
}
MessageViewerCheckBeforeDeletingParameters::DeleteType mType = MessageViewerCheckBeforeDeletingParameters::Unknown;
};
MessageViewerCheckBeforeDeletingParameters::MessageViewerCheckBeforeDeletingParameters()
......@@ -20,6 +21,35 @@ MessageViewerCheckBeforeDeletingParameters::MessageViewerCheckBeforeDeletingPara
{
}
MessageViewerCheckBeforeDeletingParameters::MessageViewerCheckBeforeDeletingParameters(const MessageViewerCheckBeforeDeletingParameters &other)
: d(new MessageViewer::MessageViewerCheckBeforeDeletingParametersPrivate)
{
(*this) = other;
}
MessageViewerCheckBeforeDeletingParameters::~MessageViewerCheckBeforeDeletingParameters()
{
}
MessageViewerCheckBeforeDeletingParameters::DeleteType MessageViewerCheckBeforeDeletingParameters::deleteType() const
{
return d->mType;
}
void MessageViewerCheckBeforeDeletingParameters::setDeleteType(DeleteType type)
{
d->mType = type;
}
MessageViewerCheckBeforeDeletingParameters &MessageViewerCheckBeforeDeletingParameters::operator=(const MessageViewerCheckBeforeDeletingParameters &other)
{
if (this != &other) {
d->mType = other.deleteType();
}
return *this;
}
bool MessageViewerCheckBeforeDeletingParameters::operator==(const MessageViewerCheckBeforeDeletingParameters &other) const
{
return (d->mType == other.deleteType());
}
......@@ -6,6 +6,7 @@
#pragma once
#include "messageviewer_export.h"
#include <QString>
namespace MessageViewer
{
class MessageViewerCheckBeforeDeletingParametersPrivate;
......@@ -13,8 +14,21 @@ class MESSAGEVIEWER_EXPORT MessageViewerCheckBeforeDeletingParameters
{
public:
MessageViewerCheckBeforeDeletingParameters();
MessageViewerCheckBeforeDeletingParameters(const MessageViewerCheckBeforeDeletingParameters &other);
~MessageViewerCheckBeforeDeletingParameters();
enum DeleteType {
Unknown = 0,
MoveToTrash = 1,
Delete = 2,
};
Q_REQUIRED_RESULT MessageViewerCheckBeforeDeletingParameters::DeleteType deleteType() const;
void setDeleteType(MessageViewerCheckBeforeDeletingParameters::DeleteType type);
MessageViewerCheckBeforeDeletingParameters &operator=(const MessageViewerCheckBeforeDeletingParameters &other);
Q_REQUIRED_RESULT bool operator==(const MessageViewerCheckBeforeDeletingParameters &other) const;
private:
MessageViewerCheckBeforeDeletingParametersPrivate *const d;
};
......
......@@ -37,13 +37,13 @@ public:
{
}
QVector<MessageViewer::MessageViewerCheckBeforeDeletingPlugin *> pluginsList() const;
QVector<PimCommon::PluginUtilData> pluginDataList() const;
Q_REQUIRED_RESULT QVector<MessageViewer::MessageViewerCheckBeforeDeletingPlugin *> pluginsList() const;
Q_REQUIRED_RESULT QVector<PimCommon::PluginUtilData> pluginDataList() const;
void initializePluginList();
void loadPlugin(CheckBeforeDeletingPluginInfo *item);
QString configGroupName() const;
QString configPrefixSettingKey() const;
MessageViewerCheckBeforeDeletingPlugin *pluginFromIdentifier(const QString &id);
Q_REQUIRED_RESULT QString configGroupName() const;
Q_REQUIRED_RESULT QString configPrefixSettingKey() const;
Q_REQUIRED_RESULT MessageViewerCheckBeforeDeletingPlugin *pluginFromIdentifier(const QString &id);
private:
QVector<PimCommon::PluginUtilData> mPluginDataList;
......@@ -77,7 +77,6 @@ QString MessageViewerCheckBeforeDeletingPluginManagerPrivate::configPrefixSettin
void MessageViewerCheckBeforeDeletingPluginManagerPrivate::initializePluginList()
{
const QVector<KPluginMetaData> plugins = KPluginLoader::findPlugins(QStringLiteral("messageviewer/checkbeforedeleting"));
QVectorIterator<KPluginMetaData> i(plugins);
i.toBack();
const QPair<QStringList, QStringList> pair = PimCommon::PluginUtil::loadPluginSetting(configGroupName(), configPrefixSettingKey());
......
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