1835 this->ignoreChanges = false; |
1941 this->ignoreChanges = false; |
1836 calcFermentables(); |
1942 calcFermentables(); |
1837 is_changed(); |
1943 is_changed(); |
1838 } |
1944 } |
1839 |
1945 |
|
1946 |
|
1947 void EditRecipe::hop_select_changed(int val) |
|
1948 { |
|
1949 QSqlQuery query; |
|
1950 bool instock = hinstockEdit->isChecked(); |
|
1951 QString w; |
|
1952 QTableWidgetItem *item; |
|
1953 |
|
1954 if (val < 1) |
|
1955 return; |
|
1956 |
|
1957 qDebug() << "hop_select_changed()" << recipe->fermentables_row << val << instock; |
|
1958 |
|
1959 /* |
|
1960 * Search the hop pointed by the index and instock flag. |
|
1961 */ |
|
1962 QString sql = "SELECT name,origin,alpha,beta,humulene,caryophyllene,cohumulone,myrcene,hsi,total_oil,type,form,cost FROM inventory_hops "; |
|
1963 if (instock) |
|
1964 sql.append("WHERE inventory > 0 "); |
|
1965 sql.append("ORDER BY origin,name"); |
|
1966 query.prepare(sql); |
|
1967 query.exec(); |
|
1968 query.first(); |
|
1969 for (int i = 0; i < (val - 1); i++) { |
|
1970 query.next(); |
|
1971 } |
|
1972 qDebug() << "found" << query.value(1).toString() << query.value(0).toString(); |
|
1973 |
|
1974 /* |
|
1975 * Replace the hop record contents |
|
1976 */ |
|
1977 this->ignoreChanges = true; |
|
1978 recipe->hops[recipe->hops_row].h_name = query.value(0).toString(); |
|
1979 recipe->hops[recipe->hops_row].h_origin = query.value(1).toString(); |
|
1980 recipe->hops[recipe->hops_row].h_alpha = query.value(2).toDouble(); |
|
1981 recipe->hops[recipe->hops_row].h_beta = query.value(3).toDouble(); |
|
1982 recipe->hops[recipe->hops_row].h_humulene = query.value(4).toDouble(); |
|
1983 recipe->hops[recipe->hops_row].h_caryophyllene = query.value(5).toDouble(); |
|
1984 recipe->hops[recipe->hops_row].h_cohumulone = query.value(6).toDouble(); |
|
1985 recipe->hops[recipe->hops_row].h_myrcene = query.value(7).toDouble(); |
|
1986 recipe->hops[recipe->hops_row].h_hsi = query.value(8).toDouble(); |
|
1987 recipe->hops[recipe->hops_row].h_total_oil = query.value(9).toDouble(); |
|
1988 recipe->hops[recipe->hops_row].h_type = query.value(10).toInt(); |
|
1989 recipe->hops[recipe->hops_row].h_form = query.value(11).toInt(); |
|
1990 recipe->hops[recipe->hops_row].h_cost = query.value(12).toDouble(); |
|
1991 |
|
1992 /* |
|
1993 * Update the visible fields |
|
1994 */ |
|
1995 hnameEdit->setText(recipe->hops.at(recipe->hops_row).h_name); |
|
1996 horiginEdit->setText(recipe->hops.at(recipe->hops_row).h_origin); |
|
1997 |
|
1998 double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, |
|
1999 recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, |
|
2000 recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, 0); |
|
2001 ibuEdit->setValue(ibu); |
|
2002 |
|
2003 ui->hopsTable->setItem(recipe->hops_row, 0, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).h_origin)); |
|
2004 ui->hopsTable->setItem(recipe->hops_row, 1, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).h_name)); |
|
2005 |
|
2006 item = new QTableWidgetItem(h_types[recipe->hops.at(recipe->hops_row).h_type]); |
|
2007 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
|
2008 ui->hopsTable->setItem(recipe->hops_row, 2, item); |
|
2009 |
|
2010 item = new QTableWidgetItem(h_forms[recipe->hops.at(recipe->hops_row).h_form]); |
|
2011 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
|
2012 ui->hopsTable->setItem(recipe->hops_row, 3, item); |
|
2013 |
|
2014 item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(recipe->hops_row).h_alpha, 2, 'f', 1, '0')); |
|
2015 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
2016 ui->hopsTable->setItem(recipe->hops_row, 4, item); |
|
2017 |
|
2018 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
|
2019 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
2020 ui->hopsTable->setItem(recipe->hops_row, 7, item); |
|
2021 |
|
2022 this->ignoreChanges = false; |
|
2023 calcIBUs(); |
|
2024 is_changed(); |
|
2025 } |
|
2026 |
|
2027 |
1840 void EditRecipe::ferment_instock_changed(bool val) |
2028 void EditRecipe::ferment_instock_changed(bool val) |
1841 { |
2029 { |
1842 QSqlQuery query; |
2030 QSqlQuery query; |
1843 |
2031 |
1844 qDebug() << "ferment_instock_changed()" << recipe->fermentables_row << val; |
2032 qDebug() << "ferment_instock_changed()" << recipe->fermentables_row << val; |
1845 |
2033 |
1846 this->selectEdit->setCurrentIndex(-1); |
2034 this->fselectEdit->setCurrentIndex(-1); |
1847 this->selectEdit->clear(); |
2035 this->fselectEdit->clear(); |
1848 QString sql = "SELECT supplier,name,color,inventory FROM inventory_fermentables "; |
2036 QString sql = "SELECT supplier,name,color,inventory FROM inventory_fermentables "; |
1849 if (val) |
2037 if (val) |
1850 sql.append("WHERE inventory > 0 "); |
2038 sql.append("WHERE inventory > 0 "); |
1851 sql.append("ORDER BY supplier,name"); |
2039 sql.append("ORDER BY supplier,name"); |
1852 query.prepare(sql); |
2040 query.prepare(sql); |
1853 query.exec(); |
2041 query.exec(); |
1854 query.first(); |
2042 query.first(); |
1855 this->selectEdit->addItem(""); // Start with empty value |
2043 this->fselectEdit->addItem(""); // Start with empty value |
1856 for (int i = 0; i < query.size(); i++) { |
2044 for (int i = 0; i < query.size(); i++) { |
1857 this->selectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+" EBC) "+ |
2045 this->fselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+" EBC) "+ |
1858 QString("%1 kg").arg(query.value(3).toDouble(), 4, 'f', 3, '0')); |
2046 QString("%1 kg").arg(query.value(3).toDouble(), 4, 'f', 3, '0')); |
1859 query.next(); |
2047 query.next(); |
1860 } |
2048 } |
1861 } |
2049 } |
|
2050 |
|
2051 |
|
2052 void EditRecipe::hop_instock_changed(bool val) |
|
2053 { |
|
2054 QSqlQuery query; |
|
2055 |
|
2056 qDebug() << "hop_instock_changed()" << recipe->hops_row << val; |
|
2057 |
|
2058 this->hselectEdit->setCurrentIndex(-1); |
|
2059 this->hselectEdit->clear(); |
|
2060 QString sql = "SELECT origin,name,alpha,inventory FROM inventory_hops "; |
|
2061 if (val) |
|
2062 sql.append("WHERE inventory > 0 "); |
|
2063 sql.append("ORDER BY origin,name"); |
|
2064 query.prepare(sql); |
|
2065 query.exec(); |
|
2066 query.first(); |
|
2067 this->hselectEdit->addItem(""); // Start with empty value |
|
2068 for (int i = 0; i < query.size(); i++) { |
|
2069 this->hselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+"%) "+ |
|
2070 QString("%1 gr").arg(query.value(3).toDouble() * 1000.0, 2, 'f', 1, '0')); |
|
2071 query.next(); |
|
2072 } |
|
2073 } |
|
2074 |
1862 |
2075 |
1863 void EditRecipe::ferment_added_changed(int val) |
2076 void EditRecipe::ferment_added_changed(int val) |
1864 { |
2077 { |
1865 qDebug() << "ferment_added_changed()" << recipe->fermentables_row << val; |
2078 qDebug() << "ferment_added_changed()" << recipe->fermentables_row << val; |
1866 |
2079 |
1946 maxLabel->setObjectName(QString::fromUtf8("maxLabel")); |
2189 maxLabel->setObjectName(QString::fromUtf8("maxLabel")); |
1947 maxLabel->setText(tr("Max in batch:")); |
2190 maxLabel->setText(tr("Max in batch:")); |
1948 maxLabel->setGeometry(QRect(420, 130, 121, 20)); |
2191 maxLabel->setGeometry(QRect(420, 130, 121, 20)); |
1949 maxLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
2192 maxLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1950 |
2193 |
1951 selectEdit = new QComboBox(dialog); |
2194 fselectEdit = new QComboBox(dialog); |
1952 selectEdit->setObjectName(QString::fromUtf8("selectEdit")); |
2195 fselectEdit->setObjectName(QString::fromUtf8("fselectEdit")); |
1953 selectEdit->setGeometry(QRect(160, 70, 371, 23)); |
2196 fselectEdit->setGeometry(QRect(160, 70, 371, 23)); |
1954 |
2197 |
1955 nameEdit = new QLineEdit(dialog); |
2198 fnameEdit = new QLineEdit(dialog); |
1956 nameEdit->setObjectName(QString::fromUtf8("nameEdit")); |
2199 fnameEdit->setObjectName(QString::fromUtf8("fnameEdit")); |
1957 nameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_name); |
2200 fnameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_name); |
1958 nameEdit->setGeometry(QRect(160, 10, 511, 23)); |
2201 fnameEdit->setGeometry(QRect(160, 10, 511, 23)); |
1959 nameEdit->setReadOnly(true); |
2202 fnameEdit->setReadOnly(true); |
1960 supplierEdit = new QLineEdit(dialog); |
2203 fsupplierEdit = new QLineEdit(dialog); |
1961 supplierEdit->setObjectName(QString::fromUtf8("supplierEdit")); |
2204 fsupplierEdit->setObjectName(QString::fromUtf8("fsupplierEdit")); |
1962 supplierEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_supplier); |
2205 fsupplierEdit->setText(recipe->fermentables.at(recipe->fermentables_row).f_supplier); |
1963 supplierEdit->setGeometry(QRect(160, 40, 511, 23)); |
2206 fsupplierEdit->setGeometry(QRect(160, 40, 511, 23)); |
1964 supplierEdit->setReadOnly(true); |
2207 fsupplierEdit->setReadOnly(true); |
1965 amountEdit = new QDoubleSpinBox(dialog); |
2208 famountEdit = new QDoubleSpinBox(dialog); |
1966 amountEdit->setObjectName(QString::fromUtf8("amountEdit")); |
2209 famountEdit->setObjectName(QString::fromUtf8("famountEdit")); |
1967 amountEdit->setGeometry(QRect(160, 100, 121, 24)); |
2210 famountEdit->setGeometry(QRect(160, 100, 121, 24)); |
1968 amountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
2211 famountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1969 amountEdit->setAccelerated(true); |
2212 famountEdit->setAccelerated(true); |
1970 amountEdit->setDecimals(3); |
2213 famountEdit->setDecimals(3); |
1971 amountEdit->setReadOnly(recipe->fermentables_use100); |
2214 famountEdit->setReadOnly(recipe->fermentables_use100); |
1972 amountEdit->setMaximum(100000.0); |
2215 famountEdit->setMaximum(100000.0); |
1973 amountEdit->setSingleStep(0.0010); |
2216 famountEdit->setSingleStep(0.0010); |
1974 amountEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_amount); |
2217 famountEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_amount); |
1975 |
2218 |
1976 pctEdit = new QDoubleSpinBox(dialog); |
2219 pctEdit = new QDoubleSpinBox(dialog); |
1977 pctEdit->setObjectName(QString::fromUtf8("pctEdit")); |
2220 pctEdit->setObjectName(QString::fromUtf8("pctEdit")); |
1978 pctEdit->setGeometry(QRect(160, 130, 121, 24)); |
2221 pctEdit->setGeometry(QRect(160, 130, 121, 24)); |
1979 pctEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
2222 pctEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
1989 } |
2232 } |
1990 pctEdit->setMaximum(100.0); |
2233 pctEdit->setMaximum(100.0); |
1991 pctEdit->setSingleStep(0.1); |
2234 pctEdit->setSingleStep(0.1); |
1992 pctEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_percentage); |
2235 pctEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_percentage); |
1993 |
2236 |
1994 addedEdit = new QComboBox(dialog); |
2237 faddedEdit = new QComboBox(dialog); |
1995 addedEdit->setObjectName(QString::fromUtf8("addedEdit")); |
2238 faddedEdit->setObjectName(QString::fromUtf8("faddedEdit")); |
1996 addedEdit->setGeometry(QRect(160, 190, 161, 23)); |
2239 faddedEdit->setGeometry(QRect(160, 190, 161, 23)); |
1997 addedEdit->addItem(tr("Mash")); |
2240 faddedEdit->addItem(tr("Mash")); |
1998 addedEdit->addItem(tr("Boil")); |
2241 faddedEdit->addItem(tr("Boil")); |
1999 addedEdit->addItem(tr("Fermentation")); |
2242 faddedEdit->addItem(tr("Fermentation")); |
2000 addedEdit->addItem(tr("Lagering")); |
2243 faddedEdit->addItem(tr("Lagering")); |
2001 addedEdit->addItem(tr("Bottle")); |
2244 faddedEdit->addItem(tr("Bottle")); |
2002 addedEdit->addItem(tr("Kegs")); |
2245 faddedEdit->addItem(tr("Kegs")); |
2003 addedEdit->setCurrentIndex(recipe->fermentables.at(recipe->fermentables_row).f_added); |
2246 faddedEdit->setCurrentIndex(recipe->fermentables.at(recipe->fermentables_row).f_added); |
2004 |
2247 |
2005 to100Edit = new QCheckBox(dialog); |
2248 to100Edit = new QCheckBox(dialog); |
2006 to100Edit->setObjectName(QString::fromUtf8("to100Edit")); |
2249 to100Edit->setObjectName(QString::fromUtf8("to100Edit")); |
2007 to100Edit->setGeometry(QRect(160, 160, 85, 21)); |
2250 to100Edit->setGeometry(QRect(160, 160, 85, 21)); |
2008 to100Edit->setChecked(recipe->fermentables.at(recipe->fermentables_row).f_adjust_to_total_100); |
2251 to100Edit->setChecked(recipe->fermentables.at(recipe->fermentables_row).f_adjust_to_total_100); |
2009 |
2252 |
2010 instockEdit = new QCheckBox(dialog); |
2253 finstockEdit = new QCheckBox(dialog); |
2011 instockEdit->setObjectName(QString::fromUtf8("instockEdit")); |
2254 finstockEdit->setObjectName(QString::fromUtf8("instockEdit")); |
2012 instockEdit->setGeometry(QRect(655, 70, 85, 21)); |
2255 finstockEdit->setGeometry(QRect(655, 70, 85, 21)); |
2013 instockEdit->setChecked(true); |
2256 finstockEdit->setChecked(true); |
2014 |
2257 |
2015 maxEdit = new QDoubleSpinBox(dialog); |
2258 fmaxEdit = new QDoubleSpinBox(dialog); |
2016 maxEdit->setObjectName(QString::fromUtf8("maxEdit")); |
2259 fmaxEdit->setObjectName(QString::fromUtf8("fmaxEdit")); |
2017 maxEdit->setGeometry(QRect(550, 130, 121, 24)); |
2260 fmaxEdit->setGeometry(QRect(550, 130, 121, 24)); |
2018 maxEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
2261 fmaxEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
2019 maxEdit->setReadOnly(true); |
2262 fmaxEdit->setReadOnly(true); |
2020 maxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
2263 fmaxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
2021 maxEdit->setDecimals(1); |
2264 fmaxEdit->setDecimals(1); |
2022 maxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_max_in_batch); |
2265 fmaxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).f_max_in_batch); |
2023 |
2266 |
2024 ferment_instock_changed(true); |
2267 ferment_instock_changed(true); |
2025 |
2268 |
2026 connect(selectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_select_changed); |
2269 connect(fselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_select_changed); |
2027 connect(amountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_amount_changed); |
2270 connect(famountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_amount_changed); |
2028 connect(pctEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_pct_changed); |
2271 connect(pctEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_pct_changed); |
2029 connect(addedEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_added_changed); |
2272 connect(faddedEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_added_changed); |
2030 connect(to100Edit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_to100_changed); |
2273 connect(to100Edit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_to100_changed); |
2031 connect(instockEdit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_instock_changed); |
2274 connect(finstockEdit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_instock_changed); |
2032 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); |
2275 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); |
2033 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); |
2276 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); |
2034 |
2277 |
2035 dialog->setModal(true); |
2278 dialog->setModal(true); |
2036 dialog->exec(); |
2279 dialog->exec(); |
2052 recipe->fermentables[i].f_percentage = recipe->fermentables.at(i).f_amount / total * 100; |
2295 recipe->fermentables[i].f_percentage = recipe->fermentables.at(i).f_amount / total * 100; |
2053 } |
2296 } |
2054 } |
2297 } |
2055 } |
2298 } |
2056 |
2299 |
2057 disconnect(selectEdit, nullptr, nullptr, nullptr); |
2300 disconnect(fselectEdit, nullptr, nullptr, nullptr); |
2058 disconnect(amountEdit, nullptr, nullptr, nullptr); |
2301 disconnect(famountEdit, nullptr, nullptr, nullptr); |
2059 disconnect(pctEdit, nullptr, nullptr, nullptr); |
2302 disconnect(pctEdit, nullptr, nullptr, nullptr); |
2060 disconnect(addedEdit, nullptr, nullptr, nullptr); |
2303 disconnect(faddedEdit, nullptr, nullptr, nullptr); |
2061 disconnect(to100Edit, nullptr, nullptr, nullptr); |
2304 disconnect(to100Edit, nullptr, nullptr, nullptr); |
2062 disconnect(instockEdit, nullptr, nullptr, nullptr); |
2305 disconnect(finstockEdit, nullptr, nullptr, nullptr); |
|
2306 disconnect(buttonBox, nullptr, nullptr, nullptr); |
|
2307 |
|
2308 emit refreshAll(); |
|
2309 } |
|
2310 |
|
2311 |
|
2312 void EditRecipe::on_editHopRow_clicked() |
|
2313 { |
|
2314 QSqlQuery query; |
|
2315 |
|
2316 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
|
2317 recipe->hops_row = pb->objectName().toInt(); |
|
2318 qDebug() << "Edit hop row" << recipe->hops_row; |
|
2319 Hops backup = recipe->hops.at(recipe->hops_row); |
|
2320 |
|
2321 QDialog* dialog = new QDialog(this); |
|
2322 dialog->resize(738, 260); |
|
2323 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); |
|
2324 buttonBox->setObjectName(QString::fromUtf8("buttonBox")); |
|
2325 buttonBox->setGeometry(QRect(30, 210, 671, 32)); |
|
2326 buttonBox->setLayoutDirection(Qt::LeftToRight); |
|
2327 buttonBox->setOrientation(Qt::Horizontal); |
|
2328 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); |
|
2329 buttonBox->setCenterButtons(true); |
|
2330 QLabel *nameLabel = new QLabel(dialog); |
|
2331 nameLabel->setObjectName(QString::fromUtf8("nameLabel")); |
|
2332 nameLabel->setText(tr("Current hop:")); |
|
2333 nameLabel->setGeometry(QRect(10, 10, 141, 20)); |
|
2334 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2335 QLabel *originLabel = new QLabel(dialog); |
|
2336 originLabel->setObjectName(QString::fromUtf8("originLabel")); |
|
2337 originLabel->setText(tr("Origin:")); |
|
2338 originLabel->setGeometry(QRect(10, 40, 141, 20)); |
|
2339 originLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2340 QLabel *amountLabel = new QLabel(dialog); |
|
2341 amountLabel->setObjectName(QString::fromUtf8("amountLabel")); |
|
2342 amountLabel->setText(tr("Amount in gr:")); |
|
2343 amountLabel->setGeometry(QRect(10, 100, 141, 20)); |
|
2344 amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2345 htimeLabel = new QLabel(dialog); |
|
2346 htimeLabel->setObjectName(QString::fromUtf8("htimeLabel")); |
|
2347 if (recipe->hops.at(recipe->hops_row).h_useat == 5) // Dry-hop |
|
2348 htimeLabel->setText(tr("Time in days:")); |
|
2349 else if (recipe->hops.at(recipe->hops_row).h_useat == 2 || recipe->hops.at(recipe->hops_row).h_useat == 4) // Boil or whirlpool |
|
2350 htimeLabel->setText(tr("Time in minutes:")); |
|
2351 else |
|
2352 htimeLabel->setText(""); |
|
2353 |
|
2354 htimeLabel->setGeometry(QRect(10, 130, 141, 20)); |
|
2355 htimeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2356 QLabel *useatLabel = new QLabel(dialog); |
|
2357 useatLabel->setObjectName(QString::fromUtf8("useatLabel")); |
|
2358 useatLabel->setText(tr("Use at:")); |
|
2359 useatLabel->setGeometry(QRect(10, 160, 141, 20)); |
|
2360 useatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2361 QLabel *selectLabel = new QLabel(dialog); |
|
2362 selectLabel->setObjectName(QString::fromUtf8("selectLabel")); |
|
2363 selectLabel->setText(tr("Select hop:")); |
|
2364 selectLabel->setGeometry(QRect(10, 70, 141, 20)); |
|
2365 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2366 QLabel *instockLabel = new QLabel(dialog); |
|
2367 instockLabel->setObjectName(QString::fromUtf8("instockLabel")); |
|
2368 instockLabel->setText(tr("In stock:")); |
|
2369 instockLabel->setGeometry(QRect(525, 70, 121, 20)); |
|
2370 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2371 QLabel *ibuLabel = new QLabel(dialog); |
|
2372 ibuLabel->setObjectName(QString::fromUtf8("maxLabel")); |
|
2373 ibuLabel->setText(tr("Bitterness IBU:")); |
|
2374 ibuLabel->setGeometry(QRect(420, 130, 121, 20)); |
|
2375 ibuLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2376 |
|
2377 hselectEdit = new QComboBox(dialog); |
|
2378 hselectEdit->setObjectName(QString::fromUtf8("selectEdit")); |
|
2379 hselectEdit->setGeometry(QRect(160, 70, 371, 23)); |
|
2380 |
|
2381 hnameEdit = new QLineEdit(dialog); |
|
2382 hnameEdit->setObjectName(QString::fromUtf8("hnameEdit")); |
|
2383 hnameEdit->setText(recipe->hops.at(recipe->hops_row).h_name); |
|
2384 hnameEdit->setGeometry(QRect(160, 10, 511, 23)); |
|
2385 hnameEdit->setReadOnly(true); |
|
2386 horiginEdit = new QLineEdit(dialog); |
|
2387 horiginEdit->setObjectName(QString::fromUtf8("horiginEdit")); |
|
2388 horiginEdit->setText(recipe->hops.at(recipe->hops_row).h_origin); |
|
2389 horiginEdit->setGeometry(QRect(160, 40, 511, 23)); |
|
2390 horiginEdit->setReadOnly(true); |
|
2391 hamountEdit = new QDoubleSpinBox(dialog); |
|
2392 hamountEdit->setObjectName(QString::fromUtf8("hamountEdit")); |
|
2393 hamountEdit->setGeometry(QRect(160, 100, 121, 24)); |
|
2394 hamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2395 hamountEdit->setAccelerated(true); |
|
2396 hamountEdit->setDecimals(1); |
|
2397 hamountEdit->setMaximum(1000000.0); |
|
2398 hamountEdit->setSingleStep(0.5); |
|
2399 hamountEdit->setValue(recipe->hops.at(recipe->hops_row).h_amount * 1000.0); |
|
2400 htimeEdit = new QSpinBox(dialog); |
|
2401 htimeEdit->setObjectName(QString::fromUtf8("htimeEdit")); |
|
2402 htimeEdit->setGeometry(QRect(160, 130, 121, 24)); |
|
2403 htimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2404 htimeEdit->setAccelerated(true); |
|
2405 htimeEdit->setMaximum(10000.0); |
|
2406 if (recipe->hops.at(recipe->hops_row).h_useat == 2 || recipe->hops.at(recipe->hops_row).h_useat == 4) { // Boil or whirlpool |
|
2407 htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time); |
|
2408 htimeEdit->setReadOnly(false); |
|
2409 } else if (recipe->hops.at(recipe->hops_row).h_useat == 5){ // Dry-hop |
|
2410 htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time / 1440); |
|
2411 htimeEdit->setReadOnly(false); |
|
2412 } else { |
|
2413 htimeEdit->setReadOnly(true); |
|
2414 } |
|
2415 useatEdit = new QComboBox(dialog); |
|
2416 useatEdit->setObjectName(QString::fromUtf8("useatEdit")); |
|
2417 useatEdit->setGeometry(QRect(160, 160, 161, 23)); |
|
2418 useatEdit->addItem(tr("Mash")); |
|
2419 useatEdit->addItem(tr("First wort")); |
|
2420 useatEdit->addItem(tr("Boil")); |
|
2421 useatEdit->addItem(tr("Aroma")); |
|
2422 useatEdit->addItem(tr("Whirlpool")); |
|
2423 useatEdit->addItem(tr("Dry hop")); |
|
2424 useatEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).h_useat); |
|
2425 |
|
2426 hinstockEdit = new QCheckBox(dialog); |
|
2427 hinstockEdit->setObjectName(QString::fromUtf8("hinstockEdit")); |
|
2428 hinstockEdit->setGeometry(QRect(655, 70, 85, 21)); |
|
2429 hinstockEdit->setChecked(true); |
|
2430 |
|
2431 ibuEdit = new QDoubleSpinBox(dialog); |
|
2432 ibuEdit->setObjectName(QString::fromUtf8("ibuEdit")); |
|
2433 ibuEdit->setGeometry(QRect(550, 130, 121, 24)); |
|
2434 ibuEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
2435 ibuEdit->setReadOnly(true); |
|
2436 ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
|
2437 ibuEdit->setDecimals(1); |
|
2438 double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, |
|
2439 recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, |
|
2440 recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, 0); |
|
2441 ibuEdit->setValue(ibu); |
|
2442 |
|
2443 hop_instock_changed(true); |
|
2444 |
|
2445 connect(hselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_select_changed); |
|
2446 connect(hamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::hop_amount_changed); |
|
2447 connect(htimeEdit, QOverload<int>::of(&QSpinBox::valueChanged), this, &EditRecipe::hop_time_changed); |
|
2448 connect(useatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_useat_changed); |
|
2449 connect(hinstockEdit, &QCheckBox::stateChanged, this, &EditRecipe::hop_instock_changed); |
|
2450 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); |
|
2451 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); |
|
2452 |
|
2453 dialog->setModal(true); |
|
2454 dialog->exec(); |
|
2455 if (dialog->result() == QDialog::Rejected) { |
|
2456 qDebug() << "reject and rollback"; |
|
2457 recipe->hops[recipe->hops_row] = backup; |
|
2458 } else { |
|
2459 /* Clear time if hop is not used for boil, whirlpool or dry-hop. */ |
|
2460 if (! (recipe->hops.at(recipe->hops_row).h_useat == 2 || |
|
2461 recipe->hops.at(recipe->hops_row).h_useat == 4 || |
|
2462 recipe->hops.at(recipe->hops_row).h_useat == 5)) { |
|
2463 if (recipe->hops.at(recipe->hops_row).h_time) { |
|
2464 recipe->hops[recipe->hops_row].h_time = 0; |
|
2465 is_changed(); |
|
2466 } |
|
2467 } |
|
2468 } |
|
2469 |
|
2470 disconnect(hselectEdit, nullptr, nullptr, nullptr); |
|
2471 disconnect(hamountEdit, nullptr, nullptr, nullptr); |
|
2472 disconnect(htimeEdit, nullptr, nullptr, nullptr); |
|
2473 disconnect(useatEdit, nullptr, nullptr, nullptr); |
|
2474 disconnect(hinstockEdit, nullptr, nullptr, nullptr); |
2063 disconnect(buttonBox, nullptr, nullptr, nullptr); |
2475 disconnect(buttonBox, nullptr, nullptr, nullptr); |
2064 |
2476 |
2065 emit refreshAll(); |
2477 emit refreshAll(); |
2066 } |
2478 } |
2067 |
2479 |