void k9ChapterEdit::urlSelected(const KUrl& _url) {
  bool fileChanged=_url.toLocalFile() !=m_aviFile->getFileName();
  if (!m_aviDecode) {
     m_aviDecode =new k9AviDecode(0,0);
     connect(m_aviDecode,SIGNAL(drawFrame(QImage)),this,SLOT(drawImage(QImage)));
  }
  m_aviDecode->open(_url.toLocalFile());
  if (!m_noUpdate) {
    m_aviFile->setFileName(_url.toLocalFile());
    if (fileChanged) {
        m_aviDecode->readFrame(0);
	m_aviFile->setStart(QTime(0,0,0));
	m_aviFile->setImage(m_image);
	QTime end(0,0,0);
	end=end.addSecs((int)(m_aviDecode->getDuration()));
	m_aviFile->setEnd(end);
	m_aviFile->setNext(NULL);
	m_aviFile->setPrevious(NULL);
        Ui_chapterEdit.ckBreakEnd->setChecked(false);
        Ui_chapterEdit.ckBreakStart->setChecked(false);
        ckBreakEndClick();
        ckBreakStartClick();
	setAviFile(m_aviFile);
    } 
  }

  QTime t;
  int sec=t.msecsTo(m_aviFile->getStart());
  Ui_chapterEdit.slider->setMaximum((int)(m_aviDecode->getDuration()*1000));

  Ui_chapterEdit.slider->setValue(sec);
  
}
void ossimQtScrollingImageWidget::timerEvent(QTimerEvent* /* evt */)
{
   QTime start = QTime::currentTime();
   eraseCursor();
   viewport()->setCursor(Qt::WaitCursor);
   
   while(theReqMap.size() > 0)
   {
      ossimQtScrollingImageWidgetReqQueueItem item = theReqQueue.top();
      std::map<ossim_int32, ossimIrect>::iterator currentIter = theReqMap.find(item.theId);
      theReqQueue.pop();
      
      ossimIrect currentTileRect = (*currentIter).second;
      
      theReqMap.erase(currentIter);
      convertRequest(currentTileRect);
      QTime end = QTime::currentTime();
      if(start.msecsTo(end) >= maxProcessingTime)
      {
         return;
      }
   }
   if(theReqMap.size() == 0)
   {
      while(!theReqQueue.empty())
      {
         theReqQueue.pop();
      }
   }
   killTimer(theTimerId);
   theTimerId = -1;
   viewport()->setCursor(Qt::CrossCursor);
}
Example #3
0
void StringTable::GC()
{
    QMutexLocker locker(&m_lock);

    int initialSize = 0;
    QTime startTime;
    if (DebugStringTable) {
        initialSize = m_strings.size();
        startTime = QTime::currentTime();
    }

    // Collect all QStrings which have refcount 1. (One reference in m_strings and nowhere else.)
    for (QSet<QString>::iterator i = m_strings.begin(); i != m_strings.end();) {
        if (m_stopGCRequested.testAndSetRelease(true, false))
            return;

        if (!isQStringInUse(*i))
            i = m_strings.erase(i);
        else
            ++i;
    }

    if (DebugStringTable) {
        const int currentSize = m_strings.size();
        qDebug() << "StringTable::GC removed" << initialSize - currentSize
                 << "strings in" << startTime.msecsTo(QTime::currentTime())
                 << "ms, size is now" << currentSize;
    }
}
Example #4
0
QList<CachedRowEntry> EventQuery::updateQueryNepomuk(const QUrl &uri)
{
    QTime startTime = QTime::currentTime();

    // first fetch all publications
    // this will lead to duplicates as we fetch for author names and types too
    // for each rdf:type and each connected author/publisher/editor we get the resource as result

    //If you update this, also update initialQueryNepomuk and processQueryResults and the enum ColumnList and the EventModel
    QString query = QString::fromLatin1("select distinct ?title ?star ?date ?publication where { {"
                                        "%1 nbib:eventpublication ?pub ."
                                        "OPTIONAL { ?pub nie:title ?publication . }"

                                        "OPTIONAL { %1 nie:title ?title . }"
                                        "OPTIONAL { %1 nao:numericRating ?star . }"
                                        "OPTIONAL { %1 ncal:date ?date . }"
                                        "}").arg( Soprano::Node::resourceToN3( uri ) );

    QList<CachedRowEntry> newCache = processQueryResults(query, uri);

    QTime endTime = QTime::currentTime();
    kDebug() << "update" << newCache.size() << "entries after" << startTime.msecsTo(endTime) << "msec";

    return newCache;
}
void Server::startAuditTimer()
{
    //Read configured time from flat file database
    QFile auditFile(AUDITCONFIG_DATABASE_FILE);
    if(!auditFile.open(QIODevice::ReadOnly)) {
        qDebug() << "error" << auditFile.errorString();
    }

    QTextStream auditFileIn(&auditFile);

    QString line;
    while(!auditFileIn.atEnd()) {
        line = auditFileIn.readLine();
        QStringList split = line.split(PIPE_DELIMETER);
        if(QString::fromLocal8Bit(split.at(0).toLocal8Bit()) == "configurabletime"){
            auditTime = QTime::fromString(QString::fromLocal8Bit(split.at(1).toLocal8Bit()),"hh:mm:ss");
            break;
        }
    }
    auditFile.close();

    //Set timer to wait till that time and then trigger the audit
    QTime currentTime = QTime::currentTime();
    int interval = currentTime.msecsTo(auditTime);
    if(interval < 0){
        interval = 86400000 + interval;
    }

    qDebug() << "Milliseconds till next audit: " << interval;

    connect(auditTimer, SIGNAL(timeout()), this, SLOT(runAudit()));
    auditTimer->start(interval);
}
Example #6
0
void Client::sendPing()
{
    //On stocke le nombre de millisecondes jusqu'à minuit.
    QTime time;
    Paquet out;
    out << SMSG_PING;
    out << quint32(time.msecsTo(QTime::currentTime()));
    out >> m_socket;

    m_pingsPending++;

    if (m_pingsPending > m_parent->getMaxPingsPending())
    {
        console(m_pseudo + " a été kické pour ping timeout.");

        //On avertit les connectés.
        if (!m_pseudo.isEmpty())
        {
            Paquet out;
            out << SMSG_USER_KICKED;
            out << QString("le serveur");    //Par qui on a été kické
            out << m_pseudo;                 //Qui a été kické
            out << QString("ping timeout");  //Raison
            m_parent->envoyerAuChannel(out, m_channel);
        }

        //Déconnexion.
        m_socket->abort();
    }
}
Example #7
0
			void BrowserWidget::SetWidgetSettings (const BrowserWidgetSettings& settings)
			{
				if (settings.ZoomFactor_ != 1)
				{
					qDebug () << Q_FUNC_INFO
						<< "setting zoomfactor to"
						<< settings.ZoomFactor_;
					Ui_.WebView_->setZoomFactor (settings.ZoomFactor_);
				}

				NotifyWhenFinished_->setChecked (settings.NotifyWhenFinished_);
				QTime interval = settings.ReloadInterval_;
				QTime null (0, 0, 0);
				int msecs = null.msecsTo (interval);
				if (msecs >= 1000)
				{
					ReloadPeriodically_->setChecked (true);
					SetActualReloadInterval (interval);
				}

				if (settings.WebHistorySerialized_.size ())
				{
					QDataStream str (settings.WebHistorySerialized_);
					str >> *Ui_.WebView_->page ()->history ();
				}
Example #8
0
// Fire any timers that have passed.
int MHGroup::CheckTimers(MHEngine *engine)
{
    QTime currentTime = QTime::currentTime(); // Get current time
    QList<MHTimer *>::iterator it = m_Timers.begin();
    MHTimer *pTimer;
    int nMSecs = 0;

    while (it != m_Timers.end())
    {
        pTimer = *it;

        if (pTimer->m_Time <= currentTime)   // Use <= rather than < here so we fire timers with zero time immediately.
        {
            // If the time has passed trigger the event and remove the timer from the queue.
            engine->EventTriggered(this, EventTimerFired, pTimer->m_nTimerId);
            delete pTimer;
            it = m_Timers.erase(it);
        }
        else
        {
            // This has not yet expired.  Set "nMSecs" to the earliest time we have.
            int nMSecsToGo = currentTime.msecsTo(pTimer->m_Time);

            if (nMSecs == 0 || nMSecsToGo < nMSecs)
            {
                nMSecs = nMSecsToGo;
            }

            ++it;
        }
    }

    return nMSecs;
}
Example #9
0
	void incomingData(Stream *stream)
	{
		Message *message = Message::receive(stream);
		UserMessage *userMessage = dynamic_cast<UserMessage *>(message);
		if (userMessage)
		{
			if (userMessage->type == eventId)
			{
				double elapsedTime = (double)startingTime.msecsTo(QTime::currentTime()) / 1000.;
				if (outputFile.is_open())
					outputFile << elapsedTime;
				timeStamps.push_back(elapsedTime);
				for (size_t i = 0; i < values.size(); i++)
				{
					if (i < userMessage->data.size())
					{
						if (outputFile.is_open())
							outputFile << " " << userMessage->data[i];
						values[i].push_back(userMessage->data[i]);
					}
					else
					{
						if (outputFile.is_open())
							outputFile << " " << 0;
						values[i].push_back(0);
					}
				}
				if (outputFile.is_open())
					outputFile << endl;
				replot();
			}
		}
		delete message;
	}
Example #10
0
QList<CachedRowEntry> EventQuery::initialQueryNepomuk()
{
    QTime startTime = QTime::currentTime();

    // helping string to filter for all documents that are related to the current project
    QString projectRelated;
    QString projectTag;
    if(m_library->libraryType() == BibGlobals::Library_Project) {
        projectRelated = QString("?r nao:isRelated  <%1> .").arg(m_library->settings()->projectThing().uri().toString());
        projectTag = QString("UNION { ?r nao:hasTag  <%1> . }").arg(m_library->settings()->projectTag().uri().toString() );
    }

    // first fetch all series
    // this will lead to duplicates as we fetch for nbib:eventpublication names
    // each connected publicaion we get the resource as result
    QString query = QString::fromLatin1("select distinct ?r ?title ?star ?date ?publication where { {"
                                        "?r a ncal:Event . "
                                        "?r nbib:eventpublication ?pub ."

                                        "OPTIONAL { ?pub nie:title ?publication . }"

                                        "OPTIONAL { ?r nie:title ?title . }"
                                        "OPTIONAL { ?r nao:numericRating ?star . }"
                                        "OPTIONAL { ?r ncal:date ?date . }"
                                        + projectRelated.toLatin1() + " }" + projectTag.toLatin1() +

                                        "}");

    QList<CachedRowEntry> newCache = processQueryResults(query);

    QTime endTime = QTime::currentTime();
    kDebug() << "add" << newCache.size() << "entries after" << startTime.msecsTo(endTime) << "msec";

    return newCache;
}
Example #11
0
float MainWindow::test_textedit_add(int count) {
    ui->tabMain->setCurrentIndex(3);
    QTime start = QTime::currentTime();
    for (int i=0; i<count; ++i) {
        ui->testTextEdit->insertPlainText("Future is open. ");
        ui->testTextEdit->repaint();
    }
    return (float)start.msecsTo(QTime::currentTime())/1000.0f;
}
Example #12
0
float MainWindow::test_checkbox(int count) {
    ui->tabMain->setCurrentIndex(2);
    QTime start = QTime::currentTime();
    for (int i=0; i<count; ++i) {
        ui->testCheckBox->setChecked(!ui->testCheckBox->isChecked());
        ui->testCheckBox->repaint();
    }
    return (float)start.msecsTo(QTime::currentTime())/1000.0f;
}
Example #13
0
float MainWindow::test_pushbutton(int count) {
    ui->tabMain->setCurrentIndex(2);
    QTime start = QTime::currentTime();
    for (int i=0; i<count; ++i) {
        ui->testButton->setDown(!ui->testButton->isDown());
        ui->testButton->repaint();
    }
    return (float)start.msecsTo(QTime::currentTime())/1000.0f;
}
Example #14
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    on_generateButton_clicked();
    QTime time;
    qsrand(time.msecsTo(QTime::currentTime())); // srand init
}
Example #15
0
void Phantom::sleep(int ms)
{
    QTime startTime = QTime::currentTime();
    while (true) {
        QApplication::processEvents(QEventLoop::AllEvents, 25);
        if (startTime.msecsTo(QTime::currentTime()) > ms)
            break;
    }
}
Example #16
0
int render(GenericShaderContext *gs, const uchar* bits, const uchar* bits1)
{
#ifdef OUTPUT_WASTE
    QTime startTime = QTime::currentTime();
#endif
    // 清除颜色缓冲区 重置为指定颜色
    glClearColor(0.18f, 0.04f, 0.14f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);

    // 这里填写场景绘制代码
    //glBindVertexArray(VAOId);
    {
        glGenBuffers(1, &gs->pos_buf);
        glBindBuffer(GL_ARRAY_BUFFER, gs->pos_buf);
        glBufferData(GL_ARRAY_BUFFER, sizeof(position), position, GL_STATIC_DRAW);

        // Step4: 指定解析方式  并启用顶点属性
        // 顶点位置属性
        GLint loc = glGetAttribLocation(gs->program, "position");
        glEnableVertexAttribArray(loc);
        glVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, 0, 0);

        glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
    //shader.use();
    glUseProgram(gs->program);
    // 启用多个纹理单元 绑定纹理对象
    GLuint textureId0, textureId1;
    textureId0=GlobalContext::load2DTexture(512, 384, bits);
    textureId1=GlobalContext::load2DTexture(512, 384, bits1);
    // 启用多个纹理单元 绑定纹理对象
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, textureId0);
    //glUniform1i(glGetUniformLocation(shader.programId, "tex1"), 0); // 设置纹理单元为0号
    glUniform1i(glGetUniformLocation(gs->program, "mSample0"), 0);
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, textureId1);
    glUniform1i(glGetUniformLocation(gs->program, "mSample1"), 1);
    
    glUniform1f(glGetUniformLocation(gs->program, "u_global_time"), 1.0);
    glUniform1f(glGetUniformLocation(gs->program, "u_total_time"), 2.0);

    glUniform2f(glGetUniformLocation(gs->program, "u_resolution"), 512, 384);

    glDrawArrays(GL_TRIANGLES, 0, 6);

    //glBindVertexArray(0);
    glUseProgram(0);

