src/EditRecipeTab6.cpp

changeset 144
c4b107bf153a
parent 128
0f4eee875ea6
child 145
fd4f0de86fd9
equal deleted inserted replaced
143:8414844c9f8b 144:c4b107bf153a
18 */ 18 */
19 19
20 20
21 void EditRecipe::refreshMashs() 21 void EditRecipe::refreshMashs()
22 { 22 {
23 QString w;
24 QWidget* pWidget;
25 QHBoxLayout* pLayout;
26 QTableWidgetItem *item;
27
28 qDebug() << "refreshYeasts" << recipe->yeasts.size();
29 std::sort(recipe->yeasts.begin(), recipe->yeasts.end(), yeast_sort_test);
30
31 /*
32 * During filling the table turn off the cellChanged signal because every cell that is filled
33 * triggers the cellChanged signal. The QTableWidget has no better signal to use.
34 */
35 this->ignoreChanges = true;
36
37 const QStringList labels({tr("Step name"), tr("Type"), tr("Start"), tr("End"), tr("Rest"), tr("Ramp"),
38 tr("Inf/dec"), tr("Inf/dec"), tr("Volume"), tr("W/G ratio"), "", "", tr("Delete"), tr("Edit") });
39
40 ui->mashsTable->setColumnCount(14);
41 ui->mashsTable->setColumnWidth(0, 189); /* Step name */
42 ui->mashsTable->setColumnWidth(1, 100); /* Type */
43 ui->mashsTable->setColumnWidth(2, 70); /* Start temp */
44 ui->mashsTable->setColumnWidth(3, 70); /* End temp */
45 ui->mashsTable->setColumnWidth(4, 70); /* Rest time */
46 ui->mashsTable->setColumnWidth(5, 70); /* Ramp time */
47 ui->mashsTable->setColumnWidth(6, 70); /* Infusion vol */
48 ui->mashsTable->setColumnWidth(7, 70); /* Infusion tmp */
49 ui->mashsTable->setColumnWidth(8, 70); /* Volume */
50 ui->mashsTable->setColumnWidth(9, 80); /* W/G ratio */
51 ui->mashsTable->setColumnWidth(10, 30); /* Up button */
52 ui->mashsTable->setColumnWidth(11, 30); /* Down button */
53 ui->mashsTable->setColumnWidth(12, 80); /* Delete */
54 ui->mashsTable->setColumnWidth(13, 80); /* Edit */
55 ui->mashsTable->setHorizontalHeaderLabels(labels);
56 ui->mashsTable->verticalHeader()->hide();
57 ui->mashsTable->setRowCount(recipe->mashs.size());
58
59 for (int i = 0; i < recipe->mashs.size(); i++) {
60
61 ui->mashsTable->setItem(i, 0, new QTableWidgetItem(recipe->mashs.at(i).step_name));
62
63 item = new QTableWidgetItem(step_types[recipe->mashs.at(i).step_type]);
64 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
65 ui->mashsTable->setItem(i, 1, item);
66
67 item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).step_temp, 2, 'f', 1, '0'));
68 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
69 ui->mashsTable->setItem(i, 2, item);
70
71 item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).end_temp, 2, 'f', 1, '0'));
72 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
73 ui->mashsTable->setItem(i, 3, item);
74
75 item = new QTableWidgetItem(QString("%1 min").arg(recipe->mashs.at(i).step_time, 1, 'f', 0, '0'));
76 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
77 ui->mashsTable->setItem(i, 4, item);
78
79 item = new QTableWidgetItem(QString("%1 min").arg(recipe->mashs.at(i).ramp_time, 1, 'f', 0, '0'));
80 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
81 ui->mashsTable->setItem(i, 5, item);
82
83 if (recipe->mashs.at(i).step_infuse_amount) {
84 item = new QTableWidgetItem(QString("%1 L").arg(recipe->mashs.at(i).step_infuse_amount, 2, 'f', 1, '0'));
85 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
86 ui->mashsTable->setItem(i, 6, item);
87 item = new QTableWidgetItem(QString("%1 °C").arg(recipe->mashs.at(i).step_infuse_temp, 3, 'f', 2, '0'));
88 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
89 ui->mashsTable->setItem(i, 7, item);
90 } else {
91 ui->mashsTable->removeCellWidget(i, 6);
92 ui->mashsTable->removeCellWidget(i, 7);
93 }
94
95 item = new QTableWidgetItem(QString("%1 L").arg(recipe->mashs.at(i).step_volume, 2, 'f', 1, '0'));
96 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
97 ui->mashsTable->setItem(i, 8, item);
98
99 item = new QTableWidgetItem(QString("%1 L/kg").arg(recipe->mashs.at(i).step_wg_ratio, 3, 'f', 2, '0'));
100 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
101 ui->mashsTable->setItem(i, 9, item);
102
103 pWidget = new QWidget();
104 QPushButton* btn_up = new QPushButton();
105 btn_up->setObjectName(QString("%1").arg(i)); /* Send row with the button */
106 btn_up->setText(tr("U"));
107 connect(btn_up, SIGNAL(clicked()), this, SLOT(upMashRow_clicked()));
108 pLayout = new QHBoxLayout(pWidget);
109 pLayout->addWidget(btn_up);
110 pLayout->setContentsMargins(5, 0, 5, 0);
111 pWidget->setLayout(pLayout);
112 ui->mashsTable->setCellWidget(i, 10, pWidget);
113
114 pWidget = new QWidget();
115 QPushButton* btn_down = new QPushButton();
116 btn_down->setObjectName(QString("%1").arg(i)); /* Send row with the button */
117 btn_down->setText(tr("D"));
118 connect(btn_down, SIGNAL(clicked()), this, SLOT(downMashRow_clicked()));
119 pLayout = new QHBoxLayout(pWidget);
120 pLayout->addWidget(btn_down);
121 pLayout->setContentsMargins(5, 0, 5, 0);
122 pWidget->setLayout(pLayout);
123 ui->mashsTable->setCellWidget(i, 11, pWidget);
124
125 pWidget = new QWidget();
126 QPushButton* btn_dele = new QPushButton();
127 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
128 btn_dele->setText(tr("Delete"));
129 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMashRow_clicked()));
130 pLayout = new QHBoxLayout(pWidget);
131 pLayout->addWidget(btn_dele);
132 pLayout->setContentsMargins(5, 0, 5, 0);
133 pWidget->setLayout(pLayout);
134 ui->mashsTable->setCellWidget(i, 12, pWidget);
135
136 pWidget = new QWidget();
137 QPushButton* btn_edit = new QPushButton();
138 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
139 btn_edit->setText(tr("Edit"));
140 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editMashRow_clicked()));
141 pLayout = new QHBoxLayout(pWidget);
142 pLayout->addWidget(btn_edit);
143 pLayout->setContentsMargins(5, 0, 5, 0);
144 pWidget->setLayout(pLayout);
145 ui->mashsTable->setCellWidget(i, 13, pWidget);
146 }
23 } 147 }
24 148
25 149
150 void EditRecipe::addMashRow_clicked()
151 {
152 }
153
154
155 void EditRecipe::deleteMashRow_clicked()
156 {
157 }
158
159
160 void EditRecipe::upMashRow_clicked()
161 {
162 }
163
164
165 void EditRecipe::downMashRow_clicked()
166 {
167 }
168
169
170 void EditRecipe::editMashRow_clicked()
171 {
172 }
173
174

mercurial