src/EditProductTab5.cpp

changeset 305
35ce719998e1
parent 301
fe6346211b5b
child 359
dfbb012c631c
equal deleted inserted replaced
304:aa8d421bfc24 305:35ce719998e1
30 return true; 30 return true;
31 return (D1.amount > D2.amount); 31 return (D1.amount > D2.amount);
32 } 32 }
33 33
34 34
35 bool EditProduct::block_misc(int stage, int use_use)
36 {
37 if (stage > PROD_STAGE_TERTIARY && use_use < MISC_USES_BOTTLING)
38 return true;
39 if (stage > PROD_STAGE_PRIMARY && use_use < MISC_USES_SECONDARY)
40 return true;
41 if (stage > PROD_STAGE_BREW && use_use < MISC_USES_PRIMARY)
42 return true;
43 if (stage > PROD_STAGE_WAIT && use_use < MISC_USES_MASH)
44 return true;
45 return false;
46 }
47
48
35 void EditProduct::refreshMiscs() 49 void EditProduct::refreshMiscs()
36 { 50 {
37 QString w; 51 QString w;
38 QWidget* pWidget; 52 QWidget* pWidget;
39 QHBoxLayout* pLayout; 53 QHBoxLayout* pLayout;
94 else 108 else
95 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).amount * 1000.0, 3, 'f', 2, '0')); 109 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).amount * 1000.0, 3, 'f', 2, '0'));
96 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 110 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
97 ui->miscsTable->setItem(i, 4, item); 111 ui->miscsTable->setItem(i, 4, item);
98 112
99 if (product->miscs.at(i).amount_is_weight) 113 if (block_misc(product->stage, product->miscs.at(i).use_use)) {
100 item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0')); 114 item = new QTableWidgetItem(QString(""));
101 else 115 } else {
102 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0')); 116 if (product->miscs.at(i).amount_is_weight)
103 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 117 item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0'));
104 if (product->miscs.at(i).inventory < product->miscs.at(i).amount) 118 else
105 item->setForeground(QBrush(QColor(Qt::red))); 119 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0'));
120 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
121 if (product->miscs.at(i).inventory < product->miscs.at(i).amount)
122 item->setForeground(QBrush(QColor(Qt::red)));
123 }
106 ui->miscsTable->setItem(i, 5, item); 124 ui->miscsTable->setItem(i, 5, item);
107 125
108 /* 126 /*
109 * Add the Delete and Edit row buttons. 127 * Add the Delete and Edit row buttons.
110 * Not for water agents, these are set on the water tab. 128 * Not for water agents, these are set on the water tab.
129 * And also not if the ingredient has been used.
111 */ 130 */
112 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT) { 131 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT) {
113 ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */ 132 ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */
114 item = new QTableWidgetItem(""); 133 item = new QTableWidgetItem("");
115 item->setToolTip(tr("Edit this from the water tab")); 134 item->setToolTip(tr("Edit this from the water tab"));
116 ui->miscsTable->setItem(i, 6, item); 135 ui->miscsTable->setItem(i, 6, item);
117 ui->miscsTable->removeCellWidget(i, 7); 136 ui->miscsTable->removeCellWidget(i, 7);
118 item = new QTableWidgetItem(""); 137 item = new QTableWidgetItem("");
119 item->setToolTip(tr("Edit this from the water tab")); 138 item->setToolTip(tr("Edit this from the water tab"));
139 ui->miscsTable->setItem(i, 7, item);
140 } else if (block_misc(product->stage, product->miscs.at(i).use_use)) {
141 ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */
142 item = new QTableWidgetItem("");
143 item->setToolTip(tr("Misc already used"));
144 ui->miscsTable->setItem(i, 6, item);
145 ui->miscsTable->removeCellWidget(i, 7);
146 item = new QTableWidgetItem("");
147 item->setToolTip(tr("Misc already used"));
120 ui->miscsTable->setItem(i, 7, item); 148 ui->miscsTable->setItem(i, 7, item);
121 } else { 149 } else {
122 if (ui->miscsTable->item(i, 6)) { 150 if (ui->miscsTable->item(i, 6)) {
123 ui->miscsTable->takeItem(i, 6); /* to remove the old tooltip */ 151 ui->miscsTable->takeItem(i, 6); /* to remove the old tooltip */
124 } 152 }

mercurial