void UtilitiesView::addLapTime(){
    QTime currentTime(0,0,0,0), prevTime(0,0,0,0), prevRoundTime(0,0,0,0), roundTime(0,0,0,0), gap(0,0,0,0);

    if(currentLap>0){
        prevTime = QTime::fromString(ui->timeTable->item(currentLap-1,0)->text(),"mm:ss:zzz");
        prevRoundTime = QTime::fromString(ui->timeTable->item(currentLap-1,1)->text(),"mm:ss:zzz");
    }

    ui->timeTable->insertRow(currentLap);

    currentTime = currentTime.addMSecs(lastTime);
    ui->timeTable->setItem(currentLap, 0, new QTableWidgetItem(currentTime.toString("mm:ss:zzz")));

    roundTime = roundTime.addMSecs(prevTime.msecsTo(currentTime));
    ui->timeTable->setItem(currentLap, 1, new QTableWidgetItem(roundTime.toString("mm:ss:zzz")));

    gap = gap.addMSecs(prevRoundTime.msecsTo(roundTime));
    ui->timeTable->setItem(currentLap, 2, new QTableWidgetItem(gap.toString("ss:zzz")));


    currentLap++;
}
Example #2
0
bool TimeScale::getTickText(double pos, double lastPos,
                            int line, QString &str) const {
	if ( !_showAbsoluteValues )
		return Ruler::getTickText(pos, lastPos, line, str);

	// Fixed floating point precision error
	pos += 0.0005;

	if ( line == 0 ) {
		try {
			Seiscomp::Core::Time time(pos);
			if ( !time.valid() ) return false;

			str = time.toString(_primaryTimeFormat).c_str();
			return true;
		}
		catch ( const Core::OverflowException&) { return false; }
		
	}

	if ( line == 1 && _showAbsoluteDate ) {
		try {
			Seiscomp::Core::Time time(pos);
			if ( time.valid() ) {
				std::string timeStr = time.toString(_secondaryTimeFormat);
				Seiscomp::Core::Time prevTime(lastPos);
				if ( !prevTime.valid() ||
				     prevTime.toString(_secondaryTimeFormat) != timeStr ) {
					str = timeStr.c_str();
					return true;
				}
			}
		}
		catch ( const Core::OverflowException&) { return false; }
	}

	return false;
}