bug fix, remove trailling space for influx inputs

This commit is contained in:
Ryan Tang 2024-08-26 15:25:19 -04:00
parent dbfb9f96bf
commit a32a1e0e71
2 changed files with 19 additions and 5 deletions

View File

@ -102,6 +102,7 @@ void Analyzer::SetDatabase(QString IP, QString Name, QString Token){
bool foundDatabase = false; bool foundDatabase = false;
for( int i = 0; i < (int) databaseList.size(); i++){ for( int i = 0; i < (int) databaseList.size(); i++){
if( databaseList[i] == dataBaseName.toStdString() ) foundDatabase = true; if( databaseList[i] == dataBaseName.toStdString() ) foundDatabase = true;
// printf("%d | %s\n", i, databaseList[i].c_str());
} }
if( foundDatabase ){ if( foundDatabase ){
influx->AddDataPoint("test value=1"); influx->AddDataPoint("test value=1");
@ -216,7 +217,7 @@ void Analyzer::SetDatabaseButton(){
// Show the dialog and get the result // Show the dialog and get the result
if (dialog.exec() == QDialog::Accepted) { if (dialog.exec() == QDialog::Accepted) {
SetDatabase(ipLineEdit.text(), nameLineEdit.text(),tokenLineEdit.text()); SetDatabase(ipLineEdit.text().trimmed(), nameLineEdit.text().trimmed(),tokenLineEdit.text().trimmed());
} }
} }

View File

@ -44,6 +44,9 @@ private:
bool allowSignalSlot; bool allowSignalSlot;
QLineEdit * leInfluxIP;
QLineEdit * leDBName;
// declaie histograms // declaie histograms
Histogram2D * h2D; Histogram2D * h2D;
Histogram1D * h1; Histogram1D * h1;
@ -307,22 +310,28 @@ inline void CoincidentAnalyzer::SetUpCanvas(){
QLabel * lbIP = new QLabel("Database IP :", box); QLabel * lbIP = new QLabel("Database IP :", box);
lbIP->setAlignment(Qt::AlignRight | Qt::AlignCenter); lbIP->setAlignment(Qt::AlignRight | Qt::AlignCenter);
boxLayout->addWidget(lbIP, rowID, 0); boxLayout->addWidget(lbIP, rowID, 0);
QLineEdit * leInfluxIP = new QLineEdit(box); leInfluxIP = new QLineEdit(box);
leInfluxIP->setReadOnly(true); leInfluxIP->setReadOnly(true);
boxLayout->addWidget(leInfluxIP, rowID, 1, 1, 3); boxLayout->addWidget(leInfluxIP, rowID, 1, 1, 3);
QPushButton * bnInflux = new QPushButton("Set Influx", box); QPushButton * bnInflux = new QPushButton("Set Influx", box);
boxLayout->addWidget(bnInflux, rowID, 1, 1, 3); boxLayout->addWidget(bnInflux, rowID, 4);
rowID ++; rowID ++;
QLabel * lbDBName = new QLabel("Database name :", box); QLabel * lbDBName = new QLabel("Database name :", box);
lbDBName->setAlignment(Qt::AlignRight | Qt::AlignCenter); lbDBName->setAlignment(Qt::AlignRight | Qt::AlignCenter);
boxLayout->addWidget(lbDBName, rowID, 0); boxLayout->addWidget(lbDBName, rowID, 0);
QLineEdit * leDBName= new QLineEdit(box); leDBName = new QLineEdit(box);
leDBName->setReadOnly(true); leDBName->setReadOnly(true);
boxLayout->addWidget(leDBName, rowID, 1); boxLayout->addWidget(leDBName, rowID, 1);
connect(bnInflux, &QPushButton::clicked, this, &Analyzer::SetDatabaseButton); connect(bnInflux, &QPushButton::clicked, this, [=](){
SetDatabaseButton();
if( influx ) {
leDBName->setText(dataBaseName);
leInfluxIP->setText(dataBaseIP);
}
});
// rowID ++; // rowID ++;
// QFrame *separator3 = new QFrame(box); // QFrame *separator3 = new QFrame(box);
@ -638,6 +647,10 @@ inline void CoincidentAnalyzer::LoadSettings(){
h2D->Rebin(x_bin, x_min, x_max, y_bin, y_min, y_max); h2D->Rebin(x_bin, x_min, x_max, y_bin, y_min, y_max);
SetDatabase(dataBaseIP, dataBaseName, dataBaseToken); SetDatabase(dataBaseIP, dataBaseName, dataBaseToken);
if( influx ){
leDBName->setText(dataBaseName);
leInfluxIP->setText(dataBaseIP);
}
} }