From 3db50aedeaea94b7395fe6fcdb56bda9bee2f2cb Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 28 Sep 2019 23:31:40 +0200 Subject: Cleanup: Turn DiveListSortModel into classical singleton To make this class available from QMLManager, the run_ui() function would create the object and then set a pointer in QMLManager. It works, but is inconsistent with the rest of the code. Therefore, make it a classical singleton class, which is generated on demand. Signed-off-by: Berthold Stoeger --- qt-models/divelistmodel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'qt-models/divelistmodel.cpp') diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 6d94b09c9..d3c4e3ce2 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -6,7 +6,7 @@ #include "core/ssrf.h" // for LOG_STP #include -DiveListSortModel::DiveListSortModel(QObject *parent) : QSortFilterProxyModel(parent) +DiveListSortModel::DiveListSortModel() { setSourceModel(DiveListModel::instance()); setDynamicSortFilter(true); @@ -16,6 +16,12 @@ DiveListSortModel::DiveListSortModel(QObject *parent) : QSortFilterProxyModel(pa LOG_STP("run_ui diveListModel sorted"); } +DiveListSortModel *DiveListSortModel::instance() +{ + static DiveListSortModel self; + return &self; +} + void DiveListSortModel::updateFilterState() { if (filterString.isEmpty()) { -- cgit v1.2.3-70-g09d2