Example #1
0
void Clock::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
    QTime time = QTime::currentTime();
    int w = this->size().width();
    int h = this->size().height();

    painter->save();
    painter->setRenderHint(QPainter::Antialiasing, true);
    //painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
    //painter->setRenderHint(QPainter::HighQualityAntialiasing , true);

    painter->translate(w/2.0, h/2.0);

    painter->drawPixmap(-mClockPix->width()/2.0, -mClockPix->height()/2.0, mClockPix->width(), mClockPix->height(), *mClockPix);

    painter->save();
    painter->rotate(30.0 * (time.hour() + time.minute() / 60.0));
    painter->drawPixmap(-mHourPix->width()/2.0, -mHourPix->height()+4 , mHourPix->width(), mHourPix->height(), *mHourPix);
    painter->restore();

    qreal a = 6.0 * time.minute();
    if (mShowSeconds)
        a += time.second() * 0.1;

    painter->save();
    painter->rotate(a);
    painter->drawPixmap(-mMinutePix->width()/2.0 , -mMinutePix->height()+3 , mMinutePix->width(), mMinutePix->height(), *mMinutePix);
    painter->restore();

    if (mShowSeconds)
    {
        painter->save();
        painter->rotate(6.0 * (time.second() /*+ time.msec() / 1000.0*/));
        painter->setPen(QColor(211, 48, 47));
        painter->drawLine(0, 0, 0, -80);
        painter->restore();
    }

    painter->drawPixmap(-mCenterPix->width()/2.0, -mCenterPix->height()/2.0, mCenterPix->width(), mCenterPix->height(), *mCenterPix);
    painter->restore();
}
Example #2
0
QByteArray USKTimePacket::getData()
{
    QByteArray array;
    //array.append((char)0x05); //установлены флаги F4 и F6
    //array.append((char)0x40); //установлен флаг F1
    array.append((char)0x44); //установлены флаги F1 и F5
    array.append(0x07); //7 байт данных
    quint8 l,h;
    QTime time = ui->dateTimeEdit->time();
    QDate date = ui->dateTimeEdit->date();

    l = time.second()%10;
    h = time.second()/10;
    h = h << 4;
    l |= h;
    array.append(l); //секунды

    l = time.minute()%10;
    h = time.minute()/10;
    h = h << 4;
    l |= h;
    array.append(l); //минуты

    l = time.hour()%10;
    h = time.hour()/10;
    h = h << 4;
    l |= h;
    array.append(l); //часы

    l = date.dayOfWeek();
    array.append(l); // день недели

    l = date.day() % 10;
    h = date.day() / 10;
    h = h << 4;
    l |= h;
    array.append(l); // дата

    l = date.month() % 10;
    h = date.month() / 10;
    h = h << 4;
    l |= h;
    array.append(l); // месяц

    l = (date.year() % 100) % 10;
    h = (date.year() % 100) / 10;
    h = h << 4;
    l |= h;
    array.append(l); // год

    //array.append((char)0x00); //0 повторов
    return array;
}
Example #3
0
TimeStamp::TimeStamp ( const QTime& tm, bool isLocal )
{
	initDefault();
	m_zone="UTC";
	QDate dt=QDate::currentDate();
	m_year=dt.year();m_month=dt.month();m_day=dt.day();
	m_hour=tm.hour();m_min=tm.minute();m_sec=tm.second();m_msec=tm.msec();
	if(isLocal)
		moveToZone(defaultzone);
	else
		moveToZone("UTC");
}
Example #4
0
void TimeToolBar::slotCurrentTime()
{
    QDateTime now = QDateTime::currentDateTime().toUTC();
    QDate d = now.date();
    QTime t = now.time();
    astro::Date celDate(d.year(), d.month(), d.day());
    celDate.hour = t.hour();
    celDate.minute = t.minute();
    celDate.seconds = (double) t.second() + t.msec() / 1000.0;

    appCore->getSimulation()->setTime(astro::UTCtoTDB(celDate));
}
Example #5
0
void frmBarRuler::initForm()
{
    //初始化随机数种子
    QTime t = QTime::currentTime();
    qsrand(t.msec() + t.second() * 1000);

    QTimer *timer = new QTimer(this);
    timer->setInterval(2000);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateValue()));
    timer->start();
    updateValue();
}
Example #6
0
// start lvk
AIMLParser::AIMLParser(const QString &xml, QIODevice *logDevice)
{
    _indent = 0;
    _root.parent = NULL;
    QTime currentTime = QTime::currentTime();
    int val = currentTime.msec() + currentTime.second() + currentTime.minute();
    srand(val);

    _logStream.setDevice(logDevice);

    loadAimlFromString(xml);
}
Example #7
0
/**
 * @brief DigitalClock::paintEvent draw the second
 */
