Commit fa5ead4e authored by Laurent Montel's avatar Laurent Montel 😁

USe abstract class

parent 9fdb405f
......@@ -21,7 +21,7 @@ include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
include(ECMInstallIcons)
set(PIM_VERSION "5.3.52")
set(PIM_VERSION "5.3.53")
set(PIMCOMMON_LIB_VERSION ${PIM_VERSION})
set(AKONADIMIME_LIB_VERSION "5.3.40")
......
......@@ -180,6 +180,8 @@ set(libpimcommon_generericplugin_SRCS
genericplugins/genericplugininterface.cpp
genericplugins/plugininterface.cpp
genericplugins/pluginutil.cpp
genericplugins/abstractgenericplugin.cpp
genericplugins/abstractgenericplugininterface.cpp
)
set(libpimcommon_configure_plugins_SRCS
......@@ -352,6 +354,8 @@ ecm_generate_headers(PimCommon_CamelCasegenericplugins_HEADERS
GenericPluginManager
GenericPlugin
GenericPluginInterface
AbstractGenericPlugin
AbstractGenericPluginInterface
PluginUtil
PluginInterface
REQUIRED_HEADERS PimCommon_genericplugins_HEADERS
......
......@@ -20,7 +20,7 @@
using namespace PimCommon;
GenericPlugin::GenericPlugin(QObject *parent)
: QObject(parent)
: AbstractGenericPlugin(parent)
{
}
......@@ -29,20 +29,3 @@ GenericPlugin::~GenericPlugin()
{
}
bool GenericPlugin::hasPopupMenuSupport() const
{
return false;
}
bool GenericPlugin::hasToolBarSupport() const
{
return false;
}
bool GenericPlugin::hasConfigureDialog() const
{
return false;
}
......@@ -18,23 +18,18 @@
#ifndef GENERICPLUGIN_H
#define GENERICPLUGIN_H
#include <QObject>
#include "abstractgenericplugin.h"
#include "pimcommon_export.h"
class KActionCollection;
namespace PimCommon
{
class GenericPluginInterface;
class PIMCOMMON_EXPORT GenericPlugin : public QObject
class PIMCOMMON_EXPORT GenericPlugin : public AbstractGenericPlugin
{
Q_OBJECT
public:
explicit GenericPlugin(QObject *parent = Q_NULLPTR);
~GenericPlugin();
virtual PimCommon::GenericPluginInterface *createInterface(KActionCollection *ac, QWidget *parent = Q_NULLPTR) = 0;
virtual bool hasPopupMenuSupport() const;
virtual bool hasToolBarSupport() const;
virtual bool hasConfigureDialog() const;
};
}
#endif // GENERICPLUGIN_H
......@@ -23,18 +23,14 @@ class PimCommon::GenericPluginInterfacePrivate
{
public:
GenericPluginInterfacePrivate()
: plugin(Q_NULLPTR),
parentWidget(Q_NULLPTR)
{
}
ActionType actionType;
GenericPlugin *plugin;
QWidget *parentWidget;
};
GenericPluginInterface::GenericPluginInterface(QObject *parent)
: QObject(parent),
: AbstractGenericPluginInterface(parent),
d(new GenericPluginInterfacePrivate)
{
......@@ -45,16 +41,6 @@ GenericPluginInterface::~GenericPluginInterface()
delete d;
}
void GenericPluginInterface::setParentWidget(QWidget *parent)
{
d->parentWidget = parent;
}
QWidget *GenericPluginInterface::parentWidget() const
{
return d->parentWidget;
}
void GenericPluginInterface::setActionType(const ActionType &type)
{
d->actionType = type;
......@@ -65,16 +51,6 @@ ActionType GenericPluginInterface::actionType() const
return d->actionType;
}
void GenericPluginInterface::setPlugin(GenericPlugin *plugin)
{
d->plugin = plugin;
}
GenericPlugin *GenericPluginInterface::plugin() const
{
return d->plugin;
}
void GenericPluginInterface::updateActions(int numberOfSelectedItems, int numberOfSelectedCollections)
{
Q_UNUSED(numberOfSelectedItems);
......@@ -106,11 +82,6 @@ PimCommon::GenericPluginInterface::RequireTypes GenericPluginInterface::requires
return None;
}
void GenericPluginInterface::showConfigureDialog(QWidget *parentWidget)
{
Q_UNUSED(parentWidget);
}
ActionType::ActionType(QAction *action, ActionType::Type type)
: mAction(action),
mType(type)
......
......@@ -17,9 +17,11 @@
#ifndef GENERICPLUGININTERFACE_H
#define GENERICPLUGININTERFACE_H
#include <QObject>
#include <AkonadiCore/Item>
#include "abstractgenericplugininterface.h"
#include "pimcommon_export.h"
#include <AkonadiCore/Item>
class QAction;
class KActionCollection;
namespace PimCommon
......@@ -53,7 +55,7 @@ private:
};
class GenericPluginInterfacePrivate;
class PIMCOMMON_EXPORT GenericPluginInterface : public QObject
class PIMCOMMON_EXPORT GenericPluginInterface : public AbstractGenericPluginInterface
{
Q_OBJECT
public:
......@@ -70,17 +72,9 @@ public:
Q_ENUMS(RequireType)
Q_DECLARE_FLAGS(RequireTypes, RequireType)
void setParentWidget(QWidget *parent);
QWidget *parentWidget() const;
void setActionType(const ActionType &type);
ActionType actionType() const;
void setPlugin(GenericPlugin *plugin);
GenericPlugin *plugin() const;
virtual void createAction(KActionCollection *ac) = 0;
virtual void exec() = 0;
virtual void setCurrentItems(const Akonadi::Item::List &items);
virtual void setItems(const Akonadi::Item::List &items);
virtual void setCurrentCollection(const Akonadi::Collection &col);
......@@ -88,12 +82,8 @@ public:
virtual GenericPluginInterface::RequireTypes requires() const;
virtual void showConfigureDialog(QWidget *parentWidget = Q_NULLPTR);
virtual void updateActions(int numberOfSelectedItems, int numberOfSelectedCollections);
Q_SIGNALS:
void emitPluginActivated(PimCommon::GenericPluginInterface *interface);
private:
GenericPluginInterfacePrivate *const d;
......
......@@ -85,14 +85,15 @@ void PluginInterface::createPluginInterface()
return;
}
Q_FOREACH (PimCommon::GenericPlugin *plugin, PimCommon::GenericPluginManager::self()->pluginsList()) {
PimCommon::GenericPluginInterface *interface = plugin->createInterface(d->mActionCollection, d->mParentWidget);
PimCommon::GenericPluginInterface *interface = static_cast<PimCommon::GenericPluginInterface *>(plugin->createInterface(d->mActionCollection, this));
interface->setParentWidget(d->mParentWidget);
interface->setPlugin(plugin);
connect(interface, &PimCommon::GenericPluginInterface::emitPluginActivated, this, &PluginInterface::slotPluginActivated);
d->mListGenericInterface.append(interface);
}
}
void PluginInterface::initializeInterfaceRequires(PimCommon::GenericPluginInterface *interface)
void PluginInterface::initializeInterfaceRequires(PimCommon::AbstractGenericPluginInterface *interface)
{
Q_UNUSED(interface)
}
......@@ -116,7 +117,7 @@ QString PluginInterface::actionXmlExtension(ActionType::Type type)
return {};
}
void PluginInterface::slotPluginActivated(PimCommon::GenericPluginInterface *interface)
void PluginInterface::slotPluginActivated(PimCommon::AbstractGenericPluginInterface *interface)
{
initializeInterfaceRequires(interface);
if (interface) {
......
......@@ -42,7 +42,7 @@ public:
void setPluginName(const QString &name);
void setServiceTypeName(const QString &name);
void initializePlugins();
virtual void initializeInterfaceRequires(PimCommon::GenericPluginInterface *interface);
virtual void initializeInterfaceRequires(AbstractGenericPluginInterface *interface);
static QString actionXmlExtension(PimCommon::ActionType::Type type);
void initializePluginActions(const QString &prefix, KXMLGUIClient *guiClient);
......@@ -55,7 +55,7 @@ public:
QString configPrefixSettingKey() const;
private Q_SLOTS:
void slotPluginActivated(PimCommon::GenericPluginInterface *interface);
void slotPluginActivated(AbstractGenericPluginInterface *interface);
private:
PluginInterfacePrivate *const d;
......
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