src/ProfileStyles.cpp

Sun, 20 Mar 2022 21:24:13 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 20 Mar 2022 21:24:13 +0100
changeset 76
93395c4d6c8d
parent 56
eb6c564192f4
child 79
e726db72da3c
permissions
-rw-r--r--

Profile Styles now on the mainscreen.

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 #include "bmsapp.h"
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
24 ProfileStyles::ProfileStyles(QWidget *parent) : QDialog(parent)
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 {
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 qDebug() << "ProfileStyles start";
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
28 gridLayout = new QGridLayout(this);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
29 gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
30 tableStyles = new QTableWidget(this);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
31 tableStyles->setObjectName(QString::fromUtf8("tableStyles"));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
32 tableStyles->setEnabled(true);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
33 QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
34 sizePolicy.setHorizontalStretch(0);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
35 sizePolicy.setVerticalStretch(0);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
36 tableStyles->setSizePolicy(sizePolicy);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
37 tableStyles->setMinimumSize(QSize(1049, 0));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
38 gridLayout->addWidget(tableStyles, 0, 0, 1, 1);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
39
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
40 groupBox = new QGroupBox(this);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
41 groupBox->setObjectName(QString::fromUtf8("groupBox"));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
42 groupBox->setEnabled(true);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
43 groupBox->setFlat(false);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
44 horizontalLayout = new QHBoxLayout(groupBox);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
45 horizontalLayout->setSpacing(6);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
46 horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
47 horizontalLayout->setContentsMargins(0, 0, 0, 0);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
48
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
49 quitButton = new QPushButton(groupBox);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
50 quitButton->setObjectName(QString::fromUtf8("quitButton"));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
51 quitButton->setMinimumSize(QSize(80, 24));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
52 quitButton->setText(tr("Quit"));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
53 QIcon icon;
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
54 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
55 quitButton->setIcon(icon);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
56 horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
57
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
58 insertButton = new QPushButton(groupBox);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
59 insertButton->setObjectName(QString::fromUtf8("insertButton"));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
60 insertButton->setMinimumSize(QSize(80, 24));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
61 insertButton->setText(tr("New"));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
62 QIcon icon3;
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
63 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
64 insertButton->setIcon(icon3);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
65 horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
66 gridLayout->addWidget(groupBox, 1, 0, 1, 1);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
67
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
68 connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromProfileStyles()));
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
69 connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked()));
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 QLabel *label;
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 QHBoxLayout* pLayout;
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 qDebug() << "ProfileStyles reload";
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 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
84 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
85 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
86
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
87 this->tableStyles->setColumnCount(16);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
88 this->tableStyles->setColumnWidth(0, 100); /* Guide */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
89 this->tableStyles->setColumnWidth(1, 25); /* Group */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
90 this->tableStyles->setColumnWidth(2, 300); /* Name */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
91 this->tableStyles->setColumnWidth(3, 50); /* OG */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
92 this->tableStyles->setColumnWidth(4, 50);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
93 this->tableStyles->setColumnWidth(5, 50); /* FG */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
94 this->tableStyles->setColumnWidth(6, 50);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
95 this->tableStyles->setColumnWidth(7, 40); /* IBU */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
96 this->tableStyles->setColumnWidth(8, 40);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
97 this->tableStyles->setColumnWidth(9, 40); /* EBC */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
98 this->tableStyles->setColumnWidth(10, 40);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
99 this->tableStyles->setColumnWidth(11, 40); /* Co2 */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
100 this->tableStyles->setColumnWidth(12, 40);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
101 this->tableStyles->setColumnWidth(13, 40); /* ABV */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
102 this->tableStyles->setColumnWidth(14, 40);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
103 this->tableStyles->setColumnWidth(15, 80); /* Edit button */
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
104 this->tableStyles->setRowCount(query.size());
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
105 this->tableStyles->setHorizontalHeaderLabels(labels);
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
106 this->tableStyles->verticalHeader()->hide();
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 QTableWidgetItem *rightitem = new QTableWidgetItem();
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 rightitem->setTextAlignment(Qt::AlignRight);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 query.first();
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 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
113 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
114 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
115 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
116
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 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
118 QTableWidgetItem *item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
120 this->tableStyles->setItem(ridx, 3, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 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
123 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
125 this->tableStyles->setItem(ridx, 4, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 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
128 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
130 this->tableStyles->setItem(ridx, 5, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 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
133 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
135 this->tableStyles->setItem(ridx, 6, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 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
138 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
140 this->tableStyles->setItem(ridx, 7, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 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
143 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
145 this->tableStyles->setItem(ridx, 8, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 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
148 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
150 this->tableStyles->setItem(ridx, 9, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 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
153 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
155 this->tableStyles->setItem(ridx, 10, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 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
158 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
160 this->tableStyles->setItem(ridx, 11, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 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
163 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
165 this->tableStyles->setItem(ridx, 12, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 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
168 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
170 this->tableStyles->setItem(ridx, 13, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 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
173 item = new QTableWidgetItem(w);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
175 this->tableStyles->setItem(ridx, 14, item);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 /* Add the Edit button */
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 pWidget = new QWidget();
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 QPushButton* btn_edit = new QPushButton();
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 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
181 btn_edit->setText(tr("Edit"));
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked()));
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 pLayout = new QHBoxLayout(pWidget);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 pLayout->addWidget(btn_edit);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 pLayout->setContentsMargins(5, 0, 5, 0);
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 pWidget->setLayout(pLayout);
76
93395c4d6c8d Profile Styles now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 56
diff changeset
187 this->tableStyles->setCellWidget(ridx, 15, pWidget);
56
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 query.next();
eb6c564192f4 Added styles tables and editor.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 }
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