src/ProfileMashs.cpp

Sun, 20 Mar 2022 20:59:05 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 20 Mar 2022 20:59:05 +0100
changeset 75
5f953abbd73c
parent 49
29cf6e350063
child 79
e726db72da3c
permissions
-rw-r--r--

Profile Mashs now on the mainscreen.

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

mercurial