@@ -711,6 +711,7 @@ def __init__(self, results_data=None, binary_view_a=None, binary_view_b=None):
711711 self .sort_order = Qt .AscendingOrder
712712 self .binary_view_a = binary_view_a # Binary Ninja view for binary A
713713 self .binary_view_b = binary_view_b # Binary Ninja view for binary B
714+ self ._initial_column_widths_set = False # Track if column widths have been set
714715 self .setup_ui ()
715716 self .load_results ()
716717
@@ -822,9 +823,13 @@ def setup_results_tab(self, tab):
822823 border: 1px solid #555555;
823824 font-weight: bold;
824825 min-height: 36px;
826+ text-align: center;
825827 }
826828 """ )
827829
830+ # Center-align header text
831+ self .table_view .horizontalHeader ().setDefaultAlignment (Qt .AlignCenter )
832+
828833 # Set minimum row height to prevent content from being cut off
829834 self .table_view .verticalHeader ().setDefaultSectionSize (40 )
830835 self .table_view .verticalHeader ().setMinimumSectionSize (35 )
@@ -1095,12 +1100,38 @@ def update_table(self):
10951100 else :
10961101 item .setForeground (QColor (255 , 255 , 255 )) # White text for all columns
10971102
1098- # Resize columns to content
1099- self .table_view .resizeColumnsToContents ()
1103+ # Only resize columns on initial load to prevent width changes during sorting
1104+ if not self ._initial_column_widths_set :
1105+ # Set explicit column widths that accommodate header text + sort indicator
1106+ # Headers: "Similarity", "Confidence", "Function A", "Address A", "Function B", "Address B",
1107+ # "Match Type", "Size A", "Size B", "BB Count A", "BB Count B", "Instr Count A", "Instr Count B"
1108+ column_widths = [
1109+ 200 , # Similarity
1110+ 200 , # Confidence
1111+ 240 , # Function A
1112+ 190 , # Address A
1113+ 240 , # Function B
1114+ 190 , # Address B
1115+ 190 , # Match Type
1116+ 110 , # Size A
1117+ 110 , # Size B
1118+ 190 , # BB Count A
1119+ 190 , # BB Count B
1120+ 190 , # Instr Count A
1121+ 190 , # Instr Count B
1122+ ]
1123+
1124+ for col , width in enumerate (column_widths ):
1125+ self .table_view .setColumnWidth (col , width )
11001126
1101- # Set specific width for Function A and Function B (approx 30 chars)
1102- self .table_view .setColumnWidth (2 , 250 ) # Function A
1103- self .table_view .setColumnWidth (4 , 250 ) # Function B
1127+ # Set header resize mode to Interactive so users can resize but sorting won't change widths
1128+ header = self .table_view .horizontalHeader ()
1129+ for col in range (self .table_view .columnCount ()):
1130+ header .setSectionResizeMode (col , QHeaderView .Interactive )
1131+ # Keep last section stretching
1132+ header .setStretchLastSection (True )
1133+
1134+ self ._initial_column_widths_set = True
11041135
11051136 # Ensure proper row height for all rows
11061137 for row in range (self .table_view .rowCount ()):
@@ -1275,25 +1306,14 @@ def get_string_sort_key(self, result, column):
12751306 return ''
12761307
12771308 def update_sort_indicator (self ):
1278- """Update the header to show sort direction indicator"""
1309+ """Update the header to show sort direction indicator using Qt's built-in indicator"""
1310+ header = self .table_view .horizontalHeader ()
12791311 if self .sort_column >= 0 :
1280- # Get the current headers
1281- headers = [
1282- "Similarity" , "Confidence" , "Function A" , "Address A" , "Function B" , "Address B" ,
1283- "Match Type" , "Size A" , "Size B" ,
1284- "BB Count A" , "BB Count B" , "Instr Count A" , "Instr Count B"
1285- ]
1286-
1287- # Add sort indicator to the current sort column
1288- for i , header in enumerate (headers ):
1289- if i == self .sort_column :
1290- if self .sort_order == Qt .AscendingOrder :
1291- headers [i ] = f"{ header } ↑"
1292- else :
1293- headers [i ] = f"{ header } ↓"
1294-
1295- # Update the headers
1296- self .table_view .setHorizontalHeaderLabels (headers )
1312+ # Use Qt's built-in sort indicator instead of modifying header text
1313+ header .setSortIndicator (self .sort_column , self .sort_order )
1314+ header .setSortIndicatorShown (True )
1315+ else :
1316+ header .setSortIndicatorShown (False )
12971317
12981318 def on_cell_clicked (self , row , column ):
12991319 """Handle cell clicks - load function pair in diff view or navigate to address"""
0 commit comments