# HG changeset patch # User Michiel Broek # Date 1649097904 -7200 # Node ID bb4607e230658d9991f709f0404e088e48751f33 # Parent 2924fb71dce92d1d99cb25499e455a01fd2e666a Added minval() and maxval() read to RangedSlider. Filled the MySQL query with the values that are ready at this point. diff -r 2924fb71dce9 -r bb4607e23065 src/EditRecipe.cpp --- a/src/EditRecipe.cpp Mon Apr 04 17:19:28 2022 +0200 +++ b/src/EditRecipe.cpp Mon Apr 04 20:45:04 2022 +0200 @@ -65,7 +65,8 @@ ui->st_guideEdit->setText(query.value(5).toString()); ui->st_catEdit->setText(query.value(6).toString()); ui->st_catnrEdit->setText(query.value(7).toString()); - ui->st_typeEdit->setText(s_types[query.value(8).toInt()]); + st_type = query.value(8).toInt(); + ui->st_typeEdit->setText(s_types[st_type]); ui->nameEdit->setText(query.value(21).toString()); ui->notesEdit->setPlainText(query.value(22).toString()); @@ -701,20 +702,65 @@ if (this->textIsChanged) { if (this->recno == -1) { - query.prepare("INSERT INTO recipes SET name=:name, " + query.prepare("INSERT INTO recipes SET locked=:locked, st_name=:st_name, st_letter=:st_letter, " + "st_guide=:st_guide, st_category=:st_category, st_category_number=:st_catnr, st_type=:st_type, " + "st_og_min=:st_og_min, st_og_max=:st_og_max, st_fg_min=:st_fg_min, st_fg_max=:st_fg_max, " + "st_ibu_min=:st_ibu_min, st_ibu_max=:st_ibu_max, st_color_min=:st_color_min, st_color_max=:st_color_max, " + "st_carb_min=:st_carb_min, st_carb_max=:st_carb_max, st_abv_min=:st_abv_min, st_abv_max=:st_abv_max, " + "name=:name, notes:=notes, type=:type, batch_size=:batch_size, boil_size=:boil_size, " + "boil_time=:boil_time, efficiency=:efficiency, " "uuid = :uuid"); } else { - query.prepare("UPDATE recipes SET name=:name " + query.prepare("UPDATE recipes SET locked=:locked, st_name=:st_name, st_letter=:st_letter, " + "st_guide=:st_guide, st_category=:st_category, st_category_number=:st_catnr, st_type=:st_type, " + "st_og_min=:st_og_min, st_og_max=:st_og_max, st_fg_min=:st_fg_min, st_fg_max=:st_fg_max, " + "st_ibu_min=:st_ibu_min, st_ibu_max=:st_ibu_max, st_color_min=:st_color_min, st_color_max=:st_color_max, " + "st_carb_min=:st_carb_min, st_carb_max=:st_carb_max, st_abv_min=:st_abv_min, st_abv_max=:st_abv_max, " + "name=:name, notes:=notes, type=:type, batch_size=:batch_size, boil_size=:boil_size, " + "boil_time=:boil_time, efficiency=:efficiency " " WHERE record = :recno"); } - //query.bindValue(":name", ui->nameEdit->text()); - //query.bindValue(":notes", ui->notesEdit->toPlainText()); + query.bindValue(":locked", ui->lockedEdit->isChecked() ? 1:0); + query.bindValue(":st_name", ui->st_nameEdit->text()); + query.bindValue(":st_letter", ui->st_groupEdit->text()); + query.bindValue(":st_guide", ui->st_guideEdit->text()); + query.bindValue(":st_category", ui->st_catEdit->text()); + query.bindValue(":st_catnr", st_type); + query.bindValue(":st_og_min", QString("%1").arg(ui->est_ogShow->minval(), 4, 'f', 3, '0')); + query.bindValue(":st_og_max", QString("%1").arg(ui->est_ogShow->maxval(), 4, 'f', 3, '0')); + query.bindValue(":st_fg_min", QString("%1").arg(ui->est_fgShow->minval(), 4, 'f', 3, '0')); + query.bindValue(":st_fg_max", QString("%1").arg(ui->est_fgShow->maxval(), 4, 'f', 3, '0')); + query.bindValue(":st_ibu_min", QString("%1").arg(ui->est_ibuShow->minval(), 4, 'f', 3, '0')); + query.bindValue(":st_ibu_max", QString("%1").arg(ui->est_ibuShow->maxval(), 4, 'f', 3, '0')); + query.bindValue(":st_color_min", QString("%1").arg(ui->est_colorShow->minval(), 4, 'f', 3, '0')); + query.bindValue(":st_color_max", QString("%1").arg(ui->est_colorShow->maxval(), 4, 'f', 3, '0')); + query.bindValue(":st_carb_min", QString("%1").arg(ui->est_carbShow->minval(), 4, 'f', 3, '0')); + query.bindValue(":st_carb_max", QString("%1").arg(ui->est_carbShow->maxval(), 4, 'f', 3, '0')); + query.bindValue(":st_abv_min", QString("%1").arg(ui->est_abvShow->minval(), 4, 'f', 3, '0')); + query.bindValue(":st_abv_max", QString("%1").arg(ui->est_abvShow->maxval(), 4, 'f', 3, '0')); + query.bindValue(":name", ui->nameEdit->text()); + query.bindValue(":notes", ui->notesEdit->toPlainText()); + query.bindValue(":type", ui->typeEdit->currentIndex()); + query.bindValue(":batch_size", QString("%1").arg(ui->batch_sizeEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":boil_size", QString("%1").arg(ui->boil_sizeEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":boil_time", QString("%1").arg(ui->boil_timeEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":efficiency", QString("%1").arg(ui->efficiencyEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":est_og", QString("%1").arg(ui->est_ogEdit->value(), 4, 'f', 3, '0')); + query.bindValue(":est_fg", QString("%1").arg(ui->est_fgEdit->value(), 4, 'f', 3, '0')); + query.bindValue(":est_abv", QString("%1").arg(ui->est_abvEdit->value(), 2, 'f', 1, '0')); + query.bindValue(":est_color", QString("%1").arg(ui->est_colorEdit->value(), 1, 'f', 0, '0')); + query.bindValue(":color_method", ui->color_methodEdit->currentIndex()); + query.bindValue(":est_ibu", QString("%1").arg(ui->est_ibuEdit->value(), 1, 'f', 0, '0')); + query.bindValue(":ibu_method", ui->ibu_methodEdit->currentIndex()); + query.bindValue(":est_carb", QString("%1").arg(ui->est_carbEdit->value(), 2, 'f', 1, '0')); + if (this->recno == -1) { query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); } else { query.bindValue(":recno", this->recno); } - query.exec(); + qDebug() << query.lastQuery(); +// query.exec(); if (query.lastError().isValid()) { qDebug() << "EditRecipe" << query.lastError(); QMessageBox::warning(this, tr("Database error"), @@ -788,7 +834,8 @@ ui->st_catnrEdit->setText(query.value(3).toString()); ui->st_groupEdit->setText(query.value(4).toString()); ui->st_guideEdit->setText(query.value(5).toString()); - ui->st_typeEdit->setText(s_types[query.value(6).toInt()]); + st_type = query.value(6).toInt(); + ui->st_typeEdit->setText(s_types[st_type]); ui->est_ogShow->setRange(query.value(7).toDouble(), query.value(8).toDouble()); ui->est_fgShow->setRange(query.value(9).toDouble(), query.value(10).toDouble()); ui->est_ibuShow->setRange(query.value(11).toDouble(), query.value(12).toDouble()); diff -r 2924fb71dce9 -r bb4607e23065 src/EditRecipe.h --- a/src/EditRecipe.h Mon Apr 04 17:19:28 2022 +0200 +++ b/src/EditRecipe.h Mon Apr 04 20:45:04 2022 +0200 @@ -64,7 +64,7 @@ QString bar_red = "QProgressBar::chunk {background: #FF0000;}"; QString bar_orange = "QProgressBar::chunk {background: #EB7331;}"; QString bar_green = "QProgressBar::chunk {background: #008C00;}"; - int recno, lasttime = 0; + int recno, st_type = 0; bool textIsChanged = false; bool ignoreChanges = false; QJsonDocument fermentables, hops, miscs, yeasts, mashs; diff -r 2924fb71dce9 -r bb4607e23065 src/RangedSlider.h --- a/src/RangedSlider.h Mon Apr 04 17:19:28 2022 +0200 +++ b/src/RangedSlider.h Mon Apr 04 20:45:04 2022 +0200 @@ -45,6 +45,8 @@ Q_PROPERTY( double value READ value WRITE setValue ) double value() const { return _val; } + double minval() const { return _prefMin; } + double maxval() const { return _prefMax; } //! \brief Set the background brush for the widget. void setBackgroundBrush( QBrush const& brush );