void MainWindow::onViewLog() { Connection *con = configHelper->connectionAt(ui->connectionView->currentIndex().row()); LogDialog *logDlg = new LogDialog(con, this); connect(logDlg, &LogDialog::finished, logDlg, &LogDialog::deleteLater); logDlg->exec(); }
static int ShowLogDialog(const QString& fileName) { KConfig* config = new KConfig("cervisiapartrc"); LogDialog* dlg = new LogDialog(*config); // get directory for file const QFileInfo fi(fileName); QString directory = fi.absolutePath(); // start the cvs DCOP service OrgKdeCervisiaCvsserviceCvsserviceInterface* cvsService = StartDBusService(directory); if( dlg->parseCvsLog(cvsService, fi.fileName()) ) dlg->show(); else delete dlg; int result = qApp->exec(); // stop the cvs D-Bus service cvsService->quit(); delete cvsService; delete config; return result; }
void MainWindow::onViewLog() { Connection *con = model->getItem(proxyModel->mapToSource(ui->connectionView->currentIndex()).row())->getConnection(); LogDialog *logDlg = new LogDialog(con, this); connect(logDlg, &LogDialog::finished, logDlg, &LogDialog::deleteLater); logDlg->exec(); }
static int ShowLogDialog(const QString& fileName) { KConfig* config = new KConfig("cervisiapartrc"); LogDialog* dlg = new LogDialog(*config); kapp->setMainWidget(dlg); // get directory for file const QFileInfo fi(fileName); QString directory = fi.dirPath(true); // start the cvs DCOP service CvsService_stub* cvsService = StartDCOPService(directory); if( dlg->parseCvsLog(cvsService, fi.fileName()) ) dlg->show(); else delete dlg; int result = kapp->exec(); // stop the cvs DCOP service cvsService->quit(); delete cvsService; delete config; return result; }
void MainWindow::on_actionLog_triggered() { LogDialog *l = new LogDialog(this); QObject::connect(l, SIGNAL(setLogVariable(bool, bool, QString)), this, SLOT(changeLogVariables(bool, bool, QString))); l->setLoggingState(logging_enabled, log_visible_only, log_filename); l->show(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); LogDialog l; //l.show(); if (l.exec() == QDialog::Accepted) { int res = QMessageBox::question(nullptr, "Method", "Wired?", QMessageBox::Yes, QMessageBox::No); bool wired = (res == QMessageBox::Yes); MainWindow w(wired); w.show(); return a.exec(); } return 0; }
//*********************************************************************************** // Import a list of antennas void cAntennaFilesImporter::ImportAntennas () { if(fileNames.size()>0) { QString logMessage("Import log:\n\n"); progress->setVisible(true); progress->reset(); progress->setMinimum(0); progress->setMaximum(fileNames.count()-1); // Extract the technology primary key from the technology combo box QStringList parts = technologyCombo->currentText().split(":"); string techKey; if(parts.size()>0) { if(parts[1]=="NULL") techKey = "NULL"; else techKey = parts[0].toStdString(); } else techKey = "NULL"; // Import the files for( int i=0 ; i<fileNames.count() ; i++) { progress->setValue(i); // Open the first file QFile file(fileNames[i]); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { logMessage += fileNames[i] + "......Error opening file\n"; } else { // Open a text stream QTextStream inFile(&file); bool verticalAngles = false; bool horizontalAngles = false; // Get the defaults for the table StringMap antennaDevice, antenna, antennaPattern; string aziAngles, aziValues; string elevAngles, elevValues; int numAziPoints = 0; int numElevPoints = 0; string deviceName; // Add the file name to the antenna pattern table QString fileName = fileNames[i]; fileName.remove(0,fileName.lastIndexOf("/")+1); antennaPattern["patternfile"] = "'" + fileName.toStdString() + "'"; antennaPattern["techkey"] = techKey; // Parse the file while(!inFile.atEnd()) { QString line = inFile.readLine(); // Parse the single string if(line=="NAME") { logMessage += fileNames[i] + "......Error, file in wrong format\n"; break; } // if QStringList list = line.split(" ", QString::SkipEmptyParts); if( (list.count()!=0)&&(list.count()>=2) ) { if(list[0]=="HORIZONTAL") { horizontalAngles = true; verticalAngles = false; aziAngles = "'{"; aziValues = "'{"; } // if HORIZONTAL else { if(list[0]=="VERTICAL") { verticalAngles = true; horizontalAngles = false; elevAngles = "'{"; elevValues = "'{"; } // if VERTICAL else { if(list[0].contains(QRegExp("[A-Z]")) && (verticalAngles||horizontalAngles)) { verticalAngles = false; verticalAngles = false; // Complete the azimuth and elevation angles and values arrays aziAngles = aziAngles.substr(0,aziAngles.length()-1); aziAngles += "}'"; aziValues = aziValues.substr(0,aziValues.length()-1); aziValues += "}'"; elevAngles = elevAngles.substr(0,elevAngles.length()-1); elevAngles += "}'"; elevValues = elevValues.substr(0,elevValues.length()-1); elevValues += "}'"; antennaPattern["azimuthangles"] = aziAngles; antennaPattern["azimuthpattern"] = aziValues; antennaPattern["elevationangles"] = elevAngles; antennaPattern["elevationpattern"] = elevValues; antennaPattern["numazipoints"] = QString::number(numAziPoints).toStdString(); antennaPattern["numelevpoints"] = QString::number(numElevPoints).toStdString(); } // if } // else VERTICAL } // else HORIZONTAL if(!verticalAngles && !horizontalAngles) { if(list[0]=="NAME") { cout << "NAME " << list[1].toStdString() << endl; //line.replace(list[0],""); antennaDevice["devicename"] = "'"+list[1].toStdString() + "'"; deviceName = list[1].toStdString(); } // if NAME else { if(list[0]=="MAKE") { cout << "MAKE " << list[1].toStdString() << endl; line.replace(list[0],""); antennaDevice["manufacturer"] = "'"+line.toStdString()+"'"; } // if MAKE else { if(list[0]=="H_WIDTH") { cout << "H_WIDTH " << list[1].toStdString() << endl; antennaPattern["azibeamwidth"] = list[1].toStdString(); } // if H_WIDTH else { if(list[0]=="GAIN") { cout << "GAIN " << list[1].toStdString() << endl; antennaPattern["gain"] = list[1].toStdString(); } // if GAIN else { if(list[0]=="TILT") { cout << "TILT " << list[1].toStdString() << endl; if(list[1] == "ELECTRICAL") { antennaDevice["electilt"] = "TRUE"; } // if ELECTRICAL else { antennaDevice["electilt"] = "FALSE"; } // else ELECTRICAL } // if TILT else { if(list[0]=="COMMENTS"||list[0]=="COMMENT") { cout << "COMMENTS " << line.toStdString() << endl; line.replace(list[0],""); antennaDevice["description"] = "'" + line.toStdString() + "'"; antennaPattern["description"] = "'" + line.toStdString() + "'"; } // if COMMENTS else { if(list[0]=="FREQUENCY") { cout << "FREQUENY " << list[1].toStdString() << endl; antennaPattern["frequency"] = list[1].toStdString(); } // if FREQUENCY else { if(list[0]=="FRONT_TO_BACK") { cout << "FRONT_TO_BACK " << list[1].toStdString() << endl; antennaPattern["fronttoback"] = list[1].toStdString(); } // if FRONT_TO_BACK else { if(list[0]=="POLARIZATION") { cout << "POLARIZATION " << list[1].toStdString() << endl; antennaPattern["polarization"] = "'"+list[1].toStdString()+"'"; } // if POLARIZATION } // else FRONT_TO_BACK } // else FREQUENCY } // else COMMENTS } // else TILT } // else GAIN } // else H_WIDTH } // else MAKE } // else NAME } else { if(horizontalAngles && list[0]!="HORIZONTAL") { aziAngles += list[0].toStdString() + ","; aziValues += list[1].toStdString() + ","; numAziPoints++; } else { if(verticalAngles && list[0]!="VERTICAL" ) { elevAngles += list[0].toStdString() + ","; elevValues += list[1].toStdString() + ","; numElevPoints++; } // if } // else } // else } // if } // while if(verticalAngles||horizontalAngles) { // Complete the azimuth and elevation angles and values arrays aziAngles = aziAngles.substr(0,aziAngles.length()-1); aziAngles += "}'"; aziValues = aziValues.substr(0,aziValues.length()-1); aziValues += "}'"; elevAngles = elevAngles.substr(0,elevAngles.length()-1); elevAngles += "}'"; elevValues = elevValues.substr(0,elevValues.length()-1); elevValues += "}'"; antennaPattern["azimuthangles"] = aziAngles; antennaPattern["azimuthpattern"] = aziValues; antennaPattern["elevationangles"] = elevAngles; antennaPattern["elevationpattern"] = elevValues; antennaPattern["numazipoints"] = QString::number(numAziPoints).toStdString(); antennaPattern["numelevpoints"] = QString::number(numElevPoints).toStdString(); } // if // Check if the antenna device already exists in the antenna device table string whereClause; whereClause = "devicename = '" + deviceName + "'"; // Perform the select query if(!gDb.Select("devicename,id","antennadevice",whereClause) ) { // A QRAP_ERROR,QRAP_INFO,QRAP_WARN or QRAP_FATAL is called by the cDatabase class and handled by Qrap::cMainWindow::Alert() logMessage += fileNames[i] + "......Error, Select devicename,id from antennadevice where devicename = '" + QString::fromStdString(deviceName) + "';\n"; } // if else { // Get the result for the select query pqxx::result r; gDb.GetLastResult(r); long long id; bool insertAntennaDevice; // Check if the antenna device already exists/ if( (int)r.size()!=0) { cout << endl << "Got " << (int)r.size() << " results" << endl; cout << "Result " << string(r[0]["devicename"].c_str()) << endl << endl; /* if(string(r[0]["devicename"].c_str()) != deviceName) { insertAntennaDevice = true; } // if antenna device exists else */ { antennaPattern["antdevicekey"] = string(r[0]["id"].c_str()); antennaPattern["techkey"] = techKey; insertAntennaDevice = false; } // if antenna device existss } else { insertAntennaDevice = true; } if(insertAntennaDevice) { // Insert the imported data into the database if( (id=gDb.Insert(antennaDevice,"antennadevice"))==-1 ) { // A QRAP_ERROR,QRAP_INFO,QRAP_WARN or QRAP_FATAL is called by the cDatabase class and handled by Qrap::cMainWindow::Alert() logMessage += fileNames[i] + "......Error, Insert into antennadevice;\n"; } // if insert antennadevice else { antennaPattern["antdevicekey"] = QString::number(id).toStdString(); antennaPattern["techkey"] = techKey; } // if insert antennadevice } // if insertAntennaDevice // Insert the antenna pattern associated with the antenna device if(gDb.Insert(antennaPattern, "antennapattern")==-1) { // A QRAP_ERROR,QRAP_INFO,QRAP_WARN or QRAP_FATAL is called by the cDatabase class and handled by Qrap::cMainWindow::Alert() logMessage += fileNames[i] + "......Error, Insert into antennapattern;\n"; } // if insert antennapattern else { logMessage += fileNames[i] + "......Imported successfully\n"; } // else insert antennapattern } // else select } // else File open } // for LogDialog* log = new LogDialog(0,logMessage); log->show(); progress->setVisible(false); accept(); } // if fileNames.size() }