Skip to content

Commit 7a18bfd

Browse files
committed
Allow adding empty strings
Fix #4689
1 parent 5aaf91f commit 7a18bfd

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

src/app/models/key-models/stringkey.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ void StringKeyModel::updateRow(int rowIndex, const QVariantMap& row,
3434

3535
QByteArray value = row.value("value").toByteArray();
3636

37-
if (value.isEmpty()) return;
38-
3937
executeCmd(
4038
{"SET", m_keyFullPath, value}, [this, c, value](const QString& err) {
4139
if (err.isEmpty()) {

src/qml/value-editor/AddKeyDialog.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ BetterDialog {
5353

5454
onLoaded: {
5555
item.state = "new"
56+
if (item.keyType !== undefined)
57+
item.keyType = typeSelector.model[typeSelector.currentIndex]
5658
item.initEmpty()
5759
}
5860
}

src/qml/value-editor/ValueTabs.qml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,11 @@ Repeater {
802802
function clear() {
803803
if (valueEditor.item) {
804804
currentRow = -1
805+
806+
if (valueEditor.item.keyType !== undefined) {
807+
valueEditor.item.keyType = keyType
808+
}
809+
805810
valueEditor.item.reset()
806811
}
807812
}

src/qml/value-editor/editors/SingleItemEditor.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ AbstractEditor {
1111
anchors.fill: parent
1212

1313
property bool active: false
14+
property string keyType: ""
1415

1516
MultilineEditor {
1617
id: textEditor
@@ -22,6 +23,11 @@ AbstractEditor {
2223
showSaveBtn: root.state == "edit"
2324
showFormatters: root.state == "edit"
2425
objectName: "rdm_key_value_field"
26+
27+
function validationRule(raw) {
28+
if (root.keyType === "string") return true;
29+
return qmlUtils.binaryStringLength(raw) > 0
30+
}
2531
}
2632

2733
function initEmpty() {

0 commit comments

Comments
 (0)