Tue, 12 Apr 2022 21:03:19 +0200
Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
#ifndef _EDITRECIPE_H #define _EDITRECIPE_H #include <QDialog> #include <QStringList> #include <QJsonDocument> #include <QJsonObject> #include <QDoubleSpinBox> #include <QCheckBox> #include <QComboBox> #include <QLineEdit> #include <QDialogButtonBox> #include <QList> #include <QLabel> /* * Fermentables, Hops, Miscs, Yeasts and Mashs are stored in the * database in json arrays. These are the QList structures. */ struct Fermentables { QString f_name; QString f_origin; QString f_supplier; double f_amount; double f_cost; int f_type; double f_yield; double f_color; double f_coarse_fine_diff; double f_moisture; double f_diastatic_power; double f_protein; double f_dissolved_protein; double f_max_in_batch; int f_graintype; int f_added; bool f_recommend_mash; bool f_add_after_boil; bool f_adjust_to_total_100; double f_percentage; double f_di_ph; double f_acid_to_ph_57; }; struct Hops { QString h_name; QString h_origin; double h_amount; double h_cost; int h_type; int h_form; int h_useat; double h_time; double h_alpha; double h_beta; double h_hsi; double h_humulene; double h_caryophyllene; double h_cohumulone; double h_myrcene; double h_total_oil; }; struct Miscs { QString m_name; double m_amount; int m_type; int m_use_use; double m_time; bool m_amount_is_weight; double m_cost; }; struct Yeasts { QString y_name; QString y_laboratory; QString y_product_id; double y_amount; int y_type; int y_form; double y_min_temperature; double y_max_temperature; int y_flocculation; double y_attenuation; double y_cells; double y_tolerance; double y_inventory; int y_use; bool y_sta1; bool y_bacteria; bool y_harvest_top; int y_harvest_time; double y_pitch_temperature; bool y_pofpos; int y_zymocide; int y_gr_hl_lo; double y_sg_lo; int y_gr_hl_hi; double y_sg_hi; double y_cost; }; struct Mashs { QString step_name; int step_type; double step_volume; // May not be present double step_infuse_amount; // May not be present double step_infuse_temp; // May not be present double step_temp; double step_time; double ramp_time; double end_temp; double step_wg_ratio; // May not be present }; /* * The main recipe record stored in the database. */ struct Recipe { int record; QString uuid; bool locked; QString st_name; QString st_letter; QString st_guide; QString st_category; int st_category_number; int st_type; double st_og_min; double st_og_max; double st_fg_min; double st_fg_max; double st_ibu_min; double st_ibu_max; double st_color_min; double st_color_max; double st_carb_min; double st_carb_max; double st_abv_min; double st_abv_max; QString name; QString notes; int type; double batch_size; double boil_size; double boil_time; double efficiency; double est_og; double est_fg; double est_abv; double est_color; int color_method; double est_ibu; int ibu_method; double est_carb; double sparge_temp; double sparge_ph; double sparge_volume; int sparge_source; int sparge_acid_type; double sparge_acid_perc; double sparge_acid_amount; double mash_ph; QString mash_name; bool calc_acid; QString w1_name; ///< Water source 1 double w1_amount; double w1_calcium; double w1_sulfate; double w1_chloride; double w1_sodium; double w1_magnesium; double w1_total_alkalinity; double w1_ph; double w1_cost; QString w2_name; ///< Water source 2 double w2_amount; double w2_calcium; double w2_sulfate; double w2_chloride; double w2_sodium; double w2_magnesium; double w2_total_alkalinity; double w2_ph; double w2_cost; double wg_amount; ///< Mixed water double wg_calcium; double wg_sulfate; double wg_chloride; double wg_sodium; double wg_magnesium; double wg_total_alkalinity; double wg_ph; double wb_calcium; ///< Treated water double wb_sulfate; double wb_chloride; double wb_sodium; double wb_magnesium; double wb_total_alkalinity; double wb_ph; int wa_acid_name; double wa_acid_perc; int wa_base_name; QList<Fermentables> fermentables; QList<Hops> hops; QList<Miscs> miscs; QList<Yeasts> yeasts; QList<Mashs> mashs; /* * These are not in the MySL database, but are global variables * that belong with the loaded recipe data and are present to * make things easier. */ int fermentables_row; ///< Current row, -1 is invalid. bool fermentables_use100; ///< Use percentages instead of amount int hops_row; int misc_row; int yeasts_row; int mashs_row; double preboil_sg; }; namespace Ui { class EditRecipe; } class EditRecipe : public QDialog { Q_OBJECT signals: void entry_changed(); public: explicit EditRecipe(int id, QWidget *parent = 0); ~EditRecipe(); private slots: void on_saveButton_clicked(); void on_quitButton_clicked(); void on_deleteButton_clicked(); void is_changed(); void name_changed(QString); void notes_changed(); void style_changed(); void colormethod_changed(); void refreshFermentables(); void refreshHops(); void refreshMiscs(); void refreshYeasts(); void refreshMashs(); void refreshWaters(); void refreshAll(); void ferment_amount_changed(double val); void ferment_pct_changed(double val); void ferment_to100_changed(bool val); void ferment_select_changed(int val); void ferment_instock_changed(bool val); void ferment_added_changed(int val); void hop_amount_changed(double val); void hop_time_changed(int val); void hop_select_changed(int val); void hop_instock_changed(bool val); void hop_useat_changed(int val); void on_addFermentRow_clicked(); void on_deleteFermentRow_clicked(); void on_editFermentRow_clicked(); void on_addHopRow_clicked(); void on_deleteHopRow_clicked(); void on_editHopRow_clicked(); void on_perc_mash_valueChanged(int value); void on_perc_sugars_valueChanged(int value); void on_perc_cara_valueChanged(int value); void on_lintner_valueChanged(int value); void on_Flavour_valueChanged(int value); void on_Aroma_valueChanged(int value); private: Ui::EditRecipe *ui; QStringList s_types = { tr("Lager"), tr("Ale"), tr("Mead"), tr("Wheat"), tr("Mixed"), tr("Cider") }; QStringList f_types = { tr("Grain"), tr("Sugar"), tr("Extract"), tr("Dry extract"), tr("Adjunct") }; QStringList f_graintypes = { tr("Base"), tr("Roast"), tr("Crystal"), tr("Kilned"), tr("Sour Malt"), tr("Special"), tr("No malt")}; QStringList f_added = { tr("Mash"), tr("Boil"), tr("Fermentation"), tr("Lagering"), tr("Bottle"), tr("Kegs") }; QStringList h_types = { tr("Bittering"), tr("Aroma"), tr("Both") }; QStringList h_forms = { tr("Pellet"), tr("Plug"), tr("Leaf"), tr("Leaf wet"), tr("Cryo") }; QStringList h_useat = { tr("Mash"), tr("First wort"), tr("Boil"), tr("Aroma"), tr("Whirlpool"), tr("Dry hop") }; QStringList m_types = { tr("Spice"), tr("Herb"), tr("Flavor"), tr("Fining"), tr("Water agent"), tr("Yeast nutrient"), tr("Other") }; QStringList m_uses = { tr("Starter"), tr("Mash"), tr("Boil"), tr("Primary"), tr("Secondary"), tr("Bottling") }; QString bar_red = "QProgressBar::chunk {background: #FF0000;}"; QString bar_orange = "QProgressBar::chunk {background: #EB7331;}"; QString bar_green = "QProgressBar::chunk {background: #008C00;}"; QString bar_20 = "QProgressBar::chunk {background: #004D00;}"; QString bar_40 = "QProgressBar::chunk {background: #008C00;}"; QString bar_60 = "QProgressBar::chunk {background: #00BF00;}"; QString bar_80 = "QProgressBar::chunk {background: #00FF00;}"; QString bar_100 = "QProgressBar::chunk {background: #80FF80;}"; int recno; bool textIsChanged = false; bool ignoreChanges = false; Recipe *recipe; /* * Variables for popup ingredients editing. */ QComboBox *fselectEdit, *faddedEdit, *hselectEdit,*haddedEdit, *useatEdit; QLineEdit *fnameEdit, *fsupplierEdit, *hnameEdit, *horiginEdit; QDoubleSpinBox *famountEdit, *pctEdit, *fmaxEdit, *hamountEdit, *ibuEdit; QSpinBox *htimeEdit; QCheckBox *to100Edit, *finstockEdit, *hinstockEdit; QLabel *htimeLabel; void to100Fermentables(int row); static bool ferment_sort_test(const Fermentables &D1, const Fermentables &D2); static bool hop_sort_test(const Hops &D1, const Hops &D2); static bool misc_sort_test(const Miscs &D1, const Miscs &D2); void WindowTitle(); void calcFermentables(); void calcIBUs(); }; #endif