50 const QSignalBlocker blocker6(ui->bs_nahco3Edit); |
50 const QSignalBlocker blocker6(ui->bs_nahco3Edit); |
51 const QSignalBlocker blocker7(ui->bs_caco3Edit); |
51 const QSignalBlocker blocker7(ui->bs_caco3Edit); |
52 const QSignalBlocker blocker8(ui->mw_acidPick); |
52 const QSignalBlocker blocker8(ui->mw_acidPick); |
53 const QSignalBlocker blocker9(ui->mw_acidvolEdit); |
53 const QSignalBlocker blocker9(ui->mw_acidvolEdit); |
54 |
54 |
55 const QStringList labels({tr("Ingredient"), tr("Type"), tr("Use at"), tr("Time"), tr("Amount"), tr("Delete"), tr("Edit") }); |
55 const QStringList labels({tr("Ingredient"), tr("Type"), tr("Use at"), tr("Time"), tr("Amount"), tr("Stock"), tr("Delete"), tr("Edit") }); |
56 |
56 |
57 ui->miscsTable->setColumnCount(7); |
57 ui->miscsTable->setColumnCount(8); |
58 ui->miscsTable->setColumnWidth(0, 300); /* Ingredient */ |
58 ui->miscsTable->setColumnWidth(0, 250); /* Ingredient */ |
59 ui->miscsTable->setColumnWidth(1, 100); /* Type */ |
59 ui->miscsTable->setColumnWidth(1, 90); /* Type */ |
60 ui->miscsTable->setColumnWidth(2, 100); /* Added */ |
60 ui->miscsTable->setColumnWidth(2, 90); /* Added */ |
61 ui->miscsTable->setColumnWidth(3, 75); /* Time */ |
61 ui->miscsTable->setColumnWidth(3, 75); /* Time */ |
62 ui->miscsTable->setColumnWidth(4, 90); /* Amount */ |
62 ui->miscsTable->setColumnWidth(4, 80); /* Amount */ |
63 ui->miscsTable->setColumnWidth(5, 80); /* Delete */ |
63 ui->miscsTable->setColumnWidth(5, 80); /* Stock */ |
64 ui->miscsTable->setColumnWidth(6, 80); /* Edit */ |
64 ui->miscsTable->setColumnWidth(6, 80); /* Delete */ |
|
65 ui->miscsTable->setColumnWidth(7, 80); /* Edit */ |
65 ui->miscsTable->setHorizontalHeaderLabels(labels); |
66 ui->miscsTable->setHorizontalHeaderLabels(labels); |
66 ui->miscsTable->verticalHeader()->hide(); |
67 ui->miscsTable->verticalHeader()->hide(); |
67 ui->miscsTable->setRowCount(product->miscs.size()); |
68 ui->miscsTable->setRowCount(product->miscs.size()); |
68 |
69 |
69 for (int i = 0; i < product->miscs.size(); i++) { |
70 for (int i = 0; i < product->miscs.size(); i++) { |
93 else |
94 else |
94 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).m_amount * 1000.0, 3, 'f', 2, '0')); |
95 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).m_amount * 1000.0, 3, 'f', 2, '0')); |
95 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
96 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
96 ui->miscsTable->setItem(i, 4, item); |
97 ui->miscsTable->setItem(i, 4, item); |
97 |
98 |
|
99 if (product->miscs.at(i).m_amount_is_weight) |
|
100 item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(i).m_inventory * 1000.0, 3, 'f', 2, '0')); |
|
101 else |
|
102 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).m_inventory * 1000.0, 3, 'f', 2, '0')); |
|
103 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
104 ui->miscsTable->setItem(i, 5, item); |
|
105 |
98 /* |
106 /* |
99 * Add the Delete and Edit row buttons. |
107 * Add the Delete and Edit row buttons. |
100 * Not for water agents, these are set on the water tab. |
108 * Not for water agents, these are set on the water tab. |
101 */ |
109 */ |
102 if (product->miscs.at(i).m_type == 4) { |
110 if (product->miscs.at(i).m_type == 4) { |
103 ui->miscsTable->removeCellWidget(i, 5); |
|
104 ui->miscsTable->removeCellWidget(i, 6); |
111 ui->miscsTable->removeCellWidget(i, 6); |
|
112 ui->miscsTable->removeCellWidget(i, 7); |
105 } else { |
113 } else { |
106 pWidget = new QWidget(); |
114 pWidget = new QWidget(); |
107 QPushButton* btn_dele = new QPushButton(); |
115 QPushButton* btn_dele = new QPushButton(); |
108 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 */ |
109 btn_dele->setText(tr("Delete")); |
117 btn_dele->setText(tr("Delete")); |
110 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMiscRow_clicked())); |
118 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMiscRow_clicked())); |
111 pLayout = new QHBoxLayout(pWidget); |
119 pLayout = new QHBoxLayout(pWidget); |
112 pLayout->addWidget(btn_dele); |
120 pLayout->addWidget(btn_dele); |
113 pLayout->setContentsMargins(5, 0, 5, 0); |
121 pLayout->setContentsMargins(5, 0, 5, 0); |
114 pWidget->setLayout(pLayout); |
122 pWidget->setLayout(pLayout); |
115 ui->miscsTable->setCellWidget(i, 5, pWidget); |
123 ui->miscsTable->setCellWidget(i, 6, pWidget); |
116 |
124 |
117 pWidget = new QWidget(); |
125 pWidget = new QWidget(); |
118 QPushButton* btn_edit = new QPushButton(); |
126 QPushButton* btn_edit = new QPushButton(); |
119 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 */ |
120 btn_edit->setText(tr("Edit")); |
128 btn_edit->setText(tr("Edit")); |
121 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editMiscRow_clicked())); |
129 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editMiscRow_clicked())); |
122 pLayout = new QHBoxLayout(pWidget); |
130 pLayout = new QHBoxLayout(pWidget); |
123 pLayout->addWidget(btn_edit); |
131 pLayout->addWidget(btn_edit); |
124 pLayout->setContentsMargins(5, 0, 5, 0); |
132 pLayout->setContentsMargins(5, 0, 5, 0); |
125 pWidget->setLayout(pLayout); |
133 pWidget->setLayout(pLayout); |
126 ui->miscsTable->setCellWidget(i, 6, pWidget); |
134 ui->miscsTable->setCellWidget(i, 7, pWidget); |
127 } |
135 } |
128 |
136 |
129 /* |
137 /* |
130 * Update the water agents. |
138 * Update the water agents. |
131 */ |
139 */ |