This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Avoiding insertion of multiple identical matches in KRunner

Tags: None
(comma "," separated)
Bakuriu2
Registered Member
Posts
2
Karma
0
I'm developping a python Runner for KRunner and it works fine, except that multiple matches for identical items are shown.
The runner searches into a database some results based on a list of "tags" provided by the user.

For example if the user digits "searching, array" the runner will look into the database and find the results that have those tags.
The problem is that when the user writes "searching" a certain number of matches is show and when it adds ", array" some other matches are added,
even though they are already present in KRunner's result list.

I've tried to set a unique id for the QueryMatches but it does not work. I tried to use RunnerContext.match(id_str) to see whether there is already a matching item but it always return an invalid QueryMatch. Also calling RunnerContext.matches() will always return an empty list, no matter what.

How can I avoid this behaviour? I thought the runner checked the ids of the matches and automatically avoided inserting duplicate matches, but it clearly does not do this.
User avatar
einar
Administrator
Posts
3402
Karma
7
OS
Is your code available somewhere? I might take a look.


"Violence is the last refuge of the incompetent."
Image
Plasma FAQ maintainer - Plasma programming with Python
Bakuriu2
Registered Member
Posts
2
Karma
0
You may find the source code on bitbucket:
https://bitbucket.org/bakuriu/pseudocoderunner/src

The relevant file is contents/code/pseudocode/runner.py.

You may create a database of examples running contents/data/examples.py adding contents/code to the PYTHONPATH. If you try to run the plug-in and digit for example "linear" you'll see two identical matches showing up(one is generated looking up the linear tag and one looking up the title).
Bakuriu
Registered Member
Posts
4
Karma
0
I've managed to avoid insterting duplicated item. Badsically before adding the matches to the runner I manually scan them and remove duplicates.
I'm still interested if there is a way of avoiding this "by hand".
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You might want to try asking on plasma-devel@kde.org about that..


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient