Example #1
0
RenderStatus& RenderThread::getStatus()
{
	status.Name = rtype;

	if (rendering)
	{
		QTime zero;
		const QTime time(zero.addMSecs((int)_est_remain));

		status.State = RenderStatus::Busy;
		status.Type = current_request->type();
		status.EstRemain = time;
		status.Percent = _percent_finished;
	}
	else if (kill_all_jobs || _stop_current_job)
	{
		status.State = RenderStatus::Killed;
	}
	else
	{
		QTime zero;
		const QTime timer(zero.addMSecs(millis));
		status.State = RenderStatus::Idle;
		status.Runtime = timer;
	}
	return status;
}
Example #2
0
void DVDPanel::updateInfo()
{
  if (!mediaPlayer->isDVD())
    return;

  int title, ch;
  long pos, len;
  mediaPlayer->dvdGetLocation(&title, &ch, &pos, &len);
  if (mediaPlayer->isPlaying()) {
    appState->dvdPos = pos;
    appState->dvdTitle = title;
    appState->dvdChapter = ch;
  }
  QTime zero;
  if (title == 0)
    labels[TRACKNAME]->setText(QString("DVD: Menu"));
  else
    labels[TRACKNAME]->setText(QString("DVD: Title %1, Chapter %2")
			       .arg(title)
			       .arg(ch));
  labels[CURRENTTRACKTIME]->setText(zero.addMSecs(pos).toString("hh:mm"));
  labels[TRACKTIME]->setText(zero.addMSecs(len).toString("hh:mm"));
  labels[TIME]->setText(QTime::currentTime().toString("hh:mm:ss"));
  labels[DATE]->setText(QDate::currentDate().toString("d/M/yyyy"));
  if (mediaPlayer->isPlaying())
    labels[STATUS]->setText("PLAY");
  else if (mediaPlayer->isPaused())
    labels[STATUS]->setText("PAUSE");
  else if (mediaPlayer->isStopped())
    labels[STATUS]->setText("STOP");
  labels[VOLUME]->setText(QString::number(mediaPlayer->getVolume()) + "%");
  //  if (mediaPlayer->isPlaying() && len > 0 && pos > len - 2*UPDATE_DELAY)
  //    next();
}
void MainDialog::showNumberImages()
{
    int numberOfImages = m_ImagesFilesListBox->imageUrls().count();
    QTime totalDuration (0, 0, 0);

    int transitionDuration = 2000;

    if ( m_openglCheckBox->isChecked() )
        transitionDuration += 500;

    if (numberOfImages != 0)
    {
        if ( m_sharedData->useMilliseconds )
            totalDuration = totalDuration.addMSecs(numberOfImages * m_delaySpinBox->text().toInt());
        else
            totalDuration = totalDuration.addSecs(numberOfImages * m_delaySpinBox->text().toInt());

        totalDuration = totalDuration.addMSecs((numberOfImages - 1) * transitionDuration);
    }

    m_totalTime = totalDuration;

    // Notify total time is changed
    emit signalTotalTimeChanged(m_totalTime);

    m_label6->setText(i18np("%1 image [%2]", "%1 images [%2]", numberOfImages, totalDuration.toString()));
}
Example #4
0
void CassetteWorker::run()
{
    /* Open serial port */
    if (!mPort->open()) {
        return;
    }

    int lastBaud = 0;
    int block = 1;
    int remainingTime = mTotalDuration;

    QTime tm = QTime::currentTime();

    foreach (CassetteRecord record, mRecords) {
        if (lastBaud != record.baudRate) {
            lastBaud = record.baudRate;
            if (!mPort->setSpeed(lastBaud)) {
                return;
            }
        }
        emit statusChanged(remainingTime);
        qDebug() << "!n" << tr("[Cassette] Playing record %1 of %2 (%3 ms of gap + %4 bytes of data)")
                .arg(block)
                .arg(mRecords.count())
                .arg(record.gapDuration)
                .arg(record.data.length());
        tm = tm.addMSecs(record.gapDuration);
        int w = QTime::currentTime().msecsTo(tm);
        if (w < 0) {
            w = 0;
        }
        if (mustTerminate.tryLock(w)) {
            return;
        }
        tm = QTime::currentTime();
        tm = tm.addMSecs((record.data.length() * 10000 + (lastBaud/2))/lastBaud);
        for (int i=0; i < record.data.length(); i+=10) {
            mPort->writeRawFrame(record.data.mid(i, 10));
            if (mustTerminate.tryLock()) {
                return;
            }
        }
        block++;
        remainingTime -= record.totalDuration;
    }
    // Wait until last written bytes are transferred and then some (FTDI bug)
    int w = QTime::currentTime().msecsTo(tm);
    if (w < 0) {
        w = 0;
    }
    msleep(w + 500);
    mPort->close();
}
Example #5
0
void RundownGroupWidget::durationChanged(int duration)
{
    Q_UNUSED(duration);

    QTime time = QTime::fromString(QString("00:00:00").append((this->useDropFrameNotation == true) ? ".00" : ":00"));
    this->labelDuration->setText(QString("Duration: %1").arg(Timecode::fromTime(time.addMSecs(this->command.getDuration()), this->useDropFrameNotation)));
}
Example #6
0
TableModel::TableModel(QObject *parent) :
    QAbstractTableModel(parent)
{
    headerNames.append(tr("Server name"));
    headerNames.append(tr("Status"));
    headerNames.append(tr("Server port"));
    headerNames.append(tr("Start time"));
    headerNames.append(tr("Running time"));
    mRowCount = GameServerFactory::registeredServer().size();
    mColCount = headerNames.size();
    table = new QVariant* [mRowCount];
    for (int i = 0; i < mRowCount; i++)
        table[i] = new QVariant [mColCount];
    for (int i = 0; i < mRowCount; i++)
        for (int j = 0; j < mColCount; j++) {
            AbstractGameServer* server = GameServerFactory::registeredServer().at(i);
            QString str = "";
            switch(j) {
            case 0 : str = server->serverName(); break;
            case 1 : str = !server->serverState() ? tr("Running") : tr("Not running"); break;
            case 2 : str = QString::number(server->serverPort()); break;
            case 3 : str = server->startTime().toString("dd.MM.yyyy hh:mm:ss"); break;
            case 4 : {
                QTime time;
                time = time.addMSecs(server->runningTime());
                str = time.toString("hh:mm:ss");
                break;
            }
            }
            table[i][j] = str;
        }

}
Example #7
0
/** \fn mythCurrentDateTime()
 *  \brief Returns the current QDateTime object, stripped of its msec component
 */
