Cleanup: initialize DiveListSortModel in constructor

The model was initialized in the global run_ui() function.
Move that into the constructor of the class.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-09-28 23:01:37 +02:00 committed by Dirk Hohndel
parent a30e6b306f
commit 2560734624
2 changed files with 6 additions and 5 deletions

View file

@ -3,11 +3,17 @@
#include "core/qthelper.h"
#include "core/trip.h"
#include "core/settings/qPrefGeneral.h"
#include "core/ssrf.h" // for LOG_STP
#include <QDateTime>
DiveListSortModel::DiveListSortModel(QObject *parent) : QSortFilterProxyModel(parent)
{
setSourceModel(DiveListModel::instance());
setDynamicSortFilter(true);
setSortRole(DiveListModel::DiveDateRole);
sort(0, Qt::DescendingOrder);
updateFilterState();
LOG_STP("run_ui diveListModel sorted");
}
void DiveListSortModel::updateFilterState()

View file

@ -99,11 +99,6 @@ void run_ui()
DiveListModel diveListModel;
LOG_STP("run_ui diveListModel started");
DiveListSortModel *sortModel = new DiveListSortModel(0);
sortModel->setSourceModel(&diveListModel);
sortModel->setDynamicSortFilter(true);
sortModel->setSortRole(DiveListModel::DiveDateRole);
sortModel->sort(0, Qt::DescendingOrder);
LOG_STP("run_ui diveListModel sorted");
GpsListModel gpsListModel;
QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(nullptr);
gpsSortModel->setSourceModel(&gpsListModel);