void DigitalClock::paintEvent(QPaintEvent *)
{
     QRectF rectangle(15.0, 90.0, 310.0, 310.0);
     int startAngle = 90 * 16;
     QTime timeM = QTime::currentTime();

     int spanAngle = 6 * timeM.second() * 16;

     QPainter painter(this);
     painter.setPen(*pen);
     painter.drawArc(rectangle, startAngle, spanAngle);
}
Example #8
0
/*! Convert a Qt4 date-time object to a Julian date.
 *
 *  TODO: leap seconds are not handled by Qt4 yet.
 *  TODO: milliseconds are not handled in the calendarTOjulian function yet.
 */
double sta::CalendarToJd(QDateTime calendarDate)
{
    Q_ASSERT(calendarDate.isValid());
    
    // Convert the timespec to UTC
    // QDateTime utcDate = calendarDate.toUTC();  // We assume for the time being that all times are UTC
    QDateTime utcDate = calendarDate;
    QDate d = utcDate.date();
    QTime t = utcDate.time();
    
    return calendarTOjulian(d.year(), d.month(), d.day(), t.hour(), t.minute(), t.second());
}
Example #9
0
AIMLParser::AIMLParser(QIODevice *logDevice)
{
    _indent = 0;
    _root.parent = NULL;
    QTime currentTime = QTime::currentTime();
    int val = currentTime.msec() + currentTime.second() + currentTime.minute();
    srand(val);

    // start lvk
    _logStream.setDevice(logDevice);
    // end lvk
}
Example #10
0
void TrackDelegate::setModelData(QWidget *editor,
                                 QAbstractItemModel *model,
                                 const QModelIndex &index) const
{
    if (index.column() == durationColumn) {
        QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor);
        QTime time = timeEdit->time();
        int secs = (time.minute() * 60) + time.second();
        model->setData(index, secs);
    } else {
        QItemDelegate::setModelData(editor, model, index);
    }
}
Example #11
0
void KoPictureKey::saveAttributes( QDomElement &elem ) const
{
    QDate date = m_lastModified.date();
    QTime time = m_lastModified.time();
    elem.setAttribute( "filename", m_filename );
    elem.setAttribute( "year", date.year() );
    elem.setAttribute( "month", date.month() );
    elem.setAttribute( "day", date.day() );
    elem.setAttribute( "hour", time.hour() );
    elem.setAttribute( "minute", time.minute() );
    elem.setAttribute( "second", time.second() );
    elem.setAttribute( "msec", time.msec() );
}
Example #12
0
void workclock::showTime()
{
     QTime time = QTime::currentTime();

     QString text = time.toString("hh:mm:ss");
     if ((time.second() % 2) == 0)

         text[2] = ' ';
     else
         text[5] = ' ';

     ui->time->display(text);
     if (works==true)
     {
         if (setminute!=time.second())
         {
            setminute=time.second();
            if (value!=0) value--;
         }
     }

    if (value==15)
    {
         // QApplication::alert ( this, 1000 );
            int n = QMessageBox::warning(0,
      "Warning",
      "Pleaes Stop",
      QMessageBox::Yes | QMessageBox::No,
      QMessageBox::Yes
      );
         if (n == QMessageBox::Yes) {
      // Saving the changes!
      }
    }


    ui->workminut->display(value);

}
Example #13
0
QTime NetworkConnection::gd_checkMainTime(TimeSystem s, const QTime & t)
{
	if(s == canadian)
	{
//		int seconds = (t.minute() * 60) + t.second();
		if(t.second())
		{
//			seconds = (t.minute() * 60);
			return QTime(0, t.minute(), 0);
		}
	}
	return t;
}
Example #14
0
void DigitalClock::showTime()
{
    QTime time = QTime::currentTime();
    QString text = time.toString("h:m:s");
qDebug() << text;
    if ((time.second() % 2) == 0) {
        //text[3] = ' ';
    }
    
    display(text);

    //display("1234567890");
}
Example #15
0
 void timerEvent(QTimerEvent *)
 {
     QTime now = QTime::currentTime();
     if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) {
         // just missed time tick over, force it, wait extra 0.5 seconds
         time.addSecs(60);
         timer.start(60500, this);
     } else {
         time = now;
         timer.start(60000-time.second()*1000, this);
     }
     emit timeChanged();
 }
