void PendingFileQueue::processCache() { QTime currentTime = QTime::currentTime(); for (const PendingFile& file : qAsConst(m_cache)) { if (file.shouldRemoveIndex()) { Q_EMIT removeFileIndex(file.path()); m_recentlyEmitted.remove(file.path()); m_pendingFiles.remove(file.path()); } else if (file.shouldIndexXAttrOnly()) { Q_EMIT indexXAttr(file.path()); } else if (file.shouldIndexContents()) { if (m_pendingFiles.contains(file.path())) { QTime time = m_pendingFiles[file.path()]; int secondsLeft = currentTime.secsTo(time); secondsLeft = qBound(m_minTimeout, secondsLeft * 2, m_maxTimeout); time = currentTime.addSecs(secondsLeft); m_pendingFiles[file.path()] = time; } else if (m_recentlyEmitted.contains(file.path())) { QTime time = currentTime.addSecs(m_minTimeout); m_pendingFiles[file.path()] = time; } else { if (file.isNewFile()) { Q_EMIT indexNewFile(file.path()); } else { Q_EMIT indexModifiedFile(file.path()); } m_recentlyEmitted.insert(file.path(), currentTime); } } else { Q_ASSERT_X(false, "FileWatch", "The PendingFile should always have some flags set"); } } m_cache.clear(); if (!m_pendingFiles.isEmpty() && !m_pendingFilesTimer.isActive()) { m_pendingFilesTimer.setInterval(m_minTimeout * 1000); m_pendingFilesTimer.start(); } if (!m_recentlyEmitted.isEmpty() && !m_clearRecentlyEmittedTimer.isActive()) { m_clearRecentlyEmittedTimer.setInterval(m_trackingTime * 1000); m_clearRecentlyEmittedTimer.start(); } }
static QTime qTimeForDuration(int duration) { if (duration == -1) { duration = 0; } QTime time; return time.addSecs(duration); }
void WorkoutMetricsSummary::updateMetrics(QStringList &order, QHash<QString,RideMetricPtr> &metrics) { int row = 0; foreach(QString name, order) { RideMetricPtr rmp = metrics[name]; if(!metricMap.contains(name)) { QLabel *label = new QLabel((rmp->name()) + ":"); label->setTextFormat(Qt::RichText); QLabel *lcd = new QLabel(); metricMap[name] = QPair<QLabel*,QLabel*>(label,lcd); layout->addWidget(label,metricMap.size(),0); layout->addWidget(lcd,metricMap.size(),1); } QLabel *lcd = metricMap[name].second; if(name == "time_riding") { QTime start (0,0,0); QTime time = start.addSecs(rmp->value(true)); QString s = time.toString("HH:mm:ss"); //qDebug() << s << " " << time.second(); lcd->setText(s); } else { lcd->setText(QString::number(rmp->value(true),'f',rmp->precision()) + " " + (rmp->units(true)) ); } //qDebug() << name << ":" << (int)rmp->value(true); row++; }
void frmtimer1::on_spinBoxPeriod_valueChanged(int arg1) { QTime dtS; dtS = ui->timeEditStart->time(); dtS.addSecs(arg1*60); ui->timeEditEnd->setTime(dtS); }
void PlaylistDetailsWidget::updatePlaylistWidgetEndsInTimer() { ecart-=1; QTime t = QTime(0,0); t = t.addSecs(ecart); _playlistEndsInValue->setText(t.toString("hh:mm:ss")); }
void DialogProgTache::verificationParties() { int min = 0; //on parcours toutes les parties for(int i = 0; i < vec_duree.size(); ++i) { //on faite la somme des durée pour vérifier que la somme == durée de la tache min += vec_duree.at(i).getHeure()*60; min += vec_duree.at(i).getMinute(); if(i < vec_duree.size() -1) { QDate d = vec_date.at(i); QDate dd = vec_date.at(i+1); QTime deb = vec_debut.at(i); QTime debdeb = vec_debut.at(i+1); //on vérifie l'ordre des parties if((d > dd) || (d==dd && deb > debdeb)) throw CalendarException("Ordre des parties incohérentes"); //date et horaire différents if(d==dd && deb == debdeb) throw CalendarException("Les parties ne peuvent pas avoir la même programmation"); QTime fin = deb.addSecs(vec_duree.at(i).getDureeEnMinutes()*60); //chevauchements if(d==dd && fin > debdeb) throw CalendarException("Les parties se chevauchent"); } //vérifie la cohérence avec disponibilité et échéance if(vec_date.at(i) < tache->getDispo() || vec_date.at(i) > tache->getEcheance()) throw CalendarException("Parties non conforme avec la disponibilité et échéance de la tache"); } Duree d(min); if(!(tache->getDuree() == d)) throw CalendarException("Somme des durées des parties non cohérentes"); }
void KTimeEdit::addTime(QTime qt) { // Calculate the new time. mTime = qt.addSecs(mTime.minute() * 60 + mTime.hour() * 3600); updateText(); emit timeChanged(mTime); }
void DownloadItem::updateDownloadInfo(double currSpeed, qint64 received, qint64 total) { #ifdef DOWNMANAGER_DEBUG qDebug() << __FUNCTION__ << currSpeed << received << total; #endif // QString QString QString QString // | m_remTime | |m_currSize| |m_fileSize| |m_speed| // Remaining 26 minutes - 339MB of 693 MB (350kB/s) int estimatedTime = ((total - received) / 1024) / (currSpeed / 1024); QString speed = currentSpeedToString(currSpeed); // We have QString speed now QTime time; time = time.addSecs(estimatedTime); QString remTime = remaingTimeToString(time); m_remTime = time; QString currSize = QzTools::fileSizeToString(received); QString fileSize = QzTools::fileSizeToString(total); if (fileSize == tr("Unknown size")) { ui->downloadInfo->setText(tr("%2 - unknown size (%3)").arg(currSize, speed)); } else { ui->downloadInfo->setText(tr("Remaining %1 - %2 of %3 (%4)").arg(remTime, currSize, fileSize, speed)); } }
void TrainModel::removeTrainsOlderThan(const QTime& since) { qDebug() << "remove trains older than:" << since; for (int i=0; i < trains_.size();) { const QTime& departureTime = trains_.at(i).departureTime; // If we're removing trains before 11:45 PM and we are displaying a // train at 12:30 AM, that train will be removed. So we don't want to // remove trains that are much earlier than 11:45 PM, say 12 hours. bool notTooOldCheck = true; if (since.hour() > 12) { QTime after = since.addSecs(-60 * 60 * 12); notTooOldCheck = departureTime >= after; qDebug() << "but don't remove trains newer than" << after << notTooOldCheck; } if (departureTime <= since && notTooOldCheck) { qDebug() << "removing:" << trains_.size() << i << trains_.at(i); beginRemoveRows(QModelIndex(), i, i); trains_.removeAt(i); endRemoveRows(); qDebug() << "trains size" << trains_.size(); } else { ++i; } } }
QTime Profil::getTempsTotal() { QTime total; foreach(QTime v, _resultatsNiveaux) total.addSecs(v.hour() * 3600 + v.minute() * 60 + v.second()); return total; }
void wrapInFunction() { //! [0] Q3DateEdit *dateEdit = new Q3DateEdit(QDate::currentDate(), this); dateEdit->setRange(QDate::currentDate().addDays(-365), QDate::currentDate().addDays( 365)); dateEdit->setOrder(Q3DateEdit::MDY); dateEdit->setAutoAdvance(true); //! [0] //! [1] QTime timeNow = QTime::currentTime(); Q3TimeEdit *timeEdit = new Q3TimeEdit(timeNow, this); timeEdit->setRange(timeNow, timeNow.addSecs(60 * 60)); //! [1] //! [2] Q3DateTimeEdit *dateTimeEdit = new Q3DateTimeEdit(QDateTime::currentDateTime(), this); dateTimeEdit->dateEdit()->setRange(QDateTime::currentDate(), QDateTime::currentDate().addDays(7)); //! [2] }
QString DateChooserWidget::getRevisionString() const { QString timeString; QString dateString; QDate today = QDate::currentDate(); if (m_selectedRadioIndex == 0) // Time { QTime currentTime = QTime::currentTime(); QTime t = m_timeEdit->time(); int seconds = t.hour() * 60 * 60 + t.minute() * 60; currentTime = currentTime.addSecs(-seconds); timeString = currentTime.toString("hh:mm"); dateString = today.toString("yyyy-MM-dd"); } else if (m_selectedRadioIndex == 1) // Days { timeString = "00:00"; today = today.addDays(-(m_dayEdit->value())); dateString = today.toString("yyyy-MM-dd"); } else if (m_selectedRadioIndex == 2) // Weeks { timeString = "00:00"; today = today.addDays(-(m_weekEdit->value() * 7)); dateString = today.toString("yyyy-MM-dd"); } else // Custom date { QTime time = m_dateTimeEdit->time(); timeString = time.toString("hh:mm"); QDate date = m_dateTimeEdit->date(); dateString = date.toString("yyyy-MM-dd"); } return "{" + dateString + " " + timeString + "}"; }
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())); }
QTime CpuStat::upTime() const { QTime t; for ( int i = 0; i < NValues; i++ ) t = t.addSecs(int(procValues[i] / 100)); return t; }
QTime ACARSAirport::getCurrentTime(QTime UTCTime) { QTime LCL = QTime(0,0,0,0); LCL = LCL.fromString(UTCTime.toString()); LCL = LCL.addSecs(m_iTimezone); return LCL; }
/*! \brief Fills the combo box with a list of time slices, per default 30 minutes intervals. * * The interval can be set with setInterval(). Each time the user changes the combo value, the signal * \e timeChanged() is emitted. The current selected time can be retrieved anytime with time(). */ void TimeComboBox::updateComboItems() { // save current displayed time for restoring later QTime oldTime = this->time(); // d->combo->clear(); for (QTime time = QTime(0, 0); time < QTime(23, 59); time = time.addSecs(d->interval * 60)) { // Each combo item is filled with the current locale's time string, and the item data is set to the QTime, d->combo->addItem(time.toString(QLocale::system().timeFormat(QLocale::ShortFormat)), time); // prevent wrapping of time to next day -> infinite loop if (time.addSecs(d->interval * 60) < time) break; } setTime(oldTime); }
void WorldTimeClock::paintEvent(QPaintEvent *) { static const QPoint hourHand[3] = { QPoint(7, 8), QPoint(-7, 8), QPoint(0, -40) }; static const QPoint minuteHand[3] = { QPoint(7, 8), QPoint(-7, 8), QPoint(0, -70) }; QColor hourColor(127, 0, 127); QColor minuteColor(0, 127, 127, 191); int side = qMin(width(), height()); QTime time = QTime::currentTime(); time = time.addSecs(timeZoneOffset); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.translate(width() / 2, height() / 2); painter.scale(side / 200.0, side / 200.0); painter.setPen(Qt::NoPen); painter.setBrush(hourColor); painter.save(); painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); painter.drawConvexPolygon(hourHand, 3); painter.restore(); painter.setPen(hourColor); for (int i = 0; i < 12; ++i) { painter.drawLine(88, 0, 96, 0); painter.rotate(30.0); } painter.setPen(Qt::NoPen); painter.setBrush(minuteColor); painter.save(); painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); painter.drawConvexPolygon(minuteHand, 3); painter.restore(); painter.setPen(minuteColor); for (int j = 0; j < 60; ++j) { if ((j % 5) != 0) painter.drawLine(92, 0, 96, 0); painter.rotate(6.0); } emit updated(time); }
void SpecificWorker::action_handObject_offer(bool first) { static QTime time; static bool localFirst=true; if (localFirst) { time = QTime::currentTime(); time.addSecs(-1000); localFirst = false; } // Lock mutex and get a model's copy QMutexLocker locker(mutex); AGMModel::SPtr newModel(new AGMModel(worldModel)); // Get action parameters try { symbols = newModel->getSymbolsMap(params, "object", "person", "status"); } catch(...) { printf("graspingAgent: Couldn't retrieve action's parameters\n"); } // Attempt to get the 'offered' edge, in which case we're done try { newModel->getEdge(symbols["object"], symbols["person"], "offered"); return; } catch(...) { } // Attempt to get the person "reach" edge. Proceed if successfull. try { // Get the person "reach" edge. newModel->getEdge(symbols["person"], symbols["status"], "reach"); // Make the robot speak if (/*first or */time.elapsed() > 15000) { time = QTime::currentTime(); speech_proxy->say("Aquii tienes",false); } // Make the action noticeable in the model. newModel->addEdge(symbols["object"], symbols["person"], "offered"); // Publish the modification sendModificationProposal(worldModel, newModel); } catch(...) { // Edge not present yet or some error raised. Try again in a few milliseconds. } }
/** * Get a human-readable time string from the given number of seconds past * midnight. * * @param time The time to be converted (counted in seconds past midnight) * @return A human-readable time string */ QString Formatting::timeToString(int time) { if (time == -1) { return ""; } QTime midnight; QTime timeObj = midnight.addSecs(time); return timeObj.toString(timeFormat); }
void ProgressWidget::updateDownloadSpeed() { qint64 currTimestamp = QDateTime::currentMSecsSinceEpoch(); if (m_lastTimestamp == 0) { m_lastTimestamp = currTimestamp - m_timer->interval(); } qint64 intervalLength = currTimestamp - m_lastTimestamp; qint64 amountDownloadedTotal = m_progressBarValue; qint64 amountDownloaded = amountDownloadedTotal - m_bytesDownloadedTotalLastInterval; qint64 amountRemaining = m_ui->progressBar->maximum() - amountDownloadedTotal; float currDownloadSpeed = (float)amountDownloaded / (float)intervalLength; if (m_avgDownloadSpeedWeighted == 0) m_avgDownloadSpeedWeighted = currDownloadSpeed; if (m_vecDownloadSpeeds.size() >= 180) { m_vecDownloadSpeeds.pop_front(); } m_vecDownloadSpeeds.push_back(currDownloadSpeed); #ifdef DEBUG_PROGRESSWIDGET m_vecDownloadSpeedsForEstimation.push_back(currDownloadSpeed); #endif float avgDownloadSpeed = 0; for (int i=0; i<m_vecDownloadSpeeds.size(); ++i) { avgDownloadSpeed += m_vecDownloadSpeeds[i]; } avgDownloadSpeed /= m_vecDownloadSpeeds.size(); m_avgDownloadSpeedWeighted = 0.02 * currDownloadSpeed + 0.70 * m_avgDownloadSpeedWeighted + 0.28 * avgDownloadSpeed; QTime remainingDlTime = QTime(); remainingDlTime = remainingDlTime.addSecs(amountRemaining / (float) m_avgDownloadSpeedWeighted / 1000.0f); #ifdef DEBUG_PROGRESSWIDGET kWarning() << "remaining msces = " << amountRemaining / m_avgDownloadSpeedWeighted; kWarning() << remainingDlTime; kWarning() << "remainingTime = " << remainingDlTime.toString(); kWarning() << "currDownload Speed = " << currDownloadSpeed; if (m_vecDownloadSpeedsForEstimation.size() % 60 == 0) { calcEstimationError(); } #endif m_ui->lblRemainingDlTime->setText(remainingDlTime.toString("h:mm:ss")); m_ui->lblDownloadSpeed->setText(QString::number(m_avgDownloadSpeedWeighted, 'f', 2) + " KB/s"); m_bytesDownloadedTotalLastInterval = amountDownloadedTotal; m_lastTimestamp = currTimestamp; }
void TimePickSelector::setCurrentTime(const QTime &time) { // Make sure that the time does not contain the seconds part QTime roundTime = time.addSecs(-time.second()); if (this->time != roundTime) { this->time = roundTime; emit selected(currentValueText()); } }
QString DurationToString(Uint32 nsecs) { KLocale* loc = KGlobal::locale(); QTime t; int ndays = nsecs / 86400; t = t.addSecs(nsecs % 86400); QString s = loc->formatTime(t,true,true); if (ndays > 0) s = i18n("1 day ","%n days ",ndays) + s; return s; }
/** *@brief Modifie la timeline selon les données de l'item. *@param item Item sélectionné. */ void DockTimeLine::update(QListWidgetItem *item) { this->thumbnailItem = 0; this->thumbnailItem = static_cast<ThumbnailItem *> (item); /* Hack - Si l'utilisateur clique trop vite sur l'item ou Service Windows Audio désactivé */ if(this->thumbnailItem->getTotalDuration().isNull()) { this->setDisabled(true); this->retranslate(); return; } else this->setDisabled(false); /*****************************************************/ if (!this->thumbnailItem->isReadable()) { this->setDisabled(true); spanSlider->setLowerPosition(0); spanSlider->setUpperPosition(0); } else { //update this->setEnabled(true); spanSlider->setRange(0,-thumbnailItem->getTotalDuration().secsTo(QTime())); if(thumbnailItem->getLowerTime().isNull()) { spanSlider->setLowerPosition(0); thumbnailItem->setLowerTime(QTime(0,0)); } else { spanSlider->setLowerPosition(-thumbnailItem->getLowerTime().secsTo(QTime())); } if(thumbnailItem->getUpperTime().isNull()) { QTime t; thumbnailItem->setUpperTime(t.addSecs(-thumbnailItem->getTotalDuration().secsTo(QTime()))); spanSlider->setUpperPosition(-thumbnailItem->getTotalDuration().secsTo(QTime())); } else { spanSlider->setUpperPosition(-thumbnailItem->getUpperTime().secsTo(QTime())); } } this->retranslate(); }
void MessagingDialog::updateProgressBar(const uint& completed, const uint& total, const QString& message) { ui->progressBar->setMaximum(total); ui->progressBar->setValue(completed); ui->progressBar->setFormat(tr("Sending message to %1: %v/%m").arg(message)); ui->progressBar->setToolTip(tr("Sending message to %1").arg(message)); //progressHint->setText(tr("Sending messages: (%2/%3)").arg(completed).arg(total)); int secs = (total-completed)*ui->intervalEdit->text().toInt(); QTime time; time = time.addSecs(secs); setWindowTitle(tr("Sending message to %1 (%2/%3), time remains: %4").arg(message).arg(completed).arg(total).arg(time.toString())); }
// Use this replacement for QDateTime::setTime_t(uint) since our time // values are signed. static QDateTime fromTime_t(qint32 seconds) { static const QDate epochDate(1970,1,1); static const QTime epochTime(0,0,0); int days = seconds / 86400; seconds -= days * 86400; if (seconds < 0) { --days; seconds += 86400; } return QDateTime(epochDate.addDays(days), epochTime.addSecs(seconds), Qt::UTC); }
bool Semaine::testChevauche(Programmation *p) const { QDate dateP; QTime heureDebutP; QTime heureFinP; QDate dateProg = p->getDate(); QTime heureDebutProg = p->getHoraireDebut(); QTime heureFinProg = heureDebutProg.addSecs(p->getEvent()->getDuree().getDureeEnMinutes()*60); bool jourSuivantP; int testJourP; int testJourProg = heureDebutProg.hour() + p->getEvent()->getDuree().getDureeEnHeures(); bool jourSuivantProg = testJourProg>24; for(multimap<const QDate, Programmation*>::const_iterator it=evenements.begin(); it!=evenements.end(); ++it){ dateP = it->second->getDate(); heureDebutP = it->second->getHoraireDebut(); heureFinP = heureDebutP.addSecs(it->second->getEvent()->getDuree().getDureeEnMinutes()*60); testJourP = heureDebutP.hour() + it->second->getEvent()->getDuree().getDureeEnHeures(); jourSuivantP = (testJourP > 24); if (dateP == dateProg) { if (!jourSuivantProg){ if(((heureDebutProg > heureDebutP) && (heureDebutProg < heureFinP)) || ((heureFinProg > heureDebutP) && (heureFinProg < heureFinP))) return false; } else{ if(jourSuivantP){ if(((heureDebutProg > heureDebutP) && (heureDebutProg < heureFinP)) || ((heureFinProg > heureDebutP) && (heureFinProg < heureFinP))) return false; } else{ if((heureDebutProg > heureDebutP) && (heureDebutProg < heureFinP)) return false; } } } } return true; }
void TripPlanner::updateTableWidget() { QDataStream in(&tcpSocket); in.setVersion(QDataStream::Qt_4_3); forever { int row = tableWidget->rowCount(); if(nextBlockSize == 0) { if(tcpSocket.bytesAvailable() < sizeof(quint16)) break; in >> nextBlockSize; } if(nextBlockSize == 0xFFFF) { closeConnection(); statusLabel->setText(tr("Found %1 trip(s)").arg(row)); break; } if(tcpSocket.bytesAvailable() < nextBlockSize) break; QDate date; QTime departureTime; QTime arrivalTime; quint16 duration; quint8 changes; QString trainType; in >> date >> departureTime >> duration >> changes >> trainType; arrivalTime = departureTime.addSecs(duration * 60); tableWidget->setRowCount(row + 1); QStringList fields; fields << date.toString(Qt::LocalDate) << departureTime.toString(tr("hh:mm")) << arrivalTime.toString(tr("hh:mm")) << tr("%1 hr %2 min").arg(duration / 60) .arg(duration % 60) << QString::number(changes) << trainType; for(int i = 0; i < fields.count(); ++i) tableWidget->setItem(row, i, new QTableWidgetItem(fields[i])); nextBlockSize = 0; } }
QTime DataPlot::upTime() const { time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); int hour = timeinfo->tm_hour; int min = timeinfo->tm_min; int sec = timeinfo->tm_sec; int time = hour*3600+min*60+sec-60; QTime t; t = t.addSecs(time); return t; }
void DummySIProvider::timeout() { if (m_runners.contains(m_index)) { emit runnerPunched(m_runners[m_index], QTime::currentTime()); } else if (20 < m_index) { if (qrand() % 5 == 0) { QTime time = QTime::currentTime(); time.addSecs(qrand() % 7200); emit runnerPunched(qrand() % 9999999, time); } } m_index++; }
QDateTime KTimeZone::fromTime_t(time_t t) { static const int secondsADay = 86400; static const QDate epochDate(1970,1,1); static const QTime epochTime(0,0,0); int days = t / secondsADay; int secs; if (t >= 0) secs = t % secondsADay; else { secs = secondsADay - (-t % secondsADay); --days; } return QDateTime(epochDate.addDays(days), epochTime.addSecs(secs), Qt::UTC); }