First setup of the mash tab with the table.

Tue, 19 Apr 2022 11:17:16 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 19 Apr 2022 11:17:16 +0200
changeset 144
c4b107bf153a
parent 143
8414844c9f8b
child 145
fd4f0de86fd9

First setup of the mash tab with the table.

CMakeLists.txt file | annotate | diff | comparison | revisions
src/EditRecipe.cpp file | annotate | diff | comparison | revisions
src/EditRecipe.h file | annotate | diff | comparison | revisions
src/EditRecipeTab6.cpp file | annotate | diff | comparison | revisions
ui/EditRecipe.ui file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Mon Apr 18 21:56:11 2022 +0200
+++ b/CMakeLists.txt	Tue Apr 19 11:17:16 2022 +0200
@@ -9,7 +9,7 @@
 
 SET( bmsapp_VERSION_MAJOR 0 )
 SET( bmsapp_VERSION_MINOR 1 )
-SET( bmsapp_VERSION_PATCH 1 )
+SET( bmsapp_VERSION_PATCH 2 )
 
 # Compile flags
 
--- a/src/EditRecipe.cpp	Mon Apr 18 21:56:11 2022 +0200
+++ b/src/EditRecipe.cpp	Tue Apr 19 11:17:16 2022 +0200
@@ -76,6 +76,13 @@
         ui->wt_sourceEdit->addItem(query.value(0).toString());
     }
 
+    query.prepare("SELECT name FROM profile_mash ORDER BY name");
+    query.exec();
+    ui->mash_pickEdit->addItem("");
+    while (query.next()) {
+	ui->mash_pickEdit->addItem(query.value(0).toString());
+    }
+
     ui->beerstyleEdit->addItem("");	// First add a dummy
     query.prepare("SELECT style_guide,style_letter,name FROM profile_styles ORDER BY style_guide,style_letter,name");
     query.exec();
@@ -531,6 +538,9 @@
     ui->est_fg3Edit->setValue(recipe->est_fg);
     ui->est_abv2Edit->setValue(recipe->est_abv);
 
