54 lines
1.4 KiB
C
54 lines
1.4 KiB
C
|
|
// src/canvas/PluginItemFactory.h
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#include "export.hpp"
|
||
|
|
#include "functionModelItem/graphicsFunctionModelItem.h"
|
||
|
|
#include <QObject>
|
||
|
|
|
||
|
|
class PluginManager;
|
||
|
|
class ICanvasItem;
|
||
|
|
|
||
|
|
class DIAGRAM_DESIGNER_PUBLIC PluginItemFactory : public QObject
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
static PluginItemFactory* instance();
|
||
|
|
|
||
|
|
// 删除拷贝构造函数和赋值运算符
|
||
|
|
PluginItemFactory(const PluginItemFactory&) = delete;
|
||
|
|
PluginItemFactory& operator=(const PluginItemFactory&) = delete;
|
||
|
|
|
||
|
|
// 设置插件管理器
|
||
|
|
void setPluginManager(PluginManager *manager);
|
||
|
|
PluginManager* pluginManager() const;
|
||
|
|
|
||
|
|
// 创建图形项
|
||
|
|
GraphicsFunctionModelItem* createItem(const QString &shapeId,
|
||
|
|
QGraphicsItem *parent = nullptr);
|
||
|
|
|
||
|
|
// 从插件项创建图形项
|
||
|
|
GraphicsFunctionModelItem* createItemFromPlugin(ICanvasItem *pluginItem,
|
||
|
|
QGraphicsItem *parent = nullptr);
|
||
|
|
|
||
|
|
signals:
|
||
|
|
void itemCreated(GraphicsFunctionModelItem *item);
|
||
|
|
void creationFailed(const QString &shapeId, const QString &error);
|
||
|
|
|
||
|
|
private:
|
||
|
|
// 内联定义Private类
|
||
|
|
class Private
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
PluginManager *pluginManager = nullptr;
|
||
|
|
|
||
|
|
Private() = default;
|
||
|
|
~Private() = default;
|
||
|
|
};
|
||
|
|
|
||
|
|
explicit PluginItemFactory(QObject *parent = nullptr);
|
||
|
|
~PluginItemFactory() = default; // QScopedPointer自动管理内存
|
||
|
|
|
||
|
|
QScopedPointer<Private> d;
|
||
|
|
};
|