From fa7dfa37102fe2b0cf7518c329c3ba0273e39ab9 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 12 Sep 2020 23:31:46 +0200 Subject: desktop: add tab-widget for dive computer names If we want to include dive computer names in the undo system, there should be visual feedback on undo/redo. This would mean opening the divecomputer dialog, which would appear quite strange. Therefore, add a tab. This is not ideal, but consistent with the dive site tab, which probably shouldn't be there either. In the future, the UI needs some rethinking. Signed-off-by: Berthold Stoeger --- qt-models/divecomputermodel.cpp | 8 ++++++++ qt-models/divecomputermodel.h | 1 + 2 files changed, 9 insertions(+) (limited to 'qt-models') diff --git a/qt-models/divecomputermodel.cpp b/qt-models/divecomputermodel.cpp index d0b9f7637..356e24ef8 100644 --- a/qt-models/divecomputermodel.cpp +++ b/qt-models/divecomputermodel.cpp @@ -113,3 +113,11 @@ bool DiveComputerSortedModel::lessThan(const QModelIndex &i1, const QModelIndex return sortHelper(i1, i2, DiveComputerModel::MODEL, DiveComputerModel::ID); } } + +void DiveComputerSortedModel::remove(const QModelIndex &index) +{ + int row = mapToSource(index).row(); + if (row < 0 || row >= (int)device_table.devices.size()) + return; + device_table.devices.erase(device_table.devices.begin() + row); +} diff --git a/qt-models/divecomputermodel.h b/qt-models/divecomputermodel.h index b21eadcc9..7f3d4171f 100644 --- a/qt-models/divecomputermodel.h +++ b/qt-models/divecomputermodel.h @@ -33,6 +33,7 @@ private: class DiveComputerSortedModel : public QSortFilterProxyModel { public: using QSortFilterProxyModel::QSortFilterProxyModel; + void remove(const QModelIndex &index); private: bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const; }; -- cgit v1.2.3-70-g09d2