@@ -51,77 +51,77 @@ def slot_setNameFilter(self, regExp):
5151 # self.invalidateFilter()
5252
5353 # Write a test function for this for the different cases
54- def filterAcceptsRow (self , sourceRow , sourceParent ):
55- """
56- This function overrides the parent class' function
57- Args:
58- sourceRow: row that is being looked at
59- QModelIndex: QModelIndex of parent that contians source row
60- """
61- # logger.error('')
62- # logger.error(f' sourceRow:{sourceRow} {type(sourceRow)}')
63- # logger.error(f' sourceParent:{sourceParent} {type(sourceParent)}')
54+ # def filterAcceptsRow(self, sourceRow, sourceParent):
55+ # """
56+ # This function overrides the parent class' function
57+ # Args:
58+ # sourceRow: row that is being looked at
59+ # QModelIndex: QModelIndex of parent that contians source row
60+ # """
61+ # # logger.error('')
62+ # # logger.error(f' sourceRow:{sourceRow} {type(sourceRow)}')
63+ # # logger.error(f' sourceParent:{sourceParent} {type(sourceParent)}')
6464
65- # super().filterAcceptsRow(sourceRow)
66- # Specific column is already set in QTableView and comparison value
67-
68- # row, column, qmodelindx
69- filterCol = self .filterKeyColumn ()
70- # logger.error(f' filterCol:{filterCol}')
71- valIndex = self .sourceModel ().index (sourceRow , filterCol , sourceParent )
72- role = QtCore .Qt .DisplayRole
73- val = self .sourceModel ().data (valIndex , role )
74-
75- # logger.info(f'self.nameRegExp pattern: {self.nameRegExp.pattern()}, valIndex: {valIndex}, val: {val}')
76- # logger.info(f'ComparisonValue: {self.currentComparisonValue}, ComparisonSymbol : {self.currentComparisonSymbol}')
77-
78- checkPattern = self .nameRegExp .pattern () in val
79- checkComparisonVal = self .currentComparisonValue != ""
80-
81- #Check for float conversion?
82- if checkPattern :
83- if (checkComparisonVal ):
84- # Change this to an enumerated type
85- if (self .currentComparisonSymbol == "" ):
86- return True
87- elif (self .currentComparisonSymbol == "=" ):
88- if float (self .currentComparisonValue ) == float (val ):
89- return True
90- else :
91- return False
92- elif (self .currentComparisonSymbol == ">" ):
93- if float (val ) > float (self .currentComparisonValue ):
94- # logger.info(f"here in > !!!")
95- return True
96- # return False
97- else :
98- return False
99- elif (self .currentComparisonSymbol == "<" ):
100- if float (val ) < float (self .currentComparisonValue ):
101- return True
102- else :
103- return False
104- elif (self .currentComparisonSymbol == "<=" ):
105- if float (val ) <= float (self .currentComparisonValue ):
106- return True
107- else :
108- return False
109- elif (self .currentComparisonSymbol == ">=" ):
110- if float (val ) >= float (self .currentComparisonValue ):
111- return True
112- else :
113- return False
114- elif (self .currentComparisonSymbol == "None" ):
115- return True
116- else :
117- # Any unaccounted for symbol will be False
118- logger .info (f'Warning: Symbol is not accounted for.' )
119- return False
120- else :
121- # When there is no comparison value show row
122- return True
123- else :
124- return False
65+ # # super().filterAcceptsRow(sourceRow)
66+ # # Specific column is already set in QTableView and comparison value
67+
68+ # # row, column, qmodelindx
69+ # filterCol = self.filterKeyColumn()
70+ # # logger.error(f' filterCol:{filterCol}')
71+ # valIndex = self.sourceModel().index(sourceRow, filterCol, sourceParent)
72+ # role = QtCore.Qt.DisplayRole
73+ # val = self.sourceModel().data(valIndex, role)
74+
75+ # # logger.info(f'self.nameRegExp pattern: {self.nameRegExp.pattern()}, valIndex: {valIndex}, val: {val}')
76+ # # logger.info(f'ComparisonValue: {self.currentComparisonValue}, ComparisonSymbol : {self.currentComparisonSymbol}')
77+
78+ # checkPattern = self.nameRegExp.pattern() in val
79+ # checkComparisonVal = self.currentComparisonValue != ""
80+
81+ # #Check for float conversion?
82+ # if checkPattern:
83+ # if (checkComparisonVal):
84+ # # Change this to an enumerated type
85+ # if (self.currentComparisonSymbol == ""):
86+ # return True
87+ # elif(self.currentComparisonSymbol == "="):
88+ # if float(self.currentComparisonValue) == float(val):
89+ # return True
90+ # else:
91+ # return False
92+ # elif(self.currentComparisonSymbol == ">"):
93+ # if float(val) > float(self.currentComparisonValue):
94+ # # logger.info(f"here in > !!!")
95+ # return True
96+ # # return False
97+ # else:
98+ # return False
99+ # elif(self.currentComparisonSymbol == "<"):
100+ # if float(val) < float(self.currentComparisonValue):
101+ # return True
102+ # else:
103+ # return False
104+ # elif(self.currentComparisonSymbol== "<="):
105+ # if float(val) <= float(self.currentComparisonValue):
106+ # return True
107+ # else:
108+ # return False
109+ # elif(self.currentComparisonSymbol == ">="):
110+ # if float(val) >= float(self.currentComparisonValue):
111+ # return True
112+ # else:
113+ # return False
114+ # elif(self.currentComparisonSymbol == "None"):
115+ # return True
116+ # else:
117+ # # Any unaccounted for symbol will be False
118+ # logger.info(f'Warning: Symbol is not accounted for.')
119+ # return False
120+ # else:
121+ # # When there is no comparison value show row
122+ # return True
123+ # else:
124+ # return False
125125
126126class TableModel (QAbstractTableModel ):
127127 """
@@ -197,9 +197,31 @@ def data(self, index, role) -> str:
197197
198198 # print('qqq Table model used "at" to get row', row, 'colName', colName, 'returnVal:', returnVal)
199199
200- # print(f"row: {row} col: {col} colName: {colName} returnVal: {returnVal} returnVal type: {type(returnVal)}")=
200+ # print(f"row: {row} col: {col} colName: {colName} returnVal: {returnVal} returnVal type: {type(returnVal)}")
201201 # TODO: possible type checking
202- return str (returnVal )
202+ # return str(returnVal)
203+ # return returnVal
204+ # data does not like returning numpy ints
205+ # type checking to see if value can be converted to int
206+
207+ try :
208+ checkVal = float (returnVal )
209+ except TypeError :
210+ checkVal = None
211+ # logger.info(f"Col {colName} values do not have the correct type")
212+ except ValueError :
213+ checkVal = None
214+ # logger.info("table data value is not a float")
215+
216+ if checkVal is not None and not checkVal .is_integer ():
217+ return round (float (returnVal ), 2 )
218+ elif str (returnVal ).isdigit (): # check for int
219+ # logger.info(f"colName: {colName}")
220+ return int (returnVal )
221+ else :
222+ return str (returnVal )
223+
224+ # TODO: check if filtering still works after this
203225 except KeyError :
204226 print (f'Error occurred when accessing dataframe: { KeyError } ' )
205227
@@ -617,7 +639,7 @@ def _selectRow(self, rowList):
617639 Called by other widgets like annotationPlotWidget
618640 """
619641
620- logger .info (f'programattic select of row(s) -->> { self .getMyName ()} rowList:{ rowList } ' )
642+ # logger.info(f'programattic select of row(s) -->> {self.getMyName()} rowList:{rowList}')
621643
622644 if rowList is None or len (rowList )== 0 :
623645 with self ._blockSlotsManager ():
@@ -635,18 +657,18 @@ def _selectRow(self, rowList):
635657 for _idx , rowIdx in enumerate (rowList ):
636658 # abb already row label
637659 # abb 20241121 -->> this is not getting the correct row
638- logger .info (f"rowIdx in _selectRow{ rowIdx } " )
660+ # logger.info(f"rowIdx in _selectRow{rowIdx}")
639661
640662 modelIndex = self .findModelIndex (column = 0 , value = rowIdx ) # column = 0, assuming index is always first column
641- logger .info (f"modelIdx in _selectRow { modelIndex } " )
663+ # logger.info(f"modelIdx in _selectRow {modelIndex}")
642664
643665 # find the correct model.index get a spine Index(rowIndex)
644666
645667 # 2nd argument is column
646668 # here we default to zero since we will select the entire row regardless
647669 # modelIndex = self.model.index(rowIdx, 0)
648670 proxyIndex = self .proxyModel .mapFromSource (modelIndex )
649- logger .info (f' modelIndex.row():{ modelIndex .row ()} proxyIndex.row():{ proxyIndex .row ()} ' )
671+ # logger.info(f' modelIndex.row():{modelIndex.row()} proxyIndex.row():{proxyIndex.row()}')
650672
651673 mode = QtCore .QItemSelectionModel .Select | QtCore .QItemSelectionModel .Rows
652674 self .mySelectionModel .select (proxyIndex , mode )
0 commit comments