109 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).amount, 4, 'f', 3, '0')); |
117 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).amount, 4, 'f', 3, '0')); |
110 } |
118 } |
111 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
119 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
112 ui->hopsTable->setItem(i, 8, item); |
120 ui->hopsTable->setItem(i, 8, item); |
113 |
121 |
114 if (product->hops.at(i).inventory < 1.0) { |
122 if (block_hop(product->stage, product->hops.at(i).useat)) { |
115 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).inventory * 1000.0, 2, 'f', 1, '0')); |
123 item = new QTableWidgetItem(QString("")); |
116 } else { |
124 } else { |
117 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).inventory, 4, 'f', 3, '0')); |
125 if (product->hops.at(i).inventory < 1.0) { |
118 } |
126 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).inventory * 1000.0, 2, 'f', 1, '0')); |
119 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
127 } else { |
120 if (product->hops.at(i).inventory < product->hops.at(i).amount) |
128 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).inventory, 4, 'f', 3, '0')); |
121 item->setForeground(QBrush(QColor(Qt::red))); |
129 } |
|
130 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
131 if (product->hops.at(i).inventory < product->hops.at(i).amount) |
|
132 item->setForeground(QBrush(QColor(Qt::red))); |
|
133 } |
122 ui->hopsTable->setItem(i, 9, item); |
134 ui->hopsTable->setItem(i, 9, item); |
123 |
135 |
124 /* Add the Delete row button */ |
136 /* Add the Delete row button */ |
125 pWidget = new QWidget(); |
137 if (block_hop(product->stage, product->hops.at(i).useat)) { |
126 QPushButton* btn_dele = new QPushButton(); |
138 item = new QTableWidgetItem(""); |
127 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
139 item->setToolTip(tr("Hop already used")); |
128 btn_dele->setText(tr("Delete")); |
140 ui->hopsTable->setItem(i, 10, item); |
129 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_clicked())); |
141 item = new QTableWidgetItem(""); |
130 pLayout = new QHBoxLayout(pWidget); |
142 item->setToolTip(tr("Hop already used")); |
131 pLayout->addWidget(btn_dele); |
143 ui->hopsTable->setItem(i, 11, item); |
132 pLayout->setContentsMargins(5, 0, 5, 0); |
144 } else { |
133 pWidget->setLayout(pLayout); |
145 pWidget = new QWidget(); |
134 ui->hopsTable->setCellWidget(i, 10, pWidget); |
146 QPushButton* btn_dele = new QPushButton(); |
135 |
147 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
136 pWidget = new QWidget(); |
148 btn_dele->setText(tr("Delete")); |
137 QPushButton* btn_edit = new QPushButton(); |
149 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_clicked())); |
138 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
150 pLayout = new QHBoxLayout(pWidget); |
139 btn_edit->setText(tr("Edit")); |
151 pLayout->addWidget(btn_dele); |
140 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_clicked())); |
152 pLayout->setContentsMargins(5, 0, 5, 0); |
141 pLayout = new QHBoxLayout(pWidget); |
153 pWidget->setLayout(pLayout); |
142 pLayout->addWidget(btn_edit); |
154 ui->hopsTable->setCellWidget(i, 10, pWidget); |
143 pLayout->setContentsMargins(5, 0, 5, 0); |
155 |
144 pWidget->setLayout(pLayout); |
156 pWidget = new QWidget(); |
145 ui->hopsTable->setCellWidget(i, 11, pWidget); |
157 QPushButton* btn_edit = new QPushButton(); |
|
158 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
|
159 btn_edit->setText(tr("Edit")); |
|
160 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_clicked())); |
|
161 pLayout = new QHBoxLayout(pWidget); |
|
162 pLayout->addWidget(btn_edit); |
|
163 pLayout->setContentsMargins(5, 0, 5, 0); |
|
164 pWidget->setLayout(pLayout); |
|
165 ui->hopsTable->setCellWidget(i, 11, pWidget); |
|
166 } |
146 } |
167 } |
147 } |
168 } |
148 |
169 |
149 |
170 |
150 void EditProduct::hop_Flavour_valueChanged(int value) |
171 void EditProduct::hop_Flavour_valueChanged(int value) |