Skip to content
Permalink
Browse files

Add edit-in-place algorithms to locator fuzzy search

  • Loading branch information
uclaros authored and nyalldawson committed Nov 15, 2020
1 parent fba2e03 commit 72fea560ee835888e6d763f1d1ccb4d392fde891
Showing with 25 additions and 11 deletions.
  1. +25 −11 python/plugins/processing/gui/AlgorithmLocatorFilter.py
@@ -161,17 +161,31 @@ def fetchResults(self, string, context, feedback):
if not a.supportInPlaceEdit(iface.activeLayer()):
continue

if QgsLocatorFilter.stringMatches(a.displayName(), string) or [t for t in a.tags() if QgsLocatorFilter.stringMatches(t, string)] or \
(context.usingPrefix and not string):
result = QgsLocatorResult()
result.filter = self
result.displayString = a.displayName()
result.icon = a.icon()
result.userData = a.id()
if string and QgsLocatorFilter.stringMatches(a.displayName(), string):
result.score = float(len(string)) / len(a.displayName())
else:
result.score = 0
result = QgsLocatorResult()
result.filter = self
result.displayString = a.displayName()
result.icon = a.icon()
result.userData = a.id()
result.score = 0

if (context.usingPrefix and not string):
self.resultFetched.emit(result)

if not string:
return

string = string.lower()
tagScore = 0
tags = [*a.tags(), a.provider().name(), a.group()]

for t in tags:
if string in t.lower():
tagScore = 1
break

result.score = QgsStringUtils.fuzzyScore(result.displayString, string) * 0.5 + tagScore * 0.5

if result.score > 0:
self.resultFetched.emit(result)

def triggerResult(self, result):

0 comments on commit 72fea56

Please sign in to comment.
You can’t perform that action at this time.