36 QTableWidgetItem *item; |
36 QTableWidgetItem *item; |
37 |
37 |
38 std::sort(recipe->yeasts.begin(), recipe->yeasts.end(), yeast_sort_test); |
38 std::sort(recipe->yeasts.begin(), recipe->yeasts.end(), yeast_sort_test); |
39 |
39 |
40 const QStringList labels({tr("Yeast"), tr("Laboratory"), tr("Code"), tr("Type"), tr("Use for"), tr("Min. °C"), tr("Max. °C"), |
40 const QStringList labels({tr("Yeast"), tr("Laboratory"), tr("Code"), tr("Type"), tr("Use for"), tr("Min. °C"), tr("Max. °C"), |
41 tr("Tol. %"), tr("Attn. %"), tr("Amount"), tr("Delete"), tr("Edit") }); |
41 tr("Tol. %"), tr("Attn. %"), tr("STA"), tr("Amount"), tr("Delete"), tr("Edit") }); |
42 |
42 |
43 ui->yeastsTable->setColumnCount(12); |
43 ui->yeastsTable->setColumnCount(13); |
44 ui->yeastsTable->setColumnWidth(0, 200); /* Yeast */ |
44 ui->yeastsTable->setColumnWidth(0, 200); /* Yeast */ |
45 ui->yeastsTable->setColumnWidth(1, 125); /* Laboratory */ |
45 ui->yeastsTable->setColumnWidth(1, 125); /* Laboratory */ |
46 ui->yeastsTable->setColumnWidth(2, 80); /* Code */ |
46 ui->yeastsTable->setColumnWidth(2, 80); /* Code */ |
47 ui->yeastsTable->setColumnWidth(3, 80); /* Type */ |
47 ui->yeastsTable->setColumnWidth(3, 80); /* Type */ |
48 ui->yeastsTable->setColumnWidth(4, 100); /* Usage */ |
48 ui->yeastsTable->setColumnWidth(4, 100); /* Usage */ |
49 ui->yeastsTable->setColumnWidth(5, 60); /* Min. */ |
49 ui->yeastsTable->setColumnWidth(5, 50); /* Min. */ |
50 ui->yeastsTable->setColumnWidth(6, 60); /* Max. */ |
50 ui->yeastsTable->setColumnWidth(6, 50); /* Max. */ |
51 ui->yeastsTable->setColumnWidth(7, 60); /* Tolerance */ |
51 ui->yeastsTable->setColumnWidth(7, 50); /* Tolerance */ |
52 ui->yeastsTable->setColumnWidth(8, 60); /* Attenuation */ |
52 ui->yeastsTable->setColumnWidth(8, 50); /* Attenuation */ |
53 ui->yeastsTable->setColumnWidth(9, 90); /* Amount */ |
53 ui->yeastsTable->setColumnWidth(9, 40); /* STA1 gen */ |
54 ui->yeastsTable->setColumnWidth(10, 80); /* Delete */ |
54 ui->yeastsTable->setColumnWidth(10, 90); /* Amount */ |
55 ui->yeastsTable->setColumnWidth(11, 80); /* Edit */ |
55 ui->yeastsTable->setColumnWidth(11, 80); /* Delete */ |
|
56 ui->yeastsTable->setColumnWidth(12, 80); /* Edit */ |
56 ui->yeastsTable->setHorizontalHeaderLabels(labels); |
57 ui->yeastsTable->setHorizontalHeaderLabels(labels); |
57 ui->yeastsTable->verticalHeader()->hide(); |
58 ui->yeastsTable->verticalHeader()->hide(); |
58 ui->yeastsTable->setRowCount(recipe->yeasts.size()); |
59 ui->yeastsTable->setRowCount(recipe->yeasts.size()); |
59 |
60 |
60 for (int i = 0; i < recipe->yeasts.size(); i++) { |
61 for (int i = 0; i < recipe->yeasts.size(); i++) { |
85 |
86 |
86 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).attenuation, 2, 'f', 1, '0')); |
87 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(i).attenuation, 2, 'f', 1, '0')); |
87 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
88 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
88 ui->yeastsTable->setItem(i, 8, item); |
89 ui->yeastsTable->setItem(i, 8, item); |
89 |
90 |
90 if (recipe->yeasts.at(i).form == 0) |
91 if (recipe->yeasts.at(i).use != YEAST_USE_BOTTLE && recipe->yeasts.at(i).sta1) { |
|
92 QWidget *pWidget = new QWidget(); |
|
93 QLabel *label = new QLabel; |
|
94 label->setPixmap(QPixmap(":icons/silk/tick.png")); |
|
95 QHBoxLayout *pLayout = new QHBoxLayout(pWidget); |
|
96 pLayout->addWidget(label); |
|
97 pLayout->setAlignment(Qt::AlignCenter); |
|
98 pLayout->setContentsMargins(0, 0, 0, 0); |
|
99 pWidget->setLayout(pLayout); |
|
100 ui->yeastsTable->setCellWidget(i, 9, pWidget); |
|
101 } else { |
|
102 ui->yeastsTable->removeCellWidget(i, 9); |
|
103 } |
|
104 |
|
105 if (recipe->yeasts.at(i).form == YEAST_FORMS_LIQUID) |
91 item = new QTableWidgetItem(QString("%1 pack").arg(recipe->yeasts.at(i).amount, 1, 'f', 0, '0')); |
106 item = new QTableWidgetItem(QString("%1 pack").arg(recipe->yeasts.at(i).amount, 1, 'f', 0, '0')); |
92 else if (recipe->yeasts.at(i).form == 1) |
107 else if (recipe->yeasts.at(i).form == YEAST_FORMS_DRY || recipe->yeasts.at(i).form == YEAST_FORMS_DRIED) |
93 item = new QTableWidgetItem(QString("%1 gr").arg(recipe->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0')); |
108 item = new QTableWidgetItem(QString("%1 gr").arg(recipe->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0')); |
94 else |
109 else |
95 item = new QTableWidgetItem(QString("%1 ml").arg(recipe->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0')); |
110 item = new QTableWidgetItem(QString("%1 ml").arg(recipe->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0')); |
96 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
111 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
97 ui->yeastsTable->setItem(i, 9, item); |
112 ui->yeastsTable->setItem(i, 10, item); |
98 |
113 |
99 pWidget = new QWidget(); |
114 pWidget = new QWidget(); |
100 QPushButton* btn_dele = new QPushButton(); |
115 QPushButton* btn_dele = new QPushButton(); |
101 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
116 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
102 btn_dele->setText(tr("Delete")); |
117 btn_dele->setText(tr("Delete")); |
103 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteYeastRow_clicked())); |
118 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteYeastRow_clicked())); |
104 pLayout = new QHBoxLayout(pWidget); |
119 pLayout = new QHBoxLayout(pWidget); |
105 pLayout->addWidget(btn_dele); |
120 pLayout->addWidget(btn_dele); |
106 pLayout->setContentsMargins(5, 0, 5, 0); |
121 pLayout->setContentsMargins(5, 0, 5, 0); |
107 pWidget->setLayout(pLayout); |
122 pWidget->setLayout(pLayout); |
108 ui->yeastsTable->setCellWidget(i, 10, pWidget); |
123 ui->yeastsTable->setCellWidget(i, 11, pWidget); |
109 |
124 |
110 pWidget = new QWidget(); |
125 pWidget = new QWidget(); |
111 QPushButton* btn_edit = new QPushButton(); |
126 QPushButton* btn_edit = new QPushButton(); |
112 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
127 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
113 btn_edit->setText(tr("Edit")); |
128 btn_edit->setText(tr("Edit")); |
114 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editYeastRow_clicked())); |
129 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editYeastRow_clicked())); |
115 pLayout = new QHBoxLayout(pWidget); |
130 pLayout = new QHBoxLayout(pWidget); |
116 pLayout->addWidget(btn_edit); |
131 pLayout->addWidget(btn_edit); |
117 pLayout->setContentsMargins(5, 0, 5, 0); |
132 pLayout->setContentsMargins(5, 0, 5, 0); |
118 pWidget->setLayout(pLayout); |
133 pWidget->setLayout(pLayout); |
119 ui->yeastsTable->setCellWidget(i, 11, pWidget); |
134 ui->yeastsTable->setCellWidget(i, 12, pWidget); |
120 } |
135 } |
121 } |
136 } |
122 |
137 |
123 |
138 |
124 /* |
139 /* |
208 |
223 |
209 void EditRecipe::addYeastRow_clicked() |
224 void EditRecipe::addYeastRow_clicked() |
210 { |
225 { |
211 Yeasts newy; |
226 Yeasts newy; |
212 |
227 |
|
228 #ifdef DEBUG_YEAST |
213 qDebug() << "Add yeast row"; |
229 qDebug() << "Add yeast row"; |
|
230 #endif |
214 |
231 |
215 for (int i = 0; i < recipe->yeasts.size(); i++) { |
232 for (int i = 0; i < recipe->yeasts.size(); i++) { |
216 if (recipe->yeasts.at(i).amount == 0) |
233 if (recipe->yeasts.at(i).amount == 0) |
217 return; // Add only one at a time. |
234 return; // Add only one at a time. |
218 } |
235 } |
219 |
236 |
220 newy.name = "Select one"; |
237 newy.name = "Select one"; |
221 newy.laboratory = ""; |
238 newy.laboratory = ""; |
222 newy.product_id = ""; |
239 newy.product_id = ""; |
223 newy.amount = 0; |
240 newy.amount = 0; |
224 newy.type = 0; |
241 newy.type = YEAST_TYPES_ALE; |
225 newy.form = 0; |
242 newy.form = YEAST_FORMS_LIQUID; |
226 newy.min_temperature = 0; |
243 newy.min_temperature = 0; |
227 newy.max_temperature = 0; |
244 newy.max_temperature = 0; |
228 newy.flocculation = 0; |
245 newy.flocculation = 0; |
229 newy.attenuation = 0; |
246 newy.attenuation = 0; |
230 newy.cells = 0; |
247 newy.cells = 0; |
231 newy.tolerance = 0; |
248 newy.tolerance = 0; |
232 newy.inventory = 0; |
249 newy.inventory = 0; |
233 newy.use = 0; |
250 newy.use = YEAST_USE_PRIMARY; |
234 newy.sta1 = false; |
251 newy.sta1 = false; |
235 newy.bacteria = false; |
252 newy.bacteria = false; |
236 newy.harvest_top = false; |
253 newy.harvest_top = false; |
237 newy.harvest_time = 0; |
254 newy.harvest_time = 0; |
238 newy.pitch_temperature = 0; |
255 newy.pitch_temperature = 0; |
391 |
414 |
392 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).attenuation, 2, 'f', 1, '0')); |
415 item = new QTableWidgetItem(QString("%1").arg(recipe->yeasts.at(recipe->yeasts_row).attenuation, 2, 'f', 1, '0')); |
393 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
416 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
394 ui->yeastsTable->setItem(recipe->yeasts_row, 8, item); |
417 ui->yeastsTable->setItem(recipe->yeasts_row, 8, item); |
395 |
418 |
396 calcYeast(); |
419 if (recipe->yeasts.at(product->yeasts_row).use != YEAST_USE_BOTTLE && recipe->yeasts.at(product->yeasts_row).sta1) { |
|
420 QWidget *pWidget = new QWidget(); |
|
421 QLabel *label = new QLabel; |
|
422 label->setPixmap(QPixmap(":icons/silk/tick.png")); |
|
423 QHBoxLayout *pLayout = new QHBoxLayout(pWidget); |
|
424 pLayout->addWidget(label); |
|
425 pLayout->setAlignment(Qt::AlignCenter); |
|
426 pLayout->setContentsMargins(0, 0, 0, 0); |
|
427 pWidget->setLayout(pLayout); |
|
428 ui->yeastsTable->setCellWidget(product->yeasts_row, 9, pWidget); |
|
429 } else { |
|
430 ui->yeastsTable->removeCellWidget(product->yeasts_row, 9); |
|
431 } |
|
432 |
397 is_changed(); |
433 is_changed(); |
398 } |
434 } |
399 |
435 |
400 |
436 |
401 void EditRecipe::yeast_instock_changed(bool val) |
437 void EditRecipe::yeast_instock_changed(bool val) |
402 { |
438 { |
403 QSqlQuery query; |
439 QSqlQuery query; |
404 |
440 |
|
441 #ifdef DEBUG_YEAST |
405 qDebug() << "yeast_instock_changed()" << recipe->yeasts_row << val; |
442 qDebug() << "yeast_instock_changed()" << recipe->yeasts_row << val; |
|
443 #endif |
406 |
444 |
407 this->yselectEdit->setCurrentIndex(-1); |
445 this->yselectEdit->setCurrentIndex(-1); |
408 this->yselectEdit->clear(); |
446 this->yselectEdit->clear(); |
409 QString sql = "SELECT name,laboratory,product_id,inventory FROM inventory_yeasts "; |
447 QString sql = "SELECT name,laboratory,product_id,inventory FROM inventory_yeasts "; |
410 if (val) |
448 if (val) |