@@ -16,6 +16,14 @@ ColumnLayout
1616 property string fieldLabel: qsTr (" Value:" )
1717 property bool isEdited: false
1818 property var value
19+ property int valueSizeLimit: 150000
20+
21+ function initEmpty () {
22+ // init editor with empty model
23+ textView .model = qmlUtils .wrapLargeText (" " )
24+ textView .readOnly = false
25+ textView .textFormat = TextEdit .PlainText
26+ }
1927
2028 function validate (callback ) {
2129 loadRawValue (function (error , raw ) {
@@ -55,7 +63,7 @@ ColumnLayout
5563 return ;
5664 }
5765
58- if (binaryUtils .binaryStringLength (root .value ) > 150000 ) {
66+ if (binaryUtils .binaryStringLength (root .value ) > valueSizeLimit ) {
5967 root .showFormatters = false
6068 formatterSelector .currentIndex = 0
6169 } else {
@@ -87,14 +95,14 @@ ColumnLayout
8795 if (format === " json" ) {
8896 // 1 is JSON
8997 return formatterSelector .model [1 ].instance .getFormatted (formatted, function (formattedJson , r , f ) {
90- textView .model = keyTab . keyModel .wrapLargeText (formattedJson)
98+ textView .model = qmlUtils .wrapLargeText (formattedJson)
9199 textView .readOnly = isReadOnly
92100 textView .textFormat = TextEdit .PlainText
93101 root .isEdited = false
94102 uiBlocker .visible = false
95103 })
96104 } else {
97- textView .model = keyTab . keyModel .wrapLargeText (formatted)
105+ textView .model = qmlUtils .wrapLargeText (formatted)
98106 textView .readOnly = isReadOnly
99107 root .isEdited = false
100108
@@ -111,6 +119,11 @@ ColumnLayout
111119 function reset () {
112120 if (textView .model )
113121 textView .model .cleanUp ()
122+
123+ if (textView .model ) {
124+ qmlUtils .deleteTextWrapper (textView .model )
125+ }
126+
114127 textView .model = null
115128 root .value = " "
116129 root .isEdited = false
@@ -152,10 +165,11 @@ ColumnLayout
152165 }
153166 }
154167
155- Text { visible: ! showFormatters; text: qsTr (" Large value (>150kB). Formatters is not available." ); color: " red" ; }
168+ Text { visible: ! showFormatters && binaryUtils . binaryStringLength ( root . value ) > valueSizeLimit ; text: qsTr (" Large value (>150kB). Formatters is not available." ); color: " red" ; }
156169 }
157170
158171 Rectangle {
172+ id: texteditorWrapper
159173 Layout .fillWidth : true
160174 Layout .fillHeight : true
161175 Layout .preferredHeight : 100
@@ -181,7 +195,7 @@ ColumnLayout
181195 NewTextArea {
182196 id: textAreaPart
183197 width: textView .width
184- height: textAreaPart .contentHeight
198+ height: textAreaPart .contentHeight < texteditorWrapper . height ? texteditorWrapper . height - 5 : textAreaPart . contentHeight
185199
186200 enabled: root .enabled
187201 text: value
@@ -216,5 +230,5 @@ ColumnLayout
216230 }
217231
218232 MouseArea { anchors .fill : parent }
219- }
233+ }
220234}
0 commit comments