{"id":13630048,"url":"https://github.com/oKcerG/SortFilterProxyModel","last_synced_at":"2025-04-17T13:31:17.542Z","repository":{"id":4223987,"uuid":"52406733","full_name":"oKcerG/SortFilterProxyModel","owner":"oKcerG","description":"A nicely exposed QSortFilterProxyModel for QML","archived":false,"fork":false,"pushed_at":"2023-07-18T14:31:39.000Z","size":245,"stargazers_count":303,"open_issues_count":40,"forks_count":102,"subscribers_count":36,"default_branch":"master","last_synced_at":"2024-11-08T21:38:21.067Z","etag":null,"topics":["filter","proxy-model","qml","qpm","qt","sort"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oKcerG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-02-24T02:05:20.000Z","updated_at":"2024-11-02T11:20:57.000Z","dependencies_parsed_at":"2024-01-14T06:56:33.794Z","dependency_job_id":null,"html_url":"https://github.com/oKcerG/SortFilterProxyModel","commit_stats":{"total_commits":123,"total_committers":12,"mean_commits":10.25,"dds":0.4552845528455285,"last_synced_commit":"5a930885b7ea99f7f41c25fce08bf8006ee54e3f"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oKcerG%2FSortFilterProxyModel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oKcerG%2FSortFilterProxyModel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oKcerG%2FSortFilterProxyModel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oKcerG%2FSortFilterProxyModel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oKcerG","download_url":"https://codeload.github.com/oKcerG/SortFilterProxyModel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249344776,"owners_count":21254734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filter","proxy-model","qml","qpm","qt","sort"],"created_at":"2024-08-01T22:01:28.402Z","updated_at":"2025-04-17T13:31:17.249Z","avatar_url":"https://github.com/oKcerG.png","language":"C++","readme":"SortFilterProxyModel\n====================\n\nSortFilterProxyModel is an implementation of `QSortFilterProxyModel` conveniently exposed for QML.\n\nInstall\n-------\n##### With [qpm](https://qpm.io) :\n1. `qpm install fr.grecko.sortfilterproxymodel`\n2. add `include(vendor/vendor.pri)` in your .pro if it is not already done\n3. `import SortFilterProxyModel 0.2` to use this library in your QML files\n\n##### Without qpm :\n1. clone or download this repository\n2. * `qmake` add `include  (\u003cpath/to/SortFilterProxyModel\u003e/SortFilterProxyModel.pri)` in your `.pro`\n   * `CMake` add $\u003cTARGET_OBJECTS:SortFilterProxyModel\u003e to the sources of your executable target in your cmake project\n3. `import SortFilterProxyModel 0.2` to use this library in your QML files\n\nSample Usage\n------------\n\n- You can do simple filtering and sorting with SortFilterProxyModel:\n```qml\nimport QtQuick 2.2\nimport QtQuick.Controls 1.2\nimport SortFilterProxyModel 0.2\n\nApplicationWindow {\n    visible: true\n    width: 640\n    height: 480\n\n    ListModel {\n        id: personModel\n        ListElement {\n            firstName: \"Erwan\"\n            lastName: \"Castex\"\n            favorite: true\n        }\n        // ...\n    }\n\n    TextField {\n        id: textField\n        anchors { top: parent.top; left: parent.left; right: parent.right }\n        height: implicitHeight\n    }\n\n    SortFilterProxyModel {\n        id: personProxyModel\n        sourceModel: personModel\n        filters: RegExpFilter {\n            roleName: \"lastName\"\n            pattern: textField.text\n            caseSensitivity: Qt.CaseInsensitive\n        }\n        sorters: StringSorter { roleName: \"firstName\" }\n    }\n\n    ListView {\n        anchors { top: textField.bottom; bottom: parent.bottom; left: parent.left; right: parent.right }\n        model: personProxyModel\n        delegate: Text { text: model.firstName + \" \" + model.lastName}\n    }\n}\n```\nHere the `ListView` will only show elements that contains the content of the `TextField` in their `lastName` role.\n\n- But you can also achieve more complex filtering or sorting with multiple `filters` and `sorters`:\n```qml\n    SortFilterProxyModel {\n        id: personProxyModel\n        sourceModel: personModel\n        filters: [\n            ValueFilter {\n                enabled: onlyShowFavoritesCheckbox.checked\n                roleName: \"favorite\"\n                value: true\n            },\n            AnyOf {\n                RegExpFilter {\n                    roleName: \"lastName\"\n                    pattern: textField.text\n                    caseSensitivity: Qt.CaseInsensitive\n                }\n                RegExpFilter {\n                    roleName: \"firstName\"\n                    pattern: textField.text\n                    caseSensitivity: Qt.CaseInsensitive\n                }\n            }\n        ]\n        sorters: [\n            RoleSorter { roleName: \"favorite\"; sortOrder: Qt.DescendingOrder },\n            StringSorter { roleName: \"firstName\" },\n            StringSorter { roleName: \"lastName\" }\n        ]\n    }\n\n    CheckBox {\n        id:onlyShowFavoritesCheckbox\n    }\n```\nThis will show in the corresponding `ListView` only the elements where the `firstName` or the `lastName` match the text entered in the `textField`, and if the `onlyShowFavoritesCheckbox` is checked it will aditionnally filter the elements where `favorite` is `true`.\nThe favorited elements will be shown first and all the elements are sorted by `firstName` and then `lastName`.\n\nShowcase Application\n--------------------\nYou can find an application showcasing this library here: https://github.com/oKcerG/SFPMShowcase\n\nLicense\n-------\nThis library is licensed under the MIT License.\n\nDocumentation\n-------------\nThis component is a subclass of [`QSortFilterProxyModel`](http://doc.qt.io/qt-5/qsortfilterproxymodel.html), to use it, you need to set the `sourceModel` property to a [`QAbstractItemModel*`](http://doc.qt.io/qt-5/qabstractitemmodel.html) with correct role names.\nThis means you can use it with custom c++ models or `ListModel`, but not with JavaScript models like arrays, integers or object instances.\n\nThe complete documentation reference is available here: https://okcerg.github.io/SortFilterProxyModel/\n\nContributing\n------------\nDon't hesitate to open an issue about a suggestion, a bug, a lack of clarity in the documentation, etc.\n\nPull requests are also welcome, if it's a important change you should open an issue first though.\n","funding_links":[],"categories":["C++","Misc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FoKcerG%2FSortFilterProxyModel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FoKcerG%2FSortFilterProxyModel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FoKcerG%2FSortFilterProxyModel/lists"}