src/ProfileMashs.cpp

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

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

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

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()));
79
e726db72da3c All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
70 connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString)));
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
71 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
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
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 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
76 {
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 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
78 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
79 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
80 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
81
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 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
83
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 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
85 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
86
75
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
87 this->tableMashs->setColumnCount(4);
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
88 this->tableMashs->setColumnWidth(0, 250); /* Name */
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
89 this->tableMashs->setColumnWidth(1, 675); /* Notes */
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
90 this->tableMashs->setColumnWidth(2, 75); /* Steps */
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
91 this->tableMashs->setColumnWidth(3, 80); /* Edit button */
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
92 this->tableMashs->setRowCount(query.size());
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
93 this->tableMashs->setHorizontalHeaderLabels(labels);
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
94 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
95
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 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
97 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
98
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 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
100 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
101 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
102 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
103
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 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
105 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
106
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 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
108 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
109 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
110
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 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
112 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
113
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 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
115 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
116 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
75
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
117 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
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
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 /* 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
121 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
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 pWidget->setLayout(pLayout);
75
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
130 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
131 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
132 }
79
e726db72da3c All inventory and profiles now show the items sizes in the statusbar.
Michiel Broek <mbroek@mbse.eu>
parents: 75
diff changeset
133 emit setStatus(QString(tr("Total items: %1")).arg(query.size()));
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
134 }
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
135
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
75
5f953abbd73c Profile Mashs now on the mainscreen.
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
137 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
138
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 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
141 {
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 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
143 /* 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
144 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
145 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
146 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
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
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 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
151 {
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 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
153 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
154 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
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
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 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
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 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
161 }
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
162
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
163

mercurial