bool TimeBasedEnumerationTrigger::enumerationNeeded() { bool ret = false; unsigned int currentTime = Time::getTimeAsMilliseconds(); if ( currentTime>=mNextTime ) { ret = true; updateNextTime(); } return ret; }
/*! * \brief Saves all the waiters to disk. * \details Saves all the waiters to disk. Called whenever a waiter is added or * removed. * Additionally this updates the time the next speech should occur, and notifies * the component. */ void WaiterDialog::commitChanges() { if(!statePath.isNull()) { std::sort(widgets.begin(), widgets.end(), [](const WaiterWidget *w1, const WaiterWidget *w2) { return w1->getMsecs() < w2->getMsecs(); }); for(auto w : widgets) ui->TimerScrollerWidget->layout()->removeWidget(w); for(auto w : widgets) ui->TimerScrollerWidget->layout()->addWidget(w); QFile file(statePath); file.open(QIODevice::WriteOnly); QTextStream out(&file); for(WaiterWidget *w : widgets) { out << w->toLoggableString() << '\n'; } updateNextTime(); Q_EMIT changeTimers(); } }
/*! * \brief Updates when to speak next, then sends the text to the component. * \param what What to say. */ void WaiterDialog::emitTextSlot(QString what) { Q_EMIT emitText(what); updateNextTime(); }