Bug 396102

Summary: ResultsModel emits wrong rowsMoved transactions
Product: [Frameworks and Libraries] frameworks-activities-stats Reporter: Eike Hein <hein>
Component: generalAssignee: Ivan Čukić <ivan.cukic>
Status: RESOLVED FIXED    
Severity: normal CC: plasma-bugs-null
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Eike Hein 2018-07-02 18:02:55 UTC
A ResultsModel with the following query:

RecentlyUsedFirst | Agent::any() | Type::any() | Activity::current() | Url::startsWith("applications:") | Limit(15)

... does not correctly update when apps listed in the model are launched. For example, after launching the app at index 3, I would expect a moveRows from 3 to 0, but I get a 3 to 5.
Comment 1 Eike Hein 2018-07-02 18:04:03 UTC
Note that KActivitiesStatsTestApp doesn't catch this because it doesn't seem to use ResultsModel and doesn't do live updating. The query when re-run produces the right results, so the db is fine; just the model doesn't update correctly.
Comment 2 Eike Hein 2018-07-02 18:44:46 UTC
I'm currently too busy to attempt a fix in KActivitiesStats, so here's a workaround for Kicker for now: https://phabricator.kde.org/D13856
Comment 3 Ivan Čukić 2018-07-02 23:08:05 UTC
I'm currently without my development machine. I'll check this out when it becomes operational.
Comment 4 David Edmundson 2018-07-03 14:23:10 UTC
Git commit 75d6103df944c02a7ff4f85f2d2e565d3fdc40bc by David Edmundson.
Committed on 03/07/2018 at 14:22.
Pushed by davidedmundson into branch 'master'.

Fix ResultModel item moving

Summary:
The intention of this code is to find the new insertion index in the
cache where a resource should now be by counting number of items in the
cache with a higher score/update time/whatever.

FixedItems comparison compares two resources by string IDs, checking if
they're user pinned. If so they go on top.

In FullOrdering if neither compared item is pinned it also compares literal
resourceId. Useful if you have no other sorting tests and want to
maintain order, not useful if we want to contintue to compare the score
as in 50% case of the cases we'll fail our lessThan early.

Test Plan:
Ran test app
Changed some scores by clicking in kickoff
They moved appropriately instead of being moved all over the place

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D13866

M  +1    -1    src/resultmodel.cpp

https://commits.kde.org/kactivities-stats/75d6103df944c02a7ff4f85f2d2e565d3fdc40bc