|
| 1 | +# 📦 Data Models & State Management |
| 2 | + |
| 3 | +This directory contains the **Model** layer of the MVC architecture. It is responsible for data storage, state validation, and providing standard interfaces for the View layer (`ui/`) and Controller layer (`controllers/`). |
| 4 | + |
| 5 | +## 📂 Module Descriptions |
| 6 | + |
| 7 | +### 1. `app_state.py` (Core Logic) |
| 8 | +* **Purpose:** The central repository for the application's runtime state. |
| 9 | +* **Key Class:** **`AppStateModel`** |
| 10 | + * **Responsibility:** |
| 11 | + * Stores Project Metadata (Path, Task Name, Modalities). |
| 12 | + * Manages JSON Schema Definitions (`label_definitions`). |
| 13 | + * Stores Annotation Data (Classification labels & Localization events). |
| 14 | + * Manages the **Undo/Redo Stack**. |
| 15 | + * **Validation:** Contains logic to validate imported JSON structures (`validate_gac_json`, `validate_loc_json`). |
| 16 | +* **Key Enum:** **`CmdType`** |
| 17 | + * Defines types of commands (e.g., `SCHEMA_ADD_LBL`, `LOC_EVENT_ADD`) used by the `HistoryManager` to track user actions. |
| 18 | + |
| 19 | +### 2. `project_tree.py` (UI Data Model) |
| 20 | +* **Purpose:** A specialized Qt Model for the Left Sidebar (Clip Explorer). |
| 21 | +* **Key Class:** **`ProjectTreeModel`** |
| 22 | + * **Inheritance:** `QStandardItemModel` |
| 23 | + * **Responsibility:** |
| 24 | + * Adapts the raw data list into a hierarchical format suitable for `QTreeView`. |
| 25 | + * Handles standard Item data (Display Name, Icon) and User Roles (File Path). |
| 26 | + * Allows the UI to be decoupled from the raw list logic. |
| 27 | + * **Usage:** |
| 28 | + * Instantiated in `viewer.py`. |
| 29 | + * Shared across both Classification and Localization views. |
| 30 | + * Manipulated by Controllers (`NavigationManager`, `LocalizationManager`). |
| 31 | + |
| 32 | +## 🔄 Data Flow |
| 33 | +1. **Controllers** update `AppStateModel` (business data) and `ProjectTreeModel` (UI list data) simultaneously. |
| 34 | +2. **Views** (`QTreeView`) automatically reflect changes in `ProjectTreeModel` via Qt signals (`rowsInserted`, etc.). |
| 35 | +3. **Serialization** (Save/Export) reads directly from `AppStateModel`. |
0 commit comments