Component item model¶
Contains item models for view widgets such as NCS pathway or IM views.
ActivityItem ¶
Bases: LayerComponentItem
Standard item for an activity object.
Source code in src/cplus_plugin/gui/component_item_model.py
activity
property
¶
Returns an instance of the underlying activity object.
Returns:
Type | Description |
---|---|
Activity
|
The underlying activity object. |
layer_item
property
¶
Returns the view item for the layer.
Returns:
Type | Description |
---|---|
QtGui.QStandardItem
|
Returns the view item for the map layer else None if no layer has been specified for the model. |
ncs_items
property
¶
Returns a collection of NcsPathwayItem in this activity object.
Returns:
Type | Description |
---|---|
list
|
Collection of NcsPathwayItem objects in this activity object. |
ncs_pathways
property
¶
Returns a collection of NcsPathway objects.
Returns:
Type | Description |
---|---|
list
|
Collection of NcsPathway objects linked to the underlying activity object. |
original_ncs_pathways
property
¶
Returns a collection of NcsPathway objects but with their original UUIDs.
These are used for persisting the NCsPathway objects related to the underlying activity object.
Returns:
Type | Description |
---|---|
list
|
Collection of NcsPathway objects with their original UUIDs linked to the underlying activity object. |
add_ncs_pathway_item ¶
Adds an NCS pathway item to this activity item.
If the item already contains a layer, then the add operation will not be successful.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_item |
NcsPathwayItem
|
NCS pathway item to the collection. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the NCS pathway item was successfully added, else False if there underlying NCS pathway object was invalid, there is an existing item with the same UUID or if the layer property had already been set. |
Source code in src/cplus_plugin/gui/component_item_model.py
bottom_ncs_item_index ¶
Returns the model index of the bottom-most NcsPathwayItem under this activity item.
Returns:
Type | Description |
---|---|
QModelIndex
|
Model index of the bottom-most NcsPathwayItem. |
Source code in src/cplus_plugin/gui/component_item_model.py
clear_layer ¶
clone ¶
Creates a cloned version of this item.
The cloned IM will contain pathways with the original UUID. The UUID of the activity object will not change.
Source code in src/cplus_plugin/gui/component_item_model.py
contains_ncs_item ¶
Checks whether this item contains an NcsPathway item with the given UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item_uuid |
str
|
UUID of the NcsPathway item to search for. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if there is an NcsPathwayItem matching the given UUID, else False. |
Source code in src/cplus_plugin/gui/component_item_model.py
create
staticmethod
¶
Creates an instance of the activity item from the model object.
Returns:
Type | Description |
---|---|
Activity
|
An instance of the activity item to be used in a standard model. |
Source code in src/cplus_plugin/gui/component_item_model.py
enable_default_pathways ¶
Enable or disable default NCS pathway items.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
bool
|
True to enable default NCS pathways else False to disable them. |
required |
Source code in src/cplus_plugin/gui/component_item_model.py
ncs_item_by_uuid ¶
Returns an NcsPathway item matching the given UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_uuid |
str
|
UUID of the NcsPathway item to retrieve. |
required |
Returns:
Type | Description |
---|---|
NcsPathwayItem
|
NcsPathwayItem matching the given UUID, else None if not found. |
Source code in src/cplus_plugin/gui/component_item_model.py
ncs_item_from_original_pathway ¶
Retrieves the NCS item corresponding to the original NCS pathway i.e. before it is added to this activity item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_pathway |
Union[NcsPathway, str]
|
Original NCS pathway data model or unique identifier of the NCS pathway. |
required |
Returns:
Type | Description |
---|---|
Union[NcsPathwayItem, None]
|
The matching NCS pathway item in this activity item, else None if there is no matching item. |
Source code in src/cplus_plugin/gui/component_item_model.py
remove_ncs_pathway_item ¶
Removes the NcsPathwayItem matching the given UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item_uuid |
str
|
The UUID of the NcsPathwayItem to remove. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the item was successfully removed, else False. |
Source code in src/cplus_plugin/gui/component_item_model.py
setEnabled ¶
Override for default implementation that also enables or disables NCS pathway items.
Source code in src/cplus_plugin/gui/component_item_model.py
set_bold_font ¶
Set the text to bold or normal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bold |
bool
|
True to set the text font to be bold, else False to normal. |
required |
Source code in src/cplus_plugin/gui/component_item_model.py
type ¶
Returns the type of the standard item.
Returns:
Type | Description |
---|---|
int
|
Type identifier of the standard item. |
ActivityItemModel ¶
Bases: ComponentItemModel
View model for activity.
Source code in src/cplus_plugin/gui/component_item_model.py
activities ¶
Returns activity objects in the view model.
Returns:
Type | Description |
---|---|
list
|
Activity objects in the view model. |
Source code in src/cplus_plugin/gui/component_item_model.py
activity_items ¶
Returns all activity item objects in the model.
Returns:
Type | Description |
---|---|
list
|
Activity items in the model. |
Source code in src/cplus_plugin/gui/component_item_model.py
add_activity ¶
Add an activity object to the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity |
Activity
|
Activity object to be added to the view. |
required |
layer |
QgsMapLayer
|
Map layer for the activity. |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if an activity object was added successfully, else False. |
Source code in src/cplus_plugin/gui/component_item_model.py
add_ncs_pathway ¶
Adds an NCS pathway item to the activity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_item |
NcsPathwayItem
|
NCS pathway item to the collection. |
required |
target_activity_item |
ActivityItem
|
Target activity for the NCS item. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the NCS pathway item was successfully added, else False if there underlying NCS pathway object was invalid, there is an existing item with the same UUID or if there is already a map layer defined for the activity. |
Source code in src/cplus_plugin/gui/component_item_model.py
dropMimeData ¶
Implements behaviour for handling data supplied by drag and drop operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
QMimeData
|
Object containing data from the drag operation. |
required |
action |
DropAction
|
Type of the drag and drop operation. |
required |
row |
int
|
Row location of dropped data. |
required |
column |
int
|
Column location of dropped data. |
required |
parent |
QModelIndex
|
Index location for target item where the operation ended. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the data and action can be handled by the model, else False. |
Source code in src/cplus_plugin/gui/component_item_model.py
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 |
|
remove_activity ¶
Remove an activity item from the view model.
param uuid: UUID of the activity item to be removed.
Returns:
Type | Description |
---|---|
bool
|
True if the activity item was successfully removed, else False if there was not matching UUID. |
Source code in src/cplus_plugin/gui/component_item_model.py
remove_layer ¶
Removes the layer reference from the underlying activity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_item |
ActivityItem
|
activity item whose layer is to be removed. |
required |
Source code in src/cplus_plugin/gui/component_item_model.py
remove_ncs_pathway_item ¶
Remove an NCS pathway item from the activity.
param uuid: UUID of the NCS pathway item to be removed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent |
ActivityItem
|
Reference activity item that is the parent to the NCS pathway item. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the NCS pathway item has been successfully removed, else False if there was no matching UUID. |
Source code in src/cplus_plugin/gui/component_item_model.py
remove_ncs_pathway_items ¶
Delete NCS pathway items matching the given NCS pathway model.
If the NCS pathway model is not valid then the NCS pathway items in the activity item will not be deleted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_pathway_uuid |
str
|
Unique identifier of the NCS pathway object whose corresponding models are to be removed in the activities. |
required |
Source code in src/cplus_plugin/gui/component_item_model.py
set_model_layer ¶
Set the layer for the given activity item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity_item |
ActivityItem
|
activity item whose layer is to be specified. |
required |
layer |
QgsMapLayer
|
Map layer to be set for the activity. |
required |
display_name |
str
|
Display name for the layer node. If not specified then the name from the map layer is used. |
''
|
Returns:
Type | Description |
---|---|
bool
|
True if the layer was successfully set for the activity, else False if the layer is invalid, if there are already existing NCS pathways in the activity or if the item is not in the model. |
Source code in src/cplus_plugin/gui/component_item_model.py
update_activity ¶
Updates the activity item using the given activity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity |
Activity
|
Activity object whose corresponding item is to be updated. |
required |
layer |
QgsMapLayer
|
Map layer to be updated for the activity if specified. |
None
|
Returns:
Type | Description |
---|---|
bool
|
Returns True if the operation was successful else False if the matching item was not found in the activity. |
Source code in src/cplus_plugin/gui/component_item_model.py
update_ncs_pathway_items ¶
Update NCS pathway items matching the given NCS pathway model.
If the NCS pathway model is not valid then the NCS pathway items in the activity item will not be updated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs_pathway |
NcsPathway
|
Original NCS pathway object whose corresponding models are to be updated. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if matching NCS pathway items have been updated, else False. |
Source code in src/cplus_plugin/gui/component_item_model.py
ComponentItemModel ¶
Bases: QStandardItemModel
View model for ModelComponent objects.
Source code in src/cplus_plugin/gui/component_item_model.py
add_component_item ¶
Adds a model component item to the view model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
component_item |
ModelComponentItem
|
Model component item to be added to the view model. |
required |
position |
int
|
Reference row to insert the item. |
-1
|
Returns:
Type | Description |
---|---|
bool
|
True if the component item was successfully added, else False if there is an existing component item with the same UUID. |
Source code in src/cplus_plugin/gui/component_item_model.py
component_item_by_uuid ¶
Retrieves a ModelComponentItem based on a matching UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uuid_str |
str
|
UUID of the model item. |
required |
Returns:
Type | Description |
---|---|
ModelComponentItem
|
Component item matching the given UUID or None if not found. |
Source code in src/cplus_plugin/gui/component_item_model.py
contains_item ¶
Checks if the model contains an item with the given UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item_uuid |
str
|
UUID of the model item. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if there is an existing item else False. |
Source code in src/cplus_plugin/gui/component_item_model.py
disabled_items ¶
Gets the list of disabled items in the model.
Returns:
Type | Description |
---|---|
list
|
Disabled items in the model. |
Source code in src/cplus_plugin/gui/component_item_model.py
enable_default_items ¶
Enable or disable items for default model components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
bool
|
True to enable or False to disable. |
required |
Source code in src/cplus_plugin/gui/component_item_model.py
index_by_uuid ¶
Get the QModelIndex object for the component item matching the given UUID identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uuid_str |
str
|
UUID of the model item. |
required |
Returns:
Type | Description |
---|---|
QtCore.QModelIndex
|
QModelIndex for the component item matching the given UUID or an invalid QModelIndex if not found. |
Source code in src/cplus_plugin/gui/component_item_model.py
model_component_items ¶
Returns model component items in the model.
Returns:
Type | Description |
---|---|
list
|
Model component items in the model. |
Source code in src/cplus_plugin/gui/component_item_model.py
model_components ¶
Returns a collection of model component objects in the model.
Returns:
Type | Description |
---|---|
list
|
A collection of all model component objects. |
Source code in src/cplus_plugin/gui/component_item_model.py
remove_component_item ¶
Removes a ModelComponentItem based on a matching UUID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uuid_str |
str
|
UUID of the model item to be removed. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the component item was successfully removed, else False if there was not matching UUID. |
Source code in src/cplus_plugin/gui/component_item_model.py
update_item ¶
Update an existing ModelComponentItem if it exists in the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
ModelComponentItemType
|
An updated instance of the ModelComponentItem. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the item was successfully updated, else False if there was no matching item found in the model. |
Source code in src/cplus_plugin/gui/component_item_model.py
LayerComponentItem ¶
Bases: ModelComponentItem
Base class view item for layer-based component items.
Source code in src/cplus_plugin/gui/component_item_model.py
layer
property
¶
Returns the map layer from the underlying model component object.
Returns:
Type | Description |
---|---|
QgsMapLayer
|
Map layer corresponding from the underlying model component. |
user_defined
property
¶
Returns whether the model component is user-defined or default that is shipped together with the plugin.
Returns:
Type | Description |
---|---|
bool
|
True if the model component is user-defined else False if its a default component. |
clone
abstractmethod
¶
Creates a deep copied version of the model item.
Returns:
Type | Description |
---|---|
ModelComponentItem
|
Cloned version of the model item containing all the properties as the source. |
Source code in src/cplus_plugin/gui/component_item_model.py
create
abstractmethod
staticmethod
¶
Factory method for creating an instance of a model item.
This is an abstract method that needs to be implemented by subclasses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_component |
BaseModelComponent
|
Source model component for creating the corresponding item. |
required |
Returns:
Type | Description |
---|---|
ModelComponentItem
|
Model component item for use in a standard item model. |
Source code in src/cplus_plugin/gui/component_item_model.py
is_valid ¶
Checks whether the map layer of the underlying model component object is valid.
Returns:
Type | Description |
---|---|
bool
|
True if the map layer is valid, else False if map layer is invalid or of None type. |
Source code in src/cplus_plugin/gui/component_item_model.py
set_layer ¶
Set the map layer for the component item.
It sets the :py:attr:~path
attribute of the
underlying data model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
QgsMapLayer
|
Map layer for the component item. |
required |
Returns:
Type | Description |
---|---|
bool
|
Returns True if the layer was successfully set, else False if the layer is invalid. |
Source code in src/cplus_plugin/gui/component_item_model.py
LayerItem ¶
Bases: QStandardItem
Contains a custom identifier for an item used to define a layer for an activity.
type ¶
Returns the type of the standard item.
Returns:
Type | Description |
---|---|
int
|
Type identifier of the standard item. |
ModelComponentItem ¶
Bases: QStandardItem
Base standard item for a BaseModelComponent object.
Source code in src/cplus_plugin/gui/component_item_model.py
description
property
¶
Returns the description of the item.
Returns:
Type | Description |
---|---|
str
|
Description of the item. |
model_component
property
¶
Returns an instance of the underlying model component object.
Returns:
Type | Description |
---|---|
BaseModelComponent
|
Instance of underlying model component object. |
uuid
property
¶
Returns the UUID of the item.
Returns:
Type | Description |
---|---|
str
|
UUID string of the item. |
clone
abstractmethod
¶
Creates a deep copied version of the model item.
Returns:
Type | Description |
---|---|
ModelComponentItem
|
Cloned version of the model item containing all the properties as the source. |
Source code in src/cplus_plugin/gui/component_item_model.py
create
abstractmethod
staticmethod
¶
Factory method for creating an instance of a model item.
This is an abstract method that needs to be implemented by subclasses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_component |
BaseModelComponent
|
Source model component for creating the corresponding item. |
required |
Returns:
Type | Description |
---|---|
ModelComponentItem
|
Model component item for use in a standard item model. |
Source code in src/cplus_plugin/gui/component_item_model.py
update ¶
Update the component-related properties of the item.
Source code in src/cplus_plugin/gui/component_item_model.py
NcsPathwayItem ¶
Bases: LayerComponentItem
Standard item for an NCS pathway object.
Source code in src/cplus_plugin/gui/component_item_model.py
ncs_pathway
property
¶
Returns an instance of the underlying NcsPathway object.
Returns:
Type | Description |
---|---|
NcsPathway
|
The underlying NcsPathway model object. |
parent
property
¶
Returns the parent activity item if specified.
Returns:
Type | Description |
---|---|
ActivityItem
|
Returns the parent item if set when this item is mapped to an ActivityItem. |
clone ¶
create
staticmethod
¶
Creates an instance of the NcsPathwayItem from the model object.
Returns:
Type | Description |
---|---|
NcsPathwayItem
|
An instance of the NcsPathway item to be used in a standard model. |
Source code in src/cplus_plugin/gui/component_item_model.py
is_carbon_valid ¶
Returns the validity of the carbon layers in the underlying NCSPathway model object.
Returns:
Type | Description |
---|---|
bool
|
True if the carbon layers are valid, else False. |
Source code in src/cplus_plugin/gui/component_item_model.py
json_data ¶
Creates a mapping of NCS pathway property names and their corresponding values.
Returns:
Type | Description |
---|---|
str
|
JSON representation of property name-value pairs for an NCS pathway object. |
Source code in src/cplus_plugin/gui/component_item_model.py
setEnabled ¶
Override for default implementation that also enables or disables selection of the item.
type ¶
Returns the type of the standard item.
Returns:
Type | Description |
---|---|
int
|
Type identifier of the standard item. |
NcsPathwayItemModel ¶
Bases: ComponentItemModel
View model for NCS pathways.
Source code in src/cplus_plugin/gui/component_item_model.py
add_ncs_pathway ¶
Add an NCS pathway object to the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs |
NcsPathway
|
NCS pathway object to the added to the view. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the NCS pathway object was added successfully, else False if the NcsPathway object is invalid. |
Source code in src/cplus_plugin/gui/component_item_model.py
mimeData ¶
Serializes the NCS items corresponding to the specified indexes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indexes |
List[QModelIndex]
|
NCS items stored in the specified indexes. |
required |
Returns:
Type | Description |
---|---|
QtCore.QMimeData
|
Mime object containing serialized NCS items. |
Source code in src/cplus_plugin/gui/component_item_model.py
mimeTypes ¶
Returns supported MIME types that can be used to describe a list of model indexes for NCS pathway items.
Returns:
Type | Description |
---|---|
list
|
MIME type for NCS pathway items which is JSON string but MIME type is the default datalist type for Qt since it does not allow custom types. |
Source code in src/cplus_plugin/gui/component_item_model.py
pathways ¶
Returns NCS pathway objects in the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
valid_only |
bool
|
Whether to only return NCS pathway objects that are valid. |
False
|
Returns:
Type | Description |
---|---|
list
|
All NCS pathway objects in the model (default), else only those NCS pathway objects that are valid if valid_only is True. |
Source code in src/cplus_plugin/gui/component_item_model.py
remove_ncs_pathway ¶
Remove an NCS pathway item from the model.
param uuid: UUID of the NCS pathway item to be removed.
Returns:
Type | Description |
---|---|
bool
|
True if the NCS pathway item as successfully removed, else False if there was not matching UUID. |
Source code in src/cplus_plugin/gui/component_item_model.py
supportedDropActions ¶
Configure the model to only support copying items in a drag-and-drop operation.
Returns:
Type | Description |
---|---|
QtCore.Qt.DropActions
|
Supported drag-and-drop action for NCS pathway items. |
Source code in src/cplus_plugin/gui/component_item_model.py
update_ncs_pathway ¶
Updates the NCS pathway item in the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ncs |
NcsPathway
|
NcsPathway whose corresponding item is to be updated. |
required |
Returns:
Type | Description |
---|---|
bool
|
Returns True if the operation was successful else False if the matching item was not found in the model. |