From f1fc89b978c178fcd0f4f3ddb7629dc7df0d939d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 27 Dec 2018 10:06:11 +0100 Subject: Dive list: split DiveTripModel into distinct models (tree and list) The DiveTripModel was used to represent both, trip and list views. Thus many functions had conditionals checking for the current mode and both modes had to be represented by the same data structure. Instead, split the model in two and derive them from a base class, which implements common functions and defines an interface. The model can be switched by a call to resetModel(), which invalidates any pointer obtained by instance(). This is quite surprising behavior. To handle it, straighten out the control flow: DiveListView --> MultiFilterSortModel --> DiveTripModelBase Before, DiveListView accessed DiveTripModelBase directly. A goal of this commit is to enable usage of the same model by mobile and desktop. Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop-widgets/mainwindow.cpp') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 6c0b42c9d..aba1cfc63 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -702,7 +702,7 @@ void MainWindow::cleanUpEmpty() mainTab->updateDiveInfo(true); graphics->setEmptyState(); diveList->reload(); - diveList->setSortOrder(DiveTripModel::NR, Qt::DescendingOrder); + diveList->setSortOrder(DiveTripModelBase::NR, Qt::DescendingOrder); MapWidget::instance()->reload(); if (!existing_filename) setTitle(); -- cgit v1.2.3-70-g09d2