mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:43:25 +00:00
QML UI: Sort dives by date
Sort the dives by date, with the latest one appearing before the others. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
This commit is contained in:
parent
ab44c78993
commit
b0df506a8c
1 changed files with 7 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include "qt-mobile/qmlmanager.h"
|
#include "qt-mobile/qmlmanager.h"
|
||||||
#include "qt-models/divelistmodel.h"
|
#include "qt-models/divelistmodel.h"
|
||||||
#include "qt-mobile/qmlprofile.h"
|
#include "qt-mobile/qmlprofile.h"
|
||||||
|
@ -44,8 +45,13 @@ void run_ui()
|
||||||
qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
|
qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
DiveListModel diveListModel;
|
DiveListModel diveListModel;
|
||||||
|
QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(0);
|
||||||
|
sortModel->setSourceModel(&diveListModel);
|
||||||
|
sortModel->setDynamicSortFilter(true);
|
||||||
|
sortModel->setSortRole(DiveListModel::DiveDateRole);
|
||||||
|
sortModel->sort(0, Qt::DescendingOrder);
|
||||||
QQmlContext *ctxt = engine.rootContext();
|
QQmlContext *ctxt = engine.rootContext();
|
||||||
ctxt->setContextProperty("diveModel", &diveListModel);
|
ctxt->setContextProperty("diveModel", sortModel);
|
||||||
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
||||||
qqWindowObject = engine.rootObjects().value(0);
|
qqWindowObject = engine.rootObjects().value(0);
|
||||||
if (!qqWindowObject) {
|
if (!qqWindowObject) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue