Sun, 19 Jun 2022 10:40:37 +0200
Added co2pressure (carbonation) log graph.
src/EditProduct.cpp | file | annotate | diff | comparison | revisions | |
src/EditProduct.h | file | annotate | diff | comparison | revisions | |
src/EditProductTab1.cpp | file | annotate | diff | comparison | revisions | |
src/EditProductTab11.cpp | file | annotate | diff | comparison | revisions | |
ui/EditProduct.ui | file | annotate | diff | comparison | revisions |
--- a/src/EditProduct.cpp Sat Jun 18 20:39:59 2022 +0200 +++ b/src/EditProduct.cpp Sun Jun 19 10:40:37 2022 +0200 @@ -708,6 +708,7 @@ connect(ui->keg_sug_waterEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::kegs_water_changed); connect(ui->keg_tempEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::kegs_temp_changed); connect(ui->keg_forcedEdit, &QCheckBox::stateChanged, this, &EditProduct::kegs_forced_changed); + connect(ui->carb_logButton, SIGNAL(clicked()), this, SLOT(carb_log_button())); /* All signals from tab Tasting */ connect(ui->taste_dateEdit, &QDateEdit::dateChanged, this, &EditProduct::taste_date_changed);
--- a/src/EditProduct.h Sat Jun 18 20:39:59 2022 +0200 +++ b/src/EditProduct.h Sun Jun 19 10:40:37 2022 +0200 @@ -224,6 +224,7 @@ void kegs_water_changed(double val); void kegs_forced_changed(bool val); void kegs_temp_changed(double val); + void carb_log_button(); void taste_date_changed(QDate val); void taste_date_button(); void taste_date_ack();
--- a/src/EditProductTab1.cpp Sat Jun 18 20:39:59 2022 +0200 +++ b/src/EditProductTab1.cpp Sun Jun 19 10:40:37 2022 +0200 @@ -563,6 +563,13 @@ ui->pack_dateEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); ui->pack_dateButton->hide(); ui->pack_ackButton->hide(); + if (product->log_co2pressure) { + ui->carb_logLabel->show(); + ui->carb_logButton->show(); + } else { + ui->carb_logLabel->hide(); + ui->carb_logButton->hide(); + } if (((stage == PROD_STAGE_TERTIARY) || (stage == PROD_STAGE_PACKAGE)) && (product->package_volume > 1) && ((product->bottle_amount + product->keg_amount) > 1)) { ui->pack_dateEdit->setReadOnly(false);
--- a/src/EditProductTab11.cpp Sat Jun 18 20:39:59 2022 +0200 +++ b/src/EditProductTab11.cpp Sun Jun 19 10:40:37 2022 +0200 @@ -581,3 +581,81 @@ } +void EditProduct::carb_log_button() +{ + QSqlQuery query; + double timestamp; + + QDialog* dialog = new QDialog(this); + dialog->resize(1024, 600); + dialog->setWindowTitle(tr("Carbonation log")); + dialog->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); + buttonBox->setObjectName(QString::fromUtf8("buttonBox")); + buttonBox->setGeometry(QRect(40, 565, 944, 36)); + buttonBox->setLayoutDirection(Qt::LeftToRight); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Ok); + buttonBox->setCenterButtons(true); + + QSplineSeries *temperature = new QSplineSeries(); + QSplineSeries *pressure = new QSplineSeries(); + + query.prepare("SELECT * FROM log_co2pressure WHERE code=:code ORDER BY datetime"); + query.bindValue(":code", product->code); + query.exec(); + while (query.next()) { + timestamp = query.value("datetime").toDateTime().toSecsSinceEpoch() * 1000; + temperature->append(timestamp, query.value("temperature").toDouble()); + pressure->append(timestamp, query.value("pressure").toDouble()); + } + + temperature->setName(tr("Temperature")); + temperature->setColor(QColorConstants::Svg::red); + pressure->setName(tr("Pressure bar")); + QPen pen(QColorConstants::Svg::navy); + pen.setWidth(3); + pressure->setPen(pen); + + QChart *chart = new QChart(); + chart->setTitle(QString("%1 \"%2\"").arg(product->code).arg(product->name)); + chart->addSeries(temperature); + chart->addSeries(pressure); + + QDateTimeAxis *axisX = new QDateTimeAxis; + axisX->setTickCount(10); + axisX->setFormat("dd MMM"); + axisX->setTitleText("Date"); + axisX->setLabelsFont(QFont("Helvetica", 8, QFont::Normal)); + chart->addAxis(axisX, Qt::AlignBottom); + temperature->attachAxis(axisX); + pressure->attachAxis(axisX); + + QValueAxis *axisYT = new QValueAxis; + axisYT->setTickCount(10); + axisYT->setLabelFormat("%.1f"); + axisYT->setTitleText("Temp"); + axisYT->setLabelsFont(QFont("Helvetica", 8, QFont::Normal)); + chart->addAxis(axisYT, Qt::AlignRight); + temperature->attachAxis(axisYT); + + QValueAxis *axisYP = new QValueAxis; + axisYP->setTickCount(10); + axisYP->setLabelFormat("%.1f"); + axisYP->setTitleText("Bar"); + axisYP->setLabelsFont(QFont("Helvetica", 8, QFont::Normal)); + chart->addAxis(axisYP, Qt::AlignLeft); + pressure->attachAxis(axisYP); + + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); + dialog->setLayout(new QVBoxLayout); + dialog->layout()->addWidget(chartView); + dialog->layout()->addWidget(buttonBox); + + connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); + dialog->setModal(true); + dialog->exec(); +} +
--- a/ui/EditProduct.ui Sat Jun 18 20:39:59 2022 +0200 +++ b/ui/EditProduct.ui Sun Jun 19 10:40:37 2022 +0200 @@ -10226,6 +10226,42 @@ <normaloff>:/icons/silk/accept.png</normaloff>:/icons/silk/accept.png</iconset> </property> </widget> + <widget class="QToolButton" name="carb_logButton"> + <property name="geometry"> + <rect> + <x>180</x> + <y>430</y> + <width>28</width> + <height>22</height> + </rect> + </property> + <property name="toolTip"> + <string>Brew log chart</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"> + <normaloff>:/icons/silk/chart_line.png</normaloff>:/icons/silk/chart_line.png</iconset> + </property> + </widget> + <widget class="QLabel" name="carb_logLabel"> + <property name="geometry"> + <rect> + <x>10</x> + <y>430</y> + <width>161</width> + <height>20</height> + </rect> + </property> + <property name="text"> + <string>Show carbonation log:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> </widget> <widget class="QWidget" name="taste"> <attribute name="title">