import: initialize DiveSiteImportModel in constructor

The old code would construct and then initialize the object
in a separate function, which added lots of complication.

Just initialize the thing in the constructor, store a
reference, not a pointer to the table. And do a few other
code cleanups. The result is distinctly more pleasing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-12 22:09:18 +02:00 committed by bstoeger
parent 512eada468
commit 858a0aecba
3 changed files with 23 additions and 35 deletions

View file

@ -13,7 +13,7 @@
DivesiteImportDialog::DivesiteImportDialog(dive_site_table imported, QString source, QWidget *parent) : QDialog(parent),
importedSites(std::move(imported)),
importedSource(std::move(source)),
divesiteImportedModel(std::make_unique<DivesiteImportedModel>())
divesiteImportedModel(std::make_unique<DivesiteImportedModel>(importedSites))
{
QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_W), this);
QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q), this);
@ -40,8 +40,6 @@ DivesiteImportDialog::DivesiteImportDialog(dive_site_table imported, QString sou
connect(quit, SIGNAL(activated()), parent, SLOT(close()));
ui.ok->setEnabled(true);
divesiteImportedModel->repopulate(&importedSites);
}
DivesiteImportDialog::~DivesiteImportDialog()