diff options
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 6 | ||||
-rw-r--r-- | qt-models/divetripmodel.cpp | 7 | ||||
-rw-r--r-- | qt-models/divetripmodel.h | 3 |
3 files changed, 11 insertions, 5 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 632917733..7b3120ca4 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -657,12 +657,8 @@ void MainWindow::closeCurrentFile() { /* free the dives and trips */ clear_git_id(); - clear_dive_file_data(); + DiveTripModelBase::instance()->clear(); setCurrentFile(nullptr); - graphics->setEmptyState(); - mainTab->clearTabs(); - mainTab->updateDiveInfo(); - diveList->reload(); diveList->setSortOrder(DiveTripModelBase::NR, Qt::DescendingOrder); MapWidget::instance()->reload(); LocationInformationModel::instance()->update(); diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index d8166d2eb..5fedd432f 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -372,6 +372,13 @@ void DiveTripModelBase::resetModel(DiveTripModelBase::Layout layout) currentModel.reset(new DiveTripModelList); } +void DiveTripModelBase::clear() +{ + beginResetModel(); + clear_dive_file_data(); + endResetModel(); +} + DiveTripModelBase::DiveTripModelBase(QObject *parent) : QAbstractItemModel(parent) { } diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h index dc0d4b299..6b3f26fd7 100644 --- a/qt-models/divetripmodel.h +++ b/qt-models/divetripmodel.h @@ -70,6 +70,9 @@ public: // by instance(). static void resetModel(Layout layout); + // Clear all dives + void clear(); + Qt::ItemFlags flags(const QModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; |