diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-09-28 23:05:49 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-04 09:19:10 -0700 |
commit | 36d42a6a57e8f79de1c8daf01e77a811ef0392dc (patch) | |
tree | 313b56c6cc4cba5bb72a52c6390d7f6b6d7f6f6a /qt-models | |
parent | 2560734624d404728b28ff7c5e7e34a1006a4b36 (diff) | |
download | subsurface-36d42a6a57e8f79de1c8daf01e77a811ef0392dc.tar.gz |
Cleanup: turn DiveListModel into standard singleton
DiveListModel was one of those "special" singletons that could
be created explicitly with new. This would make sense if a
parameter were passed to the constructor. We only passed null,
so one might as well turn that into a classical singleton with
default constructor.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divelistmodel.cpp | 9 | ||||
-rw-r--r-- | qt-models/divelistmodel.h | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 39f8fbc47..6d94b09c9 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -140,11 +140,9 @@ QString DiveListSortModel::tripShortDate(const QString §ion) return QStringLiteral("%1\n'%2").arg(firstMonth,firstTime.toString("yy")); } -DiveListModel *DiveListModel::m_instance = NULL; - -DiveListModel::DiveListModel(QObject *parent) : QAbstractListModel(parent) +DiveListModel::DiveListModel() { - m_instance = this; + LOG_STP("run_ui diveListModel started"); } void DiveListModel::insertDive(int i) @@ -297,7 +295,8 @@ QString DiveListModel::startAddDive() DiveListModel *DiveListModel::instance() { - return m_instance; + static DiveListModel self; + return &self; } struct dive *DiveListModel::getDive(int i) diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 19838f468..87c5bb254 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -46,7 +46,7 @@ public: }; static DiveListModel *instance(); - DiveListModel(QObject *parent = 0); + DiveListModel(); void addDive(const QList<dive *> &listOfDives); void addAllDives(); void insertDive(int i); @@ -64,8 +64,6 @@ public: void resetInternalData(); void clear(); // Clear all dives in core Q_INVOKABLE DiveObjectHelper at(int i); -private: - static DiveListModel *m_instance; }; #endif // DIVELISTMODEL_H |