src/ProfileStyles.cpp

Tue, 31 Jan 2023 16:24:11 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 31 Jan 2023 16:24:11 +0100
changeset 482
e13763ec829f
parent 90
2396457a8167
permissions
-rw-r--r--

Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.

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

mercurial