+    // Tab mashs.
+    ui->mash_nameEdit->setText(recipe->mash_name);
+
     // Tab waters.
     qDebug() << "water 1" << recipe->w1_name << "default" << my_default_water;
     if (recipe->w1_ph > 4.0) {
@@ -673,6 +683,9 @@
     connect(ui->addYeast, SIGNAL(clicked()), this, SLOT(addYeastRow_clicked()));
 
     // All signals from tab "Mash"
+    ui->mashsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
+    //connect(ui->addMash, SIGNAL(clicked()), this, SLOT(addMashRow_clicked()));
+    //connect(ui->mash_pickEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::mash_select_changed);
 
     // All signals from tab "Water"
     connect(ui->bs_cacl2Edit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::wb_cacl2_changed);
--- a/src/EditRecipe.h	Mon Apr 18 21:56:11 2022 +0200
+++ b/src/EditRecipe.h	Tue Apr 19 11:17:16 2022 +0200
@@ -113,14 +113,14 @@
 {
     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
+    double	step_volume;		///< The water volume upto this step.
+    double	step_infuse_amount;	///< Infuse/decoction volume this step.
+    double	step_infuse_temp;	///< Infuse/decoction temperature.
+    double	step_temp;		///< Start tmperature this step.
+    double	step_time;		///< Step rest time.
+    double	ramp_time;		///< Estimated ramp time to this step.
+    double	end_temp;		///< End temperature this step.
+    double	step_wg_ratio;		///< Current water/grain ratio.
 };
 
 
@@ -301,6 +301,11 @@
     void addYeastRow_clicked();
     void deleteYeastRow_clicked();
     void editYeastRow_clicked();
+    void addMashRow_clicked();
+    void deleteMashRow_clicked();
+    void editMashRow_clicked();
+    void upMashRow_clicked();
+    void downMashRow_clicked();
 
     void w2_volume_changed(double val);
     void wb_cacl2_changed(double val);
@@ -339,6 +344,7 @@
     QStringList y_forms = { tr("Liquid"), tr("Dry"), tr("Slant"), tr("Culture"), tr("Frozen"), tr("Bottle"), tr("Dried") };
     QStringList y_use = { tr("Primary"), tr("Secondary"), tr("Tertiary"), tr("Bottle") };
     QStringList starters = { tr("Stirred"), tr("Shaken"), tr("Simple") };
+    QStringList step_types = { tr("Infusion"), tr("Temperature"), tr("Decoction") };
     QString bar_red = "QProgressBar::chunk {background: #FF0000;}";
     QString bar_orange = "QProgressBar::chunk {background: #EB7331;}";
     QString bar_green = "QProgressBar::chunk {background: #008C00;}";
--- a/src/EditRecipeTab6.cpp	Mon Apr 18 21:56:11 2022 +0200
+++ b/src/EditRecipeTab6.cpp	Tue Apr 19 11:17:16 2022 +0200
@@ -20,6 +20,155 @@
 
 void EditRecipe::refreshMashs()
 {
+    QString w;
+    QWidget* pWidget;
+    QHBoxLayout* pLayout;
+    QTableWidgetItem *item;
+
+    qDebug() << "refreshYeasts" << recipe->yeasts.size();
+    std::sort(recipe->yeasts.begin(), recipe->yeasts.end(), yeast_sort_test);
+
+    /*
+     * During filling the table turn off the cellChanged signal because every cell that is filled
+     * triggers the cellChanged signal. The QTableWidget has no better signal to use.
+     */
+    this->ignoreChanges = true;
+
+    const QStringList labels({tr("Step name"), tr("Type"), tr("Start"), tr("End"), tr("Rest"), tr("Ramp"),
+			      tr("Inf/dec"), tr("Inf/dec"), tr("Volume"), tr("W/G ratio"), "", "", tr("Delete"), tr("Edit") });
+
+    ui->mashsTable->setColumnCount(14);
+    ui->mashsTable->setColumnWidth(0, 189);	/* Step name	*/
+    ui->mashsTable->setColumnWidth(1, 100);	/* Type		*/
+    ui->mashsTable->setColumnWidth(2,  70);	/* Start temp	*/
+    ui->mashsTable->setColumnWidth(3,  70);	/* End temp	*/
+    ui->mashsTable->setColumnWidth(4,  70);	/* Rest time	*/
+    ui->mashsTable->setColumnWidth(5,  70);	/* Ramp time	*/
+    ui->mashsTable->setColumnWidth(6,  70);	/* Infusion vol	*/
+    ui->mashsTable->setColumnWidth(7,  70);     /* Infusion tmp	*/
+    ui->mashsTable->setColumnWidth(8,  70);	/* Volume	*/
+    ui->mashsTable->setColumnWidth(9,  80);	/* W/G ratio	*/
+    ui->mashsTable->setColumnWidth(10, 30);	/* Up button	*/
+    ui->mashsTable->setColumnWidth(11, 30);	/* Down button	*/
+    ui->mashsTable->setColumnWidth(12, 80);	/* Delete	*/
+    ui->mashsTable->setColumnWidth(13, 80);	/* Edit		*/
+    ui->mashsTable->setHorizontalHeaderLabels(labels);
+    ui->mashsTable->verticalHeader()->hide();
+    ui->mashsTable->setRowCount(recipe->mashs.size());
+
+    for (int i = 0; i < recipe->mashs.size(); i++) {
+
+	ui->mashsTable->setItem(i, 0, new QTableWidgetItem(recipe->mashs.at(i).step_name));
+
+	item = new QTableWidgetItem(step_types[recipe->mashs.at(i).step_type]);
+        item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
+        ui->mashsTable->setItem(i, 1, item);
+
+	item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).step_temp, 2, 'f', 1, '0'));
+	item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+	ui->mashsTable->setItem(i, 2, item);
+
+	item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).end_temp, 2, 'f', 1, '0'));
+        item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+        ui->mashsTable->setItem(i, 3, item);
+
+	item = new QTableWidgetItem(QString("%1 min").arg(recipe->mashs.at(i).step_time, 1, 'f', 0, '0'));
+        item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+        ui->mashsTable->setItem(i, 4, item);
+
+	item = new QTableWidgetItem(QString("%1 min").arg(recipe->mashs.at(i).ramp_time, 1, 'f', 0, '0'));
+        item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+        ui->mashsTable->setItem(i, 5, item);
+
+	if (recipe->mashs.at(i).step_infuse_amount) {
+	    item = new QTableWidgetItem(QString("%1 L").arg(recipe->mashs.at(i).step_infuse_amount, 2, 'f', 1, '0'));
+            item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+            ui->mashsTable->setItem(i, 6, item);
+	    item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).step_infuse_temp, 3, 'f', 2, '0'));
+            item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+            ui->mashsTable->setItem(i, 7, item);
+	} else {
+	    ui->mashsTable->removeCellWidget(i, 6);
+	    ui->mashsTable->removeCellWidget(i, 7);
+	}
+
+	item = new QTableWidgetItem(QString("%1 L").arg(recipe->mashs.at(i).step_volume, 2, 'f', 1, '0'));
+        item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+        ui->mashsTable->setItem(i, 8, item);
+
+	item = new QTableWidgetItem(QString("%1 L/kg").arg(recipe->mashs.at(i).step_wg_ratio, 3, 'f', 2, '0'));
+        item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
+        ui->mashsTable->setItem(i, 9, item);
+
+	pWidget = new QWidget();
+        QPushButton* btn_up = new QPushButton();
+        btn_up->setObjectName(QString("%1").arg(i));  /* Send row with the button */
+        btn_up->setText(tr("U"));
+        connect(btn_up, SIGNAL(clicked()), this, SLOT(upMashRow_clicked()));
+        pLayout = new QHBoxLayout(pWidget);
+        pLayout->addWidget(btn_up);
+        pLayout->setContentsMargins(5, 0, 5, 0);
+        pWidget->setLayout(pLayout);
+        ui->mashsTable->setCellWidget(i, 10, pWidget);
+
+	pWidget = new QWidget();
+        QPushButton* btn_down = new QPushButton();
+        btn_down->setObjectName(QString("%1").arg(i));  /* Send row with the button */
+        btn_down->setText(tr("D"));
+        connect(btn_down, SIGNAL(clicked()), this, SLOT(downMashRow_clicked()));
+        pLayout = new QHBoxLayout(pWidget);
+        pLayout->addWidget(btn_down);
+        pLayout->setContentsMargins(5, 0, 5, 0);
+        pWidget->setLayout(pLayout);
+        ui->mashsTable->setCellWidget(i, 11, pWidget);
+
+	pWidget = new QWidget();
+        QPushButton* btn_dele = new QPushButton();
+        btn_dele->setObjectName(QString("%1").arg(i));  /* Send row with the button */
+        btn_dele->setText(tr("Delete"));
+        connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMashRow_clicked()));
+        pLayout = new QHBoxLayout(pWidget);
+        pLayout->addWidget(btn_dele);
+        pLayout->setContentsMargins(5, 0, 5, 0);
+        pWidget->setLayout(pLayout);
+        ui->mashsTable->setCellWidget(i, 12, pWidget);
+
+        pWidget = new QWidget();
+        QPushButton* btn_edit = new QPushButton();
+        btn_edit->setObjectName(QString("%1").arg(i));  /* Send row with the button */
+        btn_edit->setText(tr("Edit"));
+        connect(btn_edit, SIGNAL(clicked()), this, SLOT(editMashRow_clicked()));
+        pLayout = new QHBoxLayout(pWidget);
+        pLayout->addWidget(btn_edit);
+        pLayout->setContentsMargins(5, 0, 5, 0);
+        pWidget->setLayout(pLayout);
+        ui->mashsTable->setCellWidget(i, 13, pWidget);
+    }
 }
 
 
+void EditRecipe::addMashRow_clicked()
+{
+}
+
+
+void EditRecipe::deleteMashRow_clicked()
+{
+}
+
+
+void EditRecipe::upMashRow_clicked()
+{
+}
+
+
+void EditRecipe::downMashRow_clicked()
+{
+}
+
+
+void EditRecipe::editMashRow_clicked()
+{
+}
+
+
--- a/ui/EditRecipe.ui	Mon Apr 18 21:56:11 2022 +0200
+++ b/ui/EditRecipe.ui	Tue Apr 19 11:17:16 2022 +0200
@@ -95,7 +95,7 @@
        <enum>QTabWidget::Rounded</enum>
       </property>
       <property name="currentIndex">
-       <number>4</number>
+       <number>5</number>
       </property>
       <property name="elideMode">
        <enum>Qt::ElideNone</enum>
@@ -1797,7 +1797,7 @@
          </rect>
         </property>
         <property name="currentIndex">
-         <number>1</number>
+         <number>0</number>
         </property>
         <widget class="QWidget" name="yeastNot"/>
         <widget class="QWidget" name="yeastLiquid">

mercurial