2
* MashEditor.cpp is part of Brewtarget, and is Copyright Philip G. Lee
3
* (rocketman768@gmail.com), 2009.
5
* Brewtarget is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* Brewtarget is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#include "MashEditor.h"
22
#include "brewtarget.h"
24
#include "equipment.h"
26
MashEditor::MashEditor(QWidget* parent) : QDialog(parent)
31
connect(pushButton_fromEquipment, SIGNAL(clicked()), this, SLOT(fromEquipment()) );
32
connect(this, SIGNAL(accepted()), this, SLOT(saveAndClose()) );
33
connect(this, SIGNAL(rejected()), this, SLOT(closeEditor()) );
36
void MashEditor::showEditor()
42
void MashEditor::closeEditor()
47
void MashEditor::saveAndClose()
51
// Create a new mash if the recipe has none.
54
else if( rec->getMash() == 0 )
61
mash = rec->getMash();
64
mash->disableNotification(); // If we don't do this, the notification will propagate to a showChanges() and we'll lose any info we want saved.
65
mash->setEquipAdjust( true ); // BeerXML won't like me, but it's just stupid not to adjust for the equipment when you're able.
67
mash->setName( lineEdit_name->text().toStdString() );
68
mash->setGrainTemp_c(Unit::qstringToSI(lineEdit_grainTemp->text()));
69
mash->setSpargeTemp_c(Unit::qstringToSI(lineEdit_spargeTemp->text()));
70
mash->setPh(Unit::qstringToSI(lineEdit_spargePh->text()));
71
mash->setTunTemp_c(Unit::qstringToSI(lineEdit_tunTemp->text()));
72
mash->setTunWeight_kg(Unit::qstringToSI(lineEdit_tunMass->text()));
73
mash->setTunSpecificHeat_calGC(Unit::qstringToSI(lineEdit_tunSpHeat->text()) );
75
mash->setNotes( textEdit_notes->toPlainText().toStdString() );
77
mash->reenableNotification();
81
void MashEditor::fromEquipment()
83
if( rec == 0 || rec->getEquipment() == 0 )
88
Equipment* equip = rec->getEquipment();
90
lineEdit_tunMass->setText(Brewtarget::displayAmount(equip->getTunWeight_kg(), Units::kilograms));
91
lineEdit_tunSpHeat->setText(Brewtarget::displayAmount(equip->getTunSpecificHeat_calGC()));
94
void MashEditor::setRecipe(Recipe* recipe)
100
void MashEditor::showChanges()
102
if( rec == 0 || rec->getMash() == 0 )
108
Mash* mash = rec->getMash();
110
lineEdit_name->setText(mash->getName().c_str());
111
lineEdit_grainTemp->setText(Brewtarget::displayAmount(mash->getGrainTemp_c(), Units::celsius));
112
lineEdit_spargeTemp->setText(Brewtarget::displayAmount(mash->getSpargeTemp_c(), Units::celsius));
113
lineEdit_spargePh->setText(Brewtarget::displayAmount(mash->getPh()));
114
lineEdit_tunTemp->setText(Brewtarget::displayAmount(mash->getTunTemp_c(), Units::celsius));
115
lineEdit_tunMass->setText(Brewtarget::displayAmount(mash->getTunWeight_kg(), Units::kilograms));
116
lineEdit_tunSpHeat->setText(Brewtarget::displayAmount(mash->getTunSpecificHeat_calGC()));
118
textEdit_notes->setPlainText(mash->getNotes().c_str());
121
void MashEditor::clear()
123
lineEdit_name->setText("");
124
lineEdit_grainTemp->setText("");
125
lineEdit_spargeTemp->setText("");
126
lineEdit_spargePh->setText("");
127
lineEdit_tunTemp->setText("");
128
lineEdit_tunMass->setText("");
129
lineEdit_tunSpHeat->setText("");
131
textEdit_notes->setPlainText("");
b'\\ No newline at end of file'