src/EditRecipeTab1.cpp

changeset 127
475c8b8df67f
child 150
fd568cc1dd0e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/EditRecipeTab1.cpp	Mon Apr 11 17:22:43 2022 +0200
@@ -0,0 +1,98 @@
+/**
+ * EditRecipe.cpp is part of bmsapp.
+ *
+ * Tab 1, generic settings.
+ *
+ * bmsapp is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * bmsapp is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+void EditRecipe::name_changed(QString name)
+{
+    recipe->name = name;
+    is_changed();
+}
+
+
+void EditRecipe::notes_changed()
+{
+    /* The text cannot be passed in a simple way :) */
+    recipe->notes = ui->notesEdit->toPlainText();
+    is_changed();
+}
+
+
+/*
+ * New beerstyle is selected.
+ */
+void EditRecipe::style_changed()
+{
+    QSqlQuery query;
+
+    if (ui->beerstyleEdit->currentIndex() < 1)
+	return;
+
+    query.prepare("SELECT * FROM profile_styles ORDER BY style_guide,style_letter,name");
+    query.exec();
+    query.first();
+    // Skip to the record index.
+    for (int i = 0; i < (ui->beerstyleEdit->currentIndex() - 1); i++) {
+        query.next();
+    }
+    // Set relevant fields and update ranges.
+    recipe->st_name = query.value(1).toString();
+    recipe->st_category = query.value(2).toString();
+    recipe->st_category_number = query.value(3).toInt();
+    recipe->st_letter = query.value(4).toString();
+    recipe->st_guide = query.value(5).toString();
+    recipe->st_type = query.value(6).toInt();
+    recipe->st_og_min = query.value(7).toDouble();
+    recipe->st_og_max = query.value(8).toDouble();
+    recipe->st_fg_min = query.value(9).toDouble();
+    recipe->st_fg_max = query.value(10).toDouble();
+    recipe->st_ibu_min = query.value(11).toDouble();
+    recipe->st_ibu_max = query.value(12).toDouble();
+    recipe->st_color_min = query.value(13).toDouble();
+    recipe->st_color_max = query.value(14).toDouble();
+    recipe->st_carb_min = query.value(15).toDouble();
+    recipe->st_carb_max = query.value(16).toDouble();
+    recipe->st_abv_min = query.value(17).toDouble();
+    recipe->st_abv_max = query.value(18).toDouble();
+
+    ui->st_nameEdit->setText(recipe->st_name);
+    ui->st_groupEdit->setText(recipe->st_letter);
+    ui->st_guideEdit->setText(recipe->st_guide);
+    ui->st_catEdit->setText(recipe->st_category);
+    ui->st_catnrEdit->setText(QString("%1").arg(recipe->st_category_number));
+    ui->st_typeEdit->setText(s_types[recipe->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());
+    ui->est_colorShow->setRange(query.value(13).toDouble(), query.value(14).toDouble());
+    ui->est_carbShow->setRange(query.value(15).toDouble(), query.value(16).toDouble());
+    ui->est_abvShow->setRange(query.value(17).toDouble(), query.value(18).toDouble());
+
+    is_changed();
+}
+
+
+void EditRecipe::colormethod_changed()
+{
+    calcFermentables();
+    is_changed();
+}
+
+

mercurial