Fuzzy text search, part 0: Allow subclassing filters and sorters of SortFilterProxyModel#14
Fuzzy text search, part 0: Allow subclassing filters and sorters of SortFilterProxyModel#14juli27 wants to merge 6 commits into
Conversation
- Remove unused private method `reset()` - Remove unused invokable method `refresh()` - Remove unused signal `filtersChanged` - it is never emitted - expose roleIdFromName (formerly roleKey) - this is needed by later commits
This prevented multiple filters from using the same role. Also, filter subclasses won't necessarily operate on a single role.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (14)
📝 WalkthroughWalkthroughThis pull request refactors the UI components filtering and sorting architecture from concrete 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@framework/uicomponents/qml/Muse/UiComponents/filtervalue.cpp`:
- Around line 42-44: The code dereferences proxyModel.sourceModel() without a
null check; modify the logic around the call that gets sourceModel (the const
QAbstractItemModel* sourceModel = proxyModel.sourceModel() line) to test for
nullptr before using it (e.g., if sourceModel is null, bail out early or return
the appropriate default/false), so subsequent calls to sourceModel->index(...)
and sourceModel->data(...) are only executed when sourceModel is valid; update
the surrounding function (where index and data are used) to handle the null-case
consistently.
In `@framework/uicomponents/qml/Muse/UiComponents/sortervalue.cpp`:
- Around line 42-44: The code calls proxyModel.sourceModel() in sortervalue.cpp
and immediately dereferences it; add a null check for the returned
QAbstractItemModel* (e.g., store into a local const QAbstractItemModel*
sourceModel and if sourceModel is nullptr) before calling sourceModel->data(...)
to avoid dereferencing null (mirror the guard used in FilterValue::acceptsRow);
if null, handle appropriately (return a safe default/abort the comparison)
inside the SorterValue comparison logic so subsequent lines using sourceModel,
sourceLeft, and sourceRight are only executed when sourceModel is valid.
In `@framework/uicomponents/qml/Muse/UiComponents/sortfilterproxymodel.cpp`:
- Around line 44-51: The code uses inconsistent enum qualification for the
filter change direction: inside the invalidateRows lambda (function
invalidateRows) it calls endFilterChange(Direction::Rows) while elsewhere (e.g.,
where endFilterChange is called around line 120) the fully qualified
QSortFilterProxyModel::Direction::Rows is used; update the lambda to use the
same fully qualified enum (QSortFilterProxyModel::Direction::Rows) so enum
references are consistent across beginFilterChange/endFilterChange and the
invalidateRows lambda.
In
`@framework/uicomponents/qml/Muse/UiComponents/tests/sortfilterproxymodel_tests.cpp`:
- Around line 61-157: Add a regression test that verifies SortFilterProxyModel
dispatches to subclasses of Filter and Sorter by creating minimal test-double
subclasses (e.g., class TestFilter : public Filter and class TestSorter : public
Sorter) that override the base virtual methods (match/filter and compare/sort),
instantiate them, append them to proxyModel->filters() and
proxyModel->sorters(), and assert the proxyModel behavior changes according to
those overrides; place this alongside the existing tests (e.g.,
testFilterValue/testSorterValue) and use the same helper listModel(),
QQmlListProperty append pattern to attach the test doubles so you confirm
subclass polymorphism works through the Filter/Sorter contracts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4f2118b7-4a6a-4f45-aef3-23870cbc2234
📒 Files selected for processing (16)
framework/ui/internal/uiconfiguration.cppframework/ui/internal/uicontextconfiguration.cppframework/uicomponents/qml/Muse/UiComponents/CMakeLists.txtframework/uicomponents/qml/Muse/UiComponents/ValueList.qmlframework/uicomponents/qml/Muse/UiComponents/filter.cppframework/uicomponents/qml/Muse/UiComponents/filter.hframework/uicomponents/qml/Muse/UiComponents/filtervalue.cppframework/uicomponents/qml/Muse/UiComponents/filtervalue.hframework/uicomponents/qml/Muse/UiComponents/sorter.cppframework/uicomponents/qml/Muse/UiComponents/sorter.hframework/uicomponents/qml/Muse/UiComponents/sortervalue.cppframework/uicomponents/qml/Muse/UiComponents/sortervalue.hframework/uicomponents/qml/Muse/UiComponents/sortfilterproxymodel.cppframework/uicomponents/qml/Muse/UiComponents/sortfilterproxymodel.hframework/uicomponents/qml/Muse/UiComponents/tests/CMakeLists.txtframework/uicomponents/qml/Muse/UiComponents/tests/sortfilterproxymodel_tests.cpp
💤 Files with no reviewable changes (1)
- framework/ui/internal/uiconfiguration.cpp
f19df01 to
c4563a7
Compare
This is a prerequisite part for my effort to implement fuzzy search in MSS. (musescore/MuseScore#15983)
This aligns our
SortFilterProxyModela bit closer to Qt's new-ish Qml SortFilterProxyModel, while allowing custom filters and sorters.MuseScore Studio builds over at the previous home of these changes: musescore/MuseScore#33052.
Also used GitHub code search in the Audacity repo to check for uses of the removed methods. The changes shouldn't be breaking.
Build configuration
audacity: audacity/audacity/master
audacity platforms: linux_x64
musescore: musescore/MuseScore/master
musescore platforms: linux_x64 windows_x64 macos