"Standard_Map_Type" cleanup and refactor
This commit is contained in:
@@ -282,10 +282,6 @@ class ConfigEditorDialog(QDialog):
|
||||
standard_maps_label = QLabel("Standard Map Types:")
|
||||
standard_maps_layout.addWidget(standard_maps_label)
|
||||
|
||||
self.standard_map_types_list = QListWidget()
|
||||
self.standard_map_types_list.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) # Allow list to expand
|
||||
standard_maps_layout.addWidget(self.standard_map_types_list)
|
||||
self.widgets["STANDARD_MAP_TYPES_LIST"] = self.standard_map_types_list # Store list widget reference
|
||||
|
||||
standard_maps_button_layout = QHBoxLayout()
|
||||
add_button = QPushButton("Add")
|
||||
@@ -1080,10 +1076,6 @@ class ConfigEditorDialog(QDialog):
|
||||
elif key == "MAP_BIT_DEPTH_RULES" and "MAP_BIT_DEPTH_RULES_TABLE" in self.widgets:
|
||||
self.populate_map_bit_depth_rules_table(self.widgets["MAP_BIT_DEPTH_RULES_TABLE"], value)
|
||||
|
||||
elif key == "STANDARD_MAP_TYPES" and "STANDARD_MAP_TYPES_LIST" in self.widgets and isinstance(value, list):
|
||||
self.widgets["STANDARD_MAP_TYPES_LIST"].addItems(value)
|
||||
# Populate DEFAULT_ASSET_CATEGORY ComboBox from Asset Types table (deferred)
|
||||
# This will be done after the Asset Types table is populated.
|
||||
|
||||
elif key == "MAP_MERGE_RULES" and hasattr(self, 'merge_rules_list'): # Check if the list widget exists
|
||||
self.populate_merge_rules_list(value)
|
||||
|
||||
@@ -255,7 +255,7 @@ class ItemTypeSearchDelegate(QStyledItemDelegate):
|
||||
value_to_set = final_text if final_text else None # Set None if empty after stripping
|
||||
|
||||
# Set data in the model
|
||||
# The model's setData handles updating the override and standard_map_type
|
||||
# The model's setData handles updating the override and item_type
|
||||
model.setData(index, value_to_set, Qt.EditRole)
|
||||
# DO NOT add to a persistent list or save back to config
|
||||
|
||||
|
||||
@@ -348,7 +348,6 @@ class LLMPredictionHandler(BasePredictionHandler):
|
||||
target_asset_name_override=asset_name, # Default to asset name
|
||||
output_format_override=None,
|
||||
is_gloss_source=False, # LLM doesn't predict this
|
||||
standard_map_type=None, # LLM doesn't predict this directly
|
||||
resolution_override=None,
|
||||
channel_merge_instructions={}
|
||||
)
|
||||
|
||||
@@ -441,13 +441,9 @@ class RuleBasedPredictionHandler(BasePredictionHandler):
|
||||
log.warning(f"Predicted ItemType '{base_item_type}' (checked as '{final_item_type}') for file '{file_info['file_path']}' is not in FILE_TYPE_DEFINITIONS. Setting to FILE_IGNORE.")
|
||||
final_item_type = "FILE_IGNORE"
|
||||
|
||||
standard_map_type = None
|
||||
file_type_details = file_type_definitions.get(final_item_type)
|
||||
if file_type_details: standard_map_type = file_type_details.get('standard_type')
|
||||
else:
|
||||
file_type_details_alias = file_type_definitions.get(base_item_type)
|
||||
if file_type_details_alias: standard_map_type = file_type_details_alias.get('standard_type')
|
||||
elif base_item_type in file_type_definitions: standard_map_type = base_item_type
|
||||
# standard_map_type is no longer stored on FileRule
|
||||
# It will be looked up from config when needed for naming/output
|
||||
# Remove the logic that determined and assigned it here.
|
||||
|
||||
is_gloss_source_value = file_info.get('is_gloss_source', False)
|
||||
|
||||
@@ -458,7 +454,6 @@ class RuleBasedPredictionHandler(BasePredictionHandler):
|
||||
target_asset_name_override=target_asset_name_override,
|
||||
output_format_override=None,
|
||||
is_gloss_source=is_gloss_source_value if isinstance(is_gloss_source_value, bool) else False,
|
||||
standard_map_type=standard_map_type,
|
||||
resolution_override=None,
|
||||
channel_merge_instructions={},
|
||||
)
|
||||
|
||||
@@ -415,47 +415,16 @@ class UnifiedViewModel(QAbstractItemModel):
|
||||
if new_value == "": new_value = None # Treat empty string as None
|
||||
# Update item_type_override
|
||||
if item.item_type_override != new_value:
|
||||
log.debug(f"setData COL_ITEM_TYPE: File='{Path(item.file_path).name}', Original Override='{item.item_type_override}', Original Standard='{getattr(item, 'standard_map_type', 'N/A')}', New Value='{new_value}'") # DEBUG LOG - Added getattr for safety
|
||||
log.debug(f"setData COL_ITEM_TYPE: File='{Path(item.file_path).name}', Original Override='{item.item_type_override}', New Value='{new_value}'") # DEBUG LOG
|
||||
old_override = item.item_type_override # Store old value for logging
|
||||
item.item_type_override = new_value
|
||||
changed = True
|
||||
|
||||
# --- BEGIN FIX: Update standard_map_type ---
|
||||
try:
|
||||
base_config = load_base_config()
|
||||
file_type_definitions = base_config.get('FILE_TYPE_DEFINITIONS', {})
|
||||
# standard_map_type is no longer stored on FileRule.
|
||||
# Remove the logic that updated it here.
|
||||
pass # No action needed to update standard_map_type
|
||||
|
||||
# Determine the type to look up (override first, then original)
|
||||
type_to_lookup = new_value if new_value is not None else item.item_type
|
||||
|
||||
new_standard_type = None
|
||||
if type_to_lookup:
|
||||
type_info = file_type_definitions.get(type_to_lookup)
|
||||
if type_info:
|
||||
new_standard_type = type_info.get("standard_type")
|
||||
# If standard_type itself is missing in the definition, treat as None or keep old? Let's default to None.
|
||||
if new_standard_type is None:
|
||||
log.warning(f"setData: No 'standard_type' defined for item type '{type_to_lookup}' in FILE_TYPE_DEFINITIONS.")
|
||||
else:
|
||||
log.warning(f"setData: Item type '{type_to_lookup}' not found in FILE_TYPE_DEFINITIONS.")
|
||||
# Fallback: Keep the existing standard_map_type if lookup fails completely
|
||||
new_standard_type = getattr(item, 'standard_map_type', None)
|
||||
else:
|
||||
# If both override and original type are None, standard type should be None
|
||||
new_standard_type = None
|
||||
|
||||
# Update the standard_map_type if it changed or needs setting
|
||||
current_standard_type = getattr(item, 'standard_map_type', None)
|
||||
if current_standard_type != new_standard_type:
|
||||
item.standard_map_type = new_standard_type
|
||||
log.debug(f"setData: Updated standard_map_type from '{current_standard_type}' to '{new_standard_type}' for file '{Path(item.file_path).name}' based on type '{type_to_lookup}'")
|
||||
# No need to set 'changed = True' again, already set above
|
||||
|
||||
except Exception as e:
|
||||
log.exception(f"setData: Error updating standard_map_type for file '{Path(item.file_path).name}': {e}")
|
||||
# --- END FIX ---
|
||||
|
||||
log.debug(f"setData COL_ITEM_TYPE: File='{Path(item.file_path).name}', Final Override='{item.item_type_override}', Final Standard='{getattr(item, 'standard_map_type', 'N/A')}'") # DEBUG LOG - Updated
|
||||
log.debug(f"setData COL_ITEM_TYPE: File='{Path(item.file_path).name}', Final Override='{item.item_type_override}'") # DEBUG LOG - Updated
|
||||
|
||||
|
||||
if changed:
|
||||
@@ -653,17 +622,9 @@ class UnifiedViewModel(QAbstractItemModel):
|
||||
existing_file.item_type = new_file.item_type
|
||||
changed_roles.extend([Qt.DisplayRole, Qt.EditRole, Qt.BackgroundRole]) # Include BackgroundRole for color
|
||||
|
||||
# Update standard_map_type (assuming it's derived/set during prediction)
|
||||
# Check if standard_map_type exists on both objects before comparing
|
||||
new_standard_type = getattr(new_file, 'standard_map_type', None)
|
||||
old_standard_type = getattr(existing_file, 'standard_map_type', None)
|
||||
if old_standard_type != new_standard_type:
|
||||
# Update only if item_type_override is not set, as override dictates standard type
|
||||
if existing_file.item_type_override is None:
|
||||
existing_file.standard_map_type = new_standard_type
|
||||
# standard_map_type might not directly affect display, but item_type change covers it
|
||||
if Qt.DisplayRole not in changed_roles: # Avoid duplicates
|
||||
changed_roles.extend([Qt.DisplayRole, Qt.EditRole])
|
||||
# standard_map_type is no longer stored on FileRule.
|
||||
# Remove the logic that updated it during merge.
|
||||
pass # No action needed for standard_map_type during merge
|
||||
|
||||
|
||||
# Emit dataChanged only if something actually changed
|
||||
|
||||
Reference in New Issue
Block a user