61 lines
1.6 KiB
C
61 lines
1.6 KiB
C
|
|
// genericPluginAdapter.h
|
||
|
|
#pragma once
|
||
|
|
|
||
|
|
#include "pluginCommon/iPluginAdapter.h"
|
||
|
|
#include <QObject>
|
||
|
|
|
||
|
|
class ICanvasItem;
|
||
|
|
|
||
|
|
// 通用适配器实现
|
||
|
|
class GenericPluginAdapter :public IPluginAdapter
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
explicit GenericPluginAdapter(ICanvasItem *pluginItem, QObject *parent = nullptr);
|
||
|
|
virtual ~GenericPluginAdapter();
|
||
|
|
|
||
|
|
// IPluginAdapter接口
|
||
|
|
QString adapterType() const override { return "generic"; }
|
||
|
|
QString pluginType() const override;
|
||
|
|
|
||
|
|
QRectF bounds() const override;
|
||
|
|
void setBounds(const QRectF &bounds) override;
|
||
|
|
|
||
|
|
void paint(QPainter *painter, const QRectF &bounds) override;
|
||
|
|
QPainterPath shape() const override;
|
||
|
|
|
||
|
|
QVariant property(const QString &key) const override;
|
||
|
|
void setProperty(const QString &key, const QVariant &value) override;
|
||
|
|
|
||
|
|
void move(const QPointF &delta) override;
|
||
|
|
void resize(const QRectF &newBounds) override;
|
||
|
|
|
||
|
|
bool isSelected() const override;
|
||
|
|
void setSelected(bool selected) override;
|
||
|
|
|
||
|
|
QVariantMap saveState() const override;
|
||
|
|
bool loadState(const QVariantMap &state) override;
|
||
|
|
|
||
|
|
// 获取原始插件项
|
||
|
|
ICanvasItem* pluginItem() const;
|
||
|
|
|
||
|
|
signals:
|
||
|
|
void boundsChanged(const QRectF &newBounds);
|
||
|
|
void propertyChanged(const QString &key, const QVariant &value);
|
||
|
|
void selectionChanged(bool selected);
|
||
|
|
void adapterChanged();
|
||
|
|
|
||
|
|
private:
|
||
|
|
ICanvasItem *m_pluginItem = nullptr;
|
||
|
|
bool m_selected = false;
|
||
|
|
QRectF m_cachedBounds;
|
||
|
|
|
||
|
|
void updateCache();
|
||
|
|
void connectSignals();
|
||
|
|
|
||
|
|
private slots:
|
||
|
|
void onPluginBoundsChanged(const QRectF &newBounds);
|
||
|
|
void onPluginPropertyChanged(const QString &key, const QVariant &value);
|
||
|
|
};
|