mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
2560734624
commit
36d42a6a57
3 changed files with 5 additions and 10 deletions
|
@ -140,11 +140,9 @@ QString DiveListSortModel::tripShortDate(const QString §ion)
|
||||||
return QStringLiteral("%1\n'%2").arg(firstMonth,firstTime.toString("yy"));
|
return QStringLiteral("%1\n'%2").arg(firstMonth,firstTime.toString("yy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DiveListModel *DiveListModel::m_instance = NULL;
|
DiveListModel::DiveListModel()
|
||||||
|
|
||||||
DiveListModel::DiveListModel(QObject *parent) : QAbstractListModel(parent)
|
|
||||||
{
|
{
|
||||||
m_instance = this;
|
LOG_STP("run_ui diveListModel started");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListModel::insertDive(int i)
|
void DiveListModel::insertDive(int i)
|
||||||
|
@ -297,7 +295,8 @@ QString DiveListModel::startAddDive()
|
||||||
|
|
||||||
DiveListModel *DiveListModel::instance()
|
DiveListModel *DiveListModel::instance()
|
||||||
{
|
{
|
||||||
return m_instance;
|
static DiveListModel self;
|
||||||
|
return &self;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dive *DiveListModel::getDive(int i)
|
struct dive *DiveListModel::getDive(int i)
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static DiveListModel *instance();
|
static DiveListModel *instance();
|
||||||
DiveListModel(QObject *parent = 0);
|
DiveListModel();
|
||||||
void addDive(const QList<dive *> &listOfDives);
|
void addDive(const QList<dive *> &listOfDives);
|
||||||
void addAllDives();
|
void addAllDives();
|
||||||
void insertDive(int i);
|
void insertDive(int i);
|
||||||
|
@ -64,8 +64,6 @@ public:
|
||||||
void resetInternalData();
|
void resetInternalData();
|
||||||
void clear(); // Clear all dives in core
|
void clear(); // Clear all dives in core
|
||||||
Q_INVOKABLE DiveObjectHelper at(int i);
|
Q_INVOKABLE DiveObjectHelper at(int i);
|
||||||
private:
|
|
||||||
static DiveListModel *m_instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIVELISTMODEL_H
|
#endif // DIVELISTMODEL_H
|
||||||
|
|
|
@ -96,8 +96,6 @@ void run_ui()
|
||||||
qDebug() << "QML import path" << engine.importPathList();
|
qDebug() << "QML import path" << engine.importPathList();
|
||||||
#endif // __APPLE__ not Q_OS_IOS
|
#endif // __APPLE__ not Q_OS_IOS
|
||||||
engine.addImportPath("qrc://imports");
|
engine.addImportPath("qrc://imports");
|
||||||
DiveListModel diveListModel;
|
|
||||||
LOG_STP("run_ui diveListModel started");
|
|
||||||
DiveListSortModel *sortModel = new DiveListSortModel(0);
|
DiveListSortModel *sortModel = new DiveListSortModel(0);
|
||||||
GpsListModel gpsListModel;
|
GpsListModel gpsListModel;
|
||||||
QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(nullptr);
|
QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(nullptr);
|
||||||
|
|
Loading…
Add table
Reference in a new issue