<metawidget name="foobar" layout="hbox" format="foo ${a}${b} bar"> <label caption="a:"/> <lineedit name="a"/> <label caption="b:"/> <lineedit name="b"/> </metawidget>
The meta widget encapsulates a number of widgets in a single widget, producing their result value through a format string.
When getValue
is called on the meta widget it constructs its result string by parsing the format string, and replacing every ${foobar}
occurrence with the corresponding getValue
call to the foobar
widget.
It does not as such make any sense to setValue
on the meta widget, and the only reasonable thing to do when setValue
is called, is to ignore it.
The contained (named) widgets will not be stored independently in the database.
Is it possible to split a result string into its original subvalues using regexp?
format="foo ${a} ${b} bar." value="foo I am Sir Lancelot 42 bar." regexp="^foo ($1) ($2) bar.$"
In general, no. But if format contain only a single value, or if the values are separated by uniquely definable patterns, then it might be possible.
format="foo ${a} bar." value="foo I am Sir Lancelot bar." regexp="^foo ($1) bar.$" format="foo ${a} splatterplask ${b} bar." value="foo I am Sir Lancelot splatterplask 42 bar." regexp="^foo ($1) splatterplask ($2) bar.$"
In the latter this requires the input fields to no contain the string “splatterplask” otherwise it will confuse the regexp matcher.
The entire regexp match scenario might be implemented and activated through an attribute use_regexp_set_value
or something the like. So the user only enables it when absolute certain that it makes sense for the contained widgets and their format string.
<altcombobox name="somefield" layout="vbox"> <item caption="Name1" value="Value1"/> <item caption="Name2" value="Value2"/> <item caption="Name3" value="Value3"/> <altitem caption="Name4" value="Value4" layout="hbox" innerwidget="bar"> <label caption="Bar:"/> <lineedit name="bar" value="custom value"/> </altitem> </altcombobox>
This code will produce a combobox with 4 values. The fourth value being “Name4” which will active the bar
lineedit, and use its value as the combobox value.
The lineedit and its label will be put below the combobox (due to the vbox layout attribute of the altcombobox) and the label and lineedit will be positioned horizontally (due to the hbox layout attribute of the altitem tag).
When the altitem is selected, the lineedit is active, and its value is defining the value of the outer altcombo.
When reloading the value from the db, it will first try to match the value against all items, and if that fails, it will set the value to “Name4”, and cal setValue on the inner widget (bar
).
IDEA: Mulitple altitem
s!
An area are reserved for the largest altitem
and the selected altitem
shows up in that space. If a normal item is selected, the space is left empty.
IDEA-Shootdown!
Multiple altitem
s makes it impossible to determine where an old value came from.
OBSOLETE
Two format strings. One for each widget set.
<alt name="somefield"> <primary format="blah ${foo} blah"> <lineedit name="foo"/> </primary> <secondary format="doh ${bar} aah"> <lineedit name="bar"/> </secondary> </alt>
Creates the data:
somefield="blah ${foo|foo's value} blah"
which can be used later to determine which of the alternatives were used, given that the fields in primary and secondary do not contain overlapping names.
name() type() value() setValue() enabled() setEnabled() visible() setVisible() valid() setValid()
checked() setChecked()