D22735: Introduce ResultsModel with better data processing and filtering

Kai Uwe Broulik noreply at phabricator.kde.org
Thu Jul 25 10:25:38 BST 2019


broulik created this revision.
broulik added a reviewer: Plasma.
Herald added a project: Plasma.
Herald added a subscriber: plasma-devel.
broulik requested review of this revision.

REVISION SUMMARY
  This adds a new `Milou.ResultsModel` for runner results which tries very hard to avoid model resets and instead signals addition, removal, and changes in results.
  The various result processing, filtering, and grouping features are split into tiny dedicated proxy models to make the code easier to follow and maintain. The QML API isn't changed so that look and feel themes don't need to be adjusted.
  
  The raw results model is a tree of runner results grouped by `matchCategory` (e.g. "Documents", "Applications").
  Results are then sorted by result type (`ExactMatch`, `HelperMatch`, etc) and by their `relevance`. The highest scored match in a group determines its overall score. The previous heuristic of prefering categories who have results with the query in their visible text has been removed but could easily be added back if deemed beneficial for the quality of results.
  
  The groups are then limited in size with higher scored categories being allowed to show more matches. This model could in the future also be extended to allow expanding groups to show all of the results inside.
  After that the model is flattened back into a tree with the group items removed for consumption in the existing `ListView`. Items with an identical `text` will have their `subtext` displayed automatically for disambiguation.

TEST PLAN
  - KRunner feels snappier overall, especially when dealing with a result set that hardly changes, e.g. using the calculator runner
  - Ran model test and fixed most of its complaints. However, when updating a category, we append the new items, replace the entire list, and afterwards signal a data change, which model test doesn't like. It checks for whether the data before the inserted area didn't change, which it did at this point but that's why we signal a data change afterwards :)
  
  - Running results still works
  - Replacing the query string when requested still works, e.g. clicking on a calculator runner result changes the query string to that number
  - Dragging results from KRunner to elsewhere still works. I noticed dragging applications from krunner to kickoff doesn't work but didn't check if that is a regression or because KRunner closes when kickoff opens
  - Invoking runner actions (e.g. "run in terminal") still work

REPOSITORY
  R112 Milou

REVISION DETAIL
  https://phabricator.kde.org/D22735

AFFECTED FILES
  CMakeLists.txt
  lib/CMakeLists.txt
  lib/qml/ResultDelegate.qml
  lib/qml/ResultsView.qml
  lib/qml/qmlplugins.cpp
  lib/resultsmodel.cpp
  lib/resultsmodel.h
  lib/runnerresultsmodel.cpp
  lib/runnerresultsmodel.h

To: broulik, #plasma
Cc: plasma-devel, LeGast00n, jraleigh, fbampaloukas, GB_2, ragreen, Pitel, ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20190725/3f045132/attachment-0001.html>


More information about the Plasma-devel mailing list