def fetchResults(self, string, context, feedback): # collect results in main thread, since this method is inexpensive and # accessing the processing registry/current layer is not thread safe if iface.activeLayer() is None or iface.activeLayer().type() != QgsMapLayer.VectorLayer or not iface.activeLayer().selectedFeatureCount(): return for a in QgsApplication.processingRegistry().algorithms(): if not a.flags() & QgsProcessingAlgorithm.FlagSupportsInPlaceEdits: continue 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 self.resultFetched.emit(result)
def fetchResults(self, string, context, feedback): # collect results in main thread, since this method is inexpensive and # accessing the processing registry/current layer is not thread safe if iface.activeLayer() is None or iface.activeLayer().type() != QgsMapLayer.VectorLayer: return for a in QgsApplication.processingRegistry().algorithms(): if not a.flags() & QgsProcessingAlgorithm.FlagSupportsInPlaceEdits: continue 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 self.resultFetched.emit(result)
def fetchResults(self, string, context, feedback): # collect results in main thread, since this method is inexpensive and # accessing the processing registry is not thread safe for a in QgsApplication.processingRegistry().algorithms(): if a.flags() & QgsProcessingAlgorithm.FlagHideFromToolbox: continue if QgsLocatorFilter.stringMatches(a.displayName(), string) or [t for t in a.tags() if QgsLocatorFilter.stringMatches(t, 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 self.resultFetched.emit(result)
def fetchResults(self, string, context, feedback): for a in QgsApplication.processingRegistry().algorithms(): if feedback.isCanceled(): return if a.flags() & QgsProcessingAlgorithm.FlagHideFromToolbox: continue if QgsLocatorFilter.stringMatches(a.displayName(), string) or [t for t in a.tags() if QgsLocatorFilter.stringMatches(t, 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 self.resultFetched.emit(result)
def testStringMatches(self): self.assertFalse(QgsLocatorFilter.stringMatches('xxx', 'yyyy')) self.assertTrue(QgsLocatorFilter.stringMatches('axxxy', 'xxx')) self.assertTrue(QgsLocatorFilter.stringMatches('aXXXXy', 'xxx')) self.assertFalse(QgsLocatorFilter.stringMatches('aXXXXy', ''))
def __init__(self, plugin): QgsLocatorFilter.__init__(self, None) self.plugin = plugin