-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomsdialog.cpp
More file actions
68 lines (56 loc) · 2.41 KB
/
comsdialog.cpp
File metadata and controls
68 lines (56 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "comsdialog.h"
#include <QSerialPortInfo>
#include <QLabel>
#include <QVBoxLayout>
COMsDialog::COMsDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
combo_com_pump->addItem("None");
combo_com_cond->addItem("None");
//combo_com_pump->addItem("TEST");
//combo_com_cond->addItem("TEST");
for (const QSerialPortInfo &info : QSerialPortInfo::availablePorts()) {
QString port = info.portName();
combo_com_pump->addItem(port);
combo_com_cond->addItem(port);
}
// Add meter type selector
QComboBox *combo_meter_type = new QComboBox(this);
combo_meter_type->setObjectName("combo_meter_type");
combo_meter_type->addItem("eDAQ EPU357 (Preferred)", static_cast<int>(ConductivityMeterType::eDAQ_EPU357));
combo_meter_type->addItem("Thermo Orion EC112 (Legacy)", static_cast<int>(ConductivityMeterType::ThermoOrion_EC112));
combo_meter_type->setCurrentIndex(0); // Default to EPU357
QLabel *label_meter = new QLabel("Conductivity Meter Type:", this);
// Add to the form layout (assuming there's a formLayout in the UI)
// If not, we'll add it to the main layout
if (formLayout) {
formLayout->addRow(label_meter, combo_meter_type);
}
connect(combo_com_cond, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &COMsDialog::updatePump);
connect(combo_com_pump, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &COMsDialog::updateCond);
}
void COMsDialog::updateCond()
{
if (combo_com_pump->currentIndex() == combo_com_cond->currentIndex() && combo_com_pump->currentIndex() > 0) {
combo_com_cond->setCurrentIndex(combo_com_cond->currentIndex() - 1);
}
}
void COMsDialog::updatePump()
{
if (combo_com_pump->currentIndex() == combo_com_cond->currentIndex() && combo_com_pump->currentIndex() > 0) {
combo_com_pump->setCurrentIndex(combo_com_pump->currentIndex() - 1);
}
}
void COMsDialog::accept()
{
// Get the meter type from the combo box
QComboBox *combo_meter_type = findChild<QComboBox*>("combo_meter_type");
ConductivityMeterType meterType = ConductivityMeterType::eDAQ_EPU357; // Default
if (combo_meter_type) {
int meterTypeInt = combo_meter_type->currentData().toInt();
meterType = static_cast<ConductivityMeterType>(meterTypeInt);
}
emit coms(combo_com_cond->currentText(), combo_com_pump->currentText(), meterType);
QDialog::accept();
}