diff -r 0f15edebc665 -r 61c114afb0ee src/MoniSpindels.cpp --- a/src/MoniSpindels.cpp Thu Oct 12 17:03:50 2023 +0200 +++ b/src/MoniSpindels.cpp Fri Oct 13 14:47:21 2023 +0200 @@ -16,6 +16,7 @@ */ #include "MoniSpindels.h" #include "DetailiSpindel.h" +#include "CalibrateiSpindel.h" #include "MainWindow.h" #include "Utils.h" #include "config.h" @@ -75,16 +76,17 @@ QTableWidgetItem *item; QSqlQuery query("SELECT record,alias,node,online,mode,temperature,gravity,beercode,beername FROM mon_ispindels ORDER BY alias"); - const QStringList labels({tr("Unit"), tr("Node"), tr("Status"), tr("Beer"), tr("Temperature"), tr("SG"), tr("Details")}); + const QStringList labels({tr("Unit"), tr("Node"), tr("Status"), tr("Beer"), tr("Temperature"), tr("SG"), tr("Cal"), tr("Details")}); - this->tableiSpindels->setColumnCount(7); + this->tableiSpindels->setColumnCount(8); this->tableiSpindels->setColumnWidth(0, 150); /* Alias */ this->tableiSpindels->setColumnWidth(1, 120); /* Node */ this->tableiSpindels->setColumnWidth(2, 100); /* Status */ - this->tableiSpindels->setColumnWidth(3, 390); /* Beer */ + this->tableiSpindels->setColumnWidth(3, 330); /* Beer */ this->tableiSpindels->setColumnWidth(4, 90); /* Temperature */ this->tableiSpindels->setColumnWidth(5, 90); /* Gravity */ - this->tableiSpindels->setColumnWidth(6, 90); /* Edit button */ + this->tableiSpindels->setColumnWidth(6, 60); /* Calibrate */ + this->tableiSpindels->setColumnWidth(7, 90); /* Edit button */ this->tableiSpindels->setRowCount(query.size()); this->tableiSpindels->setHorizontalHeaderLabels(labels); this->tableiSpindels->verticalHeader()->hide(); @@ -124,7 +126,19 @@ this->tableiSpindels->setItem(i, 5, new QTableWidgetItem(QString(""))); } - /* Add the Edit button */ + /* Add the Calibrate button */ + QWidget* cWidget = new QWidget(); + QPushButton* btn_cal = new QPushButton(); + btn_cal->setObjectName(QString("%1").arg(query.value("record").toString())); /* Send record with the button */ + btn_cal->setText(tr("Cal")); + connect(btn_cal, SIGNAL(clicked()), this, SLOT(on_calButton_clicked())); + QHBoxLayout* cLayout = new QHBoxLayout(cWidget); + cLayout->addWidget(btn_cal); + cLayout->setContentsMargins(5, 0, 5, 0); + cWidget->setLayout(cLayout); + this->tableiSpindels->setCellWidget(i, 6, cWidget); + + /* Add the Details button */ QWidget* pWidget = new QWidget(); QPushButton* btn_edit = new QPushButton(); btn_edit->setObjectName(QString("%1").arg(query.value("record").toString())); /* Send record with the button */ @@ -134,7 +148,7 @@ pLayout->addWidget(btn_edit); pLayout->setContentsMargins(5, 0, 5, 0); pWidget->setLayout(pLayout); - this->tableiSpindels->setCellWidget(i, 6, pWidget); + this->tableiSpindels->setCellWidget(i, 7, pWidget); query.next(); } emit setStatus(QString(tr("Total items: %1")).arg(query.size())); @@ -167,3 +181,18 @@ } +void MoniSpindels::cal(int recno) +{ + CalibrateiSpindel dialog(recno, this); + dialog.setModal(true); + dialog.exec(); +} + + +void MoniSpindels::on_calButton_clicked() +{ + QPushButton *pb = qobject_cast(QObject::sender()); + int recno = pb->objectName().toInt(); + cal(recno); +} +