src/EditProductTab9.cpp

Sun, 15 May 2022 09:57:32 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 15 May 2022 09:57:32 +0200
changeset 207
3b164a0aea90
parent 205
ae6109192fb2
child 209
19c50b1f58d3
permissions
-rw-r--r--

Implemented brewday mah ph edit, mash sg edit, sparge ph edit, pre and after boil ph edit.

/**
 * EditProduct.cpp is part of bmsapp.
 *
 * Tab 9, brewday.
 *
 * 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/>.
 */


/**
 * @brief Check the state by examining the date values.
 *        1. startdate and enddate invalid, planning/wait status.
 *           The enddate cannot be set.
 *        2. startdate valid and endate invalid, brewdate is planned.
 *           The fase will be brew. Enable setting of enddate.
 *        3. startdate valid, enddate and start and endtime can be set.
 *           The enddate cannot be before the startdate and not after 4
 *           days from the start.
 *        4. startdate and enddate and times are set and valid. Block
 *           the startdate setting. But only after setting a lot of
 *           brewdata move the fase to primary.
 *
 */
void EditProduct::updateBrewday()
{
    setStage();

    qDebug() << "updateBrewday" << product->brew_date_start.date() << product->brew_date_end.date();

    ui->brew_startDate->setDate(product->brew_date_start.date());
    ui->brew_startTime->setTime(product->brew_date_start.time());
    ui->brew_endDate->setDate(product->brew_date_end.date());
    ui->brew_endTime->setTime(product->brew_date_end.time());
}


void EditProduct::brew_date_clear()
{
    product->brew_date_start.setDate(QDate());
    ui->brew_startDate->setDate(QDate());
}


void EditProduct::brew_date_today()
{
    product->brew_date_start.setDate(QDate::currentDate());
    ui->brew_startDate->setDate(QDate::currentDate());
}


void EditProduct::brew_start_date_changed(QDate val)
{
    product->brew_date_start.setDate(ui->brew_startDate->nullDate());
    qDebug() << "brew_start_date_changed" << product->brew_date_start.date();
    updateBrewday();
    is_changed();
}


void EditProduct::brew_end_today()
{
}


void EditProduct::brew_end_date_changed(QDate val)
{
    qDebug() << "brew_end_date_changed" << val;
}


void EditProduct::brew_mashph_changed(double val)
{
    if (product->brew_mash_ph == 0) {
	product->brew_mash_ph = 4.8;
	const QSignalBlocker blocker1(ui->brew_mashphEdit);
	ui->brew_mashphEdit->setValue(4.8);
    } else {
    	product->brew_mash_ph = val;
    }
    is_changed();
}


void EditProduct::brew_mashsg_changed(double val)
{
    product->brew_mash_sg = val;
    double c = Utils::sg_to_plato(product->est_mash_sg);
    double m = Utils::sg_to_plato(val);

    if (c > 0.5)
	product->brew_mash_efficiency = 100 * m / c;
    else
	product->brew_mash_efficiency = 0;
    ui->brew_masheffShow->setValue(product->brew_mash_efficiency);
    is_changed();
}


void EditProduct::brew_spargeph_changed(double val)
{
    if (product->brew_sparge_ph == 0) {
        product->brew_sparge_ph = 4.8;
        const QSignalBlocker blocker1(ui->brew_spargephEdit);
        ui->brew_spargephEdit->setValue(4.8);
    } else {
    	product->brew_sparge_ph = val;
    }
    is_changed();
}


void EditProduct::brew_preboilph_changed(double val)
{
    if (product->brew_preboil_ph == 0) {
        product->brew_preboil_ph = 4.8;
        const QSignalBlocker blocker1(ui->brew_preboilphEdit);
        ui->brew_preboilphEdit->setValue(4.8);
    } else {
        product->brew_preboil_ph = val;
    }
    is_changed();
}


void EditProduct::brew_aboilph_changed(double val)
{
    if (product->brew_aboil_ph == 0) {
        product->brew_aboil_ph = 4.8;
        const QSignalBlocker blocker1(ui->brew_aboilphEdit);
        ui->brew_aboilphEdit->setValue(4.8);
    } else {
        product->brew_aboil_ph = val;
    }
    is_changed();
}

mercurial