QDateTime mythCurrentDateTime()
{
    QDateTime rettime = QDateTime::currentDateTime();
    QTime orig = rettime.time();
    rettime.setTime(orig.addMSecs(-orig.msec()));
    return rettime;
}
Example #8
0
/*!
  Translate from double to QDateTime

  \param value Number of milliseconds since the epoch, 
               1970-01-01T00:00:00 UTC
  \param timeSpec Time specification
  \return Datetime value

  \sa toDouble(), QDateTime::setMSecsSinceEpoch()
  \note The return datetime for Qt::OffsetFromUTC will be Qt::UTC
 */
QDateTime QwtDate::toDateTime( double value, Qt::TimeSpec timeSpec )
{
    const int msecsPerDay = 86400000;

    const double days = static_cast<qint64>( ::floor( value / msecsPerDay ) );

    const double jd = QwtDate::JulianDayForEpoch + days;
    if ( ( jd > maxJulianDayD ) || ( jd < minJulianDayD ) )
    {
        qWarning() << "QwtDate::toDateTime: overflow";
        return QDateTime();
    }

    const QDate d = QDate::fromJulianDay( static_cast<QwtJulianDay>( jd ) );

    const int msecs = static_cast<int>( value - days * msecsPerDay );

    static const QTime timeNull( 0, 0, 0, 0 );

    QDateTime dt( d, timeNull.addMSecs( msecs ), Qt::UTC );

    if ( timeSpec == Qt::LocalTime )
        dt = qwtToTimeSpec( dt, timeSpec );

    return dt;
}
Example #9
0
/**
 * called when the user changes the slider position 
 * @param value
 */
