summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-22 11:28:20 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-22 11:28:20 (GMT)
commitfa5ead4e626590cfa06d22720b6d1757792d4095 (patch)
treef4592e15f149f2cb4a718fd0fe7689441ce50cf1
parent9fdb405f608216bb5e9397a3017e055771cb1378 (diff)
USe abstract class
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/genericplugins/genericplugin.cpp19
-rw-r--r--src/genericplugins/genericplugin.h9
-rw-r--r--src/genericplugins/genericplugininterface.cpp31
-rw-r--r--src/genericplugins/genericplugininterface.h18
-rw-r--r--src/genericplugins/plugininterface.cpp7
-rw-r--r--src/genericplugins/plugininterface.h4
8 files changed, 19 insertions, 75 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2c441d5..02f2fad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2d8aa7a..a923695 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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
diff --git a/src/genericplugins/genericplugin.cpp b/src/genericplugins/genericplugin.cpp
index 04b94e5..64311d0 100644
--- a/src/genericplugins/genericplugin.cpp
+++ b/src/genericplugins/genericplugin.cpp
@@ -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;
-}
-
-
diff --git a/src/genericplugins/genericplugin.h b/src/genericplugins/genericplugin.h
index 99a68de..7f123e7 100644
--- a/src/genericplugins/genericplugin.h
+++ b/src/genericplugins/genericplugin.h
@@ -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
diff --git a/src/genericplugins/genericplugininterface.cpp b/src/genericplugins/genericplugininterface.cpp
index 887bd65..a610918 100644
--- a/src/genericplugins/genericplugininterface.cpp
+++ b/src/genericplugins/genericplugininterface.cpp
@@ -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)
diff --git a/src/genericplugins/genericplugininterface.h b/src/genericplugins/genericplugininterface.h
index 6cbcad3..a1e4997 100644
--- a/src/genericplugins/genericplugininterface.h
+++ b/src/genericplugins/genericplugininterface.h
@@ -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;
diff --git a/src/genericplugins/plugininterface.cpp b/src/genericplugins/plugininterface.cpp
index 61e82b4..a7e59cc 100644
--- a/src/genericplugins/plugininterface.cpp
+++ b/src/genericplugins/plugininterface.cpp
@@ -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) {
diff --git a/src/genericplugins/plugininterface.h b/src/genericplugins/plugininterface.h
index 0b86832..ea860f3 100644
--- a/src/genericplugins/plugininterface.h
+++ b/src/genericplugins/plugininterface.h
@@ -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;