nymea/libnymea-core/scriptengine/scriptevent.h

84 lines
2.4 KiB
C++

// SPDX-License-Identifier: LGPL-3.0-or-later
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright (C) 2013 - 2024, nymea GmbH
* Copyright (C) 2024 - 2025, chargebyte austria GmbH
*
* This file is part of nymea.
*
* nymea is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* nymea 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nymea. If not, see <https://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef SCRIPTEVENT_H
#define SCRIPTEVENT_H
#include <QObject>
#include <QUuid>
#include <QQmlParserStatus>
#include "types/event.h"
#include "integrations/thingmanager.h"
namespace nymeaserver {
namespace scriptengine {
class ScriptParams;
class ScriptEvent: public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString thingId READ thingId WRITE setThingId NOTIFY thingIdChanged)
Q_PROPERTY(QString deviceId READ thingId WRITE setThingId NOTIFY thingIdChanged) // DEPRECATED
Q_PROPERTY(QString eventTypeId READ eventTypeId WRITE setEventTypeId NOTIFY eventTypeIdChanged)
Q_PROPERTY(QString eventName READ eventName WRITE setEventName NOTIFY eventNameChanged)
public:
ScriptEvent(QObject *parent = nullptr);
void classBegin() override;
void componentComplete() override;
QString thingId() const;
void setThingId(const QString &thingId);
QString eventTypeId() const;
void setEventTypeId(const QString &eventTypeId);
QString eventName() const;
void setEventName(const QString &eventName);
private slots:
void onEventTriggered(const Event &event);
signals:
void thingIdChanged();
void eventTypeIdChanged();
void eventNameChanged();
void triggered(const QVariantMap &params);
private:
ThingManager *m_thingManager = nullptr;
QString m_thingId;
QString m_eventTypeId;
QString m_eventName;
};
}
}
#endif // SCRIPTEVENT_H