src/EditHop.cpp

changeset 380
8f5c03ed4321
parent 377
5c1f81c75bc4
child 385
09af9f46518f
equal deleted inserted replaced
379:0f2ce4ebd1b8 380:8f5c03ed4321
69 ui->oilEdit->setValue(query.value("total_oil").toDouble()); 69 ui->oilEdit->setValue(query.value("total_oil").toDouble());
70 ui->utilisationEdit->setValue(query.value("utilisation").toDouble()); 70 ui->utilisationEdit->setValue(query.value("utilisation").toDouble());
71 ui->bufactorEdit->setValue(query.value("bu_factor").toDouble()); 71 ui->bufactorEdit->setValue(query.value("bu_factor").toDouble());
72 } else { 72 } else {
73 /* Set some defaults */ 73 /* Set some defaults */
74 ui->typeEdit->setCurrentIndex(0); 74 ui->typeEdit->setCurrentIndex(HOP_TYPE_BITTERING);
75 ui->formEdit->setCurrentIndex(0); 75 ui->formEdit->setCurrentIndex(HOP_FORMS_PELLET);
76 ui->utilisationEdit->setValue(20.0); 76 ui->utilisationEdit->setValue(my_ut_pellet);
77 ui->bufactorEdit->setValue(1.0); 77 ui->bufactorEdit->setValue(1.0);
78 ui->prodEdit->clear(); 78 ui->prodEdit->clear();
79 ui->thtEdit->clear(); 79 ui->thtEdit->clear();
80 } 80 }
81 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditHop::is_changed); 81 connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditHop::is_changed);
85 connect(ui->caryEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed); 85 connect(ui->caryEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
86 connect(ui->cohumuloneEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed); 86 connect(ui->cohumuloneEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
87 connect(ui->myrceneEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed); 87 connect(ui->myrceneEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
88 connect(ui->hsiEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed); 88 connect(ui->hsiEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
89 connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditHop::is_changed); 89 connect(ui->typeEdit, &QComboBox::currentTextChanged, this, &EditHop::is_changed);
90 connect(ui->formEdit, &QComboBox::currentTextChanged, this, &EditHop::is_changed); 90 connect(ui->formEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditHop::form_changed);
91 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); 91 connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed()));
92 connect(ui->originEdit, &QLineEdit::textChanged, this, &EditHop::is_changed); 92 connect(ui->originEdit, &QLineEdit::textChanged, this, &EditHop::is_changed);
93 connect(ui->substitutesEdit, &QLineEdit::textChanged, this, &EditHop::is_changed); 93 connect(ui->substitutesEdit, &QLineEdit::textChanged, this, &EditHop::is_changed);
94 connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditHop::is_changed); 94 connect(ui->alwaysEdit, &QCheckBox::stateChanged, this, &EditHop::is_changed);
95 connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed); 95 connect(ui->inventoryEdit, &QDoubleSpinBox::textChanged, this, &EditHop::is_changed);
134 134
135 if (this->textIsChanged) { 135 if (this->textIsChanged) {
136 txt.append((QString(" **"))); 136 txt.append((QString(" **")));
137 } 137 }
138 setWindowTitle(txt); 138 setWindowTitle(txt);
139
140 if (ui->formEdit->currentIndex() < HOP_FORMS_CO2EXTRACT) {
141 ui->inventoryEdit->setSuffix(tr(" Kg"));
142 } else {
143 ui->inventoryEdit->setSuffix(tr(" L"));
144 }
145 } 139 }
146 140
147 141
148 void EditHop::on_saveButton_clicked() 142 void EditHop::on_saveButton_clicked()
149 { 143 {
304 this->textIsChanged = true; 298 this->textIsChanged = true;
305 WindowTitle(); 299 WindowTitle();
306 } 300 }
307 301
308 302
303 void EditHop::form_changed(int val)
304 {
305 switch (val) {
306 case HOP_FORMS_PELLET: ui->utilisationEdit->setValue(my_ut_pellet); break;
307 case HOP_FORMS_PLUG: ui->utilisationEdit->setValue(my_ut_plug); break;
308 case HOP_FORMS_LEAF: ui->utilisationEdit->setValue(my_ut_leaf); break;
309 case HOP_FORMS_LEAF_WET: ui->utilisationEdit->setValue(my_ut_wethop); break;
310 case HOP_FORMS_CRYO: ui->utilisationEdit->setValue(my_ut_t45); break;
311 case HOP_FORMS_CO2EXTRACT: ui->utilisationEdit->setValue(my_ut_co2extract); break;
312 }
313 is_changed();
314 }
315
316
309 void EditHop::on_quitButton_clicked() 317 void EditHop::on_quitButton_clicked()
310 { 318 {
311 if (this->textIsChanged) { 319 if (this->textIsChanged) {
312 int rc = QMessageBox::warning(this, tr("Hop changed"), tr("This hop has been modified. Save changes?"), 320 int rc = QMessageBox::warning(this, tr("Hop changed"), tr("This hop has been modified. Save changes?"),
313 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); 321 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);

mercurial