some fixes for timer letter
This commit is contained in:
parent
f7629352dd
commit
190a231a7b
3 changed files with 37 additions and 8 deletions
|
@ -284,6 +284,16 @@ public slots:
|
|||
*/
|
||||
bool setReactionTime(double rectionTime);
|
||||
|
||||
/*!
|
||||
* \brief Function to dircetly change the letter
|
||||
*
|
||||
* Only works when directControlEnabled is set to true!
|
||||
*
|
||||
* \param newLetter the letter to change to
|
||||
* \return false when directControlEnabled is set to false and the letter was therefore not modified, true otherwise
|
||||
*/
|
||||
bool setLetter(QString newLetter);
|
||||
|
||||
protected slots:
|
||||
|
||||
/*!
|
||||
|
|
|
@ -207,6 +207,8 @@ bool ScStwRemoteMonitorRace::refreshRemoteTimers(QVariantList remoteTimers) {
|
|||
this->timers[currId]->setReactionTime(remoteTimer.toMap()["reactionTime"].toDouble());
|
||||
|
||||
this->timers[currId]->setState(newState, true);
|
||||
|
||||
this->timers[currId]->setLetter(remoteTimer.toMap()["letter"].toString());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -21,7 +21,12 @@
|
|||
ScStwTimer::ScStwTimer(QObject *parent, bool directControlEnabled, QString letter) : QObject(parent)
|
||||
{
|
||||
this->directControlEnabled = directControlEnabled;
|
||||
this->letter = letter;
|
||||
|
||||
if(letter.length() > 1)
|
||||
this->letter = letter[0];
|
||||
else
|
||||
this->letter = letter;
|
||||
|
||||
this->startTime = 0;
|
||||
this->stopTime = 0;
|
||||
this->reactionTime = 0;
|
||||
|
@ -199,6 +204,14 @@ void ScStwTimer::setState(TimerState newState){
|
|||
}
|
||||
}
|
||||
|
||||
bool ScStwTimer::setLetter(QString newLetter) {
|
||||
if(!this->directControlEnabled)
|
||||
return false;
|
||||
|
||||
this->letter = newLetter;
|
||||
return true;
|
||||
}
|
||||
|
||||
ScStwTimer::TimerState ScStwTimer::getState() {
|
||||
return this->state;
|
||||
}
|
||||
|
@ -225,26 +238,27 @@ QString ScStwTimer::getLetter() {
|
|||
}
|
||||
|
||||
QString ScStwTimer::getText() {
|
||||
//qDebug() << this->getState();
|
||||
QString newText;
|
||||
|
||||
QString newText = "";
|
||||
int newTime = 0;
|
||||
switch (this->state) {
|
||||
case ScStwTimer::IDLE:
|
||||
newText = "0.000 sec";
|
||||
newTime = 0;
|
||||
break;
|
||||
case ScStwTimer::STARTING:
|
||||
newText = "0.000 sec";
|
||||
newTime = 0;
|
||||
break;
|
||||
case ScStwTimer::WAITING:
|
||||
newText = "please wait...";
|
||||
break;
|
||||
case ScStwTimer::RUNNING:
|
||||
newText = QString::number( this->getCurrentTime() / 1000.0, 'f', 3 ) + " sec";
|
||||
newTime = this->getCurrentTime();
|
||||
break;
|
||||
case ScStwTimer::WON:
|
||||
newText = QString::number( this->getCurrentTime() / 1000.0, 'f', 3 ) + " sec";
|
||||
newTime = this->getCurrentTime();
|
||||
break;
|
||||
case ScStwTimer::LOST:
|
||||
newText = QString::number( this->getCurrentTime() / 1000.0, 'f', 3 ) + " sec";
|
||||
newTime = this->getCurrentTime();
|
||||
break;
|
||||
case ScStwTimer::FAILED:
|
||||
newText = "false start";
|
||||
|
@ -257,6 +271,9 @@ QString ScStwTimer::getText() {
|
|||
break;
|
||||
}
|
||||
|
||||
if(newText == "")
|
||||
newText = QString::number( newTime / 1000.0, 'f', 3 ).rightJustified(6, '0');
|
||||
|
||||
return newText;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue