aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-01-30 20:12:11 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-02-11 20:37:09 -0800
commit6622f42aab937e72cc11cb5512012394aa687767 (patch)
tree42302a42594b78b99111e98c6fd9325a0b9c5959 /desktop-widgets/tab-widgets/TabDiveEquipment.cpp
parentb37c261c95761cb5762e91b5d43277d2b0181678 (diff)
downloadsubsurface-6622f42aab937e72cc11cb5512012394aa687767.tar.gz
Cylinders: Add CylindersModelFiltered
When the show_unused_cylinders flag is not set, the cylinder tables in the equipment tab and the planner should not show unused cylinders. However, the code in CylindersModel is fundamentally broken if the unused cylinders are not at the end of the list: The correct number of cylinders is shown, but not the correct cylinders. Therefore, add a higher-level CylindersModelFiltered model on top of CylindersModel that does the actual filtering. Some calls are routed through to the base model (notably those that take indexes, as these have to be mapped), for some calls the caller has to get access to the source model first. We might want to adjust this. For filtering, reuse the already existing show_cylinder function and export it via CylindersModel. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/TabDiveEquipment.cpp')
-rw-r--r--desktop-widgets/tab-widgets/TabDiveEquipment.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
index f731631eb..0a5786e50 100644
--- a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
@@ -17,7 +17,7 @@
#include <QCompleter>
TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent),
- cylindersModel(new CylindersModel(this)),
+ cylindersModel(new CylindersModelFiltered(this)),
weightModel(new WeightModel(this))
{
QCompleter *suitCompleter;
@@ -33,7 +33,7 @@ TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent),
ui.weights->setModel(weightModel);
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveEquipment::divesChanged);
- connect(ui.cylinders, &TableView::itemClicked, cylindersModel, &CylindersModel::remove);
+ connect(ui.cylinders, &TableView::itemClicked, cylindersModel, &CylindersModelFiltered::remove);
connect(ui.cylinders, &TableView::itemClicked, this, &TabDiveEquipment::editCylinderWidget);
connect(ui.weights, &TableView::itemClicked, this, &TabDiveEquipment::editWeightWidget);
@@ -164,7 +164,7 @@ void TabDiveEquipment::addWeight_clicked()
void TabDiveEquipment::editCylinderWidget(const QModelIndex &index)
{
- if (cylindersModel->changed && !MainWindow::instance()->mainTab->isEditing()) {
+ if (cylindersModel->model()->changed && !MainWindow::instance()->mainTab->isEditing()) {
MainWindow::instance()->mainTab->enableEdition();
return;
}
@@ -228,7 +228,7 @@ void TabDiveEquipment::acceptChanges()
// to the original value in current_dive like it should
QVector<dive *> selectedDives = getSelectedDivesCurrentLast();
- if (cylindersModel->changed) {
+ if (cylindersModel->model()->changed) {
mark_divelist_changed(true);
MODIFY_DIVES(selectedDives,
// if we started out with the same cylinder description (for multi-edit) or if we do copt & paste
@@ -257,12 +257,12 @@ void TabDiveEquipment::acceptChanges()
if (do_replot)
MainWindow::instance()->graphics->replot();
- cylindersModel->changed = false;
+ cylindersModel->model()->changed = false;
}
void TabDiveEquipment::rejectChanges()
{
- cylindersModel->changed = false;
+ cylindersModel->model()->changed = false;
cylindersModel->updateDive();
weightModel->updateDive(current_dive);
}