24 lines
714 B
C++
24 lines
714 B
C++
#pragma once
|
|
/****************************
|
|
* 变量控制处理器
|
|
* *************************/
|
|
#include "eventHandler.h"
|
|
|
|
class VariableSetEventHandler : public EventHandler {
|
|
public:
|
|
bool canHandle(const QString& eventType) const override {
|
|
return eventType == "setVariable";
|
|
}
|
|
|
|
void handle(const EventData& event, GraphicsFunctionModelItem* item) override {
|
|
QString varName = event.parameters.value("variable").toString();
|
|
QVariant value = event.parameters.value("value");
|
|
|
|
if (auto context = item->eventContext()) {
|
|
context->emitVariableSet(varName, value);
|
|
}
|
|
}
|
|
|
|
QString handlerName() const override { return "VariableSetHandler"; }
|
|
};
|