src/EditRecipeTab3.cpp

changeset 139
f947c6988e91
parent 131
0115b97e8c39
child 150
fd568cc1dd0e
equal deleted inserted replaced
138:1189d072f346 139:f947c6988e91
118 /* Add the Delete row button */ 118 /* Add the Delete row button */
119 pWidget = new QWidget(); 119 pWidget = new QWidget();
120 QPushButton* btn_dele = new QPushButton(); 120 QPushButton* btn_dele = new QPushButton();
121 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ 121 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
122 btn_dele->setText(tr("Delete")); 122 btn_dele->setText(tr("Delete"));
123 connect(btn_dele, SIGNAL(clicked()), this, SLOT(on_deleteHopRow_clicked())); 123 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_clicked()));
124 pLayout = new QHBoxLayout(pWidget); 124 pLayout = new QHBoxLayout(pWidget);
125 pLayout->addWidget(btn_dele); 125 pLayout->addWidget(btn_dele);
126 pLayout->setContentsMargins(5, 0, 5, 0); 126 pLayout->setContentsMargins(5, 0, 5, 0);
127 pWidget->setLayout(pLayout); 127 pWidget->setLayout(pLayout);
128 ui->hopsTable->setCellWidget(i, 9, pWidget); 128 ui->hopsTable->setCellWidget(i, 9, pWidget);
129 129
130 pWidget = new QWidget(); 130 pWidget = new QWidget();
131 QPushButton* btn_edit = new QPushButton(); 131 QPushButton* btn_edit = new QPushButton();
132 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ 132 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
133 btn_edit->setText(tr("Edit")); 133 btn_edit->setText(tr("Edit"));
134 connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editHopRow_clicked())); 134 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_clicked()));
135 pLayout = new QHBoxLayout(pWidget); 135 pLayout = new QHBoxLayout(pWidget);
136 pLayout->addWidget(btn_edit); 136 pLayout->addWidget(btn_edit);
137 pLayout->setContentsMargins(5, 0, 5, 0); 137 pLayout->setContentsMargins(5, 0, 5, 0);
138 pWidget->setLayout(pLayout); 138 pWidget->setLayout(pLayout);
139 ui->hopsTable->setCellWidget(i, 10, pWidget); 139 ui->hopsTable->setCellWidget(i, 10, pWidget);
140 } 140 }
141 this->ignoreChanges = false; 141 this->ignoreChanges = false;
142 } 142 }
143 143
144 144
145 void EditRecipe::on_Flavour_valueChanged(int value) 145 void EditRecipe::hop_Flavour_valueChanged(int value)
146 { 146 {
147 if (value < 20) { 147 if (value < 20) {
148 ui->hop_tasteShow->setStyleSheet(bar_20); 148 ui->hop_tasteShow->setStyleSheet(bar_20);
149 ui->hop_tasteShow->setFormat(tr("Very low")); 149 ui->hop_tasteShow->setFormat(tr("Very low"));
150 } else if (value < 40) { 150 } else if (value < 40) {
161 ui->hop_tasteShow->setFormat(tr("Very high")); 161 ui->hop_tasteShow->setFormat(tr("Very high"));
162 } 162 }
163 } 163 }
164 164
165 165
166 void EditRecipe::on_Aroma_valueChanged(int value) 166 void EditRecipe::hop_Aroma_valueChanged(int value)
167 { 167 {
168 if (value < 20) { 168 if (value < 20) {
169 ui->hop_aromaShow->setStyleSheet(bar_20); 169 ui->hop_aromaShow->setStyleSheet(bar_20);
170 ui->hop_aromaShow->setFormat(tr("Very low")); 170 ui->hop_aromaShow->setFormat(tr("Very low"));
171 } else if (value < 40) { 171 } else if (value < 40) {
210 ui->hop_tasteShow->setValue(hop_flavour); 210 ui->hop_tasteShow->setValue(hop_flavour);
211 ui->hop_aromaShow->setValue(hop_aroma); 211 ui->hop_aromaShow->setValue(hop_aroma);
212 } 212 }
213 213
214 214
215 void EditRecipe::on_addHopRow_clicked() 215 void EditRecipe::addHopRow_clicked()
216 { 216 {
217 Hops newh; 217 Hops newh;
218 218
219 qDebug() << "Add hop row"; 219 qDebug() << "Add hop row";
220 220
243 recipe->hops.append(newh); 243 recipe->hops.append(newh);
244 emit refreshAll(); 244 emit refreshAll();
245 } 245 }
246 246
247 247
248 void EditRecipe::on_deleteHopRow_clicked() 248 void EditRecipe::deleteHopRow_clicked()
249 { 249 {
250 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); 250 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
251 int row = pb->objectName().toInt(); 251 int row = pb->objectName().toInt();
252 qDebug() << "Delete hop row" << row << recipe->hops.size(); 252 qDebug() << "Delete hop row" << row << recipe->hops.size();
253 253
461 is_changed(); 461 is_changed();
462 emit refreshAll(); 462 emit refreshAll();
463 } 463 }
464 464
465 465
466 void EditRecipe::on_editHopRow_clicked() 466 void EditRecipe::editHopRow_clicked()
467 { 467 {
468 QSqlQuery query; 468 QSqlQuery query;
469 469
470 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); 470 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
471 recipe->hops_row = pb->objectName().toInt(); 471 recipe->hops_row = pb->objectName().toInt();

mercurial