diff --git a/cmd/miqt-uic/types.go b/cmd/miqt-uic/types.go index 9e2cdbb..80d2c4a 100644 --- a/cmd/miqt-uic/types.go +++ b/cmd/miqt-uic/types.go @@ -5,8 +5,10 @@ import ( ) type UiLayoutItem struct { - Row *int `xml:"row,attr"` - Column *int `xml:"column,attr"` + Row *int `xml:"row,attr"` + Column *int `xml:"column,attr"` + RowSpan *int `xml:"rowspan,attr"` + ColSpan *int `xml:"colspan,attr"` // A layout item either has a widget, or a spacer Widget *UiWidget `xml:"widget"` diff --git a/cmd/miqt-uic/ui2go.go b/cmd/miqt-uic/ui2go.go index f275915..5b93c78 100644 --- a/cmd/miqt-uic/ui2go.go +++ b/cmd/miqt-uic/ui2go.go @@ -298,12 +298,29 @@ func generateWidget(w UiWidget, parentName string, parentClass string) (string, `) case `QGridLayout`: - // For QGridLayout it's AddWidget2 - // FIXME in Miqt this function has optionals, needs to be called with the correct arity - // TODO support rowSpan, columnSpan - ret.WriteString(` + if child.ColSpan != nil || child.RowSpan != nil { + // If either are present, use full four-value AddWidget3 + rowSpan := 1 + if child.RowSpan != nil { + rowSpan = *child.RowSpan + } + colSpan := 1 + if child.ColSpan != nil { + colSpan = *child.ColSpan + } + + ret.WriteString(` + ui.` + w.Layout.Name + `.AddWidget3(` + qwidgetName(`ui.`+child.Widget.Name, child.Widget.Class) + `, ` + fmt.Sprintf("%d, %d, %d, %d", *child.Row, *child.Column, rowSpan, colSpan) + `) + `) + + } else { + // Row and Column are always present in the .ui file + // For row/column it's AddWidget2 + + ret.WriteString(` ui.` + w.Layout.Name + `.AddWidget2(` + qwidgetName(`ui.`+child.Widget.Name, child.Widget.Class) + `, ` + fmt.Sprintf("%d, %d", *child.Row, *child.Column) + `) `) + } case "QVBoxLayout", "QHBoxLayout": // For box layout it's AddWidget