Changed a lot of code to reduce boilerplate on models in the future.

So, I changed a lot of code to reduce boilerplate on models in the
future. Currently we do not have a lot of models, but this can increase
quite rapdly. There's a second TreeModel in the works, the Yearly
Statistics, this patch will save around 250 LOC for this new model,
and more and more models will give us a greater saving.

Iwll do that for the table models in the future too - I did the tree
models now because they are the most complex case and I didn't wanted
to create a second tree model without this.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-06-17 18:59:50 -03:00
parent 14ccbbf6e8
commit ae68ae38bb
5 changed files with 165 additions and 154 deletions

View file

@ -437,7 +437,7 @@ void MainWindow::initialUiSetup()
/* if no width are set, use the calculated width for each column;
* for that to work we need to temporarily expand all rows */
ui->ListWidget->expandAll();
for (i = TreeItemDT::NR; i < TreeItemDT::COLUMNS; i++) {
for (i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) {
QVariant width = settings.value(QString("colwidth%1").arg(i));
if (width.isValid())
ui->ListWidget->setColumnWidth(i, width.toInt());
@ -526,7 +526,7 @@ void MainWindow::writeSettings()
settings.endGroup();
settings.beginGroup("ListWidget");
for (i = TreeItemDT::NR; i < TreeItemDT::COLUMNS; i++)
for (i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++)
if (!ui->ListWidget->isColumnHidden(i))
settings.setValue(QString("colwidth%1").arg(i), ui->ListWidget->columnWidth(i));
settings.endGroup();