@@ -6,12 +6,13 @@ import "./formatters/formatters.js" as Formatters
66
77ColumnLayout
88{
9- id: root
10- property alias text : textArea . originalText
9+ id: root
10+
1111 property alias enabled: textArea .enabled
1212 property alias textColor: textArea .textColor
1313 property alias style: textArea .style
1414 property bool showFormatters: true
15+ property string fieldLabel: " Value:"
1516 property var value
1617
1718 function getText () {
@@ -27,25 +28,24 @@ ColumnLayout
2728
2829 binaryFlag .visible = false
2930
30- if (isBin) binaryFlag .visible = true
31- else text = val
31+ if (isBin) binaryFlag .visible = true
3232
3333 autoDetectFormatter (isBin)
3434 }
3535
3636 function autoDetectFormatter (isBinary ) {
37- formatterSelector .currentIndex = Formatters .guessFormatter (
38- isBinary, isBinary? binaryUtils .valueToBinary (value) : text)
37+ formatterSelector .currentIndex = Formatters .guessFormatter (isBinary, value)
3938 }
4039
4140 RowLayout{
4241 visible: showFormatters
42+ Layout .fillWidth : true
4343
44- Text { text: " Value: " }
44+ Text { text: root . fieldLabel }
4545 Text { id: binaryFlag; text: " [Binary]" ; visible: false ; color: " green" ; }
4646 Text { id: compressedFlag; text: " [GZIP compressed]" ; visible: false ; color: " red" ; } // TBD
4747 Item { Layout .fillWidth : true }
48- Text { text: " View value as:" }
48+ Text { text: " View as:" }
4949
5050 ComboBox {
5151 id: formatterSelector
@@ -76,7 +76,7 @@ ColumnLayout
7676 Layout .fillWidth : true
7777 Layout .fillHeight : true
7878 Layout .preferredHeight : 100
79- textFormat: formatter && formatter .readOnly ? TextEdit .RichText : TextEdit .PlainText
79+ textFormat: formatter && formatter .htmlOutput ? TextEdit .RichText : TextEdit .PlainText
8080 readOnly: (formatter)? formatter .readOnly : enabled ? true : false
8181
8282 onEnabledChanged: {
@@ -85,12 +85,20 @@ ColumnLayout
8585
8686 text: {
8787 if (! formatter) return ' '
88+ var val
8889 if (formatter .binary === true )
89- return formatter .getFormatted (binaryUtils .valueToBinary (value))
90+ val = formatter .getFormatted (binaryUtils .valueToBinary (value))
9091 else
91- return formatter .getFormatted (originalText)
92+ val = formatter .getFormatted (binaryUtils .toUtf (value))
93+
94+ if (val === undefined ) {
95+ formatterSelector .currentIndex = 0
96+ binaryFlag .visible = false
97+ }
98+
99+ return (val === undefined ) ? ' ' : val
92100 }
93- property string originalText
101+
94102 property var formatter: {
95103 var index = formatterSelector .currentIndex ? formatterSelector .currentIndex : Formatters .defaultFormatterIndex
96104 return Formatters .enabledFormatters [index]
0 commit comments