mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Cleanup: use DiveTripModelBase::clear() to reset the log
Introduce a DiveTripModelBase::clear() function that cleanly clears all dive data inside a beginResetModel()/endResetModel() pair. Thus, the UI will be cleanly reset and we can remove explicit calls to - graphics->setEmptyState() - mainTab->clearTabs() - mainTab->clearTabs() - diveList->reload() from MainWindow::closeCurrentFile(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f0a89759bf
commit
8a33c04894
3 changed files with 11 additions and 5 deletions
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue