Skip to content

Commit

Permalink
allow nested messages to be unset aka nil
Browse files Browse the repository at this point in the history
  • Loading branch information
rogchap committed Aug 9, 2020
1 parent 6749997 commit a116f59
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion darwin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0-alpha</string>
<string>0.2.0-alpha</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion internal/app/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// The following variables are set via LDFlags at build time
var (
appname = "Wombat"
semver = "0.1.0-alpha.1"
semver = "0.2.0-alpha"
isDebug = true
)

Expand Down
14 changes: 11 additions & 3 deletions internal/app/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,28 @@ func (c *workspaceController) send(service, method string) error {
}

func processMessage(msg *model.Message) *dynamic.Message {
if !msg.IsEnabled() {
return nil
}
dm := dynamic.NewMessage(msg.Ref)
for _, f := range msg.Fields() {
switch f.FdType {
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
if f.IsRepeated {
var fields []interface{}
for _, v := range f.ValueListModel().Values() {
fields = append(fields, processMessage(v.MsgValue()))
m := processMessage(v.MsgValue())
if m != nil {
fields = append(fields, m)
}
}
dm.SetFieldByNumber(f.Tag(), fields)
break
}
dm.SetFieldByNumber(f.Tag(), processMessage(f.Message()))

m := processMessage(f.Message())
if m != nil {
dm.SetFieldByNumber(f.Tag(), m)
}
default:
if f.IsRepeated {
var fields []interface{}
Expand Down
5 changes: 5 additions & 0 deletions internal/model/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Message struct {

_ map[int]*core.QByteArray `property:"roles"`
_ string `property:"label"`
_ bool `property:"enabled"`
_ []*Field `property:"fields"`

_ func(row int, val string) `slot:"updateFieldValue"`
Expand All @@ -64,6 +65,10 @@ func (i *Message) init() {
FieldEnum: core.NewQByteArray2("enumListModel", -1),
})

// TODO: [RC] Should we default to enabled for nested meeasges?
// Maybe this should be a setting?
i.SetEnabled(true)

i.ConnectData(i.data)
i.ConnectRowCount(i.rowCount)
i.ConnectColumnCount(i.columnCount)
Expand Down
14 changes: 13 additions & 1 deletion qml/views/DelegateMessageField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,28 @@ Item {
}

Label {
id: msgType
anchors.left: msgLabel.right
anchors.leftMargin: 10
color: Qt.darker(Style.textColor3, 1.6)
text: message.label
}

CheckBox{
id: enabled
anchors.left: msgType.right
anchors.leftMargin: 10
anchors.verticalCenter: msgType.verticalCenter
checked: (msgOverride || message).enabled
onCheckedChanged: (msgOverride || message).enabled = checked
}

Pane {
id: msgPane

implicitHeight: msgLoader.height
visible: enabled.checked

implicitHeight: visible ? msgLoader.height : 0
anchors.top: msgLabel.bottom

Loader {
Expand Down

0 comments on commit a116f59

Please sign in to comment.