@@ -12,9 +12,10 @@ def __init__(self, parent, undo_stack, commands, colors):
1212 super ().__init__ (parent )
1313 self .parent_tab = parent
1414 self .undo_stack = undo_stack
15- self .commands = commands
15+ self .commands = set ( commands )
1616 self .colors = colors
1717 self .cached_objects = [] # Cache for objects
18+ self .cached_objects_set = set ()
1819 self .objects_dirty = True
1920 self .duplicate_names_cache = set ()
2021 self .duplicate_names_dirty = True
@@ -185,7 +186,7 @@ def setModelData(self, editor, model, index):
185186 self .undo_stack .push (command )
186187
187188 def update_command_list (self , new_commands ):
188- self .commands = new_commands
189+ self .commands = set ( new_commands )
189190
190191 def invalidate_objects_cache (self ):
191192 self .objects_dirty = True
@@ -199,8 +200,10 @@ def _get_objects(self):
199200 if obj_repo_model and not obj_repo_model .df .empty :
200201 self .cached_objects = obj_repo_model .df .iloc [:, ObjRepoModel .NAME_COL ].dropna ().astype (str ).unique ().tolist ()
201202 self .cached_objects .sort ()
203+ self .cached_objects_set = set (self .cached_objects )
202204 else :
203205 self .cached_objects = []
206+ self .cached_objects_set = set ()
204207 self .objects_dirty = False
205208 return self .cached_objects
206209
@@ -256,8 +259,9 @@ def paint(self, painter, option, index):
256259 final_color = QColor ("#E57373" )
257260
258261 elif TestScenarioModel .DATA1_COL <= current_col <= TestScenarioModel .DATA5_COL :
259- objects = self ._get_objects ()
260- if value not in objects :
262+ if self .objects_dirty :
263+ self ._get_objects ()
264+ if value not in self .cached_objects_set :
261265 final_color = QColor ("#64B5F6" )
262266 elif isinstance (model , ObjRepoModel ):
263267 if current_col == ObjRepoModel .NAME_COL :
0 commit comments