diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/main.cpp | 4 | ||||
-rw-r--r-- | src/model/FilterModel.cpp | 8 | ||||
-rw-r--r-- | src/model/FilterModel.h | 14 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/main/main.cpp b/src/main/main.cpp index 7f4e9f7..27a4800 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -21,6 +21,7 @@ #include <QDebug> // #include <iostream> #include "../model/Sport.h" +#include "../model/FilterModel.h" int main(int argc, char *argv[]) { @@ -31,7 +32,10 @@ int main(int argc, char *argv[]) SportModel model; model.request("ARC"); + FilterModel filter; + filter.setSourceModel(&model); objectContext->setContextProperty("sports", &model); + objectContext->setContextProperty("filter", &filter); QQmlComponent component(&engine, "qrc:/qt/qml/itat/res/gui/application.qml"); QObject *object = component.create(objectContext); diff --git a/src/model/FilterModel.cpp b/src/model/FilterModel.cpp new file mode 100644 index 0000000..7fe07d6 --- /dev/null +++ b/src/model/FilterModel.cpp @@ -0,0 +1,8 @@ +#include "FilterModel.h" +#include "Sport.h" + +FilterModel::FilterModel(QObject *parent) + : QSortFilterProxyModel(parent) { + setFilterRole(SportModel::Role::EventName); + } + diff --git a/src/model/FilterModel.h b/src/model/FilterModel.h new file mode 100644 index 0000000..0bd1fbb --- /dev/null +++ b/src/model/FilterModel.h @@ -0,0 +1,14 @@ +#include <QSortFilterProxyModel> + +#pragma once + +class FilterModel : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + FilterModel(QObject *parent = nullptr); + +private: +}; + |