src/Setup.cpp

Mon, 28 Feb 2022 21:21:33 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 28 Feb 2022 21:21:33 +0100
changeset 31
ab17a56a47dd
parent 17
f0bcdbd3d36f
child 41
dc4b659a320b
permissions
-rw-r--r--

Setup translation system and started the Dutch translation

15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Setup.cpp is part of bmsapp.
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "Setup.h"
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "../ui/ui_Setup.h"
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "config.h"
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "bmsapp.h"
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 Setup::Setup(QWidget *parent) : QDialog(parent), ui(new Ui::Setup)
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 {
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
26 QSqlQuery query;
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
27
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 qDebug() << "Setup start";
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 ui->setupUi(this);
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
30 setWindowTitle( QString("BMSapp - %1 - Setup").arg(VERSIONSTRING) );
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
32 query.prepare("SELECT * FROM profile_setup WHERE record='1'");
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
33 query.exec();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
34 query.next();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
35
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
36 ui->breweryEdit->setText(query.value(1).toString()); // max 128
17
f0bcdbd3d36f Forgot one signal in Setup. EditSupplier now has signals to track edit changes. The Window header has ** mark if anything is changed. Added errors message boxes.
Michiel Broek <mbroek@mbse.eu>
parents: 16
diff changeset
37 connect(ui->breweryEdit, &QLineEdit::textChanged, this, &Setup::is_changed);
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
38
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
39 ui->fwhEdit->setValue(query.value(4).toInt());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
40 ui->mashhopEdit->setValue(query.value(3).toInt());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
41 ui->pelletEdit->setValue(query.value(5).toInt());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
42 ui->hopplugEdit->setValue(query.value(6).toInt());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
43 ui->wethopEdit->setValue(query.value(7).toInt());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
44 ui->cryohopEdit->setValue(query.value(8).toInt());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
45 connect(ui->fwhEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
46 connect(ui->mashhopEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
47 connect(ui->pelletEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
48 connect(ui->hopplugEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
49 connect(ui->wethopEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
50 connect(ui->cryohopEdit, &QSpinBox::textChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
51
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
52 ui->grainEdit->setValue(query.value(12).toDouble());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
53 ui->brixEdit->setValue(query.value(11).toDouble());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
54 connect(ui->grainEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
55 connect(ui->brixEdit, &QDoubleSpinBox::textChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
56
31
ab17a56a47dd Setup translation system and started the Dutch translation
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
57 ui->colorEdit->addItem("Morey");
ab17a56a47dd Setup translation system and started the Dutch translation
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
58 ui->colorEdit->addItem("Mosher");
ab17a56a47dd Setup translation system and started the Dutch translation
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
59 ui->colorEdit->addItem("Daniels");
ab17a56a47dd Setup translation system and started the Dutch translation
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
60 ui->colorEdit->addItem("Halberstadt");
ab17a56a47dd Setup translation system and started the Dutch translation
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
61 ui->colorEdit->addItem("Naudts");
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
62 ui->colorEdit->setEditable(true);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
63 ui->colorEdit->setCurrentIndex(query.value(10).toInt());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
64 connect(ui->colorEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
65
31
ab17a56a47dd Setup translation system and started the Dutch translation
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
66 ui->ibuEdit->addItem("Tinseth");
ab17a56a47dd Setup translation system and started the Dutch translation
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
67 ui->ibuEdit->addItem("Rager");
ab17a56a47dd Setup translation system and started the Dutch translation
Michiel Broek <mbroek@mbse.eu>
parents: 17
diff changeset
68 ui->ibuEdit->addItem("Daniels");
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
69 ui->ibuEdit->setEditable(true);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
70 ui->ibuEdit->setCurrentIndex(query.value(9).toInt());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
71 connect(ui->ibuEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
72
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
73 QSqlQuery query2("SELECT record,name FROM inventory_waters");
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
74 query2.first();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
75 int pos = -1;
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
76 ui->waterEdit->setEditable(true);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
77 ui->waterEdit->setPlaceholderText(tr("Choose default water"));
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
78 for (int i = 0 ; i < query2.size() ; i++ ) {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
79 ui->waterEdit->addItem(query2.value(1).toString());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
80 if (query2.value(0).toInt() == query.value(13).toInt()) {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
81 pos = i;
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
82 }
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
83 query2.next();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
84 }
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
85 if (pos >= 0)
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
86 ui->waterEdit->setCurrentIndex(pos);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
87 connect(ui->waterEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
88
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
89 QSqlQuery query3("SELECT DISTINCT laboratory FROM inventory_yeasts ORDER BY laboratory");
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
90 query3.first();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
91 pos = -1;
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
92 ui->yeastEdit->setEditable(true);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
93 ui->yeastEdit->setPlaceholderText(tr("Choose laboratory"));
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
94 for (int i = 0 ; i < query3.size() ; i++ ) {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
95 ui->yeastEdit->addItem(query3.value(0).toString());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
96 if (QString::compare(query.value(14).toString(), query3.value(0).toString(), Qt::CaseSensitive) == 0)
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
97 pos = i;
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
98 query3.next();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
99 }
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
100 if (pos >= 0)
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
101 ui->yeastEdit->setCurrentIndex(pos);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
102 connect(ui->yeastEdit, &QComboBox::currentTextChanged, this, &Setup::is_changed);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
103
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
104 // query.value(2).toString() logo varchar(1024)
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 }
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 Setup::~Setup()
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 {
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 qDebug() << "Setup done";
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 delete ui;
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 }
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
115 /*
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
116 * Also called from the Quit button if there are changes to save.
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
117 */
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
118 void Setup::on_saveButton_clicked()
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
119 {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
120 QSqlQuery query;
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
121
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
122 /*
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
123 * Search record number of the current water.
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
124 */
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
125 query.prepare("SELECT record FROM inventory_waters WHERE name=:name");
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
126 query.bindValue(":name", ui->waterEdit->currentText());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
127 query.exec();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
128 query.first();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
129 int record = query.value(0).toInt();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
130
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
131 /*
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
132 * Update all other data
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
133 */
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
134 query.prepare("UPDATE profile_setup SET brewery_name=:brewery, factor_mashhop=:mashhop, factor_fwh=:fwh, factor_pellet=:pellet, "
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
135 "factor_plug=:plug, factor_wethop=:wet, factor_cryohop=:cryo, color_method=:color, ibu_method=:ibu, "
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
136 "brix_correction=:brix, grain_absorbtion=:grain, default_water=:water, my_yeastlab=:yeast WHERE record='1'");
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
137 query.bindValue(":brewery", ui->breweryEdit->text());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
138 query.bindValue(":mashhop", ui->mashhopEdit->value());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
139 query.bindValue(":fwh", ui->fwhEdit->value());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
140 query.bindValue(":pellet", ui->pelletEdit->value());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
141 query.bindValue(":plug", ui->hopplugEdit->value());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
142 query.bindValue(":wet", ui->wethopEdit->value());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
143 query.bindValue(":cryo", ui->cryohopEdit->value());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
144 query.bindValue(":color", ui->colorEdit->currentIndex());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
145 query.bindValue(":ibu", ui->ibuEdit->currentIndex());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
146 query.bindValue(":brix", ui->brixEdit->value());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
147 query.bindValue(":grain", ui->grainEdit->value());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
148 query.bindValue(":water", record);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
149 query.bindValue(":yeast", ui->yeastEdit->currentText());
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
150 query.exec();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
151 if (query.lastError().isValid()) {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
152 qDebug() << "Setup Save error:" << query.lastError();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
153 QMessageBox::warning(this, tr("Database error"),
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
154 tr("MySQL error: %1\n%2\n%3")
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
155 .arg(query.lastError().nativeErrorCode())
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
156 .arg(query.lastError().driverText())
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
157 .arg(query.lastError().databaseText()));
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
158 } else {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
159 qDebug() << "Setup Saved";
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
160 }
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
161
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
162 this->fieldIsChanged = false;
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
163 setWindowTitle( QString("BMSapp - %1 - Setup").arg(VERSIONSTRING) );
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
164 }
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
165
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
166
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 void Setup::on_quitButton_clicked()
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 {
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
169 if (this->fieldIsChanged) {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
170 int rc = QMessageBox::warning(this, tr("Setup changed"), tr("The setup has been modified\n Save changes?"),
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
171 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
172 switch (rc) {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
173 case QMessageBox::Save:
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
174 on_saveButton_clicked();
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
175 break; /* Saved and then Quit */
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
176 case QMessageBox::Discard:
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
177 break; /* Quit without Save */
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
178 case QMessageBox::Cancel:
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
179 return; /* Return to the setup page */
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
180 }
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
181 }
15
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 emit firstWindow();
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 }
c58b82549713 Started adding the global setup screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184
16
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
185
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
186 void Setup::is_changed()
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
187 {
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
188 this->fieldIsChanged = true;
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
189 setWindowTitle( QString("BMSapp - %1 - Setup **").arg(VERSIONSTRING) );
a5d8e783a7b0 Completed the global setup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 15
diff changeset
190 }

mercurial