void NewProjectDialog::crearArchivoProyecto() { if(!checkDates()) { QMessageBox::warning(this,tr("ToolsPCot - New projecto"),tr("write de name of project")); return; } QString dirProyecto=ui->lineEditFolderProject->text(); //Casos de la direccion en windows o linux barras inclinadas QFileInfo archivo; archivo.setFile(QDir(dirProyecto),ui->lineEditProjectFile->text()); _aProyecto=new ArchivoProyecto(0,archivo.filePath()); _aProyecto->setnameProyect(ui->lineEditProject->text()); _aProyecto->setdescriptionProyecte(ui->textEditDescription->toPlainText()); _aProyecto->setautorProyect(ui->lineEditAutor->text()); _aProyecto->setdateflight(ui->dateEditDateFlight->date()); }
// Initialize the dialog widgets and connect the signals/slots void MeteorShowerDialog::createDialogContent() { ui->setupUi(dialog); ui->tabs->setCurrentIndex(0); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); plugin = GETSTELMODULE(MeteorShowers); // Settings tab / updates group connect(ui->internetUpdates, SIGNAL(clicked(bool)), this, SLOT(setUpdatesEnabled(bool))); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateJSON())); connect(plugin, SIGNAL(updateStateChanged(MeteorShowers::UpdateState)), this, SLOT(updateStateReceiver(MeteorShowers::UpdateState))); connect(plugin, SIGNAL(jsonUpdateComplete(void)), this, SLOT(updateCompleteReceiver(void))); connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int))); refreshUpdateValues(); // fetch values for last updated and so on updateTimer = new QTimer(this); connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())); updateTimer->start(7000); // Settings tab / event group connect(ui->searchButton, SIGNAL(clicked()), this, SLOT(checkDates())); refreshRangeDates(); treeWidget = ui->listEvents; initListEvents(); connect(treeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectEvent(QModelIndex))); // Settings tab / radiant group ui->displayRadiant->setChecked(plugin->getFlagRadiant()); connect(ui->displayRadiant, SIGNAL(clicked(bool)), plugin, SLOT(setFlagRadiant(bool))); ui->activeRadiantsOnly->setChecked(plugin->getFlagActiveRadiant()); connect(ui->activeRadiantsOnly, SIGNAL(clicked(bool)), plugin, SLOT(setFlagActiveRadiant(bool))); ui->radiantLabels->setChecked(plugin->getFlagLabels()); connect(ui->radiantLabels, SIGNAL(clicked(bool)), plugin, SLOT(setFlagLabels(bool))); ui->fontSizeSpinBox->setValue(plugin->getLabelFontSize()); connect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)), plugin, SLOT(setLabelFontSize(int))); // Settings tab / meteor showers group ui->displayMeteorShower->setChecked(plugin->getEnableAtStartup()); connect(ui->displayMeteorShower, SIGNAL(clicked(bool)), plugin, SLOT(setEnableAtStartup(bool))); ui->displayShowMeteorShowerButton->setChecked(plugin->getFlagShowMSButton()); connect(ui->displayShowMeteorShowerButton, SIGNAL(clicked(bool)), plugin, SLOT(setFlagShowMSButton(bool))); // ///////////////////////////////////////// connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(restoreDefaults())); connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSettings())); // Markers tab refreshColorMarkers(); connect(ui->changeColorARG, SIGNAL(clicked()), this, SLOT(setColorARG())); connect(ui->changeColorARR, SIGNAL(clicked()), this, SLOT(setColorARR())); connect(ui->changeColorIR, SIGNAL(clicked()), this, SLOT(setColorIR())); // About tab setAboutHtml(); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui()); if (gui != NULL) { ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); } updateGuiFromSettings(); }
void MainWindow::fillSensorStateTable() { if (!checkDates()) return; QString seqQuery; // get the latest row from the existing sensorStateHistory into a temporary table seqQuery = "DROP TEMPORARY TABLE IF EXISTS tempState"; // qDebug() << seqQuery; query.clear(); if (!query.exec(seqQuery)) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Cannot drop temporary table tempState!"); msgBox.exec(); return; } seqQuery = "select max(lastUpdate) from SensorStateHistory"; // qDebug() << seqQuery; query.clear(); if (!query.exec(seqQuery)) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Cannot select from sensorStateHistory!"); msgBox.exec(); return; } // insert the lateset row from sensorStateHistory to temp table QDateTime lastDate; while (query.next()) { lastDate = query.value(0).toDateTime(); } qDebug()<<"Latest date on sensorStateHistory is: " << lastDate.toString("yyyy-MM-dd hh:mm:ss"); seqQuery = "CREATE TEMPORARY TABLE tempState ( select * from SensorStateHistory where lastUpdate = '"; seqQuery += lastDate.toString("yyyy-MM-dd hh:mm:ss") + "')"; // qDebug() << seqQuery; query.clear(); if (!query.exec(seqQuery)) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Cannot create temporary table tempState!"); msgBox.exec(); qDebug()<<query.lastError(); qDebug()<<query.executedQuery(); return; } // get the current values from behaviourLog if (lv == "BATCH" || "BATCHNORM") { seqQuery = "select timestamp,sensorId,status,trainingNumber from " + behTable + " where sensorID < 61 ORDER BY trainingNumber, timestamp"; } else { seqQuery = "select timestamp,sensorId,status,trainingNumber from " + behTable + " where sensorID < 61 and timestamp between '"; seqQuery += ui->dateFrom->dateTime().toString("yyyy-MM-dd hh:mm:ss"); seqQuery += "' and '"; seqQuery += ui->dateTo->dateTime().toString("yyyy-MM-dd hh:mm:ss") + "' ORDER BY timestamp"; } qDebug() << seqQuery; query.clear(); if (!query.exec(seqQuery)) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Cannot select from SensorLog table!"); msgBox.exec(); return; } int numRowsRead = query.numRowsAffected(); int numRowsProcessed = 0; int numRowsInserted = 0; while (query.next()) { if (numRowsProcessed%50 == 0) { qDebug()<<"Processed " << numRowsProcessed << " rows..."; } qDebug()<<query.value(0).toDateTime().toString("yyyy-MM-dd hh:mm:ss"); qDebug()<< query.value(1).toString(); qDebug()<< query.value(2).toString(); qDebug()<< query.value(3).toString(); qDebug()<< lastDate.toString("yyyy-MM-dd hh:mm:ss"); // update the temp table and insert to db if (query.value(0).toDateTime() == lastDate) // dates the same, update row with sensor values { qDebug()<<"Same - updating temp table"; if (!updateTempTable()) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Problem updating temp table!"); msgBox.exec(); return; } numRowsProcessed++; } if (query.value(0).toDateTime() > lastDate) // new event, insert a new stateHistory row { qDebug() << "Greater"; if (numRowsProcessed > 0) // insert the current row on temp to stateHistory { // qDebug()<< "insert current temp to stateHistory"; seqQuery = "insert INTO SensorStateHistory select * from tempState"; // qDebug() << seqQuery; QSqlQuery insertQuery; insertQuery.clear(); if (!insertQuery.exec(seqQuery)) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Cannot insert into sensorStateHistory!"); msgBox.exec(); msgBox.setText(insertQuery.lastError().text()); msgBox.exec(); qDebug()<<insertQuery.lastError(); qDebug()<<insertQuery.executedQuery(); return; } numRowsInserted++; } // now update it if (!updateTempTable()) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Problem updating temp table!"); msgBox.exec(); return; } numRowsProcessed++; // QDateTime latestDate = query.value(0).toDateTime(); // int days = lastDate.daysTo ( latestDate ) ; // QTime when = QTime ( 0, 0, 0, 0 ) ; // when = when.addSecs ( lastDate.addDays(days).secsTo( latestDate ) ) ; // qDebug() << latestDate.toString( "M/d/yyyy h:mm:ss AP" ) // << " - " // << lastDate.toString( "M/d/yyyy h:mm:ss AP" ) // << " = " // << days << when.toString( ".HH:mm:ss" ) ; lastDate = query.value(0).toDateTime(); } } // final row if (numRowsProcessed > 0) // insert the current row on temp to stateHistory { // qDebug()<< "insert final temp to stateHistory"; // seqQuery = "insert INTO SensorStateHistory select * from tempState"; // qDebug() << seqQuery; QSqlQuery insertQuery; insertQuery.clear(); if (!insertQuery.exec(seqQuery)) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); msgBox.setText("Cannot insert into sensorStateHistory!"); msgBox.exec(); msgBox.setText(insertQuery.lastError().text()); msgBox.exec(); qDebug()<<insertQuery.lastError(); qDebug()<<insertQuery.executedQuery(); return; } numRowsInserted++; } qDebug()<<"Rows Read: " << numRowsRead << "Rows Procesed: " << numRowsProcessed << "Rows inserted: " << numRowsInserted; }