/*! @copydoc HbWidget::updatePrimitives() */ void SnsrOledClockWidget::updatePrimitives() { if (!mClockHourHand || !mClockMinuteHand || !mClockAmPmLabel) { createPrimitives(); } Q_ASSERT( mClockHourHand && mClockMinuteHand && mClockAmPmLabel ); // Calculate angles for clock hands. // Use granularity of one minute so that minute hand is always exactly // on some minute and not between minutes. OLED clock is not updated more // frequently than once per minute and using finer granularity would cause // the minute hand to be always between even minutes. QTime time = QTime::currentTime(); qreal m = 6 * time.minute(); qreal h = 30 * ((time.hour() % 12) + m/360); int x = mClockHourHand->preferredSize().width()/2; int y = mClockHourHand->preferredSize().height()/2; mClockHourHand->setTransform(QTransform().translate(x, y).rotate(h).translate(-x, -y)); x = mClockMinuteHand->preferredSize().width()/2; y = mClockMinuteHand->preferredSize().height()/2; mClockMinuteHand->setTransform(QTransform().translate(x, y).rotate(m).translate(-x, -y)); QString amPmString = (time.hour()<12) ? HbExtendedLocale().amText() : HbExtendedLocale().pmText(); mClockAmPmLabel->setText( amPmString ); }
static DATE QDateTimeToDATE(const QDateTime &dt) { if (!dt.isValid() || dt.isNull()) return 949998; SYSTEMTIME stime; memset(&stime, 0, sizeof(stime)); QDate date = dt.date(); QTime time = dt.time(); if (date.isValid() && !date.isNull()) { stime.wDay = date.day(); stime.wMonth = date.month(); stime.wYear = date.year(); } if (time.isValid() && !time.isNull()) { stime.wMilliseconds = time.msec(); stime.wSecond = time.second(); stime.wMinute = time.minute(); stime.wHour = time.hour(); } double vtime; SystemTimeToVariantTime(&stime, &vtime); return vtime; }
void Timelapse::setInterval(const QTime &time){ intervalTime->setHMS(time.hour(),time.minute(),time.second(),time.msec()); realinterval = interval = time.second()*1000+time.msec(); LOG_TIMELAPSE_DEBUG << "Timelapse setInterval: " << time.second() << time.msec() << interval; timer->setInterval(timerresolution); }
void QxtScheduleHeaderWidget::paintSection(QPainter * painter, const QRect & rect, int logicalIndex) const { if (model()) { switch (orientation()) { case Qt::Horizontal: { QHeaderView::paintSection(painter, rect, logicalIndex); } break; case Qt::Vertical: { QTime time = model()->headerData(logicalIndex, Qt::Vertical, Qt::DisplayRole).toTime(); if (time.isValid()) { QRect temp = rect; temp.adjust(1, 1, -1, -1); painter->fillRect(rect, this->palette().background()); if (time.minute() == 0) { painter->drawLine(temp.topLeft() + QPoint(temp.width() / 3, 0), temp.topRight()); painter->drawText(temp, Qt::AlignTop | Qt::AlignRight, time.toString("hh:mm")); } } } break; default: Q_ASSERT(false); //this will never happen... normally } } }
int SessionDefaults::timeToMins(const QTime &time) const { int hour = time.hour(); int min = time.minute(); return hour * 60 + min + 1; }
static PyObject *meth_QTime_toPyTime(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QTime *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QTime, &sipCpp)) { PyObject * sipRes = 0; #line 299 "/home/tsheasha/GUC/Bachelors/android-python27/python-build/PyQt-x11-gpl-4.8/sip/QtCore/qdatetime.sip" if (!PyDateTimeAPI) PyDateTime_IMPORT; // Convert to a Python time object. sipRes = PyTime_FromTime(sipCpp->hour(), sipCpp->minute(), sipCpp->second(), sipCpp->msec() * 1000); #line 74 "sipQtCoreQTime.cpp" return sipRes; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QTime, sipName_toPyTime, NULL); return NULL; }
void TourWidget::handleSliderMove( int value ) { d->m_playback.seek( value / 100.0 ); QTime nullTime( 0, 0, 0 ); QTime time = nullTime.addSecs( value / 100.0 ); d->m_tourUi.m_elapsedTime->setText( QString("%L1:%L2").arg( time.minute(), 2, 10, QChar('0') ).arg( time.second(), 2, 10, QChar('0') ) ); }
void KTimeEdit::subTime(QTime qt) { int h, m; // Note that we cannot use the same method for determining the new // time as we did in addTime, because QTime does not handle adding // negative seconds well at all. h = mTime.hour() - qt.hour(); m = mTime.minute() - qt.minute(); if(m < 0) { m += 60; h -= 1; } if(h < 0) { h += 24; } // store the newly calculated time. mTime.setHMS(h, m, 0); updateText(); emit timeChanged(mTime); }
void cTranscript::addLineToAdvTranscript (cTextChunk *chunk) { if (!advrunning) return; QString timestamp; if (includetimestamp) { QTime time = QTime::currentTime (); timestamp.sprintf ("[%02d:%02d:%02d.%02d] ", time.hour(), time.minute(), time.second(), time.msec() / 10); fputs (timestamp.toLatin1(), advfile); } cANSIParser *ap = dynamic_cast<cANSIParser *>(object ("ansiparser")); QString s; switch (advtype) { case TRANSCRIPT_PLAIN: s = chunk->toText (); break; case TRANSCRIPT_ANSI: s = chunk->toAnsi (ap); break; case TRANSCRIPT_HTML: s = chunk->toHTML (); break; }; QByteArray b = s.toLocal8Bit (); const char *ch = b.constData(); if (ch) fputs (ch, advfile); fflush (advfile); }
int Tano::Xmltv::timeZoneDiff() { QDateTime local = QDateTime::currentDateTime(); local.setTime(QTime(0, 0)); QDateTime utc = local.toUTC(); local.setTimeSpec(Qt::LocalTime); QDateTime offset = local.toUTC(); QTime properTimeOffset = QTime(offset.time().hour(), offset.time().minute()); offset.setTimeSpec(Qt::LocalTime); utc.setTimeSpec(Qt::UTC); bool isNegative; if (offset.secsTo(utc) < 0) { isNegative = true; } else { isNegative = false; properTimeOffset.setHMS(24 - properTimeOffset.hour() - (properTimeOffset.minute()/60.0) - (properTimeOffset.second()/3600.0), properTimeOffset.minute() - (properTimeOffset.second()/60.0), properTimeOffset.second()); if (!properTimeOffset.isValid()) { //Midnight case properTimeOffset.setHMS(0,0,0); } } if (isNegative) return properTimeOffset.secsTo(QTime(0, 0)); else return - properTimeOffset.secsTo(QTime(0, 0)); }
void TrackDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { if ( !index.isValid()) { return; } QTimeEdit* timeEditor = qobject_cast<QTimeEdit*>(editor); if ( !timeEditor) { return; } if (isRightColumn(index, TrackDelegate::columnNumber)) { QTime time = timeEditor->time(); int secs = time.hour() * 60 + time.minute(); //int secs = index.model()->data(index, Qt::EditRole).toInt(); model->setData(index, secs, Qt::EditRole); } else { QStyledItemDelegate::setModelData(editor, model, index); } }
void MainWindow::updateTimer() { int milisegundos, segundos, minutos; QTime timeAct = QTime::currentTime(); int minInicial = timeInicial.minute(); int minActual = timeAct.minute(); int segInicial = timeInicial.second(); int segActual = timeAct.second(); int msegInicial = timeInicial.msec(); int msegActual = timeAct.msec(); if (msegActual < msegInicial){ msegActual = 1000 + msegActual; segActual = segActual -1; } if (segActual < segInicial){ segActual = 60 + segActual; minActual = minActual -1; } minutos = minActual - minInicial; segundos = segActual - segInicial; milisegundos = (msegActual - msegInicial); QTime *time = new QTime(0,minutos,segundos,milisegundos); textTiempo = time->toString("mm:ss.zzz"); valorTiempo = milisegundos + segundos*1000 + minutos *60000; ui->lcdNumber->display(textTiempo); }
// ------------------------------------------------------------------------------------------------- void ParameterBox::timeValueChanged(const QTime& time) throw () { Settings& set = Settings::set(); set.writeEntry("Measuring/Triggering/Minutes", time.minute()); set.writeEntry("Measuring/Triggering/Seconds", time.second()); }
/* Log to the logfile only. */ void cLog::log( eLogLevel loglevel, cUOSocket* sock, const QString& string, bool timestamp ) { if ( !( Config::instance()->logMask() & loglevel ) ) { return; } // -> Log Event cPythonScript *globalHook = ScriptManager::instance()->getGlobalHook(EVENT_LOG); if (globalHook && globalHook->canHandleEvent(EVENT_LOG)) { PyObject *args = Py_BuildValue("(iNNO)", (unsigned int)loglevel, PyGetSocketObject(sock), QString2Python(string), Py_None ); bool result = globalHook->callEventHandler(EVENT_LOG, args); Py_DECREF(args); if (result) { return; } } if ( !checkLogFile() ) return; // Timestamp the data QTime now = QTime::currentTime(); QString prelude; if ( timestamp || loglevel == LOG_PYTHON ) { prelude.sprintf( "%02u:%02u:", now.hour(), now.minute() ); if ( sock ) prelude.append( QString( "%1:" ).arg( sock->uniqueId(), 0, 16 ) ); } // LogLevel switch ( loglevel ) { case LOG_ERROR: prelude.append( " ERROR: " ); break; case LOG_WARNING: prelude.append( " WARNING: " ); break; case LOG_PYTHON: prelude.append( " PYTHON: " ); break; default: prelude.append( " " ); } QByteArray utfdata = string.toUtf8(); utfdata.prepend( prelude.toUtf8() ); logfile.write( utfdata ); logfile.flush(); }
void UI_JumpMenuDialog::absolutetime_changed(const QTime &time_2) { long long milliseconds; if(!mainwindow->files_open) return; QObject::disconnect(daybox1, SIGNAL(valueChanged(int)), this, SLOT(offsetday_changed(int))); QObject::disconnect(timeEdit1, SIGNAL(timeChanged(const QTime &)), this, SLOT(offsettime_changed(const QTime &))); milliseconds = (long long)(time_2.hour()) * 3600000LL; milliseconds += (long long)(time_2.minute()) * 60000LL; milliseconds += (long long)(time_2.second()) * 1000LL; milliseconds += (long long)(time_2.msec()); milliseconds += ((long long)daybox2->value() * 86400000LL); if(milliseconds<0) milliseconds = 0; milliseconds -= starttime; time1.setHMS((int)((milliseconds / 3600000LL) % 24LL), (int)((milliseconds % 3600000LL) / 60000LL), (int)((milliseconds % 60000LL) / 1000LL), (int)(milliseconds % 1000LL)); timeEdit1->setTime(time1); daybox1->setValue((int)(milliseconds / 86400000LL)); QObject::connect(daybox1, SIGNAL(valueChanged(int)), this, SLOT(offsetday_changed(int))); QObject::connect(timeEdit1, SIGNAL(timeChanged(const QTime &)), this, SLOT(offsettime_changed(const QTime &))); }
void CDDialog::trackchanged(){ int i; i = listbox->currentItem(); if (i == -1) return; QTime dml = framestoTime(cdinfo.cddbtoc[i+1].absframe - cdinfo.cddbtoc[i].absframe); QString fmt; fmt.sprintf("%02d %02d:%02d %s",i+1,dml.minute(),dml.second(),trackedit->text()); track_list.insert(i+1,trackedit->text()); track_list.remove(i+2); listbox->setAutoUpdate(false); listbox->insertItem(fmt.data(),i); listbox->removeItem(i+1); listbox->setAutoUpdate(true); listbox->repaint(); if ( i <(int) listbox->count() -1 ){ listbox->setCurrentItem(i+1); listbox->centerCurrentItem(); } }
void Tohkbd::screenShot() { QDate ssDate = QDate::currentDate(); QTime ssTime = QTime::currentTime(); ssFilename = QString("%8/ss%1%2%3-%4%5%6-%7.png") .arg((int) ssDate.day(), 2, 10, QLatin1Char('0')) .arg((int) ssDate.month(), 2, 10, QLatin1Char('0')) .arg((int) ssDate.year(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.hour(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.minute(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.second(), 2, 10, QLatin1Char('0')) .arg((int) ssTime.msec(), 3, 10, QLatin1Char('0')) .arg("/home/nemo/Pictures"); QDBusMessage m = QDBusMessage::createMethodCall("org.nemomobile.lipstick", "/org/nemomobile/lipstick/screenshot", "", "saveScreenshot" ); QList<QVariant> args; args.append(ssFilename); m.setArguments(args); if (QDBusConnection::sessionBus().send(m)) printf("Screenshot success to %s\n", qPrintable(ssFilename)); else printf("Screenshot failed\n"); notificationSend("Screenshot saved", ssFilename); }
void ClientSocket::readClient() { QDataStream in(this); in.setVersion(5); if (blockSize == 0) { if (bytesAvailable() < sizeof(Q_UINT16)) return; in >> blockSize; } if (bytesAvailable() < blockSize) return; Q_UINT8 requestType; QString from; QString to; QDate date; QTime time; Q_UINT8 flag; in >> requestType; if (requestType == 'S') { in >> from >> to >> date >> time >> flag; srand(time.hour() * 60 + time.minute()); int numTrips = rand() % 8; for (int i = 0; i < numTrips; ++i) generateRandomTrip(from, to, date, time); QDataStream out(this); out << (Q_UINT16)0xFFFF; }
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 SpawnLog::logSpawnInfo(const char *type, const char *name, int id, int level, int x, int y, int z, const QDateTime& eqDate, const QTime& time, const char *killedBy, int kid, int guildid) { if (!open()) return; const QDate& eqDateDate = eqDate.date(); const QTime& eqDateTime = eqDate.time(); outputf("%s:%s(%d):%d:%d,%d,%d:%02d.%02d.%02d:%d:%s:%02d.%02d.%02d.%02d.%04d:%s(%d):%d\n", type, name, id, level, x, y, z, time.hour(), time.minute(), time.second(), version, (const char*)zoneShortName, eqDateTime.hour(), eqDateTime.minute(), eqDateDate.month(), eqDateDate.day(), eqDateDate.year(), killedBy, kid, guildid); flush(); }
void OgreWidget::update() { QTime time = QTime::currentTime(); unsigned int curtime = time.hour() * 60 + time.minute(); curtime = (curtime * 60) + time.second(); curtime = (curtime * 1000) + time.msec(); unsigned int timediff = curtime - mLastTime; mLastTime = curtime; mRenderDelta += timediff; unsigned int targetDelta; if (mTargetRenderCount > 0) targetDelta = 1000 / mTargetRenderCount; else targetDelta = 1000000; if (mRenderDelta >= targetDelta) { mRenderDelta = mRenderDelta % targetDelta; QWidget::update(); } }
//Обновление консоли оповещени в GUI о начале и конце копиляции, её времени void Compiler::updateLog(QTime &startTime) { QTime endTime = QTime::currentTime(); if(out) { out->clear(); QString secnd = QString::number(abs(endTime.second() - startTime.second())); QString min = QString::number(abs(endTime.minute() - startTime.minute())); QString msecnd = QString::number(abs(endTime.msec() - startTime.msec())); QString outPutMsg = "Компиляция прошла успешно время: " + formatTime(min, 2) + ":" + formatTime(secnd, 2) + ':' + formatTime(msecnd, 3) ; mBar->setValue(mBar->maximum()); out->append(outPutMsg); } }
void SignalRelay::checkAlignment() { int newTime = 0; QTime t = QTime::currentTime(); if (m_align == Plasma::AlignToMinute) { int seconds = t.second(); if (seconds > 2) { newTime = ((60 - seconds) * 1000) + 500; } } else if (m_align == Plasma::AlignToHour) { int minutes = t.minute(); int seconds = t.second(); if (minutes > 1 || seconds > 10) { newTime = ((60 - minutes) * 1000 * 60) + ((60 - seconds) * 1000) + 500; } } if (newTime) { killTimer(m_timerId); m_timerId = startTimer(newTime); m_resetTimer = true; } }
// Elapsed time. This implementation assumes that the maximum elapsed time is // less than 48 hours. ElapsedTime::ElapsedTime() { QTime now = QTime::currentTime(); bigBit = now.hour() * 60 * 60 + now.minute() * 60 + now.second(); littleBit = now.msec(); }
static int place( const DateBookDayWidget *item, bool *used, int maxn ) { int place = 0; int start = item->event().startTime().hour(); QTime e = item->event().endTime(); int end = e.hour(); if ( e.minute() < 5 ) end--; if ( end < start ) end = start; while ( place < maxn ) { bool free = TRUE; int s = start; while( s <= end ) { if ( used[10*s+place] ) { free = FALSE; break; } s++; } if ( free ) break; place++; } if ( place == maxn ) { return -1; } while( start <= end ) { used[10*start+place] = TRUE; start++; } return place; }
int qTimeToMsec(QTime time) { int hours = time.hour(); int minutes = time.minute(); int seconds = time.second(); int msec = time.msec(); return 1000*seconds+60000*minutes+3600000*hours+msec; }
TimeCounter::TimeCounter( const QTime& t ) { days = 0; hours = t.hour(); minutes = t.minute(); seconds = t.second(); mseconds = t.msec(); }
// Function to convert from a time to a day,hour,minute,second list void US_RunProtocol::timeToList( QTime& timeobj, int& days, QList< int >& dhms ) { dhms.clear(); dhms << days << timeobj.hour() << timeobj.minute() << timeobj.second(); }
void MyServer::heartBeatTimeOut() { QTime now = QTime::currentTime(); int minu = now.minute(); int sec = now.second(); qDebug("HeartBeatTimeOut!"); qDebug()<<"minute:"<<minu<<"sec:"<<sec; }
QColor ColorMaker::timeColor() const { QTime time = QTime::currentTime(); int r = time.hour(); int g = time.minute()*2; int b = time.second()*4; return QColor::fromRgb(r, g, b); }