Skip to content

Commit

Permalink
Prevent DnD form generator from generating empty layout items
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Jan 8, 2025
1 parent c475d67 commit 5e9c005
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions src/config_generator/dnd_form_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ def __add_tablayout_fields(self, maplayer, projectname, layername, project, pare
for child in container:
added = False
if child.tag == "attributeEditorContainer":
item = ElementTree.Element("item")
item.set("row", str(row))
item.set("column", str(col))
item.set("colspan", "2")
layout.append(item)
added = True

if child.get('groupBox') == "0":
if child.get('type') == "Tab":
if not tabWidget:
item = ElementTree.Element("item")
item.set("row", str(row))
item.set("column", str(col))
item.set("colspan", "2")
layout.append(item)
added = True
tabWidget = ElementTree.Element("widget")
tabWidget.set("class", "QTabWidget")
item.append(tabWidget)
Expand All @@ -350,7 +350,13 @@ def __add_tablayout_fields(self, maplayer, projectname, layername, project, pare
tabWidget.append(widget)

self.__add_tablayout_fields(maplayer, projectname, layername, project, widget, child, aliases)
else:
elif child.get('type') == "GroupBox":
item = ElementTree.Element("item")
item.set("row", str(row))
item.set("column", str(col))
item.set("colspan", "2")
layout.append(item)
added = True
tabWidget = None

widget = ElementTree.Element("widget")
Expand Down Expand Up @@ -413,12 +419,6 @@ def __add_tablayout_fields(self, maplayer, projectname, layername, project, pare
col = 0
row += 1

item = ElementTree.Element("item")
item.set("row", str(row + 1))
item.set("column", "0")
item.set("colspan", str(2 * ncols))
layout.append(item)

def __add_autolayout_fields(self, maplayer, projectname, layername, project, parent, aliases):
fields = maplayer.findall("fieldConfiguration/field")
layout = ElementTree.Element("layout")
Expand Down Expand Up @@ -464,7 +464,7 @@ def __add_autolayout_fields(self, maplayer, projectname, layername, project, par
continue

widget = self.__create_relation_widget(projectname, layername, project, relation, True)
if not widget:
if widget is None:
continue

item = ElementTree.Element("item")
Expand All @@ -476,8 +476,3 @@ def __add_autolayout_fields(self, maplayer, projectname, layername, project, par
layout.append(item)
row += 1

item = ElementTree.Element("item")
item.set("row", str(row + 1))
item.set("column", "0")
item.set("colspan", str(2))
layout.append(item)

0 comments on commit 5e9c005

Please sign in to comment.