You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
1.6 KiB
C++
89 lines
1.6 KiB
C++
#ifndef IPLUGIN_H
|
|
#define IPLUGIN_H
|
|
|
|
#include <QString>
|
|
#include <QWidget>
|
|
#include <QtPlugin>
|
|
#include <QJsonObject>
|
|
#include <QStringList>
|
|
#include <QIcon>
|
|
|
|
#include "service.h"
|
|
#include "igridform.h"
|
|
|
|
class IPlugin
|
|
{
|
|
|
|
public:
|
|
IPlugin() {
|
|
m_ui = NULL;
|
|
m_service = NULL;
|
|
m_settingsUi = NULL;
|
|
}
|
|
|
|
virtual ~IPlugin() {
|
|
if (m_service != NULL)
|
|
{
|
|
delete m_service;
|
|
}
|
|
|
|
if (m_ui != NULL && m_ui->parent() == NULL)
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
if (m_settingsUi != NULL && m_settingsUi->parent() == NULL)
|
|
{
|
|
delete m_settingsUi;
|
|
}
|
|
}
|
|
|
|
virtual QString pluginName() = 0;
|
|
virtual QString pluginId() = 0;
|
|
virtual QString pluginDescription() = 0;
|
|
virtual int schemaVersion() = 0;
|
|
virtual QStringList schemas() = 0;
|
|
virtual QStringList dependsOn() = 0;
|
|
|
|
virtual void init(const QJsonObject &metaData) = 0;
|
|
|
|
virtual QWidget *ui() {
|
|
IGridForm *form = qobject_cast<IGridForm*>(m_ui);
|
|
|
|
if (form != NULL)
|
|
{
|
|
form->fillData();
|
|
}
|
|
|
|
return m_ui;
|
|
}
|
|
|
|
virtual QWidget *settingsUi() {
|
|
return m_settingsUi;
|
|
}
|
|
|
|
virtual QString settingsTabLabel() {
|
|
return pluginName();
|
|
}
|
|
|
|
template<class T>
|
|
Service<T> *service() {
|
|
return (Service<T>*)m_service;
|
|
}
|
|
|
|
virtual QIcon pluginIcon() {
|
|
return QIcon();
|
|
}
|
|
|
|
protected:
|
|
QWidget *m_ui;
|
|
QWidget *m_settingsUi;
|
|
IService *m_service;
|
|
};
|
|
|
|
#define PluginInterface_iid "cz.itsolved.prodejna.IPlugin"
|
|
|
|
Q_DECLARE_INTERFACE(IPlugin, PluginInterface_iid)
|
|
|
|
#endif // IPLUGIN_H
|