From 947bbe21e42d870bb057d048bdc9922f61a6f52d Mon Sep 17 00:00:00 2001 From: csrichter Date: Tue, 2 May 2017 15:01:24 +0200 Subject: [PATCH] added showInvalid checkbox --- python/tmc_classes.py | 15 ++++++++------- python/tmc_parser.py | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/python/tmc_classes.py b/python/tmc_classes.py index 2b20b29..6dcfb54 100644 --- a/python/tmc_classes.py +++ b/python/tmc_classes.py @@ -587,16 +587,16 @@ class tmc_dict: self.dict_lock=threading.Lock() self.list_lock=threading.Lock() @staticmethod - def matchFilter(msg,filters): - if not msg.location.is_valid: + def matchFilter(msg,showInvalid,filters): + #print("fun:matchFilter:%s,showInvalid:%i"%(filters,showInvalid)) + if showInvalid and not msg.location.is_valid: return True#always show invalid messages loc_str=str(msg.location)+str(msg.location.reflocs) if not msg.location.linRef==None: loc_str+=str(msg.location.linRef.roadnumber) - for f in filters:#filters is list of dicts {"type":"event","str":"Stau"} - stringlist=f["str"].lower().split(";") + stringlist=f["str"].lower().split(";")#filters can be separated by semicolon for string in stringlist: if f["type"]=="event" and unicode(str(msg.event), encoding="UTF-8").lower().find(string)==-1:#if event filter does not match return False @@ -629,11 +629,12 @@ class tmc_dict: print("ERROR, not adding: "+str(message)) finally: self.dict_lock.release() - def getLogString(self,filters): + def getLogString(self,showInvalid,filters): self.list_lock.acquire() retStr="" + #print("fun:getLogString,filters:%s"%filters) for message in self.message_list: - if tmc_dict.matchFilter(message,filters): + if tmc_dict.matchFilter(message,showInvalid,filters): retStr+=message.log_string() retStr+="\n" retStr+=message.multi_str() @@ -821,7 +822,7 @@ class tmc_message: text+=templates[language+"_2b"].format(D=self.location.first_name) else: text+=templates[language+"_2a"].format(D=self.location.first_name,E=offset_loc_name) - + text+=", dir:"+str(self.tmc_dir) #LocCode: RefLine: RoadNr #A #LocCode:RefLine:Name2 diff --git a/python/tmc_parser.py b/python/tmc_parser.py index 39dd656..3d70cbc 100644 --- a/python/tmc_parser.py +++ b/python/tmc_parser.py @@ -271,7 +271,7 @@ class tmc_parser_Widget(QtGui.QWidget): ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower() lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower() filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] - if tmc_dict.matchFilter(tmc_msg,filters): + if tmc_dict.matchFilter(tmc_msg,self.showInvalid,filters): print_dbg("a",end="") self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.log_string())) print_dbg("a",end="") @@ -285,8 +285,10 @@ class tmc_parser_Widget(QtGui.QWidget): print_dbg("s",end="") self.logMutex.release(1) print_dbg("\tdone") + def filterChanged(self): self.logMutex.acquire(1) + #code.interact(local=locals()) print_dbg("filterChanged:got mutex,",end="") ef="" lf="" @@ -301,10 +303,13 @@ class tmc_parser_Widget(QtGui.QWidget): self.logOutput.clear() print_dbg("cleared,",end="") filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] - self.logOutput.append(Qt.QString.fromUtf8(self.parser.tmc_messages.getLogString(filters))) + #print("getting logstring with filters:%s, showInvalid:%i"%(filters,self.showInvalid)) + self.logOutput.append(Qt.QString.fromUtf8(self.parser.tmc_messages.getLogString(self.showInvalid,filters))) print_dbg("appended,",end="") self.logMutex.release(1) print_dbg("done") + def update_showInvalid(self): + self.showInvalid=self.GUI_showInvalid.isChecked() def __init__(self, parser,maxheight): QtGui.QWidget.__init__(self) layout = Qt.QVBoxLayout() @@ -316,13 +321,18 @@ class tmc_parser_Widget(QtGui.QWidget): self.location_filter=QtGui.QLineEdit(u"Baden-Württemberg") self.event_filter.returnPressed.connect(self.filterChanged) self.location_filter.returnPressed.connect(self.filterChanged) - + self.showInvalid=False + self.GUI_showInvalid=QtGui.QCheckBox() + self.GUI_showInvalid.setChecked(self.showInvalid) + #self.showInvalid.stateChanged.connect(lambda:self.btnstate(self.b1)) + self.GUI_showInvalid.stateChanged.connect(self.update_showInvalid) filter_layout = Qt.QHBoxLayout() filter_layout.addWidget(QtGui.QLabel("event filter:")) filter_layout.addWidget(self.event_filter) filter_layout.addWidget(QtGui.QLabel("location filter:")) filter_layout.addWidget(self.location_filter) - + filter_layout.addWidget(QtGui.QLabel("showInvalid:")) + filter_layout.addWidget(self.GUI_showInvalid) layout.addLayout(filter_layout) layout.addWidget(self.tmc_message_label) self.logOutput = Qt.QTextEdit()