summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-22 11:23:49 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-22 11:23:49 (GMT)
commit9fdb405f608216bb5e9397a3017e055771cb1378 (patch)
treeec551f81b75751f4f295184b124d97bde8a0309e
parentf82a210808b4aaed9adcd545c03df7f944f4d6d6 (diff)
Add abstract class for plugin and plugin interface
-rw-r--r--src/genericplugins/abstractgenericplugin.cpp48
-rw-r--r--src/genericplugins/abstractgenericplugin.h40
-rw-r--r--src/genericplugins/abstractgenericplugininterface.cpp70
-rw-r--r--src/genericplugins/abstractgenericplugininterface.h54
4 files changed, 212 insertions, 0 deletions
diff --git a/src/genericplugins/abstractgenericplugin.cpp b/src/genericplugins/abstractgenericplugin.cpp
new file mode 100644
index 0000000..f9d00ba
--- /dev/null
+++ b/src/genericplugins/abstractgenericplugin.cpp
@@ -0,0 +1,48 @@
+/*
+ Copyright (c) 2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "abstractgenericplugin.h"
+
+using namespace PimCommon;
+
+AbstractGenericPlugin::AbstractGenericPlugin(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+AbstractGenericPlugin::~AbstractGenericPlugin()
+{
+
+}
+
+bool AbstractGenericPlugin::hasPopupMenuSupport() const
+{
+ return false;
+}
+
+bool AbstractGenericPlugin::hasToolBarSupport() const
+{
+ return false;
+}
+
+bool AbstractGenericPlugin::hasConfigureDialog() const
+{
+ return false;
+}
+
+
diff --git a/src/genericplugins/abstractgenericplugin.h b/src/genericplugins/abstractgenericplugin.h
new file mode 100644
index 0000000..b167e51
--- /dev/null
+++ b/src/genericplugins/abstractgenericplugin.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (c) 2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef AbstractGENERICPLUGIN_H
+#define AbstractGENERICPLUGIN_H
+
+#include <QObject>
+#include "pimcommon_export.h"
+class KActionCollection;
+namespace PimCommon
+{
+class AbstractGenericPluginInterface;
+class PIMCOMMON_EXPORT AbstractGenericPlugin : public QObject
+{
+ Q_OBJECT
+public:
+ explicit AbstractGenericPlugin(QObject *parent = Q_NULLPTR);
+ ~AbstractGenericPlugin();
+
+ virtual PimCommon::AbstractGenericPluginInterface *createInterface(KActionCollection *ac, QObject *parent = Q_NULLPTR) = 0;
+ virtual bool hasPopupMenuSupport() const;
+ virtual bool hasToolBarSupport() const;
+ virtual bool hasConfigureDialog() const;
+};
+}
+#endif // AbstractGENERICPLUGIN_H
diff --git a/src/genericplugins/abstractgenericplugininterface.cpp b/src/genericplugins/abstractgenericplugininterface.cpp
new file mode 100644
index 0000000..f1748de
--- /dev/null
+++ b/src/genericplugins/abstractgenericplugininterface.cpp
@@ -0,0 +1,70 @@
+/*
+ Copyright (c) 2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "abstractgenericplugininterface.h"
+
+using namespace PimCommon;
+
+class PimCommon::AbstractGenericPluginInterfacePrivate
+{
+public:
+ AbstractGenericPluginInterfacePrivate()
+ : plugin(Q_NULLPTR),
+ parentWidget(Q_NULLPTR)
+ {
+
+ }
+ AbstractGenericPlugin *plugin;
+ QWidget *parentWidget;
+};
+
+AbstractGenericPluginInterface::AbstractGenericPluginInterface(QObject *parent)
+ : QObject(parent),
+ d(new AbstractGenericPluginInterfacePrivate)
+{
+
+}
+
+AbstractGenericPluginInterface::~AbstractGenericPluginInterface()
+{
+ delete d;
+}
+
+void AbstractGenericPluginInterface::setParentWidget(QWidget *parent)
+{
+ d->parentWidget = parent;
+}
+
+QWidget *AbstractGenericPluginInterface::parentWidget() const
+{
+ return d->parentWidget;
+}
+
+void AbstractGenericPluginInterface::setPlugin(AbstractGenericPlugin *plugin)
+{
+ d->plugin = plugin;
+}
+
+AbstractGenericPlugin *AbstractGenericPluginInterface::plugin() const
+{
+ return d->plugin;
+}
+
+void AbstractGenericPluginInterface::showConfigureDialog(QWidget *parentWidget)
+{
+ Q_UNUSED(parentWidget);
+}
diff --git a/src/genericplugins/abstractgenericplugininterface.h b/src/genericplugins/abstractgenericplugininterface.h
new file mode 100644
index 0000000..a8450be
--- /dev/null
+++ b/src/genericplugins/abstractgenericplugininterface.h
@@ -0,0 +1,54 @@
+/*
+ Copyright (c) 2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef AbstractGENERICPLUGININTERFACE_H
+#define AbstractGENERICPLUGININTERFACE_H
+#include <QObject>
+#include "pimcommon_export.h"
+class QAction;
+class KActionCollection;
+namespace PimCommon
+{
+class AbstractGenericPlugin;
+
+class AbstractGenericPluginInterfacePrivate;
+class PIMCOMMON_EXPORT AbstractGenericPluginInterface : public QObject
+{
+ Q_OBJECT
+public:
+ explicit AbstractGenericPluginInterface(QObject *parent = Q_NULLPTR);
+ ~AbstractGenericPluginInterface();
+
+ void setParentWidget(QWidget *parent);
+ QWidget *parentWidget() const;
+
+ void setPlugin(AbstractGenericPlugin *plugin);
+ AbstractGenericPlugin *plugin() const;
+
+ virtual void createAction(KActionCollection *ac) = 0;
+ virtual void exec() = 0;
+
+ virtual void showConfigureDialog(QWidget *parentWidget = Q_NULLPTR);
+
+Q_SIGNALS:
+ void emitPluginActivated(PimCommon::AbstractGenericPluginInterface *interface);
+
+private:
+ AbstractGenericPluginInterfacePrivate *const d;
+};
+}
+#endif // AbstractGENERICPLUGININTERFACE_H