Sat, 01 Jun 2024 21:10:54 +0200
Added fields for target_water and auto upgrade the products table
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * EditProfileMash.cpp is part of bmsapp. |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "EditProfileMash.h" |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | #include "../ui/ui_EditProfileMash.h" |
90
2396457a8167
Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents:
58
diff
changeset
|
19 | #include "MainWindow.h" |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | EditProfileMash::EditProfileMash(int id, QWidget *parent) : QDialog(parent), ui(new Ui::EditProfileMash) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | QSqlQuery query; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | qDebug() << "EditProfileMash record:" << id; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | ui->setupUi(this); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | this->recno = id; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | if (id >= 0) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | query.prepare("SELECT * FROM profile_mash WHERE record = :recno"); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | query.bindValue(":recno", id); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | query.exec(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | query.next(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | ui->nameEdit->setText(query.value(1).toString()); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | ui->notesEdit->setPlainText(query.value(2).toString()); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | QJsonParseError parseError; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | const auto& json = query.value(3).toString(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | if (!json.trimmed().isEmpty()) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | const auto& formattedJson = QString("%1").arg(json); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | this->steps = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | if (parseError.error != QJsonParseError::NoError) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | qDebug() << "Parse error: " << parseError.errorString() << "at" << parseError.offset ; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | } else { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | /* Set some defaults */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | const auto& formattedJson = QString("[]"); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | this->steps = QJsonDocument::fromJson(formattedJson.toUtf8()); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | connect(ui->nameEdit, &QLineEdit::textChanged, this, &EditProfileMash::is_changed); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | connect(ui->notesEdit, SIGNAL(textChanged()), this, SLOT(is_changed())); |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
57 | connect(ui->stepsTable, SIGNAL(cellChanged(int, int)), this, SLOT(cell_Changed(int, int))); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | ui->saveButton->setEnabled(false); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | ui->deleteButton->setEnabled((id >= 0) ? true:false); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | emit refreshTable(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | WindowTitle(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | void EditProfileMash::refreshTable() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | QString w; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | QWidget* pWidget; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | QHBoxLayout* pLayout; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | double d; |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
74 | int total = 0; |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
76 | // qDebug() << "refreshTable" << this->steps << this->steps.isArray() << this->steps.array().size() ; |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
77 | /* During filling the table turn off the cellChanged signal because every cell that is filled |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
78 | * triggers the cellChanged signal. The QTableWidget has no better signal to use. */ |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
79 | this->ignoreChanges = true; |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | const QStringList labels({tr("Step name"), tr("Type"), tr("Start °C"), tr("End °C"), tr("Rest time"), tr("Ramp time"), tr("Button")}); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | ui->stepsTable->setColumnCount(7); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | ui->stepsTable->setColumnWidth(0, 250); /* Step name */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | ui->stepsTable->setColumnWidth(1, 150); /* Step type */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | ui->stepsTable->setColumnWidth(2, 75); /* Start temp */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | ui->stepsTable->setColumnWidth(3, 75); /* End temp */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | ui->stepsTable->setColumnWidth(4, 75); /* Step time */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | ui->stepsTable->setColumnWidth(5, 75); /* Ramp time */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | ui->stepsTable->setColumnWidth(6, 80); /* Button */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | ui->stepsTable->setHorizontalHeaderLabels(labels); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | ui->stepsTable->verticalHeader()->hide(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | ui->stepsTable->setRowCount(this->steps.array().size()); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | if (this->steps.isArray()) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | for (int i = 0; i < this->steps.array().size(); i++) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | QJsonObject obj = this->steps.array().at(i).toObject(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | ui->stepsTable->setItem(i, 0, new QTableWidgetItem(obj["step_name"].toString())); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
100 | /* Adding step_type 0, 1 or 2 as combobox. */ |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | QComboBox* myComboBox = new QComboBox(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | myComboBox->addItem(tr("Infusion")); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | myComboBox->addItem(tr("Temperature")); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | myComboBox->addItem(tr("Decoction")); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | ui->stepsTable->setCellWidget(i, 1, myComboBox); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | if (obj["step_type"].isString()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | d = QString(obj["step_type"].toString()).toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | else |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | d = obj["step_type"].toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | myComboBox->setCurrentIndex((int)d); |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
111 | connect<void(QComboBox::*)(int)>(myComboBox, &QComboBox::currentIndexChanged, this, &EditProfileMash::combo_Changed); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
113 | /* Numbers can be double quoted or not, the old application could do this wrong. */ |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | if (obj["step_temp"].isString()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | d = QString(obj["step_temp"].toString()).toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | else |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | d = obj["step_temp"].toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | w = QString("%1").arg(d, 2, 'f', 1, '0'); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | QTableWidgetItem *item = new QTableWidgetItem(w); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | ui->stepsTable->setItem(i, 2, item); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | if (obj["end_temp"].isString()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | d = QString(obj["end_temp"].toString()).toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | else |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | d = obj["end_temp"].toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | w = QString("%1").arg(d, 2, 'f', 1, '0'); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | item = new QTableWidgetItem(w); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | ui->stepsTable->setItem(i, 3, item); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | if (obj["step_time"].isString()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | d = QString(obj["step_time"].toString()).toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | else |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | d = obj["step_time"].toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | w = QString("%1").arg(d, 1, 'f', 0, '0'); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | item = new QTableWidgetItem(w); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | ui->stepsTable->setItem(i, 4, item); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | total += (int)d; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | if (obj["ramp_time"].isString()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | d = QString(obj["ramp_time"].toString()).toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | else |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | d = obj["ramp_time"].toDouble(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | w = QString("%1").arg(d, 1, 'f', 0, '0'); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | item = new QTableWidgetItem(w); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | ui->stepsTable->setItem(i, 5, item); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | if (i > 0) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | total += (int)d; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | /* Add the Delete row button */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | pWidget = new QWidget(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | QPushButton* btn_edit = new QPushButton(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | btn_edit->setText(tr("Delete")); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_deleteRow_clicked())); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | pLayout = new QHBoxLayout(pWidget); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | pLayout->addWidget(btn_edit); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | pLayout->setContentsMargins(5, 0, 5, 0); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | pWidget->setLayout(pLayout); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | ui->stepsTable->setCellWidget(i, 6, pWidget); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | /* Show the calculated total mash time. */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | ui->totalEdit->setText(QString("%1:%2").arg(total / 60).arg(total % 60, 2, 'f', 0, '0')); |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
169 | this->ignoreChanges = false; |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 | EditProfileMash::~EditProfileMash() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
174 | { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
175 | delete ui; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
176 | emit entry_changed(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
177 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
178 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
179 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
180 | /* |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
181 | * Window header, mark any change with '**' |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
183 | void EditProfileMash::WindowTitle() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
184 | { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
185 | QString txt; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
186 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
187 | if (this->recno < 0) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | txt = QString(tr("BMSapp - Add new mash profile")); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | } else { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
190 | txt = QString(tr("BMSapp - Edit mash profile %1").arg(this->recno)); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
191 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
193 | if (this->textIsChanged) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
194 | txt.append((QString(" **"))); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
195 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
196 | setWindowTitle(txt); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
197 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
198 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
200 | void EditProfileMash::on_saveButton_clicked() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | QSqlQuery query; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
204 | /* If there are errors in the form, show a message and do "return;" */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | if (ui->nameEdit->text().length() < 2) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
206 | QMessageBox::warning(this, tr("Edit Mash"), tr("Name empty or too short.")); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
207 | return; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
209 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
210 | if (this->textIsChanged) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | if (this->recno == -1) { |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
212 | query.prepare("INSERT INTO profile_mash SET name=:name, notes=:notes, steps=:steps, uuid=:uuid"); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | } else { |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
214 | query.prepare("UPDATE profile_mash SET name=:name, notes=:notes, steps=:steps WHERE record=:recno"); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
215 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
216 | query.bindValue(":name", ui->nameEdit->text()); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
217 | query.bindValue(":notes", ui->notesEdit->toPlainText()); |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
218 | query.bindValue(":steps", this->steps.toJson(QJsonDocument::Compact)); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | if (this->recno == -1) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
221 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | } else { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
223 | query.bindValue(":recno", this->recno); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | query.exec(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | if (query.lastError().isValid()) { |
385
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
227 | qWarning() << "EditProfileMash" << query.lastError(); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | QMessageBox::warning(this, tr("Database error"), |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
229 | tr("MySQL error: %1\n%2\n%3") |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
230 | .arg(query.lastError().nativeErrorCode()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
231 | .arg(query.lastError().driverText()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
232 | .arg(query.lastError().databaseText())); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | } else { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | qDebug() << "EditProfileMash Saved"; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
238 | ui->saveButton->setEnabled(false); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
239 | this->textIsChanged = false; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
240 | WindowTitle(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
242 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
243 | |
385
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
244 | void EditProfileMash::on_cloneButton_clicked() |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
245 | { |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
246 | QSqlQuery query; |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
247 | |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
248 | query.prepare("INSERT INTO profile_mash SET name=:name, notes=:notes, steps=:steps, uuid=:uuid"); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
249 | query.bindValue(":name", ui->nameEdit->text() + " [copy]"); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
250 | query.bindValue(":notes", ui->notesEdit->toPlainText()); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
251 | query.bindValue(":steps", this->steps.toJson(QJsonDocument::Compact)); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
252 | query.bindValue(":uuid", QUuid::createUuid().toString().mid(1, 36)); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
253 | |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
254 | query.exec(); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
255 | if (query.lastError().isValid()) { |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
256 | qWarning() << "EditProfileMash" << query.lastError(); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
257 | QMessageBox::warning(this, tr("Database error"), |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
258 | tr("MySQL error: %1\n%2\n%3") |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
259 | .arg(query.lastError().nativeErrorCode()) |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
260 | .arg(query.lastError().driverText()) |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
261 | .arg(query.lastError().databaseText())); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
262 | } else { |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
263 | qDebug() << "EditProfileMash Saved"; |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
264 | } |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
265 | } |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
266 | |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
267 | |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
268 | void EditProfileMash::on_deleteButton_clicked() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
269 | { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
270 | QSqlQuery query; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
271 | |
385
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
272 | int rc = QMessageBox::warning(this, tr("Delete mash profile"), tr("Delete %1").arg(ui->nameEdit->text()), |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
273 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
274 | if (rc == QMessageBox::No) |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
275 | return; |
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
276 | |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
277 | query.prepare("DELETE FROM profile_mash WHERE record = :recno"); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
278 | query.bindValue(":recno", this->recno); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
279 | query.exec(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
280 | if (query.lastError().isValid()) { |
385
09af9f46518f
All profile and inventory editors now log warnings if something went wrong. Also added a Clone button. Delete now asks for confirmation.
Michiel Broek <mbroek@mbse.eu>
parents:
90
diff
changeset
|
281 | qWarning() << "EditProfileMash" << query.lastError(); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
282 | QMessageBox::warning(this, tr("Database error"), |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
283 | tr("MySQL error: %1\n%2\n%3") |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
284 | .arg(query.lastError().nativeErrorCode()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
285 | .arg(query.lastError().driverText()) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
286 | .arg(query.lastError().databaseText())); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
287 | } else { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
288 | qDebug() << "EditProfileMash Deleted" << this->recno; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
289 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
290 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
291 | this->close(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
292 | this->setResult(1); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
293 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
294 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
295 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
296 | void EditProfileMash::is_changed() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
297 | { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
298 | ui->saveButton->setEnabled(true); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
299 | ui->deleteButton->setEnabled((this->recno >= 0) ? true:false); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
300 | this->textIsChanged = true; |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
301 | WindowTitle(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
302 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
303 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
304 | |
50
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
305 | /* |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
306 | * Rebuild the json string from the table contents. |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
307 | */ |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
308 | void EditProfileMash::make_Json() |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
309 | { |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
310 | QTableWidgetItem *item; |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
311 | QJsonArray array; |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
312 | |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
313 | ui->stepsTable->sortItems(2, Qt::AscendingOrder); // Sort on temperature. |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
314 | |
50
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
315 | for (int i = 0; i < ui->stepsTable->rowCount(); i++) { |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
316 | |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
317 | QJsonObject obj; |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
318 | item = ui->stepsTable->item(i, 0); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
319 | obj.insert("step_name", item->text()); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
320 | QWidget *widget = ui->stepsTable->cellWidget(i, 1); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
321 | obj.insert("step_type", static_cast<QComboBox*>(widget)->currentIndex() ); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
322 | item = ui->stepsTable->item(i, 2); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
323 | obj.insert("step_temp", item->text().toDouble()); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
324 | item = ui->stepsTable->item(i, 3); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
325 | obj.insert("end_temp", item->text().toDouble()); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
326 | item = ui->stepsTable->item(i, 4); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
327 | obj.insert("step_time", item->text().toInt()); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
328 | item = ui->stepsTable->item(i, 5); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
329 | obj.insert("ramp_time", item->text().toInt()); |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
330 | // qDebug() << "make_Json" << i << obj; |
50
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
331 | array.append(obj); /* Append this object */ |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
332 | } |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
333 | |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
334 | // qDebug() << array; |
50
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
335 | /* Copy to the global array and refresh */ |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
336 | this->steps.setArray(array); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
337 | is_changed(); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
338 | emit refreshTable(); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
339 | } |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
340 | |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
341 | |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
342 | void EditProfileMash::cell_Changed(int nRow, int nCol) |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
343 | { |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
344 | if (this->ignoreChanges) |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
345 | return; |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
346 | |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
347 | qDebug() << "Cell at row " + QString::number(nRow) + " column " + QString::number(nCol) + " was changed."; |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
348 | |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
349 | // TODO: some checks and auto fixes. |
50
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
350 | make_Json(); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
351 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
352 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
353 | |
51
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
354 | void EditProfileMash::combo_Changed() |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
355 | { |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
356 | make_Json(); |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
357 | } |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
358 | |
355100088e1f
When editing mash step cells the table is updated. The combobox changes are finally working too.
Michiel Broek <mbroek@mbse.eu>
parents:
50
diff
changeset
|
359 | |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
360 | void EditProfileMash::on_addButton_clicked() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
361 | { |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
362 | int total = ui->stepsTable->rowCount(); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
363 | QWidget* pWidget; |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
364 | QHBoxLayout* pLayout; |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
365 | |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
366 | qDebug() << "Add row" << total; |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
367 | this->ignoreChanges = true; |
50
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
368 | |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
369 | ui->stepsTable->insertRow(total); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
370 | ui->stepsTable->setItem(total, 0, new QTableWidgetItem(QString("new row %1").arg(total))); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
371 | QComboBox* myComboBox = new QComboBox(); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
372 | myComboBox->addItem(tr("Infusion")); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
373 | myComboBox->addItem(tr("Temperature")); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
374 | myComboBox->addItem(tr("Decoction")); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
375 | myComboBox->setCurrentIndex(0); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
376 | ui->stepsTable->setCellWidget(total, 1, myComboBox); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
377 | ui->stepsTable->setItem(total, 2, new QTableWidgetItem(QString("65.0"))); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
378 | ui->stepsTable->setItem(total, 3, new QTableWidgetItem(QString("65.0"))); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
379 | ui->stepsTable->setItem(total, 4, new QTableWidgetItem(QString("20"))); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
380 | ui->stepsTable->setItem(total, 5, new QTableWidgetItem(QString("10"))); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
381 | pWidget = new QWidget(); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
382 | QPushButton* btn_edit = new QPushButton(); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
383 | btn_edit->setObjectName(QString("%1").arg(total)); /* Send row with the button */ |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
384 | btn_edit->setText(tr("Delete")); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
385 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_deleteRow_clicked())); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
386 | pLayout = new QHBoxLayout(pWidget); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
387 | pLayout->addWidget(btn_edit); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
388 | pLayout->setContentsMargins(5, 0, 5, 0); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
389 | pWidget->setLayout(pLayout); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
390 | ui->stepsTable->setCellWidget(total, 6, pWidget); |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
391 | |
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
392 | this->ignoreChanges = false; |
50
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
393 | make_Json(); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
394 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
395 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
396 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
397 | void EditProfileMash::on_deleteRow_clicked() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
398 | { |
50
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
399 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
400 | int row = pb->objectName().toInt(); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
401 | qDebug() << "Delete row" << row; |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
402 | ui->stepsTable->removeRow(row); |
571a13a4860b
Show changes in the steps table. Delete row implemented.
Michiel Broek <mbroek@mbse.eu>
parents:
49
diff
changeset
|
403 | make_Json(); |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
404 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
405 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
406 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
407 | void EditProfileMash::on_quitButton_clicked() |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
408 | { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
409 | if (this->textIsChanged) { |
58
27eaf3a22c1a
Finished the profile mash editor.
Michiel Broek <mbroek@mbse.eu>
parents:
55
diff
changeset
|
410 | int rc = QMessageBox::warning(this, tr("Mash changed"), tr("This mash profile has been modified. Save changes?"), |
49
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
411 | QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
412 | switch (rc) { |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
413 | case QMessageBox::Save: |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
414 | on_saveButton_clicked(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
415 | break; /* Saved and then Quit */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
416 | case QMessageBox::Discard: |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
417 | break; /* Quit without Save */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
418 | case QMessageBox::Cancel: |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
419 | return; /* Return to the editor page */ |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
420 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
421 | } |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
422 | |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
423 | this->close(); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
424 | this->setResult(1); |
29cf6e350063
Added Mash profiles table and the first part of the Mash profile editor. Edit and write must be written.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
425 | } |