{
    "sourceFile": "Project Notes/GUI_PreviewTable_AlternatingColors_Plan.md",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 0,
            "patches": [
                {
                    "date": 1745498803515,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                }
            ],
            "date": 1745498803515,
            "name": "Commit-0",
            "content": "# Plan: Implement Alternating Row Colors Per Asset Group in GUI Preview Table\r\n\r\n## Objective\r\n\r\nModify the GUI preview table to display alternating background colors for rows based on the asset group they belong to, rather than alternating colors for each individual row. The visual appearance should be similar to the default alternating row colors (dark greys, no border, no rounded corners).\r\n\r\n## Current State\r\n\r\nThe preview table in the GUI uses a `QTableView` with `setAlternatingRowColors(True)` enabled, which applies alternating background colors based on the row index. The `PreviewTableModel` groups file prediction data by `source_asset` in its internal `_table_rows` structure and provides data to the view.\r\n\r\n## Proposed Plan\r\n\r\nTo achieve alternating colors per asset group, we will implement custom coloring logic within the `PreviewTableModel`.\r\n\r\n1.  **Disable Default Alternating Colors:**\r\n    *   In `gui/main_window.py`, locate the initialization of the `preview_table_view` (a `QTableView`).\r\n    *   Change `self.preview_table_view.setAlternatingRowColors(True)` to `self.preview_table_view.setAlternatingRowColors(False)`.\r\n\r\n2.  **Modify `PreviewTableModel.data()`:**\r\n    *   Open `gui/preview_table_model.py`.\r\n    *   In the `data()` method, add a case to handle the `Qt.ItemDataRole.BackgroundRole`.\r\n    *   Inside this case, retrieve the `source_asset` for the current row from the `self._table_rows` structure.\r\n    *   Maintain a sorted list of unique `source_asset` values. This can be done when the data is set in `set_data()`.\r\n    *   Find the index of the current row's `source_asset` within this sorted list.\r\n    *   Based on whether the index is even or odd, return a `QColor` object representing one of the two desired grey colors.\r\n    *   Ensure that the `Qt.ItemDataRole.BackgroundRole` is handled correctly for all columns in the row.\r\n\r\n3.  **Define Colors:**\r\n    *   Define two `QColor` objects within the `PreviewTableModel` class to represent the two grey colors for alternating groups. These should be chosen to be visually similar to the default alternating row colors.\r\n\r\n## Visual Representation of Data Flow with Custom Coloring\r\n\r\n```mermaid\r\ngraph TD\r\n    A[QTableView] --> B{Requests Data for Row/Column};\r\n    B --> C[PreviewSortFilterProxyModel];\r\n    C --> D[PreviewTableModel];\r\n    D -- data(index, role) --> E{Check Role};\r\n    E -- Qt.ItemDataRole.BackgroundRole --> F{Get source_asset for row};\r\n    F --> G{Determine Asset Group Index};\r\n    G --> H{Assign Color based on Index Parity};\r\n    H --> I[Return QColor];\r\n    E -- Other Roles --> J[Return Display/Tooltip/Foreground Data};\r\n    I --> C;\r\n    J --> C;\r\n    C --> A{Displays Data with Custom Background Color};\r\n\r\n    style D fill:#f9f,stroke:#333,stroke-width:2px\r\n    style H fill:#ccf,stroke:#333,stroke-width:1px\r\n    style I fill:#ccf,stroke:#333,stroke-width:1px\r\n```\r\n\r\n## Implementation Steps (for Code Mode)\r\n\r\n1.  Modify `gui/main_window.py` to disable default alternating row colors.\r\n2.  Modify `gui/preview_table_model.py` to:\r\n    *   Define the two grey `QColor` objects.\r\n    *   Update `set_data()` to create and store a sorted list of unique asset groups.\r\n    *   Implement the `Qt.ItemDataRole.BackgroundRole` logic in the `data()` method to return alternating colors based on the asset group index."
        }
    ]
}