MainTab package
Data management layer for DistrictHeatingSim application.
This module implements the Model layer of the MVP pattern, providing three core managers: - ProjectConfigManager: Configuration and user preferences - DataManager: Central data storage for analysis results - ProjectFolderManager: Project folder structure and navigation
- author:
Dipl.-Ing. (FH) Jonas Pfeiffer
- class districtheatingsim.gui.MainTab.main_data_manager.ProjectConfigManager(config_path: str | None = None, file_paths_path: str | None = None)[source]
Bases:
objectManages application configuration and resource paths.
Handles JSON-based configuration storage including user preferences, recent projects, and resource path resolution for both development and PyInstaller builds.
- Parameters:
Note
Configuration files are stored with UTF-8 encoding for international character support.
- __init__(config_path: str | None = None, file_paths_path: str | None = None)[source]
Initialize configuration manager with automatic data loading.
- get_default_config_path() str[source]
Get the default path to recent_projects.json.
- Returns:
Absolute path to the default configuration file
- Return type:
- get_default_file_paths_path() str[source]
Get the default path to file_paths.json.
- Returns:
Absolute path to the default file paths configuration file
- Return type:
- load_config() Dict[str, Any][source]
Load application configuration from JSON file with UTF-8 encoding.
- Returns:
Configuration dictionary (empty if file doesn’t exist)
- Return type:
- load_file_paths() Dict[str, str][source]
Load file path mappings from JSON configuration with UTF-8 encoding.
- Returns:
File paths dictionary mapping resource IDs to relative paths (empty if file doesn’t exist)
- Return type:
- save_config(config: Dict[str, Any]) None[source]
Save configuration data to JSON file with UTF-8 encoding.
- save_file_paths(file_paths: Dict[str, str]) None[source]
Save file paths configuration to JSON file with UTF-8 encoding.
- get_last_project() str[source]
Retrieve the path of the most recently opened project.
- Returns:
Path to last opened project (empty string if none)
- Return type:
- set_last_project(path: str) None[source]
Set the most recently opened project and update recent projects list.
Automatically manages recent projects history (max 5 entries) with duplicate prevention and configuration persistence.
- Parameters:
path (str) – Path to the project directory
- class districtheatingsim.gui.MainTab.main_data_manager.DataManager[source]
Bases:
objectCentral data storage for district heating simulation.
Manages map visualization data, weather data (TRY) filenames, and heat pump performance (COP) filenames for use across application components.
- add_data(data: Any) None[source]
Add data to the map data collection.
- Parameters:
data (any) – Data to be added to the map data collection
- get_map_data() List[Any][source]
Get the complete map data collection.
- Returns:
List of all map data entries
- Return type:
- set_try_filename(filename: str) None[source]
Set the Test Reference Year (TRY) weather data filename.
- Parameters:
filename (str) – Name of the TRY weather data file
- get_try_filename() str | None[source]
Get the currently selected TRY weather data filename.
- Returns:
TRY weather data filename or None if not set
- Return type:
str or None
- class districtheatingsim.gui.MainTab.main_data_manager.ProjectFolderManager(config_manager: ProjectConfigManager | None = None)[source]
Bases:
QObjectManages project folder structure and variant navigation.
Handles project folder hierarchy, variant switching, and emits signals when project/variant folders change for UI synchronization.
- Parameters:
config_manager (ProjectConfigManager) – Configuration manager instance (creates new if None)
- Signal project_folder_changed:
Emitted when project/variant folder changes (str)
- project_folder_changed
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- __init__(config_manager: ProjectConfigManager | None = None)[source]
- emit_project_and_variant_folder() None[source]
Emit signal for current project and variant folder state.
Creates default “Variante 1” if no variant folder exists.
- set_project_folder(path: str) None[source]
Set the project folder and update configuration.
Validates variant folder and emits signals to notify connected components. Creates default “Variante 1” if no valid variant exists.
- Parameters:
path (str) – Path to the project directory
- set_variant_folder(variant_name: str) None[source]
Set the current variant folder and emit change signal.
- Parameters:
variant_name (str) – Name of the variant folder (e.g., “Variante 1”)
Main presenter module for DistrictHeatingSim application.
Implements the Presenter component of the MVP pattern, handling business logic for project management, variant creation, and coordination between view and data management layers.
- author:
Dipl.-Ing. (FH) Jonas Pfeiffer
- class districtheatingsim.gui.MainTab.main_presenter.HeatSystemPresenter(view, folder_manager, data_manager, config_manager)[source]
Bases:
objectPresenter for district heating project management (MVP pattern).
Coordinates between view and data management layers, handling business logic for project creation, variant management, and folder structure operations.
- Parameters:
view (HeatSystemDesignGUI) – Main application view component
folder_manager (ProjectFolderManager) – Project folder management
data_manager (DataManager) – Central data storage
config_manager (ProjectConfigManager) – Configuration management
- __init__(view, folder_manager, data_manager, config_manager)[source]
Initialize presenter with manager dependencies.
- Parameters:
view (HeatSystemDesignGUI) – Main application view
folder_manager (ProjectFolderManager) – Project folder manager
data_manager (DataManager) – Data manager
config_manager (ProjectConfigManager) – Configuration manager
- create_new_project(folder_path: str, project_name: str) bool[source]
Create new district heating project with standardized folder structure.
Creates project with “Eingangsdaten allgemein”, “Definition Quartier IST”, and “Variante 1” folders. Initializes building data CSV and registers project with folder manager.
- open_existing_project(folder_path: str) None[source]
Open existing district heating project.
Registers project folder with folder manager, triggering automatic synchronization of all application components.
- Parameters:
folder_path (str) – Path to existing project folder
- create_project_copy() bool[source]
Create complete copy of current project with user-specified name.
Prompts user for new project name via dialog, then creates exact duplicate including all data files, analysis results, and structure. Automatically activates the copied project.
- Returns:
True if successful, False if cancelled or failed
- Return type:
- create_project_variant() bool[source]
Create new analysis variant within current project.
Creates sequentially numbered variant (Variante X) with standardized subfolder structure (Ergebnisse, Gebäudedaten, Lastgang, Wärmenetz). Automatically activates new variant.
- Returns:
True if successful, False if failed
- Return type:
Main GUI view module for DistrictHeatingSim application.
This module implements the main window with a multi-tab interface for district heating system simulation. Follows the View component of the MVP pattern, managing UI elements, menu system, theme management, and tab coordination.
- author:
Dipl.-Ing. (FH) Jonas Pfeiffer
- class districtheatingsim.gui.MainTab.main_view.HeatSystemDesignGUI(folder_manager, data_manager)[source]
Bases:
QMainWindowMain application window with multi-tab interface for district heating analysis.
Implements the View component of the MVP pattern, managing UI elements, menu system, theme switching, and tab coordination for the complete district heating workflow.
- Parameters:
folder_manager (ProjectFolderManager) – Project folder management system
data_manager (DataManager) – Central data storage system
Note
Tabs can be dynamically shown/hidden via the menu system to customize the workflow.
- __init__(folder_manager, data_manager)[source]
Initialize main application window with manager dependencies.
Sets up basic window structure, defers UI creation until presenter is set.
- Parameters:
folder_manager (ProjectFolderManager) – Project folder management system
data_manager (DataManager) – Central data management system
- set_presenter(presenter) None[source]
Set presenter and initialize complete user interface.
Completes MVP pattern setup by connecting presenter and triggering full UI initialization including menus, tabs, dialogs, and theme.
- Parameters:
presenter (HeatSystemPresenter) – Business logic controller
- add_theme_toggle_to_main_interface()[source]
Add theme toggle switch to the main interface next to menu bar.
- show_save_dialog(title: str, info_text: str, accept_text: str) str[source]
Show standardized save dialog for project operations.
- on_back_to_welcome()[source]
Return to the welcome screen from main interface. Give user choice to save, discard, or cancel if project is loaded.
- on_theme_change_requested(theme_path: str)[source]
Handle theme change request from welcome screen.
- apply_current_theme_to_welcome_screen()[source]
Apply the current application theme to the welcome screen.
- initMenuBar() None[source]
Initialize menu bar with File, Data, Theme, and Tabs menus.
Creates professional menu system with project management, recent projects, variant handling, data configuration, and tab visibility control.
- initTabs() None[source]
Initialize multi-tab interface for district heating analysis workflow.
Creates tabs for project definition, building data, network visualization, network calculation, energy system design, and variant comparison. Supports dynamic tab visibility control.
- initLogo() None[source]
Initialize application logo and window icon.
Loads logo via ConfigManager with fallback paths for both development and packaged application scenarios.
- update_project_folder_label(base_path: str) None[source]
Update project folder status label with current project path.
- Parameters:
base_path (str) – Current project/variant folder path
- show_error_message(message: str) None[source]
Display standardized error message dialog.
- Parameters:
message (str) – Error message text to display
- on_create_new_project() None[source]
Handle new project creation with user input and validation.
Prompts for save if project loaded, collects project name, and creates standardized project structure via presenter.
- on_open_existing_project(folder_path: str | None = None) None[source]
Handle opening existing projects with variant selection support.
Prompts for save, discovers variants, and loads selected project.
- Parameters:
folder_path (str or None) – Direct path to project folder (optional)
- get_available_variants(project_path: str) List[str][source]
Discover available project variants in specified project directory.
Scans project directory for folders starting with “Variante”.
- on_create_project_copy() None[source]
Handle project copy creation with user feedback.
Prompts for save, creates complete project duplicate via presenter, and displays success message.
- on_open_variant() None[source]
Handle variant selection within current project.
Prompts for save, discovers variants, and switches to selected variant.
- on_create_project_variant() None[source]
Handle creation of new project variant.
Prompts for save, creates new variant via presenter, and displays success message.
- on_create_project_variant_copy() None[source]
Handle creation of variant copy with data preservation.
Prompts for save, creates variant copy via presenter, and displays success message.
- show_temporary_success_message(message: str, duration_ms: int = 2000) None[source]
Display auto-dismissing success message.
- on_importResultsAction() None[source]
Load all available project data and results.
Silently loads building data, network data, and energy system results without individual confirmation dialogs. Shows single success message.
- save_all_project_results() bool[source]
Zentrale Speicherlogik für alle Projektergebnisse. Ruft die jeweiligen Save-Methoden der einzelnen Tabs/Presenter auf. Sollte vor dem Schließen der Anwendung und beim Wechsel des Projekts/Variante aufgerufen werden. Vor dem Speichern wird ein Warn-Dialog angezeigt, der auf fehlende Versionierung und mögliche Überschreibung hinweist. Bricht der Nutzer den Dialog ab, wird die Aktion abgebrochen.
- Returns:
True wenn erfolgreich gespeichert, False wenn abgebrochen
- Return type:
- applyTheme(theme_path: str) None[source]
Apply visual theme to application.
Loads and applies Qt stylesheet with fallback for missing resources.
- Parameters:
theme_path (str) – Configuration key for theme stylesheet path
- openTemperatureDataSelection() None[source]
Open temperature data configuration dialog and update system settings.
Displays dialog for TRY (Test Reference Year) selection and triggers system-wide temperature data update.
- openCOPDataSelection() None[source]
Open heat pump COP data configuration dialog and update settings.
Displays dialog for heat pump performance data selection and triggers system-wide COP data update.
- updateTemperatureData() None[source]
Update system temperature data based on user selection.
Retrieves TRY filename from dialog and updates data manager.
- updateHeatPumpData() None[source]
Update system heat pump performance data based on user selection.
Retrieves COP filename from dialog and updates data manager.