bool QTimerProto::isSingleShot() const { QTimer *item = qscriptvalue_cast<QTimer*>(thisObject()); if (item) return item->isSingleShot(); return false; }
QScriptValue TimerClass::property(const QScriptValue &object, const QScriptString &name, uint /*id*/) { QTimer *timer = qscriptvalue_cast<QTimer*>(object.data()); if (!timer) return QScriptValue(); if (name == _interval) { return timer->interval(); } else if (name == _singleShot) { return timer->isSingleShot(); } return QScriptValue(); }
void ScriptEngine::timer() { QTimer *t = (QTimer*) sender(); if (timerEvents[t].isFunction()) { timerEvents[t].call(); } else if (timerEvents[t].isString()) { eval(timerEvents[t].toString()); } else { warn("ScriptEngine::timer", "this is a bug, report it. code is not string or function"); return; } if (t->isSingleShot()) { timerEvents.remove(t); t->deleteLater(); } }