src/EditRecipe.h

changeset 108
ecfcbee4a9b2
parent 107
bb4607e23065
child 109
1ce50e72a6b1
--- a/src/EditRecipe.h	Mon Apr 04 20:45:04 2022 +0200
+++ b/src/EditRecipe.h	Tue Apr 05 22:28:35 2022 +0200
@@ -4,18 +4,224 @@
 #include <QDialog>
 #include <QStringList>
 #include <QJsonDocument>
+#include <QJsonObject>
+#include <QDoubleSpinBox>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QLineEdit>
+#include <QDialogButtonBox>
+#include <QList>
+
+
+/*
+ * 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;
+    int		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;
+    double	y_harvest_time;
+    double	y_pitch_temperature;
+    bool	y_pofpos;
+    int		y_zymocide;
+    double	y_gr_hl_lo;
+    double	y_sg_lo;
+    double	y_gr_hl_hi;
+    double	y_sg_hi;
+    double	y_cost;
+};
 
 
-typedef struct f_edit {
-    int 	f_row;				///< Row to edit, -1 for insert.
-    QString	f_name;				///< Fermentable name
-    QString	f_supplier;			///< Fermentable supplier
-    double	f_max_in_batch;			///< Max percentage in batch
-    double	f_percentage;			///< Current percentage in batch
-    double	f_amount;			///< Amount in kg
-    bool	f_adjust_to_total_100;		///< Adjust amount/percentage to 100%
-    int		f_added;			///< When to add fermentable
-} fedit;
+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_time;
+    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;
+    double	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;
+    double	wa_acid_name;
+    double	wa_acid_perc;
+    double	wa_base_name;
+
+    QList<Fermentables>	fermentables;
+    QList<Hops>		hops;
+    QList<Miscs>	miscs;
+    QList<Yeasts>	yeasts;
+    QList<Mashs>	mashs;
+};
 
 
 namespace Ui {
@@ -47,6 +253,8 @@
     void refreshMashs();
     void refreshAll();
     void cell_Fermentable_changed(int nRow, int nCol);
+    void ferment_amount_changed(double val);
+    void ferment_pct_changed(double val);
     void on_deleteFermentRow_clicked();
     void on_editFermentRow_clicked();
 
@@ -64,11 +272,20 @@
     QString bar_red = "QProgressBar::chunk {background: #FF0000;}";
     QString bar_orange = "QProgressBar::chunk {background: #EB7331;}";
     QString bar_green = "QProgressBar::chunk {background: #008C00;}";
-    int recno, st_type = 0;
+    int recno, editrow;
     bool textIsChanged = false;
     bool ignoreChanges = false;
+    bool use_to100 = false;
+    Recipe *recipe;
+    /*
+     * Variables for popup ingredients editing.
+     */
     QJsonDocument fermentables, hops, miscs, yeasts, mashs;
-    fedit fermentrow, fermentbackup;
+    QJsonObject work, backup;
+    QComboBox *selectEdit, *addedEdit;
+    QLineEdit *nameEdit, *supplierEdit;
+    QDoubleSpinBox *amountEdit, *pctEdit, *maxEdit;
+    QCheckBox *to100Edit, *instockEdit;
 
     void WindowTitle();
     void fermentable_Json();

mercurial