Exemplo n.º 1
0
int main()
{
    QDateTime dt(QDate(2004, 2, 29), QTime(1,0,0));
    qDebug() << dt.toString("yyyy");
    qDebug() << dt.toString(Qt::ISODate);

    qDebug() << "--------------------";
    QDateTime local(QDateTime::currentDateTime());
    QDateTime UTC(local.toTimeSpec(Qt::UTC));
    QDateTime UTC2(UTC.toTimeSpec(Qt::UTC));
    qDebug() << "Local time is:" << local.toString();
    qDebug() << "UTC time is:" << UTC.toString();
    qDebug() << "UTC2 time is:" << UTC2.toString();
    qDebug() << "No difference between times:" << local.secsTo(UTC);
    return 0;
}
Exemplo n.º 2
0
Arquivo: Date.cpp Projeto: bsdf/trx
 Date::Date(double year,
            double month,
            double date,
            double hours,
            double min,
            double sec,
            double msec,
            bool utcFlag)
 {
     if (year < 100) {
         year += 1900;
     }
     m_time = MakeDate(MakeDay(year, month, date),
                       MakeTime(hours, min, sec, msec));
     if (!utcFlag) {
         m_time = UTC(m_time);
     }
 }
Exemplo n.º 3
0
void loop()
{
  while(1)
  { 
    Serial.print("UTC:");
    UTC();
    Serial.print("Lat:");
    latitude();
    Serial.print("Dir:");
    lat_dir();
    Serial.print("Lon:");
    longitude();
    Serial.print("Dir:");
    lon_dir();
    Serial.print("Alt:");
    altitude();
    Serial.println(' ');
    Serial.println(' ');
  }
}
Exemplo n.º 4
0
void QtMarbleConfigDialog::readSettings()
{
    d->m_initialGraphicsSystem = graphicsSystem();
    d->m_previousGraphicsSystem = d->m_initialGraphicsSystem;

    // Sync settings to make sure that we read the current settings.
    syncSettings();
    
    // View
    d->ui_viewSettings.kcfg_distanceUnit->setCurrentIndex( measurementSystem() );
    d->ui_viewSettings.kcfg_angleUnit->setCurrentIndex( angleUnit() );
    d->ui_viewSettings.kcfg_stillQuality->setCurrentIndex( stillQuality() );
    d->ui_viewSettings.kcfg_animationQuality->setCurrentIndex( animationQuality() );
    d->ui_viewSettings.kcfg_labelLocalization->setCurrentIndex( Marble::Native );
    d->ui_viewSettings.kcfg_mapFont->setCurrentFont( mapFont() );
    d->ui_viewSettings.kcfg_graphicsSystem->setCurrentIndex( graphicsSystem() );
    
    // Navigation
    d->ui_navigationSettings.kcfg_dragLocation->setCurrentIndex( Marble::KeepAxisVertically );
    d->ui_navigationSettings.kcfg_onStartup->setCurrentIndex( onStartup() );
    d->ui_navigationSettings.kcfg_inertialEarthRotation->setChecked( inertialEarthRotation() );
    d->ui_navigationSettings.kcfg_animateTargetVoyage->setChecked( animateTargetVoyage() );
    int editorIndex = 0;
    if ( externalMapEditor() == "potlatch") {
        editorIndex = 1;
    } else if ( externalMapEditor() == "josm") {
        editorIndex = 2;
    } else if ( externalMapEditor() == "merkaartor") {
        editorIndex = 3;
    }
    d->ui_navigationSettings.kcfg_externalMapEditor->setCurrentIndex( editorIndex );

    // Cache
    d->ui_cacheSettings.kcfg_volatileTileCacheLimit->setValue( volatileTileCacheLimit() );
    d->ui_cacheSettings.kcfg_persistentTileCacheLimit->setValue( persistentTileCacheLimit() );
    d->ui_cacheSettings.kcfg_proxyUrl->setText( proxyUrl() );
    d->ui_cacheSettings.kcfg_proxyPort->setValue( proxyPort() );
    d->ui_cacheSettings.kcfg_proxyUser->setText( proxyUser() );
    d->ui_cacheSettings.kcfg_proxyPass->setText( proxyPass() );
    d->ui_cacheSettings.kcfg_proxyType->setCurrentIndex( proxyType() );
    d->ui_cacheSettings.kcfg_proxyAuth->setChecked( proxyAuth() );
 
    // Time
    d->ui_timeSettings.kcfg_systemTimezone->setChecked( systemTimezone() );
    d->ui_timeSettings.kcfg_customTimezone->setChecked( customTimezone() );
    d->ui_timeSettings.kcfg_chosenTimezone->setCurrentIndex( chosenTimezone() );
    d->ui_timeSettings.kcfg_utc->setChecked( UTC() );
    d->ui_timeSettings.kcfg_systemTime->setChecked( systemTime() );
    d->ui_timeSettings.kcfg_lastSessionTime->setChecked( lastSessionTime() );
    if( systemTimezone() == true  )
    {
        QDateTime localTime = QDateTime::currentDateTime().toLocalTime();
        localTime.setTimeSpec( Qt::UTC );
        d->m_marbleWidget->model()->setClockTimezone( QDateTime::currentDateTime().toUTC().secsTo( localTime ) );
    }
    else if( UTC() == true )
    {
        d->m_marbleWidget->model()->setClockTimezone( 0 );
    }
    else if( customTimezone() == true )
    {
        d->m_marbleWidget->model()->setClockTimezone( d->m_timezone.value( chosenTimezone() ) );
    }

    // Routing

    // ownCloud
    d->ui_cloudSyncSettings.kcfg_enableSync->setChecked( syncEnabled() );
    d->ui_cloudSyncSettings.kcfg_syncBookmarks->setChecked( syncBookmarks() );
    d->ui_cloudSyncSettings.kcfg_syncRoutes->setChecked( syncRoutes() );
    d->ui_cloudSyncSettings.kcfg_owncloudServer->setText( owncloudServer() );
    d->ui_cloudSyncSettings.kcfg_owncloudUsername->setText( owncloudUsername() );
    d->ui_cloudSyncSettings.kcfg_owncloudPassword->setText( owncloudPassword() );
    
    // Read the settings of the plugins
    d->m_marbleWidget->readPluginSettings( d->m_settings );

    // The settings loaded in the config dialog have been changed.
    emit settingsChanged();
}
Exemplo n.º 5
0
void MainWindow::on_pushButton_clicked()
{

    int *year=new int ;
    int *mon=new int ;
    int *day=new int ;
    int *hour=new int ;
    int *min=new int ;
    int *sec=new int ;
    int *mide=new int ;

    int *lengthMax=new int;
    *lengthMax=560;

    char namePDF[120];
    char dateTime[40],stringText[40];

    QDateTime UTC(QDateTime::currentDateTimeUtc());
    QDateTime local(UTC.toLocalTime());

    QByteArray captureFisrtName=ui->lineEditFirstName->text().toLatin1();
    QByteArray captureLastName=ui->lineEditLastName->text().toLatin1();
    QByteArray capturePhone=ui->lineEditPhone->text().toLatin1();
    QByteArray captureFisrtAddress=ui->lineEditAddress->text().toLatin1();
    QByteArray captureFisrtEmail=ui->lineEditemail->text().toLatin1();

    QLineF line(0, 120, 600, 120);

    QPrinter printer;
    QPainter painter;

    time_t  time=UTC.toTime_t();
    time=time-10800;
    *year=(UTC.toTime_t()/31556926);

    printer.setOutputFormat(QPrinter::PdfFormat);

    *sec=time%60;

    *min=(time/60)%60;
    //qDebug() <<"min"<<min;

    *hour=(time/3600)%24;
    //qDebug() <<"hour"<<hour;

    *day=(time/(3600*24))%31;
    //  qDebug() <<"day"<<day;

    *mon=(((time-(time/31556926)))/2629743%12)+1;

    //  qDebug() <<"month"<<mon;

    sprintf(namePDF,"/Users/leonardoamaya/Documents/QtProjects/QtPdf/Presupuesto%d-%02d-%02d %02d %02d %02d.pdf",(*year+1970),*mon,*day,*hour,*min,*sec);
//     sprintf(namePDF,"/Users/leonardoamaya/QtProjects/QtPdf/Pres.pdf");

    sprintf(dateTime,"%2d / %2d / %4d",*day,*mon,(*year+1970));
    printer.setOutputFileName(namePDF);

    delete year;
    delete mon;
    delete day;
    delete hour;
    delete min;
    delete sec;

    if (! painter.begin(&printer)) { // failed to open file
        qWarning("failed to open file, is it writable?");
        return ;
    }


    painter.setPen(Qt::gray);

    painter.setFont(QFont("Helvetica", 6, QFont::Bold));

    strcpy(stringText,"X");
    *mide=(*lengthMax-(strlen(stringText)))/2;
    painter.drawText(*mide, 10,stringText);

    strcpy(stringText,"Documento");
    *mide=(*lengthMax-(strlen(stringText)))/2;
    painter.drawText(*mide, 20,stringText);

    strcpy(stringText,"no Valido");
    *mide=(*lengthMax-(strlen(stringText)))/2;
    painter.drawText(*mide, 30,stringText);

    strcpy(stringText,"como factura");
    *mide=(*lengthMax-(strlen(stringText)))/2;
    painter.drawText(*mide, 40,stringText);


//Titles

    painter.setFont(QFont("Helvetica", 11, QFont::Bold));
    painter.drawText( 450, 70,dateTime);

    *mide=(*lengthMax-(strlen("Presupuesto"))*8)/2;
    painter.drawText(*mide, 200, "Presupuesto");

    *mide=(*lengthMax-(strlen("Lio Design")*8))/2;
    painter.drawText(*mide, 240, "Lio Design");

    delete mide;


//Data Clients

    painter.setFont(QFont("Helvetica", 11, QFont::Normal));

    painter.drawText(20, 80, "Nombre:");
    painter.drawText(20, 100, "Apellido:");
    painter.drawText(20, 120, "Telefono:");
    painter.drawText(20, 140, "Direccion:");
    painter.drawText(20, 160, "e-mail:");

    painter.setFont(QFont("Helvetica", 11, QFont::Bold));
    painter.drawText(100, 80,captureFisrtName );
    painter.drawText(100, 100, captureLastName);
    painter.drawText(100, 120, capturePhone);
    painter.drawText(100, 140, captureFisrtAddress);
    painter.drawText(100, 160, captureFisrtEmail);

//Lines

    line.setLine(0,45,*lengthMax,45);
    painter.drawLine(line);

    line.setLine(0,250,*lengthMax,250);
    painter.drawLine(line);

    line.setLine(0,750,*lengthMax,750);
    painter.drawLine(line);

    //Config Puff

    painter.setPen(Qt::black);
    painter.setFont(QFont("Helvetica", 11, QFont::Normal));



    if(ui->checkBoxPuff1->isChecked()) {
        painter.drawText(100, 400, "*   Puff 1   x unidad $ ");
    }

    if(ui->checkBoxPuff2->isChecked()) {
        painter.drawText(100, 450, "*   Puff 2   x unidad $ ");
    }

    if(ui->checkBoxPuff3->isChecked()) {
        painter.drawText(100, 500, "*   Puff 3   x unidad $ ");
    }

    if(ui->checkBoxSofa1->isChecked()) {
        painter.drawText(100, 650, "*   Sofa 1  x unidad $ ");
    }

    delete lengthMax;
    painter.end();
}
Exemplo n.º 6
0
bool CGPSgeneric::updateInfo(CGPSport &select,bool invalidate,int maxwait)
{
    int ii;
    int sleeptime=50; // ms
    int loopcount;
    bool res=true;

    double err;
    int fix;
    double lat,lon,alt;
    double spd,hdg;
    float ve,vn,vu;
    CString name;
    CTime utctime;

    // Easy waiting ... loop ...
    if (maxwait>0) {
        loopcount=maxwait*1000/sleeptime;
    }
    else {
        loopcount=2;
    }


    switch (select.getType()) {
#if USE_RPNMEA == 1
    case CGPSPortTypesSerialNMEA:
        // should we be invalidating GPS info first?
        if (invalidate) {
            select.invalidateInfo();
            select.invalidateDeviceInfo();
        }

        for (ii=0; ii<loopcount; ii++) {
            res=garNMEA.updateInfo((ii==0)?(invalidate):(false));
            if (res&&
                    garNMEA.getName(NULL) &&
                    garNMEA.getLoc(NULL,NULL,NULL) &&
                    garNMEA.getTimeData(NULL,NULL))
            {
                // we are done ...
                break;
            }
        }
        if (res) {
            CGPSData garData=garNMEA.getGPSInfo();
            if (garData.getLoc(&lat,&lon,&alt))
                select.setInfo(&lat,&lon,&alt,NULL,NULL,NULL,NULL,NULL);
            if (garData.getMov(&spd,&hdg))
                select.setInfo(NULL,NULL,NULL,&spd,&hdg,NULL,NULL,NULL);
            if (garData.getName(&name)) {
                // @@@ probably totally wrong
                const char *tname=name.GetString();
                select.setInfo(NULL,NULL,NULL,NULL,NULL,NULL,tname,NULL);
            }
            if (garData.getTimeDate(&utctime))
                select.setInfo(NULL,NULL,NULL,NULL,NULL,&utctime,NULL,NULL);
        }
        break;
#endif
#if USE_GARXFACE == 1
    case CGPSPortTypesSerialGarXface:
    case CGPSPortTypesUSBGarXface:
        // should we be invalidating GPS info first?
        if (invalidate) {
            select.invalidateInfo();
            // @@@ should we keep this and set the device info below?
            // select.invalidateDeviceInfo();
        }


        if (! garGPS.IsOpen())
            return false;

        // Set GPS to return PVT data ...
        try
        {
            garGPS.PvtDataOn();
        }
        catch(GarXface4::Exceptions::GxException &e)
        {
            // e.ReportError();
            return false;
        }

        // GPS should now be delivering PVT data ...
        // ... read data until we are happy or tired ...
        GarXface4::PVTdata *p;
        for (int ii=0; ii<loopcount; ii++) {

            try
            {
                p = garGPS.GetPVTdata();
            }
            catch(GarXface4::Exceptions::GxException &e)
            {
                // e.ReportError();
                // @@@ do we want to return or first stop PVT?
                //return false;
                res=false;
                break;
            }

            // Stop looping if we have what we wanted ...
            if (p->GetGpsConnect() && p->GetValidData())
                break;

            // Data is no good yet ... sleep a bit
            Sleep(sleeptime);
        }

        // Make sure we exited the loop with good data ...
        if (p->GetGpsConnect() && p->GetValidData()) {

            ve = p->GetVelocityEast(); // m/s
            vn = p->GetVelocityNorth();
            vu = p->GetVelocityUp();

            alt = (double)p->GetAltitude(); // m
            err = (double)p->GetEstimatedPositionError(); // m
            fix = (int)p->GetFixType(); // we might want to check this for minimum quality ...
            lat = GarXface4::Math::WGS84::radiansToDegrees(p->GetLatitude());
            lon = GarXface4::Math::WGS84::radiansToDegrees(p->GetLongitude());
            spd = GarXface4::Math::Velocity::calculateSpeed(ve,vn,vu); // undocumented units
            hdg = GarXface4::Math::Velocity::calculateHeadingDeg(ve,vn); // undocumented units

            long timeRaw = GarXface4::Math::UTC::GarminTimeToLongTime(
                               p->GetWnDays(),
                               p->GetTimeOfWeek(),
                               p->GetLeapSeconds(),
                               true);
            CTime UTC(timeRaw);

            select.setInfo(&lat,&lon,&alt,&spd,&hdg,&UTC,NULL,NULL);
        }
        else {
            res=false;
        }

        // No more PVT data for now ... thank you
        try
        {
            garGPS.PvtDataOff();
            // garGPS.Close();
        }
        catch(GarXface4::Exceptions::GxException &e)
        {
            return false;
        }
        return res;
        break;
#endif
    default:
        return false;

    }

    return true;
}
Exemplo n.º 7
0
char* UTC(){
  return UTC("T");
}