void SleepReminder::GetShowNowTime()
{
	QTime now = QDateTime::currentDateTime().time();
	ui.MaoNowTime->setText(QString::number(now.hour()) + ':' +
							QString::number(now.minute()) + ':' +
							QString::number(now.second()));

	if (true == isWork)
	{
		if (ui.MaoHour->text().toInt() == now.hour() &&
			ui.MaoMinute->text().toInt() == now.minute())
			warn.start(520);
	}
}
Example #17
0
void createTimeNode( QDomDocument& doc, QDomNode& parent,
                      const QString& elementName, const QTime& time )
{
    QDomElement timeElement = doc.createElement( elementName );
    parent.appendChild( timeElement );
    timeElement.setAttribute( "Hour",
                               QString::number( time.hour() ) );
    timeElement.setAttribute( "Minute",
                               QString::number( time.minute() ) );
    timeElement.setAttribute( "Second",
                               QString::number( time.second() ) );
    timeElement.setAttribute( "Millisecond",
                               QString::number( time.msec() ) );
}
Example #18
0
void FileImportDialog::on_buttonBox_accepted() {
    QFile f(fileLineEdit->text());
    f.open(QFile::ReadOnly);
    QString content = f.readAll();
    QStringList trames = content.split("@");
    int i=0;
    QTime base = QTime::currentTime();
    foreach(QString trame, trames) {
        Data* d = m_parent->getSensorMgr()->addData(trame);
        if(d != NULL)
            d->time = QTime(base.hour(),base.minute(),base.second()+i);

        i++;
    }
void MainWindow::showTime()
{
    QTime time = QTime::currentTime();  //smider den nuværende tid ind i en variable
    QString time_text = time.toString("hh:mm:ss");  // laver tiden om til en string og sætter en i en string variable

    if ((time.second() % 2) == 0)
    {
        time_text[2] = ' ';  // får den til at blinke
        time_text[5] = ' ';
    }

    ui->Digital_clock->setText(time_text); //Peger på den text label som skal vise tiden

}
Example #20
0
QTime SessionDefaults::correctFPTime(const QTime &time) const
{
    int hour = time.hour();
    int min = time.minute();
    int sec = time.second();

    int t = getFPLength() * 60 - hour * 3600 - min * 60 - sec;
    hour = t/3600;
    min = (t%3600)/60;
    sec = (t%3600)%60;
    QTime newTime(hour, min, sec);

    return newTime;
}
Example #21
0
void LiveTVChain::AppendNewProgram(ProgramInfo *pginfo, QString channum,
                                   QString inputname, bool discont)
{
    QMutexLocker lock(&m_lock);

    QTime tmptime = pginfo->GetRecordingStartTime().time();

    LiveTVChainEntry newent;
    newent.chanid = pginfo->GetChanID();
    newent.starttime = pginfo->GetRecordingStartTime();
    newent.starttime.setTime(QTime(tmptime.hour(), tmptime.minute(),
                                   tmptime.second()));
    newent.discontinuity = discont;
    newent.hostprefix = m_hostprefix;
    newent.cardtype = m_cardtype;
    newent.channum = channum;
    newent.inputname = inputname;

    m_chain.append(newent);

    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("INSERT INTO tvchain (chanid, starttime, endtime, chainid,"
                  " chainpos, discontinuity, watching, hostprefix, cardtype, "
                  " channame, input) "
                  "VALUES(:CHANID, :START, :END, :CHAINID, :CHAINPOS, "
                  " :DISCONT, :WATCHING, :PREFIX, :CARDTYPE, :CHANNAME, "
                  " :INPUT );");
    query.bindValue(":CHANID", pginfo->GetChanID());
    query.bindValue(":START", pginfo->GetRecordingStartTime());
    query.bindValue(":END", pginfo->GetRecordingEndTime());
    query.bindValue(":CHAINID", m_id);
    query.bindValue(":CHAINPOS", m_maxpos);
    query.bindValue(":DISCONT", discont);
    query.bindValue(":WATCHING", 0);
    query.bindValue(":PREFIX", m_hostprefix);
    query.bindValue(":CARDTYPE", m_cardtype);
    query.bindValue(":CHANNAME", channum);
    query.bindValue(":INPUT", inputname);

    if (!query.exec() || !query.isActive())
        MythDB::DBError("Chain: AppendNewProgram", query);
    else
        LOG(VB_RECORD, LOG_INFO, QString("Chain: Appended@%3 '%1_%2'")
                .arg(newent.chanid)
                .arg(newent.starttime.toString("yyyyMMddhhmmss"))
                .arg(m_maxpos));

    m_maxpos++;
    BroadcastUpdate();
}
void EdrcPlugin::testConsultResultXml()
{
    Utils::Randomizer r;
    r.setPathToFiles(settings()->path(Core::ISettings::BundleResourcesPath) + "/textfiles/");

    // Test Unique CR XML
    ConsultResult r2;
    r2.setConsultResult(1);
    r2.setChronicDiseaseState(ConsultResult::ChronicDisease);
    r2.setDiagnosisPosition(ConsultResult::A);
    r2.setMedicalFollowUp(ConsultResult::N);
    r2.setSymptomaticState(ConsultResult::Symptomatic);
    r2.setSelectedCriterias(QList<int>() << 1 << 2);
    r2.setHtmlCommentOnCR("<p>This the CR<b>comment</b><br></p>");
    r2.setHtmlCommentOnCriterias("<p>This the criteria<b>comment</b><br></p>");
    QDateTime dt = QDateTime::currentDateTime();
    r2.setDateOfExamination(dt);
    QTime time = dt.time();
    dt.time().setHMS(time.hour(), time.minute(), time.second());
    dt.setTime(time);

    QString extra;
    QList<ConsultResult> list = ConsultResult::fromXml(r2.toXml("<xtra>bla bla</xtra>"), &extra);
    extra = extra.simplified();
    QCOMPARE(list.count(), 1);
    QString control = QString("<%1> <xtra>bla bla</xtra> </%1>").arg(Constants::XML_EXTRA_TAG);
    QCOMPARE(extra, control);
    QVERIFY(r2 == list.at(0));
    QVERIFY(r2.toXml() == list.at(0).toXml());

    // Test Multiple CR XML
    list.clear();
    for(int i=0; i<10; ++i) {
        ConsultResult cr;
        cr.setConsultResult(r.randomInt(1, 300));
        cr.setDiagnosisPosition(ConsultResult::DiagnosisPosition(r.randomInt(0, 3)));
        cr.setMedicalFollowUp(ConsultResult::MedicalFollowUp(r.randomInt(0, 2)));
        cr.setSymptomaticState(ConsultResult::SymptomaticState(r.randomInt(0, 1)));
        cr.setChronicDiseaseState(ConsultResult::ChronicDiseaseState(r.randomInt(0, 1)));
        cr.setSelectedCriterias(QList<int>() << r.randomInt(0, 300) << r.randomInt(0, 300));
        cr.setHtmlCommentOnCR(r.randomString(r.randomInt(10, 500)));
        cr.setHtmlCommentOnCriterias(r.randomString(r.randomInt(10, 500)));
        cr.setDateOfExamination(r.randomDateTime(QDateTime::currentDateTime().addMonths(-10)));
        list << cr;
    }
    QString xml = ConsultResult::listToXml(list, "<xtra>bla bla</xtra>");
    QList<ConsultResult> fromXmlList = ConsultResult::fromXml(xml, &extra);
    QCOMPARE(list.count(), fromXmlList.count());
    QCOMPARE(list, fromXmlList);
}
Example #23
0
/*!
  Translate from QDateTime to double

  \param dateTime Datetime value
  \return Number of milliseconds since 1970-01-01T00:00:00 UTC has passed.

  \sa toDateTime(), QDateTime::toMSecsSinceEpoch()
  \warning For values very far below or above 1970-01-01 UTC rounding errors
           will happen due to the limited significance of a double.
 */
double QwtDate::toDouble( const QDateTime &dateTime )
{
    const int msecsPerDay = 86400000;

    const QDateTime dt = qwtToTimeSpec( dateTime, Qt::UTC );

    const double days = dt.date().toJulianDay() - QwtDate::JulianDayForEpoch;

    const QTime time = dt.time();
    const double secs = 3600.0 * time.hour() + 
        60.0 * time.minute() + time.second();

    return days * msecsPerDay + time.msec() + 1000.0 * secs;
}
Example #24
0
void Player::positionChanged()
{
    QTime position = m_GstPlayer->position();
    QTime length = m_GstPlayer->length();

    int s_pos = (position.minute() * 60) + position.second();

    if(position.toString("mss") != "3433") {
        Q_EMIT tick(position, length);
        Q_EMIT tick(s_pos);
    }

    Q_EMIT updatePos();
}
Example #25
0
Programmation::Programmation(const int id, const QDate &d, const QTime &dur, const QTime &h):id(id),date(d),duree(dur),horaire(h)
{
   ProgManager::Iterator it = ProgManager::getInstance()->getIterator();
   int jour = d.day();
   /*int debut = h.hour();
   int fin = debut + dur.hour();*/
   QTime debut=h;
   QTime fin;
   fin.setHMS(h.hour()+dur.hour(),h.minute()+dur.minute(),h.second()+dur.second());
   /*bool commencePendant=false;
   bool terminePendant=false;*/
   bool horaireinvalide=false;
   bool memeJour=false;
   while(it.courant() != ProgManager::getInstance()->end())
   {
       Programmation *p = it.valeur();
       /*int pH = p->getHoraire().hour();
       int pFin = pH + p->getDuree().hour();*/
       int pJour = it.valeur()->getDate().day();
     /*  commencePendant = (debut >= pH && debut <= pFin); //On autorise qu'un evenement se finisse à une heure h et qu'un autre commence tout de suite après
       terminePendant = (fin >= pH && fin <= pFin);*/
       QTime pDeb=p->getHoraire();
       QTime pFin;
       pFin.setHMS(p->getHoraire().hour()+p->getDuree().hour(),p->getHoraire().minute()+p->getDuree().minute(),p->getHoraire().second()+p->getDuree().second());
       /*commencePendant= (debut>=pDeb && debut<pFin);
       terminePendant= (fin>pDeb && fin<=pFin);*/
       horaireinvalide=(debut<=pDeb && fin>=pFin)
               || (debut<=pDeb && (fin<=pFin && fin>pDeb))
               || ((debut>=pDeb && debut<pFin) && fin>=pFin)
               || ((debut>=pDeb && debut<pFin) && (fin>=pDeb && fin<=pFin));
       memeJour = jour == pJour;
       if( memeJour && horaireinvalide)
               throw AgendaException("Une programmation occupe déjà une partie de cette plage horaire");
       it.next();
   }
}
Example #26
0
void Producter::getRandString(QString & randString)
{
    int max = 16;
    QString tmp = QString("0123456789ABCDEFGHIJKLMNOPQRSTUVWZYZ");
    QString str = QString();
    QTime t;
    t= QTime::currentTime();
    qsrand(t.msec()+t.second()*1000);
    for(int i=0;i<max;i++)
    {
        int ir = qrand()%tmp.length();
        str[i] = tmp.at(ir);
    }
    randString = str;
}
Example #27
0
void MainWindow::on_save_clicked()
{
    QTime time = QTime::currentTime();
    QDate date = QDate::currentDate();
    QString name;
   if(date.day()<10)
        name += "0";
    name += QString::number(date.day())+".";
    if(date.month()<10)
        name += "0";
    name += QString::number(date.month())+".";
    name += QString::number(date.year())+"_";
    if(time.hour()<10)
        name += "0";
    name += QString::number(time.hour())+"-";
    if(time.minute()<10)
        name += "0";
    name += QString::number(time.minute())+"-";
    if(time.second()<10)
        name += "0";
    name += QString::number(time.second());
    QFile file(name+".png");
    qDebug() << name;
    file.open(QIODevice::WriteOnly);
    QMessageBox msgBox;
    msgBox.setStandardButtons(QMessageBox::Ok);
    if(ui->outputGraph->pixmap()->save(&file,"PNG")) {
        msgBox.setText("Saved to program folder with name: "+name+".png");
        msgBox.setWindowTitle("Saved!");
    }
    else {
        msgBox.setText("Error saving.");
        msgBox.setWindowTitle("Error!");
    }
    msgBox.exec();
}
Example #28
0
QString DownloadItem::remaingTimeToString(QTime time)
{
    if (time < QTime(0, 0, 10)) {
        return tr("few seconds");
    }
    else if (time < QTime(0, 1)) {
        return tr("%n seconds", "", time.second());
    }
    else if (time < QTime(1, 0)) {
        return tr("%n minutes", "", time.minute());
    }
    else {
        return tr("%n hours", "", time.hour());
    }
}
Example #29
0
QTime operator/(QTime l,int r)
{
        //convert everything into milliseconds, devide, and convert back
        int left=l.hour()*60*60*1000 + l.minute()*60*1000 + l.second()*1000 + l.msec();
        int result = left/r;
        int ms = result%1000;
        result = (result - ms)/1000;
        int s = result%60;
        result = (result - s)/60;
        int m = result%60;
        result = (result - m)/60;
        int h = result;
	QTime re(h,m,s,ms);
	return re;
}
Example #30
0
static QString getRandomFileName(size_t length)
{
    const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");

    QTime currentTime = QTime::currentTime();
    qsrand(currentTime.hour() + currentTime.second() + currentTime.minute() + currentTime.msec());
    QString randomString;
    for(size_t i=0; i<length; ++i)
    {
        int index = qrand() % possibleCharacters.length();
        QChar nextChar = possibleCharacters.at(index);
        randomString.append(nextChar);
    }
    return randomString;
}