src/ProfileWaters.cpp

Mon, 21 Mar 2022 12:08:41 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 21 Mar 2022 12:08:41 +0100
changeset 79
e726db72da3c
parent 74
4ac38457a709
child 83
6f744c602139
permissions
-rw-r--r--

All inventory and profiles now show the items sizes in the statusbar.

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

mercurial