src/EditProductTab4.cpp

changeset 305
35ce719998e1
parent 301
fe6346211b5b
child 340
b9af88bfe972
equal deleted inserted replaced
304:aa8d421bfc24 305:35ce719998e1
33 /* Finally consider the amounts */ 33 /* Finally consider the amounts */
34 return (D1.amount > D2.amount); 34 return (D1.amount > D2.amount);
35 } 35 }
36 36
37 37
38 bool EditProduct::block_hop(int stage, int useat)
39 {
40 if (stage > PROD_STAGE_BREW && useat < HOP_USEAT_DRY_HOP)
41 return true;
42 return false;
43 }
44
45
38 void EditProduct::refreshHops() 46 void EditProduct::refreshHops()
39 { 47 {
40 QString w; 48 QString w;
41 QWidget* pWidget; 49 QWidget* pWidget;
42 QHBoxLayout* pLayout; 50 QHBoxLayout* pLayout;
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)

mercurial