886 disconnect(splitTable, nullptr, nullptr, nullptr); |
886 disconnect(splitTable, nullptr, nullptr, nullptr); |
887 |
887 |
888 if (! doit) |
888 if (! doit) |
889 return; |
889 return; |
890 qInfo() << "split starts now"; |
890 qInfo() << "split starts now"; |
|
891 for (int i = 0; i < product->splits.size(); i++) { |
|
892 Product *sp = new Product; |
|
893 if (DB_product::load(sp, this, product->record)) { |
|
894 double factor = round((product->splits.at(i).size / vol_availEdit->value()) * 1000.0) / 1000.0; |
|
895 qDebug() << "split prep" << i + 1 << product->splits.at(i).code << "factor" << factor; |
|
896 sp->record = -1; |
|
897 sp->uuid = ""; |
|
898 sp->name = product->splits.at(i).name; |
|
899 sp->code = product->splits.at(i).code; |
|
900 sp->divide_type = product->divide_type; |
|
901 sp->divide_size = product->splits.at(i).size; |
|
902 sp->divide_factor = factor; |
|
903 sp->divide_parts = product->splits.size(); |
|
904 sp->divide_part = i + 1; |
|
905 /* Now adjust the volumes */ |
|
906 sp->brew_sparge_est = sp->brew_sparge_est * factor; |
|
907 sp->brew_preboil_volume = sp->brew_preboil_volume * factor; |
|
908 sp->brew_aboil_volume = sp->brew_aboil_volume * factor; |
|
909 sp->brew_fermenter_volume = sp->brew_fermenter_volume * factor; |
|
910 sp->brew_fermenter_extrawater = sp->brew_fermenter_extrawater * factor; |
|
911 sp->brew_fermenter_tcloss = sp->brew_fermenter_tcloss * factor; |
|
912 sp->package_volume = sp->package_volume * factor; |
|
913 sp->package_infuse_amount = sp->package_infuse_amount * factor; |
|
914 sp->bottle_amount = sp->bottle_amount * factor; |
|
915 sp->bottle_priming_water = sp->bottle_priming_water * factor; |
|
916 sp->keg_amount = sp->keg_amount * factor; |
|
917 sp->keg_priming_water = sp->keg_priming_water * factor; |
|
918 sp->batch_size = sp->batch_size * factor; |
|
919 sp->boil_size = sp->boil_size * factor; |
|
920 sp->sparge_volume = sp->sparge_volume * factor; |
|
921 sp->sparge_acid_amount = sp->sparge_acid_amount * factor; |
|
922 sp->w1_amount = sp->w1_amount * factor; |
|
923 sp->w2_amount = sp->w2_amount * factor; |
|
924 sp->wg_amount = sp->wg_amount * factor; |
|
925 sp->prop_volume[0] = sp->prop_volume[0] * factor; |
|
926 sp->prop_volume[1] = sp->prop_volume[1] * factor; |
|
927 sp->prop_volume[2] = sp->prop_volume[2] * factor; |
|
928 sp->prop_volume[3] = sp->prop_volume[3] * factor; |
|
929 for (int j = 0; j < sp->fermentables.size(); j++) { |
|
930 sp->fermentables[j].f_amount = round(sp->fermentables.at(j).f_amount * factor * 100000) / 100000; |
|
931 } |
|
932 for (int j = 0; j < sp->hops.size(); j++) { |
|
933 sp->hops[j].h_amount = round(sp->hops.at(j).h_amount * factor * 100000) / 100000; |
|
934 } |
|
935 for (int j = 0; j < sp->miscs.size(); j++) { |
|
936 sp->miscs[j].m_amount = round(sp->miscs.at(j).m_amount * factor * 100000) / 100000; |
|
937 } |
|
938 for (int j = 0; j < sp->yeasts.size(); j++) { |
|
939 sp->yeasts[j].y_amount = round(sp->yeasts.at(j).y_amount * factor * 100000) / 100000; |
|
940 } |
|
941 for (int j = 0; j < sp->mashs.size(); j++) { |
|
942 sp->mashs[j].step_volume = round(sp->mashs.at(j).step_volume * factor * 100) / 100; |
|
943 sp->mashs[j].step_infuse_amount = round(sp->mashs.at(j).step_infuse_amount * factor * 100) / 100; |
|
944 } |
|
945 DB_product::save(sp, this); |
|
946 } |
|
947 delete sp; |
|
948 } |
891 |
949 |
892 /* Make sure the product editor is closed after splitting */ |
950 /* Make sure the product editor is closed after splitting */ |
893 qInfo() << "split ready, destroy windows"; |
951 qInfo() << "split ready, destroy windows"; |
894 this->close(); |
952 this->close(); |
895 this->setResult(1); |
953 this->setResult(1); |