14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU General Public License |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 */ |
16 */ |
17 #include "InventoryYeasts.h" |
17 #include "InventoryYeasts.h" |
18 #include "EditYeast.h" |
18 #include "EditYeast.h" |
19 #include "../ui/ui_InventoryYeasts.h" |
19 #include "MainWindow.h" |
20 #include "config.h" |
20 #include "config.h" |
21 #include "bmsapp.h" |
21 #include "bmsapp.h" |
22 |
22 |
23 |
23 |
24 InventoryYeasts::InventoryYeasts(QWidget *parent) : QDialog(parent), ui(new Ui::InventoryYeasts) |
24 InventoryYeasts::InventoryYeasts(QWidget *parent) : QDialog(parent) |
25 { |
25 { |
26 qDebug() << "InventoryYeasts start"; |
26 qDebug() << "InventoryYeasts start"; |
27 |
27 |
28 ui->setupUi(this); |
28 gridLayout = new QGridLayout(this); |
|
29 gridLayout->setObjectName(QString::fromUtf8("gridLayout")); |
|
30 tableYeasts = new QTableWidget(this); |
|
31 tableYeasts->setObjectName(QString::fromUtf8("tableYeasts")); |
|
32 tableYeasts->setEnabled(true); |
|
33 QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
|
34 sizePolicy.setHorizontalStretch(0); |
|
35 sizePolicy.setVerticalStretch(0); |
|
36 tableYeasts->setSizePolicy(sizePolicy); |
|
37 tableYeasts->setMinimumSize(QSize(1094, 0)); |
|
38 gridLayout->addWidget(tableYeasts, 0, 0, 1, 1); |
|
39 |
|
40 groupBox = new QGroupBox(this); |
|
41 groupBox->setObjectName(QString::fromUtf8("groupBox")); |
|
42 groupBox->setEnabled(true); |
|
43 groupBox->setFlat(false); |
|
44 horizontalLayout = new QHBoxLayout(groupBox); |
|
45 horizontalLayout->setSpacing(6); |
|
46 horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); |
|
47 horizontalLayout->setContentsMargins(0, 0, 0, 0); |
|
48 |
|
49 quitButton = new QPushButton(groupBox); |
|
50 quitButton->setObjectName(QString::fromUtf8("quitButton")); |
|
51 quitButton->setMinimumSize(QSize(80, 24)); |
|
52 quitButton->setText(tr("Quit")); |
|
53 QIcon icon; |
|
54 icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); |
|
55 quitButton->setIcon(icon); |
|
56 horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft); |
|
57 |
|
58 exportButton = new QPushButton(groupBox); |
|
59 exportButton->setObjectName(QString::fromUtf8("exportButton")); |
|
60 exportButton->setMinimumSize(QSize(80, 24)); |
|
61 exportButton->setText(tr("Export")); |
|
62 QIcon icon1; |
|
63 icon1.addFile(QString::fromUtf8(":/icons/silk/database_save.png"), QSize(), QIcon::Normal, QIcon::Off); |
|
64 exportButton->setIcon(icon1); |
|
65 horizontalLayout->addWidget(exportButton, 0, Qt::AlignRight); |
|
66 |
|
67 importButton = new QPushButton(groupBox); |
|
68 importButton->setObjectName(QString::fromUtf8("importButton")); |
|
69 importButton->setMinimumSize(QSize(80, 24)); |
|
70 importButton->setText(tr("Import")); |
|
71 QIcon icon2; |
|
72 icon2.addFile(QString::fromUtf8(":/icons/silk/database_add.png"), QSize(), QIcon::Normal, QIcon::Off); |
|
73 importButton->setIcon(icon2); |
|
74 horizontalLayout->addWidget(importButton, 0, Qt::AlignRight); |
|
75 |
|
76 insertButton = new QPushButton(groupBox); |
|
77 insertButton->setObjectName(QString::fromUtf8("insertButton")); |
|
78 insertButton->setMinimumSize(QSize(80, 24)); |
|
79 insertButton->setText(tr("New")); |
|
80 QIcon icon3; |
|
81 icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); |
|
82 insertButton->setIcon(icon3); |
|
83 horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); |
|
84 gridLayout->addWidget(groupBox, 1, 0, 1, 1); |
|
85 |
|
86 connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventoryYeasts())); |
|
87 connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); |
|
88 connect(exportButton, SIGNAL(clicked()), this, SLOT(on_exportButton_clicked())); |
|
89 // connect(importButton, SIGNAL(clicked()), this, SLOT(on_importButton_clicked())); |
29 emit refreshTable(); |
90 emit refreshTable(); |
30 |
|
31 setWindowTitle( QString("BMSapp - %1 - Inventory Yeasts").arg(VERSIONSTRING) ); |
|
32 } |
91 } |
33 |
92 |
34 |
93 |
35 void InventoryYeasts::refreshTable() |
94 void InventoryYeasts::refreshTable() |
36 { |
95 { |
45 const QStringList labels({tr("Laboratory"), tr("Product id"), tr("Name"), tr("Type"), tr("Form"), tr("SVG %"), tr("Tol %"), tr("POF+"), tr("STA1"), tr("Stock"), tr("Edit")}); |
104 const QStringList labels({tr("Laboratory"), tr("Product id"), tr("Name"), tr("Type"), tr("Form"), tr("SVG %"), tr("Tol %"), tr("POF+"), tr("STA1"), tr("Stock"), tr("Edit")}); |
46 const QStringList types({tr("Lager"), tr("Ale"), tr("Wheat"), tr("Wine"), tr("Champagne"), tr("Brett"), tr("Kveik"), tr("Hybrid")}); |
105 const QStringList types({tr("Lager"), tr("Ale"), tr("Wheat"), tr("Wine"), tr("Champagne"), tr("Brett"), tr("Kveik"), tr("Hybrid")}); |
47 const QStringList form({tr("Liquid"), tr("Dry"), tr("Slant"), tr("Culture"), tr("Frozen"), tr("Bottle"), tr("Dried")}); |
106 const QStringList form({tr("Liquid"), tr("Dry"), tr("Slant"), tr("Culture"), tr("Frozen"), tr("Bottle"), tr("Dried")}); |
48 |
107 |
49 /* origin supplier name type graintype color yield inventory Edit */ |
108 /* origin supplier name type graintype color yield inventory Edit */ |
50 ui->tableYeasts->setColumnCount(11); |
109 this->tableYeasts->setColumnCount(11); |
51 ui->tableYeasts->setColumnWidth(0, 120); /* Laboratory */ |
110 this->tableYeasts->setColumnWidth(0, 120); /* Laboratory */ |
52 ui->tableYeasts->setColumnWidth(1, 120); /* Product ID */ |
111 this->tableYeasts->setColumnWidth(1, 120); /* Product ID */ |
53 ui->tableYeasts->setColumnWidth(2, 250); /* Name */ |
112 this->tableYeasts->setColumnWidth(2, 250); /* Name */ |
54 ui->tableYeasts->setColumnWidth(3, 70); /* Type */ |
113 this->tableYeasts->setColumnWidth(3, 70); /* Type */ |
55 ui->tableYeasts->setColumnWidth(4, 70); /* Form */ |
114 this->tableYeasts->setColumnWidth(4, 70); /* Form */ |
56 ui->tableYeasts->setColumnWidth(5, 80); /* SVG */ |
115 this->tableYeasts->setColumnWidth(5, 80); /* SVG */ |
57 ui->tableYeasts->setColumnWidth(6, 80); /* Tolerance */ |
116 this->tableYeasts->setColumnWidth(6, 80); /* Tolerance */ |
58 ui->tableYeasts->setColumnWidth(7, 60); /* POF+ */ |
117 this->tableYeasts->setColumnWidth(7, 60); /* POF+ */ |
59 ui->tableYeasts->setColumnWidth(8, 60); /* STA1 */ |
118 this->tableYeasts->setColumnWidth(8, 60); /* STA1 */ |
60 ui->tableYeasts->setColumnWidth(9, 80); /* Stock */ |
119 this->tableYeasts->setColumnWidth(9, 80); /* Stock */ |
61 ui->tableYeasts->setColumnWidth(10, 80); /* Edit button */ |
120 this->tableYeasts->setColumnWidth(10, 80); /* Edit button */ |
62 ui->tableYeasts->setRowCount(query.size()); |
121 this->tableYeasts->setRowCount(query.size()); |
63 ui->tableYeasts->setHorizontalHeaderLabels(labels); |
122 this->tableYeasts->setHorizontalHeaderLabels(labels); |
64 ui->tableYeasts->verticalHeader()->hide(); |
123 this->tableYeasts->verticalHeader()->hide(); |
65 ui->tableYeasts->setFixedSize(1070 + 24, 640); /* Even if this is too large, it works */ |
|
66 |
124 |
67 QTableWidgetItem *rightitem = new QTableWidgetItem(); |
125 QTableWidgetItem *rightitem = new QTableWidgetItem(); |
68 rightitem->setTextAlignment(Qt::AlignRight); |
126 rightitem->setTextAlignment(Qt::AlignRight); |
69 |
127 |
70 query.first(); |
128 query.first(); |
71 for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { |
129 for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { |
72 ui->tableYeasts->setItem(ridx, 0, new QTableWidgetItem(query.value(4).toString())); /* Laboratory */ |
130 this->tableYeasts->setItem(ridx, 0, new QTableWidgetItem(query.value(4).toString())); /* Laboratory */ |
73 ui->tableYeasts->setItem(ridx, 1, new QTableWidgetItem(query.value(5).toString())); /* Product id */ |
131 this->tableYeasts->setItem(ridx, 1, new QTableWidgetItem(query.value(5).toString())); /* Product id */ |
74 ui->tableYeasts->setItem(ridx, 2, new QTableWidgetItem(query.value(1).toString())); /* Name */ |
132 this->tableYeasts->setItem(ridx, 2, new QTableWidgetItem(query.value(1).toString())); /* Name */ |
75 ui->tableYeasts->setItem(ridx, 3, new QTableWidgetItem(types[query.value(2).toInt()])); /* Type */ |
133 this->tableYeasts->setItem(ridx, 3, new QTableWidgetItem(types[query.value(2).toInt()])); /* Type */ |
76 ui->tableYeasts->setItem(ridx, 4, new QTableWidgetItem(form[query.value(3).toInt()])); /* Form */ |
134 this->tableYeasts->setItem(ridx, 4, new QTableWidgetItem(form[query.value(3).toInt()])); /* Form */ |
77 w = QString("%1 %").arg(query.value(9).toDouble(), 2, 'f', 1, '0' ); /* Attenuation% */ |
135 w = QString("%1 %").arg(query.value(9).toDouble(), 2, 'f', 1, '0' ); /* Attenuation% */ |
78 QTableWidgetItem *item = new QTableWidgetItem(w); |
136 QTableWidgetItem *item = new QTableWidgetItem(w); |
79 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
137 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
80 ui->tableYeasts->setItem(ridx, 5, item); |
138 this->tableYeasts->setItem(ridx, 5, item); |
81 w = QString(""); |
139 w = QString(""); |
82 if (query.value(10).toDouble() > 0) |
140 if (query.value(10).toDouble() > 0) |
83 w = QString("%1 %").arg(query.value(10).toDouble(), 2, 'f', 1, '0' ); /* Alcohol% */ |
141 w = QString("%1 %").arg(query.value(10).toDouble(), 2, 'f', 1, '0' ); /* Alcohol% */ |
84 item = new QTableWidgetItem(w); |
142 item = new QTableWidgetItem(w); |
85 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
143 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
86 ui->tableYeasts->setItem(ridx, 6, item); |
144 this->tableYeasts->setItem(ridx, 6, item); |
87 |
145 |
88 if (query.value(24).toInt()) { |
146 if (query.value(24).toInt()) { |
89 pWidget = new QWidget(); |
147 pWidget = new QWidget(); |
90 label = new QLabel; |
148 label = new QLabel; |
91 label->setPixmap(QPixmap(":icons/silk/tick.png")); |
149 label->setPixmap(QPixmap(":icons/silk/tick.png")); |
92 pLayout = new QHBoxLayout(pWidget); |
150 pLayout = new QHBoxLayout(pWidget); |
93 pLayout->addWidget(label); |
151 pLayout->addWidget(label); |
94 pLayout->setAlignment(Qt::AlignCenter); |
152 pLayout->setAlignment(Qt::AlignCenter); |
95 pLayout->setContentsMargins(0, 0, 0, 0); |
153 pLayout->setContentsMargins(0, 0, 0, 0); |
96 pWidget->setLayout(pLayout); |
154 pWidget->setLayout(pLayout); |
97 ui->tableYeasts->setCellWidget(ridx, 7, pWidget); |
155 this->tableYeasts->setCellWidget(ridx, 7, pWidget); |
98 } else { |
156 } else { |
99 ui->tableYeasts->removeCellWidget(ridx, 7); |
157 this->tableYeasts->removeCellWidget(ridx, 7); |
100 } |
158 } |
101 if (query.value(19).toInt()) { |
159 if (query.value(19).toInt()) { |
102 pWidget = new QWidget(); |
160 pWidget = new QWidget(); |
103 label = new QLabel; |
161 label = new QLabel; |
104 label->setPixmap(QPixmap(":icons/silk/tick.png")); |
162 label->setPixmap(QPixmap(":icons/silk/tick.png")); |
105 pLayout = new QHBoxLayout(pWidget); |
163 pLayout = new QHBoxLayout(pWidget); |
106 pLayout->addWidget(label); |
164 pLayout->addWidget(label); |
107 pLayout->setAlignment(Qt::AlignCenter); |
165 pLayout->setAlignment(Qt::AlignCenter); |
108 pLayout->setContentsMargins(0, 0, 0, 0); |
166 pLayout->setContentsMargins(0, 0, 0, 0); |
109 pWidget->setLayout(pLayout); |
167 pWidget->setLayout(pLayout); |
110 ui->tableYeasts->setCellWidget(ridx, 8, pWidget); |
168 this->tableYeasts->setCellWidget(ridx, 8, pWidget); |
111 } else { |
169 } else { |
112 ui->tableYeasts->removeCellWidget(ridx, 8); |
170 this->tableYeasts->removeCellWidget(ridx, 8); |
113 } |
171 } |
114 |
172 |
115 w = QString(""); |
173 w = QString(""); |
116 if (query.value(14).toDouble() > 0) { |
174 if (query.value(14).toDouble() > 0) { |
117 if (query.value(3).toInt() == 0 && query.value(14).toDouble() > 1) { /* Liquid yeast, multiple packs */ |
175 if (query.value(3).toInt() == 0 && query.value(14).toDouble() > 1) { /* Liquid yeast, multiple packs */ |