@@ -189,21 +189,22 @@ def init_ui(self):
189189
190190
191191 self .results_table = QTableWidget ()
192- self .results_table .setColumnCount (8 )
192+ self .results_table .setColumnCount (9 )
193193 self .results_table .setHorizontalHeaderLabels ([
194- "Virtual Address" , "Function Name" , "Matched Function" , "Signature" , "Similarity" , "Confidence" , "Matched Hash" , "Matched Binary"
194+ "Select" , " Virtual Address" , "Function Name" , "Matched Function" , "Signature" , "Similarity" , "Confidence" , "Matched Hash" , "Matched Binary"
195195 ])
196196 self .results_table .setSelectionMode (QAbstractItemView .NoSelection )
197197
198198 header = self .results_table .horizontalHeader ()
199199 header .setSectionResizeMode (0 , QHeaderView .ResizeToContents )
200- header .setSectionResizeMode (1 , QHeaderView .Stretch )
200+ header .setSectionResizeMode (1 , QHeaderView .ResizeToContents )
201201 header .setSectionResizeMode (2 , QHeaderView .Stretch )
202- header .setSectionResizeMode (3 , QHeaderView .ResizeToContents )
202+ header .setSectionResizeMode (3 , QHeaderView .Stretch )
203203 header .setSectionResizeMode (4 , QHeaderView .ResizeToContents )
204204 header .setSectionResizeMode (5 , QHeaderView .ResizeToContents )
205- header .setSectionResizeMode (6 , QHeaderView .Stretch )
205+ header .setSectionResizeMode (6 , QHeaderView .ResizeToContents )
206206 header .setSectionResizeMode (7 , QHeaderView .Stretch )
207+ header .setSectionResizeMode (8 , QHeaderView .Stretch )
207208 self .results_table .setAlternatingRowColors (True )
208209 self .results_table .verticalHeader ().setVisible (False )
209210
@@ -306,7 +307,8 @@ def on_matching_finished(self, success, data):
306307
307308
308309 def populate_results_table (self , results ):
309- self .selected_results .clear ()
310+ # Store results first so _update_selected_results can access them
311+ self .all_results = results
310312
311313 self .results_table .setRowCount (0 )
312314 self .results_table .setRowCount (len (results ))
@@ -336,6 +338,21 @@ def populate_results_table(self, results):
336338 """ )
337339
338340 for row , match in enumerate (results ):
341+ # Add checkbox in first column
342+ checkbox = QCheckBox ()
343+ if match .get ("icon_text" , "Failed" ) == "Success" :
344+ checkbox .setChecked (True )
345+ else :
346+ checkbox .setChecked (False )
347+ checkbox .stateChanged .connect (lambda state , m = match : self ._on_checkbox_changed (state , m ))
348+
349+ checkbox_widget = QWidget ()
350+ checkbox_layout = QHBoxLayout (checkbox_widget )
351+ checkbox_layout .addWidget (checkbox )
352+ checkbox_layout .setAlignment (Qt .AlignCenter )
353+ checkbox_layout .setContentsMargins (0 , 0 , 0 , 0 )
354+ self .results_table .setCellWidget (row , 0 , checkbox_widget )
355+
339356 column_data = [
340357 "function_address" ,
341358 "function_name" ,
@@ -347,7 +364,7 @@ def populate_results_table(self, results):
347364 "matched_binary_name"
348365 ]
349366
350- for column , field in enumerate (column_data , start = 0 ):
367+ for column , field in enumerate (column_data , start = 1 ):
351368 value = match .get (field , "N/A" )
352369 if field == "function_address" :
353370 if isinstance (value , int ):
@@ -373,17 +390,38 @@ def populate_results_table(self, results):
373390 icon_path = f"{ os .path .dirname (__file__ )} /../../images/success.png"
374391 item .setToolTip (value )
375392 item .setIcon (QIcon (icon_path ))
376- #item.setIconAlignment(Qt.AlignCenter)
377393 item .setText ("" )
378394 else :
379395 item .setToolTip (value )
380396 self .results_table .setItem (row , column , item )
381-
382- if match .get ("icon_text" , "Failed" ) == "Success" :
383- self .selected_results .append (match )
397+
398+ # Initialize selected_results based on checkboxes
399+ self ._update_selected_results ()
400+
401+ def _on_checkbox_changed (self , state , match ):
402+ self ._update_selected_results ()
403+
404+ def _update_selected_results (self ):
405+ self .selected_results .clear ()
406+ for row in range (self .results_table .rowCount ()):
407+ checkbox_widget = self .results_table .cellWidget (row , 0 )
408+ if checkbox_widget :
409+ checkbox = checkbox_widget .findChild (QCheckBox )
410+ if checkbox and checkbox .isChecked ():
411+ # Get the match data from the row
412+ addr_item = self .results_table .item (row , 1 )
413+ if addr_item :
414+ addr_text = addr_item .text ()
415+ # Find the corresponding match in all_results
416+ if hasattr (self , 'all_results' ):
417+ for match in self .all_results :
418+ match_addr = match .get ("function_address" , "" )
419+ if isinstance (match_addr , int ):
420+ match_addr = f"0x{ match_addr :x} "
421+ if match_addr == addr_text :
422+ self .selected_results .append (match )
423+ break
384424 log_info (f"RevEng.AI | Selected results: { len (self .selected_results )} " )
385- for result in self .selected_results :
386- log_info (f"RevEng.AI | Result: { result } " )
387425
388426
389427 def start_fetching_data_types (self ):
0 commit comments