Configuration
Handles storage and retrieval of the plugin QgsSettings.
ScenarioSettings
dataclass
ScenarioSettings(uuid, name, description, extent, activities, weighted_activities, priority_layer_groups, state=ScenarioState.IDLE, server_uuid=None)
Bases: Scenario
Plugin Scenario settings.
from_qgs_settings
classmethod
Reads QGIS settings and parses them into a scenario settings instance with the respective settings values as properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Scenario identifier |
required |
settings |
QgsSettings
|
Scenario identifier |
required |
Returns:
Type | Description |
---|---|
ScenarioSettings
|
Scenario settings object |
Source code in src/cplus_plugin/conf.py
get_scenario_extent
classmethod
Fetches Scenario extent from the passed scenario settings.
Returns:
Type | Description |
---|---|
SpatialExtent
|
Spatial extent instance extent |
Source code in src/cplus_plugin/conf.py
Settings
SettingsManager
Bases: QObject
Manages saving/loading settings for the plugin in QgsSettings.
delete_all_scenarios
Deletes all the plugin scenarios settings.
Source code in src/cplus_plugin/conf.py
delete_all_scenarios_results
Deletes all the plugin scenarios results settings.
Source code in src/cplus_plugin/conf.py
delete_online_scenario
Delete online scenario from QGIS settings
Source code in src/cplus_plugin/conf.py
delete_online_task
Delete the online task with the passed scenarion id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_id |
str
|
Scenario identifier |
required |
Source code in src/cplus_plugin/conf.py
delete_priority_group
Removes priority group that match the passed identifier
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Priority group identifier |
required |
Source code in src/cplus_plugin/conf.py
delete_priority_groups
Deletes all the plugin priority groups settings.
Source code in src/cplus_plugin/conf.py
delete_priority_layer
Removes priority layer that match the passed identifier
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Priority layer identifier |
required |
Source code in src/cplus_plugin/conf.py
delete_priority_layers
Deletes all the plugin priority weighting layers settings.
Source code in src/cplus_plugin/conf.py
delete_scenario
Delete the scenario with the passed scenarion id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_id |
str
|
Scenario identifier |
required |
Source code in src/cplus_plugin/conf.py
delete_scenario_result
Delete the scenario result that contains the scenario id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_id |
str
|
Scenario identifier |
required |
Source code in src/cplus_plugin/conf.py
delete_settings
find_activity_by_name
Finds an activity setting inside the plugin QgsSettings that equals or matches the name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Activity name. |
required |
Returns:
Type | Description |
---|---|
Activity
|
Activity object. |
Source code in src/cplus_plugin/conf.py
find_group_by_name
Finds a priority group setting inside the plugin QgsSettings by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the group |
required |
Returns:
Type | Description |
---|---|
typing.Dict
|
Priority group |
Source code in src/cplus_plugin/conf.py
find_layer_by_name
Finds a priority layer setting inside the plugin QgsSettings by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Priority layers identifier |
required |
Returns:
Type | Description |
---|---|
dict
|
Priority layers dict |
Source code in src/cplus_plugin/conf.py
find_layers_by_group
Finds priority layers inside the plugin QgsSettings that contain the passed group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Priority group name |
required |
Returns:
Type | Description |
---|---|
list
|
Priority layers list |
Source code in src/cplus_plugin/conf.py
find_settings
Returns the plugin setting keys from the plugin root group that matches the passed name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Setting name to search for |
required |
Returns:
Type | Description |
---|---|
list
|
List of the matching settings names |
Source code in src/cplus_plugin/conf.py
get_activity
Gets an activity object matching the given unique identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_uuid |
str
|
Unique identifier of the activity object. |
required |
Returns:
Type | Description |
---|---|
Activity
|
Returns the activity object matching the given identifier else None if not found. |
Source code in src/cplus_plugin/conf.py
get_all_activities
Get all the activity objects stored in settings.
Returns:
Type | Description |
---|---|
list
|
Returns all the activity objects. |
Source code in src/cplus_plugin/conf.py
get_all_layer_mapping
Return all layer mapping.
Returns:
Type | Description |
---|---|
dict
|
All layer mapping |
Source code in src/cplus_plugin/conf.py
get_all_ncs_pathways
Get all the NCS pathway objects stored in settings.
Returns:
Type | Description |
---|---|
list
|
Returns all the NCS pathway objects. |
Source code in src/cplus_plugin/conf.py
get_default_layers
Returns list of default layers by type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_type |
str
|
ncs_pathway, priority_layer, or ncs_carbon |
required |
Returns:
Type | Description |
---|---|
typing.List[dict]
|
List of dictionary of ncs pathway |
Source code in src/cplus_plugin/conf.py
get_layer_mapping
Retrieves the layer mapping that matches the passed identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Layer mapping identifier |
required |
Returns:
Type | Description |
---|---|
typing.Dict
|
Layer mapping |
Source code in src/cplus_plugin/conf.py
get_ncs_pathway
Gets an NCS pathway object matching the given unique identified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_uuid |
str
|
Unique identifier for the NCS pathway object. |
required |
Returns:
Type | Description |
---|---|
NcsPathway
|
Returns the NCS pathway object matching the given identifier else None if not found. |
Source code in src/cplus_plugin/conf.py
get_ncs_pathway_dict
Gets an NCS pathway attribute values as a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_uuid |
str
|
Unique identifier for the NCS pathway object. |
required |
Returns:
Type | Description |
---|---|
dict
|
Returns the NCS pathway attribute values matching the given identifier else an empty dictionary if not found. |
Source code in src/cplus_plugin/conf.py
get_npv_collection
Gets the collection of NPV mappings of activities.
Returns:
Type | Description |
---|---|
ActivityNpvCollection
|
The collection of activity NPV mappings or None if not defined. |
Source code in src/cplus_plugin/conf.py
get_priority_group
Retrieves the priority group that matches the passed identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Priority group identifier |
required |
Returns:
Type | Description |
---|---|
typing.Dict
|
Priority group |
Source code in src/cplus_plugin/conf.py
get_priority_groups
Gets all the available priority groups in the plugin.
Returns:
Type | Description |
---|---|
list
|
List of the priority groups instances |
Source code in src/cplus_plugin/conf.py
get_priority_layer
Retrieves the priority layer that matches the passed identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
uuid.UUID
|
Priority layers identifier |
required |
Returns:
Type | Description |
---|---|
dict
|
Priority layer dict |
Source code in src/cplus_plugin/conf.py
get_priority_layers
Gets all the available priority layers in the plugin.
Returns:
Type | Description |
---|---|
list
|
Priority layers list |
Source code in src/cplus_plugin/conf.py
get_running_online_scenario
Retrieves running online scenario UUID.
Returns:
Type | Description |
---|---|
ScenarioSettings
|
Scenario settings instance |
Source code in src/cplus_plugin/conf.py
get_scenario
Retrieves the first scenario that matched the passed scenario id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_id |
str
|
Scenario id |
required |
Returns:
Type | Description |
---|---|
ScenarioSettings
|
Scenario settings instance |
Source code in src/cplus_plugin/conf.py
get_scenario_result
Retrieves the scenario result that matched the passed scenario id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_id |
str
|
Scenario id |
required |
Returns:
Type | Description |
---|---|
ScenarioSettings
|
Scenario result |
Source code in src/cplus_plugin/conf.py
get_scenarios
Gets all the available scenarios settings in the plugin.
Returns:
Type | Description |
---|---|
list
|
List of the scenario settings instances |
Source code in src/cplus_plugin/conf.py
get_scenarios_results
Gets all the saved scenarios results.
Returns:
Type | Description |
---|---|
list
|
List of the scenario results |
Source code in src/cplus_plugin/conf.py
get_value
Gets value of the setting with the passed name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of setting key |
required |
default |
Any
|
Default value returned when the setting key does not exist |
None
|
setting_type |
Any
|
Type of the store setting |
None
|
Returns:
Type | Description |
---|---|
Any
|
Value of the setting |
Source code in src/cplus_plugin/conf.py
remove
Remove the setting with the specified name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the setting key |
required |
remove_activity
Removes an activity settings entry using the UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_uuid |
str
|
Unique identifier of the activity to be removed. |
required |
Source code in src/cplus_plugin/conf.py
remove_default_layers
remove_layer_mapping
remove_ncs_pathway
Removes an NCS pathway settings entry using the UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_uuid |
str
|
Unique identifier of the NCS pathway entry to removed. |
required |
Source code in src/cplus_plugin/conf.py
save_activity
Saves an activity object serialized to a json string indexed by the UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity |
Union[Activity, dict]
|
Activity object or attribute values in a dictionary which are then serialized to a JSON string. |
required |
Source code in src/cplus_plugin/conf.py
save_default_layers
Save default layers by type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type |
str
|
ncs_pathway, priority_layer, or ncs_carbon |
required |
layers |
List
|
layer list |
required |
Source code in src/cplus_plugin/conf.py
save_layer_mapping
Save the layer mapping into the plugin settings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_layer |
dict
|
Layer mapping |
required |
identifier |
str
|
file identifier using path |
None
|
Source code in src/cplus_plugin/conf.py
save_ncs_pathway
Saves an NCS pathway object serialized to a json string indexed by the UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_pathway |
Union[NcsPathway, dict]
|
NCS pathway object or attribute values in a dictionary which are then serialized to a JSON string. |
required |
Source code in src/cplus_plugin/conf.py
save_npv_collection
Saves the activity NPV collection in the settings as a serialized JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
npv_collection |
ActivityNpvCollection
|
Activity NPV collection serialized to a JSON string. |
required |
Source code in src/cplus_plugin/conf.py
save_online_scenario
Save the passed scenario settings into the plugin settings as online tasl
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_uuid |
str
|
Scenario UUID |
required |
Source code in src/cplus_plugin/conf.py
save_priority_group
Save the priority group into the plugin settings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
priority_group |
str
|
Priority group |
required |
Source code in src/cplus_plugin/conf.py
save_priority_layer
Save the priority layer into the plugin settings. Updates the layer with new priority groups.
Note: Emits priority_layers_changed signal
Parameters:
Name | Type | Description | Default |
---|---|---|---|
priority_layer |
dict
|
Priority layer |
required |
Source code in src/cplus_plugin/conf.py
save_scenario
Save the passed scenario settings into the plugin settings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_settings |
ScenarioSettings
|
Scenario settings |
required |
Source code in src/cplus_plugin/conf.py
save_scenario_extent
Saves the scenario extent into plugin settings using the provided settings group key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
QgsSettings group key |
required |
extent |
SpatialExtent Args: extent (SpatialExtent): Scenario extent key (str): QgsSettings group key
|
Scenario extent |
required |
Source code in src/cplus_plugin/conf.py
save_scenario_result
Save the scenario results plugin settings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario_settings |
ScenarioSettings
|
Scenario settings |
required |
Source code in src/cplus_plugin/conf.py
set_current_priority_layer
Set current priority layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Priority layer identifier |
required |
Source code in src/cplus_plugin/conf.py
set_value
Adds a new setting key and value on the plugin specific settings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of setting key |
required |
value |
Any
|
Value of the setting |
required |
Source code in src/cplus_plugin/conf.py
update_activities
Updates the attributes of the existing activities.
update_activity
Updates the attributes of the activity object in settings. On the path, the BASE_DIR in settings is used to reflect the absolute path of each NCS pathway layer. If BASE_DIR is empty then the NCS pathway setting will not be updated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity |
Activity
|
Activity object to be updated. |
required |
Source code in src/cplus_plugin/conf.py
update_ncs_pathway
Updates the attributes of the NCS pathway object in settings. On the path, the BASE_DIR in settings is used to reflect the absolute path of each NCS pathway layer. If BASE_DIR is empty then the NCS pathway setting will not be updated, this only applies for default pathways.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_pathway |
NcsPathway
|
NCS pathway object to be updated. |
required |
Source code in src/cplus_plugin/conf.py
update_ncs_pathways
Updates the path attribute of all NCS pathway settings based on the BASE_DIR settings to reflect the absolute path of each NCS pathway layer. If BASE_DIR is empty then the NCS pathway settings will not be updated.
Source code in src/cplus_plugin/conf.py
qgis_settings
Context manager to help defining groups when creating QgsSettings.
:yields: Instance of the created settings :ytype: QgsSettings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group_root |
str
|
Name of the root group for the settings |
required |
settings |
QgsSettings
|
QGIS settings to use |
None
|