#ifdef OUTPUT_WASTE
    int dt = startTime.msecsTo(QTime::currentTime());
    qDebug()<< " waste_time frag. time: " << dt
        <<" start_time: "<<startTime.toString();
#endif
    return 0;
}
Example #17
0
float MainWindow::test_qpainter_image(int count) {
    ui->tabMain->setCurrentIndex(4);
    QTime start = QTime::currentTime();
    ui->testDrawWidget->setType(TestWidget::TEST_PIXMAP);
    for (int i=0; i<count*10; ++i) {
        ui->testDrawWidget->repaint();
    }
    ui->testDrawWidget->type = TestWidget::TEST_IDLE;
    return (float)start.msecsTo(QTime::currentTime())/1000.0f;
}
Example #18
0
// create a floating-point value from date/time
KCValue::KCValue(const QDateTime& dt, const KCCalculationSettings* settings)
        : d(Private::null())
{
    const QDate refDate(settings->referenceDate());
    const QTime refTime(0, 0);    // reference time is midnight
    d->type = Float;
    d->f = KCNumber(refDate.daysTo(dt.date()));
    d->f += static_cast<double>(refTime.msecsTo(dt.time())) / 86400000.0;     // 24*60*60*1000
    d->format = fmt_DateTime;
}
Example #19
0
// create a floating-point value from time
KCValue::KCValue(const QTime& time, const KCCalculationSettings* settings)
        : d(Private::null())
{
    Q_UNUSED(settings);
    const QTime refTime(0, 0);    // reference time is midnight

    d->type = Float;
    d->f = KCNumber(static_cast<double>(refTime.msecsTo(time)) / 86400000.0);      // 24*60*60*1000
    d->format = fmt_Time;
}
/*!
    Process pending events that match \a flags for a maximum of \a
    maxTime milliseconds, or until there are no more events to
    process, which ever is shorter.

    This function is especially useful if you have a long running
    operation and want to show its progress without allowing user
    input, i.e. by using the \c ExcludeUserInput flag.

    NOTE: This function will not process events continuously; it
    returns after all available events are processed.

    NOTE: Specifying the \c WaitForMore flag makes no sense and will
    be ignored.
*/
void QEventLoop::processEvents( ProcessEventsFlags flags, int maxTime )
{
    QTime start = QTime::currentTime();
    QTime now;
    while ( ! d->quitnow && processEvents( flags & ~WaitForMore ) ) {
	now = QTime::currentTime();
	if ( start.msecsTo( now ) > maxTime )
	    break;
    }
}
Example #21
0
		void TIME(int repetitions) {
			QTime t = Logger::timeStack.pop();
			QString s = Logger::timeStringStack.pop();
			int secs = t.msecsTo(QTime::currentTime());
			if (repetitions == 0) {
				LOG(QString("Time: %1s for ").arg(secs/1000.0f) + s, TimingLevel);
			} else {
				LOG(QString("Time: %1s for %2. %3 repetitions, %4s per repetition.").arg(secs/1000.0f).arg(s)
					.arg(repetitions).arg((secs/repetitions)/1000.0f), TimingLevel);			
			}
		}; // End time...
