Skip to content

Commit

Permalink
Allow adding empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide committed Sep 10, 2020
1 parent 5aaf91f commit 7a18bfd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/app/models/key-models/stringkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ void StringKeyModel::updateRow(int rowIndex, const QVariantMap& row,

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

if (value.isEmpty()) return;

executeCmd(
{"SET", m_keyFullPath, value}, [this, c, value](const QString& err) {
if (err.isEmpty()) {
Expand Down
2 changes: 2 additions & 0 deletions src/qml/value-editor/AddKeyDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ BetterDialog {

onLoaded: {
item.state = "new"
if (item.keyType !== undefined)
item.keyType = typeSelector.model[typeSelector.currentIndex]
item.initEmpty()
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/qml/value-editor/ValueTabs.qml
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,11 @@ Repeater {
function clear() {
if (valueEditor.item) {
currentRow = -1

if (valueEditor.item.keyType !== undefined) {
valueEditor.item.keyType = keyType
}

valueEditor.item.reset()
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/qml/value-editor/editors/SingleItemEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ AbstractEditor {
anchors.fill: parent

property bool active: false
property string keyType: ""

MultilineEditor {
id: textEditor
Expand All @@ -22,6 +23,11 @@ AbstractEditor {
showSaveBtn: root.state == "edit"
showFormatters: root.state == "edit"
objectName: "rdm_key_value_field"

function validationRule(raw) {
if (root.keyType === "string") return true;
return qmlUtils.binaryStringLength(raw) > 0
}
}

function initEmpty() {
Expand Down

0 comments on commit 7a18bfd

Please sign in to comment.