src/InventorySuppliers.cpp

changeset 65
2ef981980daa
parent 64
b0d30697af67
child 66
72386c164f54
--- a/src/InventorySuppliers.cpp	Sat Mar 19 19:22:58 2022 +0100
+++ b/src/InventorySuppliers.cpp	Sat Mar 19 22:59:11 2022 +0100
@@ -17,17 +17,58 @@
 #include "InventorySuppliers.h"
 #include "EditSupplier.h"
 #include "MainWindow.h"
-#include "../ui/ui_InventorySuppliers.h"
 #include "config.h"
 #include "bmsapp.h"
 
 
 
-InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers)
+InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent)  /*, ui(new Ui::InventorySuppliers)*/
 {
     qDebug() << "InventorySuppliers start";
 
-    ui->setupUi(this);
+    gridLayout = new QGridLayout(this);
+    gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
+    tableSuppliers = new QTableWidget(this);
+    tableSuppliers->setObjectName(QString::fromUtf8("tableSuppliers"));
+    tableSuppliers->setEnabled(true);
+    QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+    sizePolicy.setHorizontalStretch(0);
+    sizePolicy.setVerticalStretch(0);
+    sizePolicy.setHeightForWidth(tableSuppliers->sizePolicy().hasHeightForWidth());
+    tableSuppliers->setSizePolicy(sizePolicy);
+    tableSuppliers->setMinimumSize(QSize(1054, 0));
+    gridLayout->addWidget(tableSuppliers, 0, 0, 1, 1);
+
+    groupBox = new QGroupBox(this);
+    groupBox->setObjectName(QString::fromUtf8("groupBox"));
+    groupBox->setEnabled(true);
+    groupBox->setFlat(false);
+    horizontalLayout = new QHBoxLayout(groupBox);
+    horizontalLayout->setSpacing(6);
+    horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
+    horizontalLayout->setContentsMargins(0, 0, 0, 0);
+    quitButton = new QPushButton(groupBox);
+    quitButton->setObjectName(QString::fromUtf8("quitButton"));
+    quitButton->setMinimumSize(QSize(80, 24));
+    QIcon icon;
+    icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off);
+    quitButton->setIcon(icon);
+    horizontalLayout->addWidget(quitButton, 0, Qt::AlignLeft);
+
+    insertButton = new QPushButton(groupBox);
+    insertButton->setObjectName(QString::fromUtf8("insertButton"));
+    insertButton->setMinimumSize(QSize(80, 24));
+    QIcon icon1;
+    icon1.addFile(QString::fromUtf8(":icons/silk/table_row_insert.png"), QSize(), QIcon::Normal, QIcon::Off);
+    insertButton->setIcon(icon1);
+    horizontalLayout->addWidget(insertButton, 0, Qt::AlignRight);
+
+    gridLayout->addWidget(groupBox, 1, 0, 1, 1);
+
+    //retranslateUi(this);
+
+    connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromInventorySuppliers()));
+    connect(insertButton, SIGNAL(clicked()), this, SLOT(on_insertButton_clicked()));
     emit refreshTable();
 }
 
@@ -39,25 +80,25 @@
     QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name");
     const QStringList labels({tr("Name"), tr("Address"), tr("City"), tr("Country"), tr("Phone"), tr("Edit")});
 
-    ui->tableSuppliers->setColumnCount(6);
-    ui->tableSuppliers->setColumnWidth(0, 250);	/* Name		*/
-    ui->tableSuppliers->setColumnWidth(1, 250);	/* Address	*/
-    ui->tableSuppliers->setColumnWidth(2, 200);	/* City		*/
-    ui->tableSuppliers->setColumnWidth(3, 120);	/* Country	*/
-    ui->tableSuppliers->setColumnWidth(4, 120);	/* Phone	*/
-    ui->tableSuppliers->setColumnWidth(5, 90);	/* Edit button	*/
-    ui->tableSuppliers->setRowCount(query.size());
-    ui->tableSuppliers->setHorizontalHeaderLabels(labels);
-    ui->tableSuppliers->verticalHeader()->hide();
+    this->tableSuppliers->setColumnCount(6);
+    this->tableSuppliers->setColumnWidth(0, 250);	/* Name		*/
+    this->tableSuppliers->setColumnWidth(1, 250);	/* Address	*/
+    this->tableSuppliers->setColumnWidth(2, 200);	/* City		*/
+    this->tableSuppliers->setColumnWidth(3, 120);	/* Country	*/
+    this->tableSuppliers->setColumnWidth(4, 120);	/* Phone	*/
+    this->tableSuppliers->setColumnWidth(5, 90);	/* Edit button	*/
+    this->tableSuppliers->setRowCount(query.size());
+    this->tableSuppliers->setHorizontalHeaderLabels(labels);
+    this->tableSuppliers->verticalHeader()->hide();
     /* Set the widget size to 1054 x 575 in the ui. */
 
     query.first();
     for (int ridx = 0 ; ridx < query.size() ; ridx++ ) {
-	ui->tableSuppliers->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString()));
-	ui->tableSuppliers->setItem(ridx, 1, new QTableWidgetItem(query.value(2).toString()));
-	ui->tableSuppliers->setItem(ridx, 2, new QTableWidgetItem(query.value(3).toString()));
-	ui->tableSuppliers->setItem(ridx, 3, new QTableWidgetItem(query.value(5).toString()));
-	ui->tableSuppliers->setItem(ridx, 4, new QTableWidgetItem(query.value(8).toString()));
+	this->tableSuppliers->setItem(ridx, 0, new QTableWidgetItem(query.value(1).toString()));
+	this->tableSuppliers->setItem(ridx, 1, new QTableWidgetItem(query.value(2).toString()));
+	this->tableSuppliers->setItem(ridx, 2, new QTableWidgetItem(query.value(3).toString()));
+	this->tableSuppliers->setItem(ridx, 3, new QTableWidgetItem(query.value(5).toString()));
+	this->tableSuppliers->setItem(ridx, 4, new QTableWidgetItem(query.value(8).toString()));
 
 	/* Add the Edit button */
 	QWidget* pWidget = new QWidget();
@@ -69,7 +110,7 @@
 	pLayout->addWidget(btn_edit);
 	pLayout->setContentsMargins(5, 0, 5, 0);
 	pWidget->setLayout(pLayout);
-	ui->tableSuppliers->setCellWidget(ridx, 5, pWidget);
+	this->tableSuppliers->setCellWidget(ridx, 5, pWidget);
 	query.next();
     }
 }
@@ -78,7 +119,6 @@
 InventorySuppliers::~InventorySuppliers()
 {
     qDebug() << "InventorySuppliers done";
-//    delete ui;
 }
 
 
@@ -109,12 +149,3 @@
     edit(-1);
 }
 
-
-void InventorySuppliers::on_quitButton_clicked()
-{
-    qDebug() << Q_FUNC_INFO;
-
-    MainWindow a;
-    a.fromInventorySuppliers();
-}
-

mercurial