PyANGKernel.GKFolder¶
- class GKFolder¶
An unsorted list of objects and folders.
Details
GKFolderis a list of objects (GKObject) or folders (GKFolder) contained in an object (GKObject). EveryGKObjectcan contain a folder, called the root folder. This root folder can contain objects and folders (that can contain objects and folder, and so on).Folders must be registered in the system before using it. See
registerFolderObject folders allow the developer to include information to an object without modifying it. They are similar to the
GKColumnandGKTypemechanism (called Extensible Object Model) but unrelated (thegetDataValueandsetDataValueoperations cannot be applied to these folders).The main advantage is that the GUI class GListViewForModel can list in a browser the content of the
GKModelfolders and that these contents can be modified at run time. This allows us the addition of non-graphical object to the model (in one ofGKModel‘s folder) that will be graphically represented (as items in the GListViewForModel widget). This representation will allow the user the selection and manipulation of these objects (double click to open its editor or using the context menu to issue commands).A
GKFolderhas a name (GKFolder::getName) and an internal name (getInternalName). The internal name identifies the folder uniquely among all the other folders in the system. It’s up to the developer to give a unique name to the folder.Each folder has a root (the object owner of the folder) if it is not a subfolder. If it is a subfolder then the root is a folder and the final object owner can be read using the
getAbsoluteRootmethod.In order to create a folder in an object that is not a folder, use the following code:
folder = GKSystem::getSystem().createFolder( object->getCreateRootFolder(), "Internal Name" );
The method
getCreateRootFolderreturns the root folder for the object. Since a root folder is optional, maybe the root folder has not been created yet, so instead of using thegetRootFoldermethod that can return NULL, we use thegetCreateRootFoldermethod that will create the root folder if needed.And in order to create a folder in a folder, use the following code:
subfolder = GKSystem::getSystem().createFolder( folder, "Internal Name" );
Where, in both examples: - External Name: is the name of the folder that will be presented to the user. - Internal Name: is the internal name of the folder that have to be unique.
Note that
GKFolderinherits fromGKObject. A folder contains a list ofGKObjectand some of these will beGKFolder; in order to determinate if they are folder or non folders, use the following code:GKFolderContents::const_iterator iter; for( iter = folder->getContents().begin(); iter != folder->getContents().end(); iter++ ){ if( dynamic_cast<GKFolder*>( obj ) ){ // It's a folder ... }else{ // It isn't a folder ... } }
The developer must create the folder before inserting any object. The folder to be created depends of the object to be inserted. Check the class documentation for the folder external and internal name.
For example, to add a new centroid configuration:
folder = model->findFolder( "GKModel::centroidsConf" ); if( folder == nullptr ){ folder = GKSystem::getSystem().createFolder( model->getCreateRootFolder(), "GKModel::centroidsConf" ); }
or, in Python:
folder = model.findFolder( "GKModel::centroidsConf" ) if folder == None: folder = GKSystem.getSystem().createFolder( model.getCreateRootFolder(), "GKModel::centroidsConf" )
Synopsis¶
Methods¶
def
__init__()def
__getitem__()def
__iter__()def
__len__()def
append()def
canBeRenamed()def
clear()def
contains()def
createFolder()def
deepClear()def
getContents()def
getProblemNet()def
getRoot()def
remove()def
setRoot()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- __init__()¶
- __len__()¶
Adds an object to this folder
Returns true if the name of this folder can be renamed (true by default)
See also
- clear()¶
Clears the folder (objects inside the folder are not deleted just removed from the folder).
Returns true if obj is in this folder.
- createFolder(aname, ainternalName[, showOnlyConts=false[, temporary=false]])¶
- Parameters:
aname – str
ainternalName – str
showOnlyConts – bool
temporary – bool
- Return type:
Creates a subfolder. First it checks if the folder is already here (using the internalName) and if so a pointer to the already existing folder is returned, if not a new one is created.
- deepClear()¶
Clears the folder and deletes all the objects inside.
In a clone operation if true the objects in this folder will be cloned and if false the contents of this folder and the contents of the original folder will be the same. False by default.
See also
Finds the best possible duplicate object name, considering the folder’s contents * with the format “<object_name> - copy” or “<object_name> - copy(x)” for x > 2.
Find any folder inside this folder to hold the object that may be better than the root one, * considering the object types that each folder can hold.
Returns the first non folder object that is a root: if the root is not a folder it will return the root. If the root is a folder it will return the getAbsoluteRoot of this folder.
- getContents()¶
- Return type:
Dictionary with keys of type .uint and values of type GKObject.
Gets the content of the folder: a list with objects (including also subfolders).
- getContentsTypes([staticOn=true[, mesoOn=true[, microOn=true[, travelDemand=true]]]])¶
- Parameters:
staticOn – bool
mesoOn – bool
microOn – bool
travelDemand – bool
- Return type:
.list of GKType
Returns the types of objects that this folder can contain. Since this information is optional an empty vector can be returned.
Use
registerFolderto set this information.Gets the internal folder name
- getProblemNet()¶
- Return type:
Search recursively in parent objects a ProblemNet. * Returns a ProblemNet if the object is in a ProblemNet, return NULL otherwise.
Gets the root of this folder: a folder if it is a subfolder or an object it is a root folder.
Removes an object from this folder
- setCanBeRenamed(status)¶
- Parameters:
status – bool
Set to true if the name of this folder can be renamed (true by default)
See also
- setDeepCopyOnStoreCopy(value)¶
- Parameters:
value – bool
In a clone operation if true the objects in this folder will be cloned and if false the contents of this folder and the contents of the original folder will be the same. False by default.
See also
- setDeepCopyOnStoreCopyRecursively(value)¶
- Parameters:
value – bool
As
setDeepCopyOnStoreCopybut it will call alsosetDeepCopyOnStoreCopyfor each folder inside this folder (reursively).- setInternalName(iname)¶
- Parameters:
iname – str
Sets the internal (and unique) folder name.
Sets the root of this folder. It is done automatically by
createFolder- setShowOnlyContents(value)¶
- Parameters:
value – bool
If true, when listing this folder in the GListViewForModel widget only its contents will appear and not the list itself and the contents as children of the folder. False by default.
See also
If true, when listing this folder in the GListViewForModel widget only its contents will appear and not the list itself and the contents as children of the folder. False by default.
See also