Variable Register
Manages custom variable data for report design and generation.
CplusVariableInfo
dataclass
Contains information about a CPLUS variable within a layout scope.
update_final_value
Computes the final value of the variable to be used in the layout.
Default implementation does nothing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context |
BaseReportContext
|
Report context object used to compute the final variable value. |
required |
Source code in src/cplus_plugin/lib/reports/variables.py
LayoutVariableRegister
Manages variables and their corresponding values for use in layout design and report generation.
Source code in src/cplus_plugin/lib/reports/variables.py
var_name_init_values
property
Creates a collection of variable names and their corresponding initial values.
Returns:
Type | Description |
---|---|
dict
|
Collection of variable names and corresponding initial values. |
variable_names
property
Gets the names of the registered variables.
Returns:
Type | Description |
---|---|
list
|
A collection of registered variable names. |
is_analysis_report
Checks whether the layout has been produced from a report generation process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout |
QgsPrintLayout
|
Layout to check whether its from a report generation process. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the layout is from a report generation process, else False. |
Source code in src/cplus_plugin/lib/reports/variables.py
register_variables
Registers custom variables and their corresponding initial values in the layout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout |
QgsPrintLayout
|
Layout object where the custom variables will be registered. |
required |
Source code in src/cplus_plugin/lib/reports/variables.py
remove_var_name_in_collection
classmethod
Remove cplus variable name matches and corresponding values in the layout variable name/value mapping.
Source code in src/cplus_plugin/lib/reports/variables.py
remove_variables
Removes duplicate variable names from the layout, this is done prior to registering new ones.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout |
QgsPrintLayout
|
Layout whose cplus variables are to be removed. |
required |
Returns:
Type | Description |
---|---|
tuple
|
Tuple only containing non-cplus variable names and corresponding values respectively. |
Source code in src/cplus_plugin/lib/reports/variables.py
set_report_flag
Set a flag indicating that the layout has been produced from a report generation process.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout |
QgsPrintLayout
|
Layout to add the flag as a custom property. |
required |
Source code in src/cplus_plugin/lib/reports/variables.py
update_variables
Update the values for the CPLUS variables in the layout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout |
QgsPrintLayout
|
Layout object whose CPLUS variable values will be updated. |
required |
context |
BaseReportContext
|
Context object containing the report information that will be used for computing the final value of the variable during the report generation process. |
required |
Source code in src/cplus_plugin/lib/reports/variables.py
NoneValueSettingsVariableInfo
dataclass
Bases: SettingsVariableInfo
Sets final value as "N/A" if there is no text specified in the settings.
update_final_value
Computes the final value of the variable to be used in the layout.
Fetches the latest settings value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context |
BaseReportContext
|
Report context object used to compute the final variable value. |
required |
Source code in src/cplus_plugin/lib/reports/variables.py
ScenarioDescriptionVariableInfo
dataclass
ScenarioNameVariableInfo
dataclass
SettingsVariableInfo
dataclass
Bases: CplusVariableInfo
Metadata for a settings-related variable.
update_final_value
Computes the final value of the variable to be used in the layout.
Fetches the latest settings value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context |
BaseReportContext
|
Report context object used to compute the final variable value. |
required |
Source code in src/cplus_plugin/lib/reports/variables.py
create_bulleted_text
Returns string containing text and bulleted/dashed text below it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
main_text |
str
|
Primary non-bulleted text. |
required |
bulleted_items |
List[str]
|
List containing bulleted items that will be rendered below the main text. |
required |
Returns:
Type | Description |
---|---|
str
|
Text containing primary text with bulleted items below it. |