src/EditProductExport.cpp

changeset 265
df17db1484f6
parent 263
14d79ec33db4
child 266
5f0782149028
equal deleted inserted replaced
264:67b5c00dd23c 265:df17db1484f6
325 } 325 }
326 326
327 327
328 void EditProduct::copyRecipe() 328 void EditProduct::copyRecipe()
329 { 329 {
330 Recipe *r = new Recipe;
331
332 r->record = -1;
333 r->name = product->name + QString(" [duplicate]");
334 r->notes = product->notes;
335 r->locked = false;
336 r->st_name = product->st_name;
337 r->st_letter = product->st_letter;
338 r->st_guide = product->st_guide;
339 r->st_category = product->st_category;
340 r->st_category_number = product->st_category_number;
341 r->st_og_min = product->st_og_min;
342 r->st_og_max = product->st_og_max;
343 r->st_fg_min = product->st_fg_min;
344 r->st_fg_max = product->st_fg_max;
345 r->st_ibu_min = product->st_ibu_min;
346 r->st_ibu_max = product->st_ibu_max;
347 r->st_color_min = product->st_color_min;
348 r->st_color_max = product->st_color_max;
349 r->st_carb_min = product->st_carb_min;
350 r->st_carb_max = product->st_carb_max;
351 r->st_abv_min = product->st_abv_min;
352 r->st_abv_max = product->st_abv_max;
353 r->type = product->type;
354 r->batch_size = product->batch_size;
355 r->boil_size = product->boil_size;
356 r->boil_time = product->boil_time;
357 r->efficiency = product->efficiency;
358 r->est_og = product->est_og;
359 r->est_fg = product->est_fg;
360 r->est_abv = product->est_abv;
361 r->est_carb = 0;
362 r->est_color = product->est_color;
363 r->color_method = product->color_method;
364 r->est_ibu = product->est_ibu;
365 r->ibu_method = product->ibu_method;
366 r->sparge_temp = product->sparge_temp;
367 r->sparge_volume = product->sparge_volume;
368 r->sparge_ph = product->sparge_ph;
369 r->sparge_acid_type = product->sparge_acid_type;
370 r->sparge_acid_perc = product->sparge_acid_perc;
371 r->sparge_acid_amount = 0;
372 r->mash_ph = product->mash_ph;
373 r->mash_name = product->mash_name;
374 r->calc_acid = product->calc_acid;
375 r->w1_name = product->w1_name;
376 r->w1_amount = product->w1_amount;
377 r->w1_calcium = product->w1_calcium;
378 r->w1_sulfate = product->w1_sulfate;
379 r->w1_chloride = product->w1_chloride;
380 r->w1_sodium = product->w1_sodium;
381 r->w1_magnesium = product->w1_magnesium;
382 r->w1_total_alkalinity = product->w1_total_alkalinity;
383 r->w1_ph = product->w1_ph;
384 r->w2_name = product->w2_name;
385 r->w2_amount = product->w2_amount;
386 r->w2_calcium = product->w2_calcium;
387 r->w2_sulfate = product->w2_sulfate;
388 r->w2_chloride = product->w2_chloride;
389 r->w2_sodium = product->w2_sodium;
390 r->w2_magnesium = product->w2_magnesium;
391 r->w2_total_alkalinity = product->w2_total_alkalinity;
392 r->w2_ph = product->w2_ph;
393 r->wg_amount = product->wg_amount;
394 r->wg_calcium = product->wg_calcium;
395 r->wg_sulfate = product->wg_sulfate;
396 r->wg_chloride = product->wg_chloride;
397 r->wg_sodium = product->wg_sodium;
398 r->wg_magnesium = product->wg_magnesium;
399 r->wg_total_alkalinity = product->wg_total_alkalinity;
400 r->wg_ph = product->wg_ph;
401 r->wb_calcium = product->wb_calcium;
402 r->wb_sulfate = product->wb_sulfate;
403 r->wb_chloride = product->wb_chloride;
404 r->wb_sodium = product->wb_sodium;
405 r->wb_magnesium = product->wb_magnesium;
406 r->wb_total_alkalinity = product->wb_total_alkalinity;
407 r->wb_ph = product->wb_ph;
408 r->wa_acid_name = product->wa_acid_name;
409 r->wa_acid_perc = product->wa_acid_perc;
410 r->wa_base_name = product->wa_base_name;
411 r->fermentables = product->fermentables;
412 r->hops = product->hops;
413 r->miscs = product->miscs;
414 r->yeasts = product->yeasts;
415 r->mashs = product->mashs;
416
417 if (DB_recipe::save(r, this)) {
418 QMessageBox::information(this, tr("Copy Product"), tr("Copy Produuct to Recipe ready."));
419 } else {
420 QMessageBox::warning(this, tr("Copy Product"), tr("Copy Product to Recipe error."));
421 }
422 delete r;
330 } 423 }
331 424
332 425
333 void EditProduct::toforumProduct() 426 void EditProduct::toforumProduct()
334 { 427 {
361 copy_productButton->setGeometry(QRect(50, 50, 171, 21)); 454 copy_productButton->setGeometry(QRect(50, 50, 171, 21));
362 copy_productButton->setText(tr("Copy to product")); 455 copy_productButton->setText(tr("Copy to product"));
363 /* QRadioButton *splitButton = new QRadioButton(dialog); 456 /* QRadioButton *splitButton = new QRadioButton(dialog);
364 splitButton->setObjectName(QString::fromUtf8("splitButton")); 457 splitButton->setObjectName(QString::fromUtf8("splitButton"));
365 splitButton->setGeometry(QRect(50, 110, 171, 21)); 458 splitButton->setGeometry(QRect(50, 110, 171, 21));
366 splitButton->setText(tr("Split this batch")); 459 splitButton->setText(tr("Split this batch")); */
367 QRadioButton *copy_recipeButton = new QRadioButton(dialog); 460 QRadioButton *copy_recipeButton = new QRadioButton(dialog);
368 copy_recipeButton->setObjectName(QString::fromUtf8("copy_recipeButton")); 461 copy_recipeButton->setObjectName(QString::fromUtf8("copy_recipeButton"));
369 copy_recipeButton->setGeometry(QRect(50, 80, 171, 21)); 462 copy_recipeButton->setGeometry(QRect(50, 80, 171, 21));
370 copy_recipeButton->setText(tr("Copy to recipe")); 463 copy_recipeButton->setText(tr("Copy to recipe"));
371 QRadioButton *toforumButton = new QRadioButton(dialog); 464 /* QRadioButton *toforumButton = new QRadioButton(dialog);
372 toforumButton->setObjectName(QString::fromUtf8("toforumButton")); 465 toforumButton->setObjectName(QString::fromUtf8("toforumButton"));
373 toforumButton->setGeometry(QRect(50, 140, 171, 21)); 466 toforumButton->setGeometry(QRect(50, 140, 171, 21));
374 toforumButton->setText(tr("Export to forum")); */ 467 toforumButton->setText(tr("Export to forum")); */
375 468
376 QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); 469 QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
381 if (dialog->result() == QDialog::Accepted) { 474 if (dialog->result() == QDialog::Accepted) {
382 if (beerxmlButton->isChecked()) 475 if (beerxmlButton->isChecked())
383 exportBeerXML(); 476 exportBeerXML();
384 if (copy_productButton->isChecked()) 477 if (copy_productButton->isChecked())
385 copyProduct(); 478 copyProduct();
479 if (copy_recipeButton->isChecked())
480 copyRecipe();
386 } 481 }
387 482
388 disconnect(buttonBox, nullptr, nullptr, nullptr); 483 disconnect(buttonBox, nullptr, nullptr, nullptr);
389 } 484 }
390 485

mercurial