269 |
269 |
270 file.close(); |
270 file.close(); |
271 } |
271 } |
272 |
272 |
273 |
273 |
|
274 void EditProduct::copyProduct() |
|
275 { |
|
276 Product *dup = new Product; |
|
277 |
|
278 dup = product; |
|
279 dup->record = -1; |
|
280 dup->uuid = ""; |
|
281 dup->name.append(" [duplicate]"); |
|
282 dup->code.append("-[dup]"); |
|
283 /* |
|
284 * Clear data of a previous brew if present and roll back stages. |
|
285 * But leave all ingredients and volumes, that's what we want. |
|
286 */ |
|
287 if (dup->stage > PROD_STAGE_WAIT) { |
|
288 dup->stage = dup->inventory_reduced = PROD_STAGE_WAIT; |
|
289 } |
|
290 dup->birth = QDate::currentDate(); |
|
291 dup->brew_date_start = dup->brew_date_end = QDateTime(); |
|
292 dup->brew_mash_ph = dup->brew_mash_sg = dup->brew_mash_efficiency = 0; |
|
293 dup->brew_sparge_ph = 0; |
|
294 dup->brew_preboil_volume = dup->brew_preboil_sg = dup->brew_preboil_ph = dup->brew_preboil_efficiency = 0; |
|
295 dup->brew_aboil_volume = dup->brew_aboil_sg = dup->brew_aboil_ph = dup->brew_aboil_efficiency = 0; |
|
296 dup->brew_cooling_time = 0; |
|
297 dup->brew_fermenter_volume = 0; |
|
298 dup->brew_fermenter_sg = dup->brew_fermenter_ibu = dup->brew_fermenter_color = 0; |
|
299 dup->og = dup->fg = 0; |
|
300 dup->primary_start_temp = dup->primary_max_temp = dup->primary_end_temp = dup->primary_end_sg = 0; |
|
301 dup->primary_end_date = dup->secondary_end_date = QDate(); |
|
302 dup->secondary_temp = dup->secondary_end_sg = dup->tertiary_temp = 0; |
|
303 dup->package_date = QDate(); |
|
304 dup->package_volume = dup->package_abv = dup->package_ph = 0; |
|
305 dup->bottle_amount = dup->bottle_carbonation = dup->bottle_priming_amount = dup->bottle_carbonation_temp = 0; |
|
306 dup->keg_amount = dup->keg_carbonation = dup->keg_priming_amount = dup->keg_carbonation_temp = 0; |
|
307 dup->bottle_priming_water = dup->keg_priming_water = 0; |
|
308 dup->taste_rate = 0; |
|
309 dup->taste_date = QDate(); |
|
310 dup->taste_notes = dup->taste_color = dup->taste_transparency = dup->taste_head = ""; |
|
311 dup->taste_aroma = dup->taste_taste = dup->taste_mouthfeel = dup->taste_aftertaste = ""; |
|
312 dup->starter_viability = 100; |
|
313 dup->yeast_prod_date = QDate(); |
|
314 dup->divide_type = dup->divide_parts = dup->divide_part = 0; |
|
315 dup->divide_size = 0; |
|
316 dup->divide_factor = 1; |
|
317 |
|
318 qDebug() << dup->record << dup->name; |
|
319 if (DB_product::save(dup, this)) { |
|
320 QMessageBox::information(this, tr("Copy Product"), tr("Copy Product export ready.")); |
|
321 } else { |
|
322 QMessageBox::warning(this, tr("Copy Product "), tr("Copy Product error.")); |
|
323 } |
|
324 delete dup; |
|
325 } |
|
326 |
|
327 |
|
328 void EditProduct::copyRecipe() |
|
329 { |
|
330 } |
|
331 |
|
332 |
|
333 void EditProduct::toforumProduct() |
|
334 { |
|
335 } |
|
336 |
|
337 |
|
338 void EditProduct::splitProduct() |
|
339 { |
|
340 } |
|
341 |
|
342 |
274 void EditProduct::on_exportButton_clicked() |
343 void EditProduct::on_exportButton_clicked() |
275 { |
344 { |
276 QDialog* dialog = new QDialog(this); |
345 QDialog* dialog = new QDialog(this); |
277 dialog->setWindowTitle(tr("Export choices")); |
346 dialog->setWindowTitle(tr("Export choices")); |
278 dialog->setObjectName(QString::fromUtf8("Dialog")); |
347 dialog->setObjectName(QString::fromUtf8("Dialog")); |
285 |
354 |
286 QRadioButton *beerxmlButton = new QRadioButton(dialog); |
355 QRadioButton *beerxmlButton = new QRadioButton(dialog); |
287 beerxmlButton->setObjectName(QString::fromUtf8("beerxmlButton")); |
356 beerxmlButton->setObjectName(QString::fromUtf8("beerxmlButton")); |
288 beerxmlButton->setGeometry(QRect(50, 20, 171, 21)); |
357 beerxmlButton->setGeometry(QRect(50, 20, 171, 21)); |
289 beerxmlButton->setText(tr("Export to beerXML")); |
358 beerxmlButton->setText(tr("Export to beerXML")); |
290 /* QRadioButton *copy_productButton = new QRadioButton(dialog); |
359 QRadioButton *copy_productButton = new QRadioButton(dialog); |
291 copy_productButton->setObjectName(QString::fromUtf8("copy_productButton")); |
360 copy_productButton->setObjectName(QString::fromUtf8("copy_productButton")); |
292 copy_productButton->setGeometry(QRect(50, 50, 171, 21)); |
361 copy_productButton->setGeometry(QRect(50, 50, 171, 21)); |
293 copy_productButton->setText(tr("Copy to product")); |
362 copy_productButton->setText(tr("Copy to product")); |
294 QRadioButton *splitButton = new QRadioButton(dialog); |
363 /* QRadioButton *splitButton = new QRadioButton(dialog); |
295 splitButton->setObjectName(QString::fromUtf8("splitButton")); |
364 splitButton->setObjectName(QString::fromUtf8("splitButton")); |
296 splitButton->setGeometry(QRect(50, 110, 171, 21)); |
365 splitButton->setGeometry(QRect(50, 110, 171, 21)); |
297 splitButton->setText(tr("Split this batch")); |
366 splitButton->setText(tr("Split this batch")); |
298 QRadioButton *copy_recipeButton = new QRadioButton(dialog); |
367 QRadioButton *copy_recipeButton = new QRadioButton(dialog); |
299 copy_recipeButton->setObjectName(QString::fromUtf8("copy_recipeButton")); |
368 copy_recipeButton->setObjectName(QString::fromUtf8("copy_recipeButton")); |
310 dialog->setModal(true); |
379 dialog->setModal(true); |
311 dialog->exec(); |
380 dialog->exec(); |
312 if (dialog->result() == QDialog::Accepted) { |
381 if (dialog->result() == QDialog::Accepted) { |
313 if (beerxmlButton->isChecked()) |
382 if (beerxmlButton->isChecked()) |
314 exportBeerXML(); |
383 exportBeerXML(); |
|
384 if (copy_productButton->isChecked()) |
|
385 copyProduct(); |
315 } |
386 } |
316 |
387 |
317 disconnect(buttonBox, nullptr, nullptr, nullptr); |
388 disconnect(buttonBox, nullptr, nullptr, nullptr); |
318 } |
389 } |
319 |
390 |