--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/InventorySuppliers.cpp Sat Feb 12 21:24:43 2022 +0100 @@ -0,0 +1,71 @@ +/** + * InventorySuppliers.cpp is part of bmsapp. + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "InventorySuppliers.h" +#include "../ui/ui_InventorySuppliers.h" +#include "config.h" + +#include <QDebug> +//#include <QSqlTableModel> +//#include <QTableView> +//#include <QtWidgets> +#include <QtSql> +#include <QTableWidget> + + + +InventorySuppliers::InventorySuppliers(QWidget *parent) : QDialog(parent), ui(new Ui::InventorySuppliers) +{ + qDebug() << Q_FUNC_INFO; + + QTableWidget* table = new QTableWidget(); + QSqlQuery query("SELECT * FROM inventory_suppliers ORDER BY name"); + + table->setColumnCount(query.record().count() - 1); /* Skip the last uuid column */ + table->setRowCount(query.size()); + + table->setHorizontalHeaderLabels({"record", "name", "address", "city", "zip", "country", "website", "email", "phone", "remark"}); + + qDebug() << query.record().count() << query.size(); + // So far, so good. + query.first(); + for (int ridx = 0 ; ridx < query.size() ; ridx++ ) { + for (int cidx = 0 ; cidx < query.record().count() - 1; cidx++) { + QTableWidgetItem* item = new QTableWidgetItem(query.value(cidx).toString()); + table->setItem(ridx, cidx, item ); + //qDebug() << ridx << cidx << query.value(cidx).toString(); + } + query.next(); + } + table->show(); /* TODO: Uses a separate window */ + + ui->setupUi(this); + setWindowTitle( QString("BMSapp - %1 - Inventory Suppliers").arg(VERSIONSTRING) ); +} + +InventorySuppliers::~InventorySuppliers() +{ + qDebug() << Q_FUNC_INFO; + delete ui; +} + + +void InventorySuppliers::on_changeButton_clicked() +{ + qDebug() << Q_FUNC_INFO; + emit firstWindow(); +} +