def __init__(self, c, listWidget): self.c = c self.lw = w = listWidget # A QListWidget. self.its = {} # Keys are id(w),values are tuples (p,pos) self.worker = threadutil.UnitWorker() self.frozen = False def searcher(inp): #print("searcher", inp) if self.frozen: return exp = inp.replace(" ", "*") res = self.bgSearch(exp) return res def dumper(): # always run on ui thread if self.frozen: return out = self.worker.output #print("dumper") self.throttler.add(out) def throttledDump(lst): """ dumps the last output """ #print "Throttled dump" # we do get called with empty list on occasion if not lst: return if self.frozen: return hm, bm = lst[-1] self.clear() self.addHeadlineMatches(hm) self.addBodyMatches(bm) self.throttler = threadutil.NowOrLater(throttledDump) self.worker.set_worker(searcher) #self.worker.set_output_f(dumper) self.worker.resultReady.connect(dumper) self.worker.start() # we want both single-clicks and activations (press enter) w.connect(w, QtCore.SIGNAL("itemActivated(QListWidgetItem*)"), self.onActivated) w.connect(w, QtCore.SIGNAL("itemPressed(QListWidgetItem*)"), self.onSelectItem) w.connect( w, QtCore.SIGNAL( "currentItemChanged(QListWidgetItem*,QListWidgetItem *)"), self.onSelectItem)
def __init__(self, c, listWidget, ui): self.c = c self.lw = w = listWidget # A QListWidget. self.its = {} # Keys are id(w),values are tuples (p,pos) self.worker = threadutil.UnitWorker() self.widgetUI = ui self.fileDirectives = [ "@clean", "@file", "@asis", "@edit", "@auto", "@auto-md", "@auto-org", "@auto-otl", "@auto-rst" ] self.frozen = False def searcher(inp): #print("searcher", inp) if self.frozen: return exp = inp.replace(" ", "*") res = self.bgSearch(exp) return res def dumper(): # always run on ui thread if self.frozen: return out = self.worker.output #print("dumper") self.throttler.add(out) def throttledDump(lst): """ dumps the last output """ #print "Throttled dump" # we do get called with empty list on occasion if not lst: return if self.frozen: return hm, bm = lst[-1] self.clear() self.addHeadlineMatches(hm) self.addBodyMatches(bm) self.throttler = threadutil.NowOrLater(throttledDump) self.worker.set_worker(searcher) #self.worker.set_output_f(dumper) self.worker.resultReady.connect(dumper) self.worker.start() if 1: # Compatible with PyQt5 # we want both single-clicks and activations (press enter) w.itemActivated.connect(self.onActivated) w.itemPressed.connect(self.onSelectItem) w.currentItemChanged.connect(self.onSelectItem) else: pass