src/EditRecipeTab2.cpp

changeset 139
f947c6988e91
parent 132
9ede9c75cb54
child 142
1caa15a0eefc
equal deleted inserted replaced
138:1189d072f346 139:f947c6988e91
121 /* Add the Delete row button */ 121 /* Add the Delete row button */
122 pWidget = new QWidget(); 122 pWidget = new QWidget();
123 QPushButton* btn_dele = new QPushButton(); 123 QPushButton* btn_dele = new QPushButton();
124 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 */
125 btn_dele->setText(tr("Delete")); 125 btn_dele->setText(tr("Delete"));
126 connect(btn_dele, SIGNAL(clicked()), this, SLOT(on_deleteFermentRow_clicked())); 126 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteFermentRow_clicked()));
127 pLayout = new QHBoxLayout(pWidget); 127 pLayout = new QHBoxLayout(pWidget);
128 pLayout->addWidget(btn_dele); 128 pLayout->addWidget(btn_dele);
129 pLayout->setContentsMargins(5, 0, 5, 0); 129 pLayout->setContentsMargins(5, 0, 5, 0);
130 pWidget->setLayout(pLayout); 130 pWidget->setLayout(pLayout);
131 ui->fermentablesTable->setCellWidget(i, 10, pWidget); 131 ui->fermentablesTable->setCellWidget(i, 10, pWidget);
132 132
133 pWidget = new QWidget(); 133 pWidget = new QWidget();
134 QPushButton* btn_edit = new QPushButton(); 134 QPushButton* btn_edit = new QPushButton();
135 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 */
136 btn_edit->setText(tr("Edit")); 136 btn_edit->setText(tr("Edit"));
137 connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editFermentRow_clicked())); 137 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editFermentRow_clicked()));
138 pLayout = new QHBoxLayout(pWidget); 138 pLayout = new QHBoxLayout(pWidget);
139 pLayout->addWidget(btn_edit); 139 pLayout->addWidget(btn_edit);
140 pLayout->setContentsMargins(5, 0, 5, 0); 140 pLayout->setContentsMargins(5, 0, 5, 0);
141 pWidget->setLayout(pLayout); 141 pWidget->setLayout(pLayout);
142 ui->fermentablesTable->setCellWidget(i, 11, pWidget); 142 ui->fermentablesTable->setCellWidget(i, 11, pWidget);
340 double sug = 3550 * fg * (0.1808 * og + 0.8192 * fg - 1.0004); 340 double sug = 3550 * fg * (0.1808 * og + 0.8192 * fg - 1.0004);
341 ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296))); 341 ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296)));
342 } 342 }
343 343
344 344
345 void EditRecipe::on_perc_mash_valueChanged(int value) 345 void EditRecipe::ferment_perc_mash_valueChanged(int value)
346 { 346 {
347 if (value < 90) 347 if (value < 90)
348 ui->perc_mashShow->setStyleSheet(bar_green); 348 ui->perc_mashShow->setStyleSheet(bar_green);
349 else if (value < 100) 349 else if (value < 100)
350 ui->perc_mashShow->setStyleSheet(bar_orange); 350 ui->perc_mashShow->setStyleSheet(bar_orange);
351 else 351 else
352 ui->perc_mashShow->setStyleSheet(bar_red); 352 ui->perc_mashShow->setStyleSheet(bar_red);
353 } 353 }
354 354
355 355
356 void EditRecipe::on_perc_sugars_valueChanged(int value) 356 void EditRecipe::ferment_perc_sugars_valueChanged(int value)
357 { 357 {
358 if (value < 20) 358 if (value < 20)
359 ui->perc_sugarsShow->setStyleSheet(bar_green); 359 ui->perc_sugarsShow->setStyleSheet(bar_green);
360 else 360 else
361 ui->perc_sugarsShow->setStyleSheet(bar_red); 361 ui->perc_sugarsShow->setStyleSheet(bar_red);
362 } 362 }
363 363
364 364
365 void EditRecipe::on_perc_cara_valueChanged(int value) 365 void EditRecipe::ferment_perc_cara_valueChanged(int value)
366 { 366 {
367 if (value < 25) 367 if (value < 25)
368 ui->perc_caraShow->setStyleSheet(bar_green); 368 ui->perc_caraShow->setStyleSheet(bar_green);
369 else 369 else
370 ui->perc_caraShow->setStyleSheet(bar_red); 370 ui->perc_caraShow->setStyleSheet(bar_red);
371 } 371 }
372 372
373 373
374 void EditRecipe::on_lintner_valueChanged(int value) 374 void EditRecipe::ferment_lintner_valueChanged(int value)
375 { 375 {
376 if (value < 30) 376 if (value < 30)
377 ui->lintnerShow->setStyleSheet(bar_red); 377 ui->lintnerShow->setStyleSheet(bar_red);
378 else if (value < 40) 378 else if (value < 40)
379 ui->lintnerShow->setStyleSheet(bar_orange); 379 ui->lintnerShow->setStyleSheet(bar_orange);
380 else 380 else
381 ui->lintnerShow->setStyleSheet(bar_green); 381 ui->lintnerShow->setStyleSheet(bar_green);
382 } 382 }
383 383
384 384
385 void EditRecipe::on_addFermentRow_clicked() 385 void EditRecipe::addFermentRow_clicked()
386 { 386 {
387 Fermentables newf; 387 Fermentables newf;
388 388
389 qDebug() << "Add fermentable row"; 389 qDebug() << "Add fermentable row";
390 390
419 recipe->fermentables.append(newf); 419 recipe->fermentables.append(newf);
420 emit refreshAll(); 420 emit refreshAll();
421 } 421 }
422 422
423 423
424 void EditRecipe::on_deleteFermentRow_clicked() 424 void EditRecipe::deleteFermentRow_clicked()
425 { 425 {
426 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); 426 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
427 int row = pb->objectName().toInt(); 427 int row = pb->objectName().toInt();
428 qDebug() << "Delete fermentable row" << row << recipe->fermentables.size(); 428 qDebug() << "Delete fermentable row" << row << recipe->fermentables.size();
429 429
716 is_changed(); 716 is_changed();
717 emit refreshAll(); 717 emit refreshAll();
718 } 718 }
719 719
720 720
721 void EditRecipe::on_editFermentRow_clicked() 721 void EditRecipe::editFermentRow_clicked()
722 { 722 {
723 QSqlQuery query; 723 QSqlQuery query;
724 724
725 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); 725 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
726 recipe->fermentables_row = pb->objectName().toInt(); 726 recipe->fermentables_row = pb->objectName().toInt();

mercurial