Example #22
0
float MainWindow::test_lineedit(int count) {
    ui->tabMain->setCurrentIndex(1);
    QTime start = QTime::currentTime();
    for (int i=0; i<count; ++i) {
        ui->testLineEdit->setText("Test String");
        ui->testLineEdit->repaint();
        ui->testLineEdit->setText("Longer test string");
        ui->testLineEdit->repaint();
    }
    return (float)start.msecsTo(QTime::currentTime())/1000.0f;
}
Example #23
0
float MainWindow::test_radiobutton(int count) {
    ui->tabMain->setCurrentIndex(2);
    QTime start = QTime::currentTime();
    bool flag = true;
    for (int i=0; i<count; ++i) {
        ui->testRadioButton1->setChecked(flag);
        ui->testRadioButton2->setChecked(!flag);
        ui->testRadioButton1->repaint();
        ui->testRadioButton2->repaint();
        flag = !flag;
    }
    return (float)start.msecsTo(QTime::currentTime())/1000.0f;
}
Example #24
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();
}
Example #25
0
void TripClient::receiveData()
{
    this->sendCommandGET();

    // Читаем файл
    QDataStream in( this );
    in.setVersion( QDataStream::Qt_4_5 );

    qint64 fileSize;
    do
        if( !this->waitForReadyRead() )
        {
            emit log("\n>> Failed receive size of data from server.");
            exit(10);
        }
    while( this->bytesAvailable() < (int)sizeof( fileSize ) );

    in >> fileSize;

    emit log("Receiving data from server, wating.");

    qint64 pos = 0;
    QTime transferStartTime;
    int timeOfTransmition = 0;
    QByteArray buf;
    transferStartTime = QTime::currentTime();
    while( pos < fileSize )
    {
        if( !this->waitForReadyRead() )
        {
            emit log("\n>> Error. Timeout read data.");
            exit(11);
        }

        buf = this->readAll();
        if( !buf.size() )
            continue;

        pos += buf.size();
    }
    timeOfTransmition = transferStartTime.msecsTo(QTime::currentTime());
    this->sendCommandTime(timeOfTransmition);
    system("cls");
    emit log(tr("Transfer ends. Client has received - %1 Mbyte").arg(fileSize / 1024 / 1024));
    log(tr("Download speed = %1 Mbit/s (Time of transmission - %2 s)")
        .arg(pos * 8 / timeOfTransmition * 0.001)
        .arg(float(timeOfTransmition) * 0.001f));
    emit log("\n\nWould you like to start again this procedure? Push Ctrl+C to exit.");
    QTimer::singleShot(5000,this,SLOT(receiveData()));
}
Example #26
0
float MainWindow::test_textedit_scroll(int count) {
    ui->tabMain->setCurrentIndex(3);
    QTime start = QTime::currentTime();
    int step = 1;
    for (int i=0; i<count; ++i) {
        if (ui->testTextEdit->verticalScrollBar()->value() == ui->testTextEdit->verticalScrollBar()->maximum())
            step = -1;
        if (ui->testTextEdit->verticalScrollBar()->value() == ui->testTextEdit->verticalScrollBar()->minimum())
            step = 1;
        ui->testTextEdit->verticalScrollBar()->setValue(ui->testTextEdit->verticalScrollBar()->value() + step);
        ui->testTextEdit->repaint();
    }
    return (float)start.msecsTo(QTime::currentTime())/1000.0f;
}
Example #27
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 #28
0
float MainWindow::test_progressbar(int count) {
    ui->tabMain->setCurrentIndex(1);
    QTime start = QTime::currentTime();
    int index=0;
    for (int i=0; i<count; ++i) {
        index = ui->testProgressBar->value();
        if (index == ui->testProgressBar->maximum())
            index = 0;
        else
            index++;
        ui->testProgressBar->setValue(index);
        ui->testProgressBar->repaint();
    }
    return (float)start.msecsTo(QTime::currentTime())/1000.0f;
}
Example #29
0
void Save::done()
{
	QTime tRender = QTime::currentTime();
	lwProgess->addItem(tr("Rendering finished at %1.").arg(tRender.toString("hh:mm:ss")));
	lwProgess->addItem(tr("Time elapsed: %1.%2s.").arg(tStart.secsTo(tRender)).arg(tStart.msecsTo(tRender) % 1000));
	lwProgess->scrollToBottom();
	QImage outImg = this->img->scaled(OUTSZ, OUTSZ, Qt::KeepAspectRatio);
	lOutput->setPixmap(QPixmap::fromImage(outImg));
	lOutput->resize(outImg.size());
#if 0
	QTime tEnd = QTime::currentTime();
	lwProgess->addItem(tr("Image scalling finished at %1.").arg(tEnd.toString("hh:mm:ss")));
	lwProgess->addItem(tr("Time elapsed: %1.%2s.").arg(tRender.secsTo(tEnd)).arg(tRender.msecsTo(tEnd) % 1000));
#endif
}
// calculates the time between time and now, and returns a
// human readable string
// e.g. 3.4s, 57s, 2m34s, 5h5m
QString BoxStates::getAbsentText(QTime time)
{
    QTime now = MainWindow::app()->getTimeBaseTime();
    int msecs = time.msecsTo(now); // milliseconds

    if(msecs < 10000){ // until 10s
        return QString("%1.%2s").arg(QString::number(msecs/1000)).arg(QString::number((msecs%1000)/100)); // e.g. "3.4 s"
    }else if(msecs < 60000){ // until 1 minute
        return QString("%1s").arg(QString::number(msecs/1000)); // e.g. "37 s"
    }else if(msecs < 36000000){
        return QString("%1m%2s").arg(QString::number(msecs/60000)).arg(QString::number((msecs%60000)/1000)); // e.g. "5m34s"
    }else{
        return QString("%1h%2m").arg(QString::number(msecs/3600000)).arg(QString::number((msecs%3600000)/60000)); // e.g. "1h59m"
    }
}