You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
543 B
30 lines
543 B
7 years ago
|
#include "widgetseventservice.h"
|
||
|
|
||
|
WidgetsEventService::WidgetsEventService(QObject *parent) :
|
||
|
QObject(parent),
|
||
|
IEventService(),
|
||
|
_cnt(0),
|
||
|
_events()
|
||
|
{}
|
||
|
|
||
|
int WidgetsEventService::addEvent(const QString &name)
|
||
|
{
|
||
|
QSharedPointer<QTimer> timer {
|
||
|
new QTimer(this),
|
||
|
&QTimer::deleteLater
|
||
|
};
|
||
|
|
||
|
_events.insert(_cnt, timer);
|
||
|
connect(timer.data(), &QTimer::timeout, this, [this, name]() {
|
||
|
emit eventTriggered(name);
|
||
|
});
|
||
|
timer->start(1000);
|
||
|
|
||
|
return _cnt++;
|
||
|
}
|
||
|
|
||
|
void WidgetsEventService::removeEvent(int eventId)
|
||
|
{
|
||
|
_events.remove(eventId);
|
||
|
}
|