44 |
44 |
45 qDebug() << "refreshHops" << product->hops.size(); |
45 qDebug() << "refreshHops" << product->hops.size(); |
46 std::sort(product->hops.begin(), product->hops.end(), hop_sort_test); |
46 std::sort(product->hops.begin(), product->hops.end(), hop_sort_test); |
47 |
47 |
48 const QStringList labels({tr("Origin"), tr("Hop"), tr("Type"), tr("Form"), tr("Alpha"), tr("Use at"), tr("Time"), |
48 const QStringList labels({tr("Origin"), tr("Hop"), tr("Type"), tr("Form"), tr("Alpha"), tr("Use at"), tr("Time"), |
49 tr("IBU"), tr("Amount"), tr("Delete"), tr("Edit") }); |
49 tr("IBU"), tr("Amount"), tr("Stock"), tr("Delete"), tr("Edit") }); |
50 |
50 |
51 ui->hopsTable->setColumnCount(11); |
51 ui->hopsTable->setColumnCount(12); |
52 ui->hopsTable->setColumnWidth(0, 150); /* Origin */ |
52 ui->hopsTable->setColumnWidth(0, 130); /* Origin */ |
53 ui->hopsTable->setColumnWidth(1, 225); /* Hop */ |
53 ui->hopsTable->setColumnWidth(1, 225); /* Hop */ |
54 ui->hopsTable->setColumnWidth(2, 84); /* Type */ |
54 ui->hopsTable->setColumnWidth(2, 74); /* Type */ |
55 ui->hopsTable->setColumnWidth(3, 84); /* Form */ |
55 ui->hopsTable->setColumnWidth(3, 84); /* Form */ |
56 ui->hopsTable->setColumnWidth(4, 75); /* Alpha% */ |
56 ui->hopsTable->setColumnWidth(4, 55); /* Alpha% */ |
57 ui->hopsTable->setColumnWidth(5, 75); /* Added */ |
57 ui->hopsTable->setColumnWidth(5, 75); /* Added */ |
58 ui->hopsTable->setColumnWidth(6, 75); /* Time */ |
58 ui->hopsTable->setColumnWidth(6, 65); /* Time */ |
59 ui->hopsTable->setColumnWidth(7, 60); /* IBU */ |
59 ui->hopsTable->setColumnWidth(7, 50); /* IBU */ |
60 ui->hopsTable->setColumnWidth(8, 90); /* Amount */ |
60 ui->hopsTable->setColumnWidth(8, 80); /* Amount */ |
61 ui->hopsTable->setColumnWidth(9, 80); /* Delete */ |
61 ui->hopsTable->setColumnWidth(9, 80); /* Stock */ |
62 ui->hopsTable->setColumnWidth(10, 80); /* Edit */ |
62 ui->hopsTable->setColumnWidth(10, 80); /* Delete */ |
|
63 ui->hopsTable->setColumnWidth(11, 80); /* Edit */ |
63 ui->hopsTable->setHorizontalHeaderLabels(labels); |
64 ui->hopsTable->setHorizontalHeaderLabels(labels); |
64 ui->hopsTable->verticalHeader()->hide(); |
65 ui->hopsTable->verticalHeader()->hide(); |
65 ui->hopsTable->setRowCount(product->hops.size()); |
66 ui->hopsTable->setRowCount(product->hops.size()); |
66 |
67 |
67 for (int i = 0; i < product->hops.size(); i++) { |
68 for (int i = 0; i < product->hops.size(); i++) { |
106 } else { |
107 } else { |
107 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).h_amount, 4, 'f', 3, '0')); |
108 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).h_amount, 4, 'f', 3, '0')); |
108 } |
109 } |
109 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
110 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
110 ui->hopsTable->setItem(i, 8, item); |
111 ui->hopsTable->setItem(i, 8, item); |
|
112 |
|
113 if (product->hops.at(i).h_inventory < 1.0) { |
|
114 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).h_inventory * 1000.0, 2, 'f', 1, '0')); |
|
115 } else { |
|
116 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).h_inventory, 4, 'f', 3, '0')); |
|
117 } |
|
118 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
|
119 ui->hopsTable->setItem(i, 9, item); |
111 |
120 |
112 /* Add the Delete row button */ |
121 /* Add the Delete row button */ |
113 pWidget = new QWidget(); |
122 pWidget = new QWidget(); |
114 QPushButton* btn_dele = new QPushButton(); |
123 QPushButton* btn_dele = new QPushButton(); |
115 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
124 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
117 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_clicked())); |
126 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_clicked())); |
118 pLayout = new QHBoxLayout(pWidget); |
127 pLayout = new QHBoxLayout(pWidget); |
119 pLayout->addWidget(btn_dele); |
128 pLayout->addWidget(btn_dele); |
120 pLayout->setContentsMargins(5, 0, 5, 0); |
129 pLayout->setContentsMargins(5, 0, 5, 0); |
121 pWidget->setLayout(pLayout); |
130 pWidget->setLayout(pLayout); |
122 ui->hopsTable->setCellWidget(i, 9, pWidget); |
131 ui->hopsTable->setCellWidget(i, 10, pWidget); |
123 |
132 |
124 pWidget = new QWidget(); |
133 pWidget = new QWidget(); |
125 QPushButton* btn_edit = new QPushButton(); |
134 QPushButton* btn_edit = new QPushButton(); |
126 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
135 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
127 btn_edit->setText(tr("Edit")); |
136 btn_edit->setText(tr("Edit")); |
128 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_clicked())); |
137 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_clicked())); |
129 pLayout = new QHBoxLayout(pWidget); |
138 pLayout = new QHBoxLayout(pWidget); |
130 pLayout->addWidget(btn_edit); |
139 pLayout->addWidget(btn_edit); |
131 pLayout->setContentsMargins(5, 0, 5, 0); |
140 pLayout->setContentsMargins(5, 0, 5, 0); |
132 pWidget->setLayout(pLayout); |
141 pWidget->setLayout(pLayout); |
133 ui->hopsTable->setCellWidget(i, 10, pWidget); |
142 ui->hopsTable->setCellWidget(i, 11, pWidget); |
134 } |
143 } |
135 } |
144 } |
136 |
145 |
137 |
146 |
138 void EditProduct::hop_Flavour_valueChanged(int value) |
147 void EditProduct::hop_Flavour_valueChanged(int value) |