diff options
Diffstat (limited to 'qt-ui/divecomputermanagementdialog.cpp')
-rw-r--r-- | qt-ui/divecomputermanagementdialog.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/qt-ui/divecomputermanagementdialog.cpp b/qt-ui/divecomputermanagementdialog.cpp index 4d9770a4d..2a1bb8bff 100644 --- a/qt-ui/divecomputermanagementdialog.cpp +++ b/qt-ui/divecomputermanagementdialog.cpp @@ -3,16 +3,26 @@ #include "ui_divecomputermanagementdialog.h" #include "mainwindow.h" #include <QMessageBox> +#include "../qthelper.h" +#include "../helpers.h" -DiveComputerManagementDialog::DiveComputerManagementDialog(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f) -, ui( new Ui::DiveComputerManagementDialog()) +DiveComputerManagementDialog::DiveComputerManagementDialog(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f), + ui( new Ui::DiveComputerManagementDialog()), + model(0) { ui->setupUi(this); - model = new DiveComputerModel(); - ui->tableView->setModel(model); + init(); connect(ui->tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(tryRemove(QModelIndex))); } +void DiveComputerManagementDialog::init() +{ + if (model) + delete model; + model = new DiveComputerModel(dcList.dcMap); + ui->tableView->setModel(model); +} + DiveComputerManagementDialog* DiveComputerManagementDialog::instance() { static DiveComputerManagementDialog *self = new DiveComputerManagementDialog(); @@ -44,3 +54,17 @@ void DiveComputerManagementDialog::tryRemove(const QModelIndex& index) model->remove(index); } } + +void DiveComputerManagementDialog::accept() +{ + model->keepWorkingList(); + hide(); + close(); +} + +void DiveComputerManagementDialog::reject() +{ + model->dropWorkingList(); + hide(); + close(); +} |