void MediaApp::setPosition(int value) {
    uint length = -m_player->getLength().msecsTo(QTime());
    if (length != 0 && value > 0) {
        QTime pos;
        pos = pos.addMSecs(length * (value / 1000.0));
        m_player->setPosition(pos);
    }
}
Example #10
0
bool QTDSResult::gotoNext(QSqlCachedResult::ValueCache &values, int index)
{
    STATUS stat = dbnextrow(d->dbproc);
    if (stat == NO_MORE_ROWS) {
        setAt(QSql::AfterLastRow);
        return false;
    }
    if ((stat == FAIL) || (stat == BUF_FULL)) {
        setLastError(d->lastError);
        return false;
    }

    if (index < 0)
        return true;

    for (int i = 0; i < d->rec.count(); ++i) {
        int idx = index + i;
        switch (d->rec.field(i).type()) {
            case QVariant::DateTime:
                if (qIsNull(d->buffer.at(i * 2 + 1))) {
                    values[idx] = QVariant(QVariant::DateTime);
                } else {
                    DBDATETIME *bdt = (DBDATETIME*) d->buffer.at(i * 2);
                    QDate date = QDate::fromString(QLatin1String("1900-01-01"), Qt::ISODate);
                    QTime time = QTime::fromString(QLatin1String("00:00:00"), Qt::ISODate);
                    values[idx] = QDateTime(date.addDays(bdt->dtdays), time.addMSecs(int(bdt->dttime / 0.3)));
                }
                break;
            case QVariant::Int:
                if (qIsNull(d->buffer.at(i * 2 + 1)))
                    values[idx] = QVariant(QVariant::Int);
                else
                    values[idx] = *((int*)d->buffer.at(i * 2));
                break;
            case QVariant::Double:
            case QVariant::String:
                if (qIsNull(d->buffer.at(i * 2 + 1)))
                    values[idx] = QVariant(QVariant::String);
                else
                    values[idx] = QString::fromLocal8Bit((const char*)d->buffer.at(i * 2)).trimmed();
                break;
            case QVariant::ByteArray: {
                if (qIsNull(d->buffer.at(i * 2 + 1)))
                    values[idx] = QVariant(QVariant::ByteArray);
                else
                    values[idx] = QByteArray((const char*)d->buffer.at(i * 2));
                break;
            }
            default:
                // should never happen, and we already fired
                // a warning while binding.
                values[idx] = QVariant();
                break;
        }
    }

    return true;
}
void k9ChapterEdit::sliderChanged(int _value) {
   if (m_aviDecode->opened()) {
        //m_aviDecode->seek((double)slider->value() / 100);
        m_aviDecode->readFrame((double)_value / 1000);
        QTime t;
        t=t.addMSecs((double)_value);
        Ui_chapterEdit.lPosition->setText(t.toString("hh:mm:ss"));
    }
}
Example #12
0
QVector<AlarmTask> AlarmRepository::match(const QTime &currentTime) const
{
    QVector<AlarmTask> result;
    foreach (AlarmTask alarmTask, alarmTaskList) {
        QTime begin = alarmTask.getTime();
        QTime end = begin.addMSecs(alarmTask.getDurationMs());
        if (currentTime >= begin  && currentTime <= end) {
            result.push_back(alarmTask);
        }
    }
Example #13
0
QString SomeUtils::prepareTime(const float ms)
{
    QTime dt = QTime::fromString("0", "z");
    dt = dt.addMSecs(ms);
    QString timeStr;
    timeStr = QString(tr("%1h %2m %3s %4ms")).arg(dt.toString("hh"))
                                             .arg(dt.toString("mm"))
                                             .arg(dt.toString("ss"))
                                             .arg(dt.toString("zzz"));
    return timeStr.remove(QRegExp("^(00. )*"));
}
Example #14
0
// get the value as time
QTime KCValue::asTime(const KCCalculationSettings* settings) const
{
    Q_UNUSED(settings);
    QTime dt;

    const int days = asInteger();
    const int msecs = qRound(numToDouble(asFloat() - double(days)) * 86400000.0);      // 24*60*60*1000
    dt = dt.addMSecs(msecs);

    return dt;
}
Example #15
0
void Player::seek(qint64 value)
{
    uint length = -m_GstPlayer->length().msecsTo(QTime());
    if (length != 0 && value > -1) {
        QTime pos;
        pos = pos.addMSecs(length * (value / 1000.0));
        m_GstPlayer->setPosition(pos);

        Q_EMIT seeked(length * (value / 1000.0) * 1000);
    }
}
Example #16
0
void FingerPrintsGenerator::complete()
{
    QTime t;
    t = t.addMSecs(d->duration.elapsed());
    setLabel(i18n("<b>Update of fingerprint database complete.</b>"));
    setTitle(i18n("Duration: %1", t.toString()));
    setButtonGuiItem(KStandardGuiItem::ok());
    setButtonText(i18n("&Close"));
    // Pop-up a message to bring user when all is done.
    KNotificationWrapper("fingerprintscompleted", i18n("Update of fingerprint database complete."),
                         this, windowTitle());
    emit signalRebuildAllFingerPrintsDone();
}
bool MDG_23_by_Geo_Stress_Test_Simple::movement()
{
    qDebug() << "MDG 23 by Geo simple stress test movement starting.";

    if (this->isNULL())
    {
        return false;
    }

    bool result = true;
    SMSD_4_2* stepMotor = this->monochromator->getStepMotorController();

    for (int i = 0; i < ui->spinBoxTimes->value(); i++)
    {
        qDebug() << "Phase number: " << i;

        if (i > 0)
        {
            qDebug() << "MDG 23 by Geo waiting pause between times.";

            QTest::qWait(1000.0*(this->times_pause_seconds));
        }

        ui->labelCurrentTimes->setText("Current times " + QString::number(i + 1));

        QTime passed = QTime(0, 0, 0, 0).addMSecs(timer.elapsed());
        ui->labelTimePassed->setText("Passed " + passed.toString("hh:mm:ss.zzz"));

        QTime remained = QTime(0, 0, 0, 0);
        if (1000*this->time_length - timer.elapsed() > 0)
        {
            remained = remained.addMSecs(1000*this->time_length - timer.elapsed());
            ui->labelTimeRemain->setText("Remained " + remained.toString("hh:mm:ss.zzz"));
        }
        else
        {
            ui->labelTimeRemain->setText("Stress test took longer, than expected...");
        }

        result &= stepMotor->moveStep(this->speed, ui->comboBoxMovementDirection->currentText() == "Right",
                                      ui->spinBoxStep->value());

        qDebug() << "MDG 23 by Geo waiting command to finish.";

        QTest::qWait(_round(1000.0*(1.0 * ui->spinBoxStep->value() / this->speed)));
    }

    qDebug() << "MDG 23 by Geo simple stress test movement finished.";

    return result;
}
Example #18
0
void QmitkSimulationView::OnTimeout()
{
  QTime currentTime = QTime::currentTime();

  if (currentTime.msecsTo(m_NextRenderWindowUpdate) > 0)
  {
    this->OnStep(false);
  }
  else
  {
    m_NextRenderWindowUpdate = currentTime.addMSecs(MsPerFrame);
    this->OnStep(true);
  }
}
Example #19
0
void BatchFaceDetector::complete()
{
    QTime t;
    t = t.addMSecs(d->duration.elapsed());
    setLabel(i18n("<b>Scanning for people completed.</b>"));
    setTitle(i18n("Duration: %1", t.toString()));
    // set value to be sure in case of scanning for tags and total was too large
    setValue(d->total);
    setButtonGuiItem(KStandardGuiItem::ok());
    setButtonText(i18n("&Close"));
    // Pop-up a message to bring user when all is done.
    KNotificationWrapper("batchfacedetectioncompleted", i18n("The face detected database has been updated."),
                         this, windowTitle());
    emit signalDetectAllFacesDone();
}
Example #20
0
  QString CDInfoDialog::framesTime(unsigned frames)
  {
      QTime time;
      double ms;

      ms = frames * 1000 / 75.0;
      time = time.addMSecs((int)ms);

      // Use ".zzz" for milliseconds...
      QString temp2;
      if (time.hour() > 0)
          temp2 = time.toString(QLatin1String( "hh:mm:ss" ));
      else
          temp2 = time.toString(QLatin1String( "mm:ss" ));
      return temp2;
  } // framesTime
Example #21
0
void MainWidget::generateData()
{
  QString sql;
  RDSqlQuery *q;
  QString rml;
  QString desc;

  //
  // Create Carts
  //
  for(int i=0;i<SAS_OUTPUTS;i++) {
    rml=QString();
    for(int j=0;j<SAS_INPUTS;j++) {
      rml+=QString().sprintf("ST %d %d %d!SP %d!",
			     SAS_MATRIX,j+1,i+1,SAS_SLEEP);
    }
    sql=QString().sprintf("insert into CART set NUMBER=%d,TYPE=2,\
                           GROUP_NAME=\"TEMP\",TITLE=\"Walk SAS Output %d\",\
                           ARTIST=\"SAS_TORTURE\",MACROS=\"%s\"",
			  i+CART_START,i+1,(const char *)rml);
    q=new RDSqlQuery(sql);
    delete q;
  }

  //
  // Create Schedule
  //
  QTime time;
  for(int i=0;i<86400000;i+=TIME_INTERVAL) {
    for(int j=0;j<SAS_OUTPUTS;j++) {
      desc=QString().sprintf("Walk SAS Output %d",j+1);
      sql=QString().sprintf("insert into RECORDINGS set STATION_NAME=\"%s\",\
                         SUN=\'Y\',MON=\'Y\',TUE=\'Y\',WED=\'Y\',THU=\'Y\',\
                         FRI=\'Y\',SAT=\'Y\',DESCRIPTION=\"%s\",\
                         CUT_NAME=\"SAS_TORTURE\",MACRO_CART=%d,\
                         START_TIME=\"%s\",TYPE=1",
			    SAS_STATION,
			    (const char *)desc,
			    CART_START+j,
			    (const char *)time.toString("hh:mm:ss"));
      q=new RDSqlQuery(sql);
      delete q;
    }
    time=time.addMSecs(TIME_INTERVAL);
  }
}
void MetaDataLoader::fetch() {
    if (m_fetched) return;
    if (m_player->error() != QMediaPlayer::NoError) {
        qDebug() << "fetch error: " << m_player->errorString() << m_player->error();
        failed();
    }
    if (!m_player->metaData(QtMultimediaKit::AlbumArtist).isNull())
    m_current.setArtist(m_player->metaData(QtMultimediaKit::AlbumArtist).toString());
    m_current.setAlbumTitle(m_player->metaData(QtMultimediaKit::AlbumTitle).toString());
    m_current.setTrackNumber(m_player->metaData(QtMultimediaKit::TrackNumber).toString());

    m_current.setComment(m_player->metaData(QtMultimediaKit::Comment).toString());
    m_current.setTrackTitle(m_player->metaData(QtMultimediaKit::Title).toString());
    m_current.setGenre(m_player->metaData(QtMultimediaKit::Genre).toString());
    QVariant imgvar = m_player->metaData(QtMultimediaKit::CoverArtImage);
    QList<QtMultimediaKit::MetaData> metadata = m_player->availableMetaData ();
    QStringList sl = m_player->availableExtendedMetaData();
    if (!imgvar.isNull())
        m_current.setImage(qVariantValue<QImage>(imgvar));

    // Musicmatch rating:
    QString rating = m_player->extendedMetaData("extended-comment").toString();
    if (!rating.isEmpty()) {
        int equalsPos = rating.indexOf("=");
        if (equalsPos != -1)
            rating = rating.mid(equalsPos+1);
        else m_current.setComment(rating);
        Preference p(rating);
        m_current.setPreference(p);
    }

    if (m_player->duration() > 0) {
        m_timeOut.stop();
        QTime t;
        t = t.addMSecs(m_player->duration());
        m_current.setTrackTime(t);
        emit fetched(m_current);
        m_isRunning = false;
        m_fetched = true;
        m_player->stop();
        // Give a short delay so we don't thrash the player
        m_timer.singleShot(400, this, SLOT(checkForWork()));
    }

}
/**
 * @brief ChordTableWidget::setTimeInfo
 * @param beginning Début du premier accord dans le morceau
 * @param bar Durée moyenne d'une case
 * @param end Fin du dernier accord de la grille
 *
 * Initialise les informations de temps des cases de la grille.
 */
void ChordTableWidget::setTimeInfo(const QTime beginning, const QTime bar, const QTime end)
{
	if(bar < beginning || bar > end || end < beginning )
	{
		QMessageBox::warning(this, tr("Error with timers"), tr("The bar timer should be greater than the beginning timer."));
		return;
	}

	int rmax = rowCount(),
		cmax = columnCount();
	bool warningShown = false,
		 warning2Shown = false,
		modifyAllCases = false;

	QTime finalCaseTime;

	for (int r = 0 ; r < rmax ; r++)
	{
		for (int c = 0 ; c < cmax - 1 ; c ++)
		{
			if(!warningShown && ((CaseItem*) item(r,c))->isTimerManuallySet())
			{
				modifyAllCases = (QMessageBox::question(this, tr("Before doing something wrong"), tr("Some timers have already been set manually. Do you want to reset them too?"), QMessageBox::Yes | QMessageBox::No)) == QMessageBox::Yes;
				warningShown = true;
			}

			QTime caseTime = MsecToTime((TimeToMsec(beginning) + ((TimeToMsec(bar) - TimeToMsec(beginning))/m_barsize)* (r * (cmax - 1) + c)));

			if(!warning2Shown && caseTime>end) {
				QMessageBox::warning(this, tr("Error with timers"), tr("There are too many cells for the end timer you entered."));
				warning2Shown = true;
				caseTime.addMSecs(10);
				finalCaseTime = caseTime;
			}
			else if(warning2Shown)
			{
				caseTime = finalCaseTime;
			}
			if(modifyAllCases || !((CaseItem*) item(r,c))->isTimerManuallySet())
				((CaseItem*) item(r,c))->setBeginning(caseTime);
		}
	}
	QMessageBox::information(this, tr("Ok"), tr("The time has been set up correctly"));
	checkBeginningTimes();
}
void MjpegStreamerClient::updateMessageReceived(QList<QByteArray> messageList)
{
    QByteArray topic;

    topic = messageList.at(0);
    m_rx.ParseFromArray(messageList.at(1).data(), messageList.at(1).size());

    m_streamBuffer.clear();
    m_streamBufferTimer->stop();
    m_currentStreamBufferItem.timestamp = 0;
    for (int i = 0; i < m_rx.frame_size(); ++i)
    {
        pb::Package_Frame frame;
        QByteArray data;
        QDateTime dateTime;
        QTime time;
        StreamBufferItem streamBufferItem;

        frame = m_rx.frame(i);
        data = QByteArray(frame.blob().data(), frame.blob().size());

#ifdef QT_DEBUG
        qDebug() << "received frame" << topic;
        qDebug() << "timestamp: " << frame.timestamp_unix() << frame.timestamp_s() << frame.timestamp_us();
#endif

        streamBufferItem.image = QImage::fromData(data, "JPG");
        streamBufferItem.timestamp = (double)frame.timestamp_s()*1000 +  (double)frame.timestamp_us() / 1000.0;

        dateTime.setMSecsSinceEpoch((quint64)frame.timestamp_unix()*(quint64)1000);
        dateTime = dateTime.toLocalTime();
        time = dateTime.time();
        streamBufferItem.time = time.addMSecs(frame.timestamp_us()/1000.0);

#ifdef QT_DEBUG
        qDebug() << "time: " << streamBufferItem.time;
#endif

        m_streamBuffer.enqueue(streamBufferItem);
    }
    m_currentStreamBufferItem = m_streamBuffer.dequeue();
    updateStreamBuffer();
}
Example #25
0
// Set up a timer or cancel a timer.
void MHGroup::SetTimer(int nTimerId, bool fAbsolute, int nMilliSecs, MHEngine *)
{
    // First remove any existing timer with the same Id.
    for (int i = 0; i < m_Timers.size(); i++) {
        MHTimer *pTimer = m_Timers.at(i);
        if (pTimer->m_nTimerId == nTimerId) {
            delete m_Timers.takeAt(i);
            break;
        }
    }
    // If the time has passed we don't set up a timer.
    QTime currentTime;
    currentTime.start(); // Set current time
    if (nMilliSecs < 0 || (fAbsolute && m_StartTime.addMSecs(nMilliSecs) < currentTime)) return;
    MHTimer *pTimer = new MHTimer;
    m_Timers.append(pTimer);
    pTimer->m_nTimerId = nTimerId;
    if (fAbsolute) pTimer->m_Time = m_StartTime.addMSecs(nMilliSecs);
    else pTimer->m_Time = currentTime.addMSecs(nMilliSecs);
}
Example #26
0
int main(int argc,char **argv)
{
	QApplication app(argc,argv,false);

	// 取得目前的時間
	QTime currentTime = QTime::currentTime();
	QTime nextTime = currentTime.addMSecs(2365);

	// 印出目前的時間
	qWarning(QString("The current time is %1").arg(currentTime.toString()));

	// 印出2365毫秒之後的時間
	qWarning(QString("The time after 2365ms is %1").arg(nextTime.toString()));

	// 印出這兩個時間的差, 由currentTime與nextTime比較
	qWarning("%d",currentTime.msecsTo(nextTime));

	// 反過來, 由nextTime與currentTime比較
	qWarning("%d",nextTime.msecsTo(currentTime));

	return app.exec();
}
void DelegateVideoControl::paint(QPainter *painter,
        const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    painter->fillPath(shape(), brush());

    qreal frameWidth = rect().height() / 2;
    int position = frameWidth;

    if (mTotalTimeInMs > 0)
    {
        position = frameWidth + (rect().width() - (2 * frameWidth)) / mTotalTimeInMs * mCurrentTimeInMs;
    }

    int radius = rect().height() / 6;
    QRectF r(rect().x() + position - radius, rect().y() + (rect().height() / 4) - radius, radius * 2, radius * 2);

    painter->setBrush(UBSettings::documentViewLightColor);
    painter->drawEllipse(r);

    if(mDisplayCurrentTime)
    {
        painter->setBrush(UBSettings::paletteColor);
        painter->setPen(QPen(Qt::NoPen));
        QRectF balloon(rect().x() + position - frameWidth, rect().y() - (frameWidth * 1.2), 2 * frameWidth, frameWidth);
        painter->drawRoundedRect(balloon, frameWidth/2, frameWidth/2);

        QTime t;
        t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs);
        QFont f = painter->font();
            f.setPointSizeF(f.pointSizeF() * mAntiScale);
        painter->setFont(f);
        painter->setPen(Qt::white);
        painter->drawText(balloon, Qt::AlignCenter, t.toString("m:ss"));
    }
}
Example #28
0
void StressTest::GoToNextScenario()
{
    Q_D( StressTest);
	if (!IncreaseCurrentAssumption()) {
#ifdef PrintExecutionTime
		QTime TempTime;
        TempTime.addMSecs(d->ExecutionTime.elapsed());
        QMessageBox::information(0, "Computation Time", QString("Stress Test Took: %1 Seconds").arg(d->ExecutionTime.elapsed() / 1000));
#endif
        disconnect(d->BaseCalculator);
        if (d->ProgressForm) 
            d->ProgressForm->NextPhase();
        if (d->BaseApplier->NumBees() > 0) {
            d->BaseApplier->StartCalculation();
		}
		else {
            d->ProgressForm->NextPhase();
			emit AllLoansCalculated();
		}
		return;
	}
	RunCurrentScenario();
}
Example #29
0
void widget::showTime(qint64 time)//时间与歌词的更新显示
{
    qint64 temp = totalTime;
//    QTime totalTime(0,(temp / 60000) % 60,(temp / 1000) % 60,time %1000);
    QTime curTime(0,(time / 60000) % 60,(time / 1000) % 60,time %1000);

    //歌词的更新显示

    if(ui->textEdit->find(curTime.toString("mm:ss.zzz").left(7)))//向后找
    {
        QString str = ui->textEdit->textCursor().block().text().replace(QRegExp("\\[\\d{2}:\\d{2}\\.\\d{2}\\]"),"");

        ui->label_lrc->setText(str);
        lrc->setText(str);
        lrc->setLrcWidth();//设置用于遮罩label的宽度为0
     //   lrc->show();

////////////////////////////////////////////////
        QTime tt = curTime;
        int b = 1;
        int c= 0;
        text->setText(ui->textEdit->document()->toPlainText());
        bool over = ui->textEdit->textCursor().block().next().text().isEmpty();
        while(!over &&!text->find(tt.addMSecs(b*100).toString("mm:ss.zzz").left(7)))
        {
            b++;
            c++;
        }
        while(over && !text->find(tt.addMSecs(b*100).toString("mm:ss.zzz").left(7),QTextDocument::FindBackward))
        {
            b++;
            c++;
            break;
        }

       lrc->timer->start(c);

    }//找不到后向前找
    else if(ui->textEdit->find(curTime.toString("mm:ss.zzz").left(7),QTextDocument::FindBackward))
    {
        QString str = ui->textEdit->textCursor().block().text().replace(QRegExp("\\[\\d{2}:\\d{2}\\.\\d{2}\\]"),"");
        ui->label_lrc->setText(str);
        lrc->setText(str);
        lrc->setLrcWidth();//设置用于遮罩label的宽度为0

       // lrc->show();

////////////////////////////////////////////////
        QTime tt = curTime;
        int b = 1;
        int c= 0;
        text->setText(ui->textEdit->document()->toPlainText());

        bool over = ui->textEdit->textCursor().block().next().text().isEmpty();
        while(!over && !text->find(tt.addMSecs(b*100).toString("mm:ss.zzz").left(7)))
        {
            b++;
            c++;
        }
        while(over && !text->find(tt.addMSecs(b*100).toString("mm:ss.zzz").left(7),QTextDocument::FindBackward))
        {
            b++;
            c++;
            break;
        }
         lrc->timer->start(c);
    }
}
Example #30
0
/** Initialisation method. Sets up all widgets and variables not done in the
 * constructor.
 *
 */
