Wed, 20 Apr 2022 22:48:20 +0200
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /** |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * ProfileFerments.cpp is part of bmsapp. |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * bmsapp is free software: you can redistribute it and/or modify |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * it under the terms of the GNU General Public License as published by |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * the Free Software Foundation, either version 3 of the License, or |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * (at your option) any later version. |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * bmsapp is distributed in the hope that it will be useful, |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * GNU General Public License for more details. |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * You should have received a copy of the GNU General Public License |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | #include "ProfileFerments.h" |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | #include "EditProfileFerment.h" |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
19 | #include "MainWindow.h" |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | #include "config.h" |
90
2396457a8167
Moved functions from bmsapp.cpp to MainWindow.cpp
Michiel Broek <mbroek@mbse.eu>
parents:
83
diff
changeset
|
21 | #include "Utils.h" |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
24 | ProfileFerments::ProfileFerments(QWidget *parent) : QDialog(parent) |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | { |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | qDebug() << "ProfileFerments start"; |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
28 | gridLayout = new QGridLayout(this); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
29 | gridLayout->setObjectName(QString::fromUtf8("gridLayout")); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
30 | tableFerments = new QTableWidget(this); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
31 | tableFerments->setObjectName(QString::fromUtf8("tableFerments")); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
32 | tableFerments->setEnabled(true); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
33 | QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
34 | sizePolicy.setHorizontalStretch(0); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
35 | sizePolicy.setVerticalStretch(0); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
36 | tableFerments->setSizePolicy(sizePolicy); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
37 | tableFerments->setMinimumSize(QSize(1004, 0)); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
38 | gridLayout->addWidget(tableFerments, 0, 0, 1, 1); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
39 | |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
40 | groupBox = new QGroupBox(this); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
41 | groupBox->setObjectName(QString::fromUtf8("groupBox")); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
42 | groupBox->setEnabled(true); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
43 | groupBox->setFlat(false); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
44 | horizontalLayout = new QHBoxLayout(groupBox); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
45 | horizontalLayout->setSpacing(6); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
46 | horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
47 | horizontalLayout->setContentsMargins(0, 0, 0, 0); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
48 | |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
49 | quitButton = new QPushButton(groupBox); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
50 | quitButton->setObjectName(QString::fromUtf8("quitButton")); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
51 | quitButton->setMinimumSize(QSize(80, 24)); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
52 | quitButton->setText(tr("Quit")); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
53 | QIcon icon; |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
54 | icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
55 | quitButton->setIcon(icon); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
56 | horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
57 | |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
58 | insertButton = new QPushButton(groupBox); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
59 | insertButton->setObjectName(QString::fromUtf8("insertButton")); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
60 | insertButton->setMinimumSize(QSize(80, 24)); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
61 | insertButton->setText(tr("New")); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
62 | QIcon icon3; |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
63 | icon3.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
64 | insertButton->setIcon(icon3); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
65 | horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
66 | gridLayout->addWidget(groupBox, 1, 0, 1, 1); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
67 | |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
68 | connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromProfileFerments())); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
69 | connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked())); |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
70 | connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | emit refreshTable(); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | } |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | void ProfileFerments::refreshTable() |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | { |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | QString w; |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | QWidget* pWidget; |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | QHBoxLayout* pLayout; |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | qDebug() << "ProfileFerments reload"; |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | QSqlQuery query("SELECT * FROM profile_fermentation ORDER BY name"); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | const QStringList labels({tr("Name"), tr("Start low"), tr("Start high"), tr("Sensor"), tr("Steps"), tr("Duration"), tr("Edit")}); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
86 | this->tableFerments->setColumnCount(7); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
87 | this->tableFerments->setColumnWidth(0, 450); /* Name */ |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
88 | this->tableFerments->setColumnWidth(1, 90); /* Min temp */ |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
89 | this->tableFerments->setColumnWidth(2, 90); /* Max temp */ |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
90 | this->tableFerments->setColumnWidth(3, 75); /* Sensor */ |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
91 | this->tableFerments->setColumnWidth(4, 75); /* Steps */ |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
92 | this->tableFerments->setColumnWidth(5, 120); /* Duration */ |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
93 | this->tableFerments->setColumnWidth(6, 80); /* Edit button */ |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
94 | this->tableFerments->setRowCount(query.size()); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
95 | this->tableFerments->setHorizontalHeaderLabels(labels); |
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
96 | this->tableFerments->verticalHeader()->hide(); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | QTableWidgetItem *rightitem = new QTableWidgetItem(); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | rightitem->setTextAlignment(Qt::AlignRight); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | query.first(); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
103 | this->tableFerments->setItem(ridx, 0, new QTableWidgetItem(query.value(2).toString())); /* Name */ |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | w = QString("%1 °C").arg(query.value(3).toDouble(), 2, 'f', 1, '0' ); /* Min start temp */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | QTableWidgetItem *item = new QTableWidgetItem(w); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
108 | this->tableFerments->setItem(ridx, 1, item); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | w = QString("%1 °C").arg(query.value(4).toDouble(), 2, 'f', 1, '0' ); /* Max start temp */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | item = new QTableWidgetItem(w); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
113 | this->tableFerments->setItem(ridx, 2, item); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | w = (query.value(5).toInt()) ? tr("Fridge") : tr("Beer"); /* Initial sensor */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | item = new QTableWidgetItem(w); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
118 | this->tableFerments->setItem(ridx, 3, item); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | w = QString("%1").arg(query.value(6).toInt()); /* Number of steps */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | item = new QTableWidgetItem(w); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
123 | this->tableFerments->setItem(ridx, 4, item); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | w = Utils::hours_to_string(query.value(7).toInt()); /* Duration */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | item = new QTableWidgetItem(w); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
128 | this->tableFerments->setItem(ridx, 5, item); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | /* Add the Edit button */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | pWidget = new QWidget(); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | QPushButton* btn_edit = new QPushButton(); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | btn_edit->setObjectName(QString("%1").arg(query.value(0).toString())); /* Send record with the button */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | btn_edit->setText(tr("Edit")); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | pLayout = new QHBoxLayout(pWidget); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | pLayout->addWidget(btn_edit); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | pLayout->setContentsMargins(5, 0, 5, 0); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | pWidget->setLayout(pLayout); |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
140 | this->tableFerments->setCellWidget(ridx, 6, pWidget); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | query.next(); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | } |
79
e726db72da3c
All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
143 | emit setStatus(QString(tr("Total items: %1")).arg(query.size())); |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | } |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | |
77
86a3277a7317
Profile Ferments now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents:
57
diff
changeset
|
147 | ProfileFerments::~ProfileFerments() {} |
57
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | void ProfileFerments::edit(int recno) |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | { |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | EditProfileFerment dialog(recno, this); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | /* Signal from editor if a refresh is needed */ |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | connect(&dialog, SIGNAL(entry_changed()), this, SLOT(refreshTable())); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | dialog.setModal(true); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | dialog.exec(); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | } |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | void ProfileFerments::on_editButton_clicked() |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | { |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | int recno = pb->objectName().toInt(); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | edit(recno); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | } |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | void ProfileFerments::on_insertButton_clicked() |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | { |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | edit(-1); |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | } |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | |
75d11cc05ce4
Added profile fermentation tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
173 |