src/InventoryHops.cpp

changeset 155
f671c599f65b
parent 90
2396457a8167
child 290
93820a8ffbff
equal deleted inserted replaced
154:1af9f7b7f317 155:f671c599f65b
16 */ 16 */
17 #include "InventoryHops.h" 17 #include "InventoryHops.h"
18 #include "EditHop.h" 18 #include "EditHop.h"
19 #include "MainWindow.h" 19 #include "MainWindow.h"
20 #include "config.h" 20 #include "config.h"
21 #include "global.h"
21 22
22 23
23 InventoryHops::InventoryHops(QWidget *parent) : QDialog(parent) 24 InventoryHops::InventoryHops(QWidget *parent) : QDialog(parent)
24 { 25 {
25 qDebug() << "InventoryHops start"; 26 qDebug() << "InventoryHops start";
98 99
99 qDebug() << "InventoryHops reload"; 100 qDebug() << "InventoryHops reload";
100 101
101 QSqlQuery query("SELECT * FROM inventory_hops ORDER BY origin,name"); 102 QSqlQuery query("SELECT * FROM inventory_hops ORDER BY origin,name");
102 const QStringList labels({tr("Origin"), tr("Name"), tr("Type"), tr("Form"), tr("Alpha"), tr("Beta"), tr("Cohumulone"), tr("HSI"), tr("Harvest"), tr("Stock"), tr("Edit")}); 103 const QStringList labels({tr("Origin"), tr("Name"), tr("Type"), tr("Form"), tr("Alpha"), tr("Beta"), tr("Cohumulone"), tr("HSI"), tr("Harvest"), tr("Stock"), tr("Edit")});
103 const QStringList types({tr("Bittering"), tr("Aroma"), tr("Both")});
104 const QStringList form({tr("Pellet"), tr("Plug"), tr("Leaf"), tr("Leaf Wet"), tr("Cryo")});
105 104
106 /* origin supplier name type graintype color yield inventory Edit */ 105 /* origin supplier name type graintype color yield inventory Edit */
107 this->tableHops->setColumnCount(11); 106 this->tableHops->setColumnCount(11);
108 this->tableHops->setColumnWidth(0, 130); /* Origin */ 107 this->tableHops->setColumnWidth(0, 130); /* Origin */
109 this->tableHops->setColumnWidth(1, 250); /* Name */ 108 this->tableHops->setColumnWidth(1, 250); /* Name */
125 124
126 query.first(); 125 query.first();
127 for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { 126 for (int ridx = 0 ; ridx < query.size() ; ridx++ ) {
128 this->tableHops->setItem(ridx, 0, new QTableWidgetItem(query.value(12).toString())); /* Origin */ 127 this->tableHops->setItem(ridx, 0, new QTableWidgetItem(query.value(12).toString())); /* Origin */
129 this->tableHops->setItem(ridx, 1, new QTableWidgetItem(query.value(1).toString())); /* Name */ 128 this->tableHops->setItem(ridx, 1, new QTableWidgetItem(query.value(1).toString())); /* Name */
130 this->tableHops->setItem(ridx, 2, new QTableWidgetItem(types[query.value(9).toInt()])); /* Type */ 129 this->tableHops->setItem(ridx, 2, new QTableWidgetItem(hop_types[query.value(9).toInt()])); /* Type */
131 this->tableHops->setItem(ridx, 3, new QTableWidgetItem(form[query.value(10).toInt()])); /* Form */ 130 this->tableHops->setItem(ridx, 3, new QTableWidgetItem(hop_forms[query.value(10).toInt()])); /* Form */
132 w = QString("%1 %").arg(query.value(2).toDouble(), 2, 'f', 1, '0' ); /* Alpha% */ 131 w = QString("%1 %").arg(query.value(2).toDouble(), 2, 'f', 1, '0' ); /* Alpha% */
133 QTableWidgetItem *item = new QTableWidgetItem(w); 132 QTableWidgetItem *item = new QTableWidgetItem(w);
134 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); 133 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
135 this->tableHops->setItem(ridx, 4, item); 134 this->tableHops->setItem(ridx, 4, item);
136 w = QString("%1 %").arg(query.value(3).toDouble(), 2, 'f', 1, '0' ); /* Beta% */ 135 w = QString("%1 %").arg(query.value(3).toDouble(), 2, 'f', 1, '0' ); /* Beta% */

mercurial