From d977c34d53a2d11b2d0f912e303c27c8af64a4cb Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Mon, 8 Apr 2019 16:45:24 +0930 Subject: database changes, lots of core work --- productinventory.cpp | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'productinventory.cpp') diff --git a/productinventory.cpp b/productinventory.cpp index 6b26aa0..5842a81 100644 --- a/productinventory.cpp +++ b/productinventory.cpp @@ -45,6 +45,12 @@ ProductInventory::ProductInventory(QWidget *parent) : headerLabels.append(QString("Brand")); headerLabels.append(QString("Color")); headerLabels.append(QString("Comment")); + headerLabels.append(QString("Images")); + headerLabels.append(QString("Date added")); + createTable("Connect to the database to populate the tables"); + + categoryLayout = new QGridLayout; + ui->filterCategoryScrollArea->setLayout(categoryLayout); } /*! @@ -53,6 +59,7 @@ ProductInventory::ProductInventory(QWidget *parent) : ProductInventory::~ProductInventory() { clearTables(); + delete categoryLayout; delete ui; } @@ -140,11 +147,7 @@ ProductInventory::resizeEvent(QResizeEvent* event) { QMainWindow::resizeEvent(event); ui->tableWidget->resizeRowsToContents(); // not needed? - QList::iterator i; - for (i = tables.begin(); i != tables.end(); i++) - { - (*i)->resizeRowsToContents(); - } + resizeRows(); } void ProductInventory::on_mustHaveImagesCheckBox_clicked() @@ -199,7 +202,16 @@ ProductInventory::clearTables() { (*l)->hide(); labels.erase(l); + delete *l; } + + QList::iterator c; + for (c = checkboxes.begin(); c != checkboxes.end(); c++) + { + checkboxes.erase(c); + delete *c; + } + } /*! @@ -213,7 +225,7 @@ ProductInventory::createTable(QString category) if (table == nullptr) return -1; table->setMinimumHeight(100); - table->setColumnCount(3); + table->setColumnCount(headerLabels.size()); table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); table->setHorizontalHeaderLabels(headerLabels); table->verticalHeader()->hide(); @@ -228,3 +240,16 @@ ProductInventory::createTable(QString category) tables.append(table); return tables.size()-1; } + +/*! + * resize each row in every table to fit its content + */ +void +ProductInventory::resizeRows() +{ + QList::iterator i; + for (i = tables.begin(); i != tables.end(); i++) + { + (*i)->resizeRowsToContents(); + } +} -- cgit v1.2.3