void ScaleDetails::initWidgets() {
  if (m_initialised) {
    return;
  } else {
    Plot *d_plot = m_graph->plotWidget();
    const QwtScaleDiv *scDiv = d_plot->axisScaleDiv(m_mappedaxis);
    double start = qMin(scDiv->lBound(), scDiv->hBound());
    double end = qMax(scDiv->lBound(), scDiv->hBound());
    ScaleDraw::ScaleType type = m_graph->axisType(m_mappedaxis);
    if (type == ScaleDraw::Date) {
      ScaleDraw *sclDraw =
          dynamic_cast<ScaleDraw *>(d_plot->axisScaleDraw(m_mappedaxis));
      if (!sclDraw) {
        throw std::runtime_error("Could not convert the axis Scale Draw object "
                                 "to a ScaleDraw object");
      }
      QDateTime origin = sclDraw->dateTimeOrigin();

      m_dspnStart->hide();
      m_timStartTime->hide();
      m_dteStartDateTime->show();
      m_dteStartDateTime->setDisplayFormat(sclDraw->format());
      m_dteStartDateTime->setDateTime(origin.addSecs((int)start));

      m_dspnEnd->hide();
      m_timEndTime->hide();
      m_dteEndDateTime->show();
      m_dteEndDateTime->setDisplayFormat(sclDraw->format());
      m_dteEndDateTime->setDateTime(origin.addSecs((int)end));

      m_cmbUnit->show();
      m_cmbUnit->addItem(tr("days"));
      m_cmbUnit->addItem(tr("weeks"));
      m_dspnStep->setValue(m_graph->axisStep(m_mappedaxis) / 86400.0);
      m_dspnStep->setSingleStep(1);
    } else if (type == ScaleDraw::Time) {
      if (ScaleDraw *sclDraw =
              dynamic_cast<ScaleDraw *>(d_plot->axisScaleDraw(m_mappedaxis))) {
        QTime origin = sclDraw->dateTimeOrigin().time();

        m_dspnStart->hide();
        m_dteStartDateTime->hide();
        m_timStartTime->show();
        m_timStartTime->setDisplayFormat(sclDraw->format());
        m_timStartTime->setTime(origin.addMSecs((int)start));

        m_dspnEnd->hide();
        m_dteEndDateTime->hide();
        m_timEndTime->show();
        m_timEndTime->setDisplayFormat(sclDraw->format());
        m_timEndTime->setTime(origin.addMSecs((int)end));

        m_cmbUnit->show();
        m_cmbUnit->addItem(tr("millisec."));
        m_cmbUnit->addItem(tr("sec."));
        m_cmbUnit->addItem(tr("min."));
        m_cmbUnit->addItem(tr("hours"));
        m_cmbUnit->setCurrentIndex(1);
        m_dspnStep->setValue(m_graph->axisStep(m_mappedaxis) / 1e3);
        m_dspnStep->setSingleStep(1000);
      }
    } else {
      m_dspnStart->show();
      m_dspnStart->setValue(start);
      m_timStartTime->hide();
      m_dteStartDateTime->hide();
      m_dspnEnd->show();
      m_dspnEnd->setValue(end);
      m_timEndTime->hide();
      m_dteEndDateTime->hide();
      m_dspnStep->setValue(m_graph->axisStep(m_mappedaxis));
      m_dspnStep->setSingleStep(0.1);
    }

    double range = fabs(scDiv->range());
    QwtScaleEngine *qwtsc_engine = d_plot->axisScaleEngine(m_mappedaxis);
    ScaleEngine *sc_engine = dynamic_cast<ScaleEngine *>(qwtsc_engine);
    if (sc_engine) {
      if (sc_engine->axisBreakLeft() > -DBL_MAX) {
        m_dspnBreakStart->setValue(sc_engine->axisBreakLeft());
      } else {
        m_dspnBreakStart->setValue(start + 0.25 * range);
      }

      if (sc_engine->axisBreakRight() < DBL_MAX) {
        m_dspnBreakEnd->setValue(sc_engine->axisBreakRight());
      } else {
        m_dspnBreakEnd->setValue(start + 0.75 * range);
      }
      m_grpAxesBreaks->setChecked(sc_engine->hasBreak());

      m_spnBreakPosition->setValue(sc_engine->breakPosition());
      m_spnBreakWidth->setValue(sc_engine->breakWidth());
      m_dspnStepBeforeBreak->setValue(sc_engine->stepBeforeBreak());
      m_dspnStepAfterBreak->setValue(sc_engine->stepAfterBreak());

      ScaleTransformation::Type scale_type = sc_engine->type();
      m_cmbMinorTicksBeforeBreak->clear();
      if (scale_type == ScaleTransformation::Log10) {
        m_cmbMinorTicksBeforeBreak->addItems({"0", "2", "4", "8"});
      } else {
        m_cmbMinorTicksBeforeBreak->addItems({"0", "1", "4", "9", "14", "19"});
      }
      m_cmbMinorTicksBeforeBreak->setEditText(
          QString::number(sc_engine->minTicksBeforeBreak()));

      m_cmbMinorTicksAfterBreak->setEditText(
          QString::number(sc_engine->minTicksAfterBreak()));
      m_chkLog10AfterBreak->setChecked(sc_engine->log10ScaleAfterBreak());
      m_chkBreakDecoration->setChecked(sc_engine->hasBreakDecoration());
      m_chkInvert->setChecked(
          sc_engine->testAttribute(QwtScaleEngine::Inverted));
      m_cmbScaleType->setCurrentIndex(scale_type);
      m_dspnN->setValue(sc_engine->nthPower());
      m_cmbMinorValue->clear();
      if (scale_type == ScaleTransformation::Log10) {
        m_cmbMinorValue->addItems({"0", "2", "4", "8"});
      } else {
        m_cmbMinorValue->addItems({"0", "1", "4", "9", "14", "19"});
      }
      m_cmbMinorValue->setEditText(
          QString::number(d_plot->axisMaxMinor(m_mappedaxis)));

      bool isColorMap = m_graph->isColorBarEnabled(m_mappedaxis);
      m_grpAxesBreaks->setEnabled(!isColorMap);
      if (isColorMap) {
        m_grpAxesBreaks->setChecked(false);
      }
    } else {
      m_grpAxesBreaks->setChecked(false);
      m_grpAxesBreaks->setEnabled(false);
    }

    const QwtValueList &lst = scDiv->ticks(QwtScaleDiv::MajorTick);
    m_spnMajorValue->setValue(lst.count());

    checkstep();
    checkscaletype();

    connect(m_grpAxesBreaks, SIGNAL(clicked()), this, SLOT(setModified()));
    connect(m_chkInvert, SIGNAL(clicked()), this, SLOT(setModified()));
    connect(m_chkLog10AfterBreak, SIGNAL(clicked()), this, SLOT(setModified()));
    connect(m_chkBreakDecoration, SIGNAL(clicked()), this, SLOT(setModified()));
    connect(m_radStep, SIGNAL(clicked()), this, SLOT(setModified()));
    connect(m_radMajor, SIGNAL(clicked()), this, SLOT(setModified()));
    connect(m_cmbMinorTicksBeforeBreak, SIGNAL(currentIndexChanged(int)), this,
            SLOT(setModified()));
    connect(m_cmbMinorTicksAfterBreak, SIGNAL(currentIndexChanged(int)), this,
            SLOT(setModified()));
    connect(m_cmbMinorValue, SIGNAL(currentIndexChanged(int)), this,
            SLOT(setModified()));
    connect(m_cmbUnit, SIGNAL(currentIndexChanged(int)), this,
            SLOT(setModified()));
    connect(m_cmbScaleType, SIGNAL(currentIndexChanged(int)), this,
            SLOT(setModified()));
    connect(m_cmbScaleType, SIGNAL(currentIndexChanged(int)), this,
            SLOT(checkscaletype()));
    connect(m_dspnEnd, SIGNAL(valueChanged(double)), this, SLOT(setModified()));
    connect(m_dspnStart, SIGNAL(valueChanged(double)), this,
            SLOT(setModified()));
    connect(m_dspnN, SIGNAL(valueChanged(double)), this, SLOT(setModified()));
    connect(m_dspnStep, SIGNAL(valueChanged(double)), this,
            SLOT(setModified()));
    connect(m_dspnBreakStart, SIGNAL(valueChanged(double)), this,
            SLOT(setModified()));
    connect(m_dspnStepBeforeBreak, SIGNAL(valueChanged(double)), this,
            SLOT(setModified()));
    connect(m_dspnStepAfterBreak, SIGNAL(valueChanged(double)), this,
            SLOT(setModified()));
    connect(m_dspnBreakEnd, SIGNAL(valueChanged(double)), this,
            SLOT(setModified()));
    connect(m_spnMajorValue, SIGNAL(valueChanged(int)), this,
            SLOT(setModified()));
    connect(m_spnBreakPosition, SIGNAL(valueChanged(int)), this,
            SLOT(setModified()));
    connect(m_spnBreakWidth, SIGNAL(valueChanged(int)), this,
            SLOT(setModified()));
    connect(m_dteStartDateTime, SIGNAL(dateTimeChanged(QDateTime)), this,
            SLOT(setModified()));
    connect(m_dteStartDateTime, SIGNAL(dateChanged(QDate)), this,
            SLOT(setModified()));
    connect(m_dteStartDateTime, SIGNAL(timeChanged(QTime)), this,
            SLOT(setModified()));
    connect(m_dteEndDateTime, SIGNAL(dateTimeChanged(QDateTime)), this,
            SLOT(setModified()));
    connect(m_dteEndDateTime, SIGNAL(dateChanged(QDate)), this,
            SLOT(setModified()));
    connect(m_dteEndDateTime, SIGNAL(timeChanged(QTime)), this,
            SLOT(setModified()));
    connect(m_timStartTime, SIGNAL(dateTimeChanged(QDateTime)), this,
            SLOT(setModified()));
    connect(m_timStartTime, SIGNAL(dateChanged(QDate)), this,
            SLOT(setModified()));
    connect(m_timStartTime, SIGNAL(timeChanged(QTime)), this,
            SLOT(setModified()));
    connect(m_timEndTime, SIGNAL(dateTimeChanged(QDateTime)), this,
            SLOT(setModified()));
    connect(m_timEndTime, SIGNAL(dateChanged(QDate)), this,
            SLOT(setModified()));
    connect(m_timEndTime, SIGNAL(timeChanged(QTime)), this,
            SLOT(setModified()));

    m_initialised = true;
  }
}