src/EditProductTab9.cpp

changeset 213
a167ee979cac
parent 212
8b84dd3579ef
child 214
641540dc6ef2
equal deleted inserted replaced
212:8b84dd3579ef 213:a167ee979cac
420 is_changed(); 420 is_changed();
421 calcFermentables(); // This will also recalculate all volumes. 421 calcFermentables(); // This will also recalculate all volumes.
422 calcIBUs(); 422 calcIBUs();
423 } 423 }
424 424
425
426 void EditProduct::brew_log_button()
427 {
428 QSqlQuery query;
429 double timestamp;
430
431 QDialog* dialog = new QDialog(this);
432 dialog->resize(1024, 600);
433 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
434 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
435 buttonBox->setGeometry(QRect(40, 565, 944, 36));
436 buttonBox->setLayoutDirection(Qt::LeftToRight);
437 buttonBox->setOrientation(Qt::Horizontal);
438 buttonBox->setStandardButtons(QDialogButtonBox::Ok);
439 buttonBox->setCenterButtons(true);
440
441 QLineSeries *pv_mlt = new QLineSeries();
442 pv_mlt->setName("MLT");
443 QLineSeries *sp_mlt = new QLineSeries();
444 sp_mlt->setName("Set");
445 QLineSeries *pv_hlt = new QLineSeries();
446 pv_hlt->setName("HLT");
447
448 query.prepare("SELECT * FROM log_brews WHERE code=:code ORDER BY datetime");
449 query.bindValue(":code", product->code);
450 query.exec();
451 while (query.next()) {
452 timestamp = query.value("datetime").toDateTime().toSecsSinceEpoch() * 1000;
453 pv_mlt->append(timestamp, query.value("pv_mlt").toDouble());
454 sp_mlt->append(timestamp, query.value("sp_mlt").toDouble());
455 pv_hlt->append(timestamp, query.value("pv_hlt").toDouble());
456 }
457
458 QChart *chart = new QChart();
459 chart->setTitle(QString("%1 \"%2\"").arg(product->code).arg(product->name));
460 chart->addSeries(pv_mlt); // Add dataset to chart
461 chart->addSeries(sp_mlt);
462 chart->addSeries(pv_hlt);
463
464 QDateTimeAxis *axisX = new QDateTimeAxis;
465 axisX->setTickCount(20);
466 axisX->setFormat("HH:mm");
467 axisX->setTitleText("Time");
468 axisX->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
469 chart->addAxis(axisX, Qt::AlignBottom);
470 pv_mlt->attachAxis(axisX);
471
472 QValueAxis *axisY = new QValueAxis;
473 axisY->setRange(5, 105);
474 axisY->setTickCount(11);
475 axisY->setMinorTickCount(1);
476 axisY->setLabelFormat("%i");
477 axisY->setTitleText("Temp");
478 axisY->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
479 chart->addAxis(axisY, Qt::AlignLeft);
480 pv_mlt->attachAxis(axisY);
481 sp_mlt->attachAxis(axisY);
482 pv_hlt->attachAxis(axisY);
483
484 QChartView *chartView = new QChartView(chart);
485 chartView->setRenderHint(QPainter::Antialiasing);
486 // chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean);
487 dialog->setLayout(new QVBoxLayout);
488 dialog->layout()->addWidget(chartView);
489 dialog->layout()->addWidget(buttonBox);
490
491 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
492 dialog->setModal(true);
493 dialog->exec();
494 }
495
496

mercurial