summaryrefslogtreecommitdiff
path: root/productinventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'productinventory.cpp')
-rw-r--r--productinventory.cpp37
1 files changed, 31 insertions, 6 deletions
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<QTableWidget *>::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<QCheckBox *>::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<QTableWidget *>::iterator i;
+ for (i = tables.begin(); i != tables.end(); i++)
+ {
+ (*i)->resizeRowsToContents();
+ }
+}