# HG changeset patch # User Michiel Broek # Date 1652791046 -7200 # Node ID a167ee979caceccfb735d03102ccba0423a7011b # Parent 8b84dd3579ef8662589784c97436e7e802f7c5d4 Added brew_log popup window. diff -r 8b84dd3579ef -r a167ee979cac CMakeLists.txt --- a/CMakeLists.txt Mon May 16 14:38:12 2022 +0200 +++ b/CMakeLists.txt Tue May 17 14:37:26 2022 +0200 @@ -64,7 +64,7 @@ # ===== Find Qt5 ===== # Minimum versio 5.13 for debug messages. -find_package(Qt5 5.13 REQUIRED COMPONENTS Core Widgets Network Sql LinguistTools PrintSupport WebSockets) +find_package(Qt5 5.13 REQUIRED COMPONENTS Core Widgets Network Sql LinguistTools PrintSupport WebSockets Charts) INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5Network_INCLUDE_DIRS}) @@ -72,6 +72,7 @@ INCLUDE_DIRECTORIES(${Qt5LinguistTools_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5PrintSupport_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5WebSockets_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${Qt5Charts_INCLUDE_DIRS}) # Xml @@ -113,29 +114,9 @@ ${QT_LIBRARY_DIR} ) - #set( SRC_FILES - # ${SRCDIR}/RangedSlider.cpp - # ${SRCDIR}/NullDateEdit.cpp - #) - # By default only QtCore and QtGui are enabled SET( QT_USE_QTDESIGNER TRUE ) - # set( MOC_FILES - # ${SRCDIR}/RangedSlider.h - # ${SRCDIR}/NullDateEdit.h - #) - - #set( PLUGIN_MOCS - # designer/RangedSliderPlugin.h - # designer/NullDateEditPlugin.h - #) - - #set( PLUGIN_SRCS - # designer/RangedSliderPlugin.cpp - # designer/NullDateEditPlugin.cpp - #) - QT_WRAP_CPP( GEN_MOC_FILES1 ${SRCDIR}/RangedSlider.h designer/RangedSliderPlugin.h) add_library(bmsapp_rangeslider SHARED ${SRCDIR}/RangedSlider.cpp @@ -284,7 +265,7 @@ ) add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES} ${QM_FILES}) - target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql Qt5::PrintSupport Qt5::WebSockets) + target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql Qt5::PrintSupport Qt5::WebSockets Qt5::Charts) # `make translations' add_custom_target(translations DEPENDS ${QM_FILES}) diff -r 8b84dd3579ef -r a167ee979cac src/EditProduct.cpp --- a/src/EditProduct.cpp Mon May 16 14:38:12 2022 +0200 +++ b/src/EditProduct.cpp Tue May 17 14:37:26 2022 +0200 @@ -1108,6 +1108,7 @@ connect(ui->brew_aertimeEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_aertime_changed); connect(ui->brew_trublossEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_trubloss_changed); connect(ui->brew_topupwaterEdit, QOverload::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_topupwater_changed); + connect(ui->brew_logButton, SIGNAL(clicked()), this, SLOT(brew_log_button())); setStage(); diff -r 8b84dd3579ef -r a167ee979cac src/EditProduct.h --- a/src/EditProduct.h Mon May 16 14:38:12 2022 +0200 +++ b/src/EditProduct.h Tue May 17 14:37:26 2022 +0200 @@ -170,6 +170,7 @@ void brew_aertime_changed(double val); void brew_trubloss_changed(double val); void brew_topupwater_changed(double val); + void brew_log_button(); /* Modified progress bars */ void ferment_perc_mash_valueChanged(int value); diff -r 8b84dd3579ef -r a167ee979cac src/EditProductTab9.cpp --- a/src/EditProductTab9.cpp Mon May 16 14:38:12 2022 +0200 +++ b/src/EditProductTab9.cpp Tue May 17 14:37:26 2022 +0200 @@ -422,3 +422,75 @@ calcIBUs(); } + +void EditProduct::brew_log_button() +{ + QSqlQuery query; + double timestamp; + + QDialog* dialog = new QDialog(this); + dialog->resize(1024, 600); + 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); + + QLineSeries *pv_mlt = new QLineSeries(); + pv_mlt->setName("MLT"); + QLineSeries *sp_mlt = new QLineSeries(); + sp_mlt->setName("Set"); + QLineSeries *pv_hlt = new QLineSeries(); + pv_hlt->setName("HLT"); + + query.prepare("SELECT * FROM log_brews WHERE code=:code ORDER BY datetime"); + query.bindValue(":code", product->code); + query.exec(); + while (query.next()) { + timestamp = query.value("datetime").toDateTime().toSecsSinceEpoch() * 1000; + pv_mlt->append(timestamp, query.value("pv_mlt").toDouble()); + sp_mlt->append(timestamp, query.value("sp_mlt").toDouble()); + pv_hlt->append(timestamp, query.value("pv_hlt").toDouble()); + } + + QChart *chart = new QChart(); + chart->setTitle(QString("%1 \"%2\"").arg(product->code).arg(product->name)); + chart->addSeries(pv_mlt); // Add dataset to chart + chart->addSeries(sp_mlt); + chart->addSeries(pv_hlt); + + QDateTimeAxis *axisX = new QDateTimeAxis; + axisX->setTickCount(20); + axisX->setFormat("HH:mm"); + axisX->setTitleText("Time"); + axisX->setLabelsFont(QFont("Helvetica", 8, QFont::Normal)); + chart->addAxis(axisX, Qt::AlignBottom); + pv_mlt->attachAxis(axisX); + + QValueAxis *axisY = new QValueAxis; + axisY->setRange(5, 105); + axisY->setTickCount(11); + axisY->setMinorTickCount(1); + axisY->setLabelFormat("%i"); + axisY->setTitleText("Temp"); + axisY->setLabelsFont(QFont("Helvetica", 8, QFont::Normal)); + chart->addAxis(axisY, Qt::AlignLeft); + pv_mlt->attachAxis(axisY); + sp_mlt->attachAxis(axisY); + pv_hlt->attachAxis(axisY); + + QChartView *chartView = new QChartView(chart); + chartView->setRenderHint(QPainter::Antialiasing); +// chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean); + dialog->setLayout(new QVBoxLayout); + dialog->layout()->addWidget(chartView); + dialog->layout()->addWidget(buttonBox); + + connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); + dialog->setModal(true); + dialog->exec(); +} + + diff -r 8b84dd3579ef -r a167ee979cac src/MainWindow.h --- a/src/MainWindow.h Mon May 16 14:38:12 2022 +0200 +++ b/src/MainWindow.h Tue May 17 14:37:26 2022 +0200 @@ -54,7 +54,13 @@ #include #include #include +#include +#include +#include +#include +#include +using namespace QtCharts; typedef struct IniMySQL {