Skip to content
Snippets Groups Projects
Commit b3159851 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added parent_index for openSection in local backend.

parent c161aa0f
No related branches found
No related tags found
No related merge requests found
...@@ -86,10 +86,10 @@ class LocalBackend(object): ...@@ -86,10 +86,10 @@ class LocalBackend(object):
(ik.name, superSectionNames)) (ik.name, superSectionNames))
self.dataManagers[ik.name] = DataManager(ik, self.sectionManagers[superSectionNames[0]]) self.dataManagers[ik.name] = DataManager(ik, self.sectionManagers[superSectionNames[0]])
def openSection(self, metaName): def openSection(self, metaName, parent_index: int = -1):
"""opens a new section and returns its new unique gIndex""" """opens a new section and returns its new unique gIndex"""
manager = self.sectionManagers[metaName] manager = self.sectionManagers[metaName]
newIndex = manager.openSection(self) newIndex = manager.openSection(self, parent_index=parent_index)
self.__openSections.add((metaName, newIndex)) self.__openSections.add((metaName, newIndex))
return newIndex return newIndex
...@@ -613,12 +613,12 @@ class SectionManager(object): ...@@ -613,12 +613,12 @@ class SectionManager(object):
self.debug = debug self.debug = debug
self.openSections = [] self.openSections = []
def openSection(self, backend): def openSection(self, backend, parent_index: int = -1):
newGIndex = self.lastSectionGIndex + 1 newGIndex = self.lastSectionGIndex + 1
self.openSectionWithGIndex(backend, newGIndex) self.openSectionWithGIndex(backend, newGIndex, parent_index=parent_index)
return newGIndex return newGIndex
def openSectionWithGIndex(self, backend, gIndex): def openSectionWithGIndex(self, backend, gIndex, parent_index: int = -1):
self.lastSectionGIndex = gIndex self.lastSectionGIndex = gIndex
references = [] references = []
parents = [] parents = []
...@@ -626,7 +626,8 @@ class SectionManager(object): ...@@ -626,7 +626,8 @@ class SectionManager(object):
for parentName in self.parentSectionNames: for parentName in self.parentSectionNames:
pSect = backend.sectionManagers.get(parentName) pSect = backend.sectionManagers.get(parentName)
try: try:
parentSection = pSect.openSections[pSect.lastSectionGIndex] parent_section_index = pSect.lastSectionGIndex if parent_index == -1 else parent_index
parentSection = pSect.openSections[parent_section_index]
except IndexError: except IndexError:
pass pass
except KeyError: except KeyError:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment