Skip to content

Commit b14bd7e

Browse files
committed
Merge pull request RedisInsight#3521 from uglide/0.8.2
Merge fixes for 0.8.2
2 parents 9c43429 + 555b261 commit b14bd7e

File tree

18 files changed

+455
-664
lines changed

18 files changed

+455
-664
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
[submodule "3rdparty/qgamp"]
1717
path = 3rdparty/qgamp
1818
url = https://github.com/uglide/qgamp.git
19+
[submodule "src/resources/qml/3rdparty/php-unserialize-js"]
20+
path = src/resources/qml/3rdparty/php-unserialize-js
21+
url = https://github.com/uglide/php-unserialize-js.git

3rdparty/3rdparty.pri

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#
55
#-------------------------------------------------
66

7+
OTHER_FILES += $$PWD/../src/resources/qml/3rdparty/php-unserialize-js/phpUnserialize.js
8+
79
# qredisclient
810
include($$PWD/qredisclient/qredisclient.pri)
911

src/modules/value-editor/binary.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,13 @@ QVariant BinaryUtils::printableToValue(const QVariant &printable)
5151
QString val = printable.toString();
5252
return printableStringToBinary(val);
5353
}
54+
55+
QVariant BinaryUtils::toUtf(const QVariant &value)
56+
{
57+
if (!value.canConvert(QVariant::ByteArray)) {
58+
return QVariant();
59+
}
60+
QByteArray val = value.toByteArray();
61+
QString result = QString::fromUtf8(val.constData(), val.size());
62+
return QVariant(result);
63+
}

src/modules/value-editor/binary.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ class BinaryUtils : public QObject
1313
Q_INVOKABLE QVariant binaryListToValue(const QVariantList& binaryList);
1414
Q_INVOKABLE QVariant printable(const QVariant &value);
1515
Q_INVOKABLE QVariant printableToValue(const QVariant &printable);
16+
Q_INVOKABLE QVariant toUtf(const QVariant &value);
1617
};

src/rdm.pro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ TEMPLATE = app
1111

1212
# Skip version file
1313
!exists( $$PWD/version.h ) {
14-
DEFINES += RDM_VERSION=\\\"0.8.1.0\\\"
15-
message("Version: 0.8.1.0")
14+
DEFINES += RDM_VERSION=\\\"0.8.2-dev\\\"
15+
message("Version: 0.8.2-dev")
1616
}
1717

1818
DEFINES += CORE_LIBRARY ELPP_QT_LOGGING ELPP_STL_LOGGING ELPP_DISABLE_DEFAULT_CRASH_HANDLING
@@ -43,6 +43,10 @@ HEADERS += \
4343
$$PWD/modules/updater/*.h \
4444
$$PWD/modules/*.h \
4545

46+
exists( $$PWD/version.h ) {
47+
HEADERS += $$PWD/version.h
48+
}
49+
4650
FORMS += \
4751
$$PWD/app/forms/*.ui \
4852

src/resources/qml/ValueTabs.qml

Lines changed: 327 additions & 302 deletions
Large diffs are not rendered by default.

src/resources/qml/WelcomeTab.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ Tab {
88
title: "RDM"
99

1010
Rectangle {
11+
id: parentWrapper
1112
color: "transparent"
1213

1314
ColumnLayout {
14-
anchors.centerIn: parent
15+
anchors.centerIn: parentWrapper
1516

1617
RowLayout {
1718
id: topLayout

src/resources/qml/editors/HashItemEditor.qml

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,36 @@ import "."
88

99
AbstractEditor {
1010
id: root
11-
anchors.fill: parent
11+
anchors.fill: parent
1212

13-
Text {
14-
Layout.fillWidth: true
15-
text: "Key:"
16-
}
17-
18-
TextField {
13+
MultilineEditor {
1914
id: keyText
20-
15+
fieldLabel: "Key:"
2116
Layout.fillWidth: true
22-
Layout.minimumHeight: 28
17+
Layout.minimumHeight: 80
18+
Layout.preferredHeight: 90
2319

24-
text: ""
20+
value: ""
2521
enabled: originalValue != "" || root.state !== "edit"
2622
property var originalValue: ""
2723

28-
style: TextFieldStyle {
29-
background: Rectangle {
30-
radius: 1
31-
implicitWidth: 100
32-
implicitHeight: 24
33-
border.color: "#BFBFBF"
34-
border.width: 1
35-
color: (textArea.text=="" && textArea.enabled
36-
&& textArea.readOnly == false) ? "lightyellow" : "white"
37-
}
38-
}
24+
style: TextAreaStyle {
25+
backgroundColor: (!keyText.value && keyText.enabled
26+
&& keyText.readOnly == false) ? "lightyellow" : "white"
27+
}
3928
}
4029

4130

4231
MultilineEditor {
4332
id: textArea
4433
Layout.fillWidth: true
45-
Layout.fillHeight: true
46-
text: ""
34+
Layout.fillHeight: true
4735
enabled: keyText.originalValue != "" || root.state !== "edit"
4836
property var originalValue: ""
4937
showFormatters: root.state != "new"
5038

5139
style: TextAreaStyle {
52-
backgroundColor: (textArea.text=="" && textArea.enabled
40+
backgroundColor: (!textArea.value && textArea.enabled
5341
&& textArea.readOnly == false) ? "lightyellow" : "white"
5442
}
5543
}
@@ -59,7 +47,7 @@ AbstractEditor {
5947
return
6048

6149
keyText.originalValue = rowValue['key']
62-
keyText.text = rowValue['key']
50+
keyText.setValue(rowValue['key'])
6351
textArea.originalValue = rowValue['value']
6452
textArea.setValue(rowValue['value'])
6553
}
@@ -70,14 +58,14 @@ AbstractEditor {
7058
}
7159

7260
function resetAndDisableEditor() {
73-
textArea.text = ""
61+
textArea.value = ""
7462
textArea.originalValue = ""
7563
keyText.originalValue = ""
76-
keyText.text = ""
64+
keyText.value = ""
7765
}
7866

7967
function getValue() {
80-
return {"value": textArea.getText(), "key": keyText.text}
68+
return {"value": textArea.getText(), "key": keyText.getText()}
8169
}
8270

8371
function isValueValid() {
@@ -94,8 +82,8 @@ AbstractEditor {
9482

9583
function reset() {
9684
textArea.originalValue = ""
97-
textArea.text = ""
85+
textArea.value = ""
9886
keyText.originalValue = ""
99-
keyText.text = ""
87+
keyText.value = ""
10088
}
10189
}

src/resources/qml/editors/MultilineEditor.qml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import "./formatters/formatters.js" as Formatters
66

77
ColumnLayout
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]

src/resources/qml/editors/SingleItemEditor.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ AbstractEditor {
1616
id: textArea
1717
Layout.fillWidth: true
1818
Layout.fillHeight: true
19-
text: ""
20-
enabled: originalValue != "" || root.state !== "edit"
19+
value: ""
20+
enabled: originalValue !== "" || root.state !== "edit"
2121
showFormatters: root.state != "new"
2222
}
2323

@@ -32,7 +32,7 @@ AbstractEditor {
3232

3333
function resetAndDisableEditor() {
3434
root.originalValue = ""
35-
textArea.text = ""
35+
textArea.value = ""
3636
}
3737

3838
function getValue() {

src/resources/qml/editors/SortedSetItemEditor.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ AbstractEditor {
3232
id: textArea
3333
Layout.fillWidth: true
3434
Layout.fillHeight: true
35-
text: ""
35+
value: ""
3636
enabled: originalValue != "" || root.state !== "edit"
3737
showFormatters: root.state != "new"
3838
property var originalValue: ""
@@ -52,7 +52,7 @@ AbstractEditor {
5252

5353
function resetAndDisableEditor() {
5454
textArea.originalValue = ""
55-
textArea.text = ""
55+
textArea.value = ""
5656
scoreText.originalValue = ""
5757
scoreText.text = ""
5858
}
@@ -76,7 +76,7 @@ AbstractEditor {
7676
}
7777

7878
function reset() {
79-
textArea.text = ""
79+
textArea.value = ""
8080
scoreText.text = ""
8181
}
8282
}

src/resources/qml/editors/formatters/formatters.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.import "./msgpack.js" as MsgPack
22
.import "./hexy.js" as Hexy
33
.import "./php-unserialize.js" as PHPUnserialize
4-
.import "./php-serialize.js" as PHPSerialize
54

65
/**
76
Plain formatter
@@ -11,6 +10,7 @@ var plain = {
1110
title: "Plain Text",
1211
readOnly: false,
1312
binary: false,
13+
htmlOutput: false,
1414

1515
getFormatted: function (raw) {
1616
return raw
@@ -29,6 +29,7 @@ var hex = {
2929
title: "HEX",
3030
readOnly: false,
3131
binary: true,
32+
htmlOutput: false,
3233

3334
getFormatted: function (raw) {
3435
return binaryUtils.printable(binaryUtils.binaryListToValue(raw))
@@ -47,6 +48,7 @@ var hexTable = {
4748
title: "HEX TABLE",
4849
readOnly: true,
4950
binary: true,
51+
htmlOutput: true,
5052

5153
getFormatted: function (raw) {
5254
var format = {'html': true}
@@ -69,6 +71,7 @@ var json = {
6971
title: "JSON",
7072
readOnly: false,
7173
binary: false,
74+
htmlOutput: false,
7275

7376
getFormatted: function (raw) {
7477

@@ -108,6 +111,7 @@ var msgpack = {
108111
title: "MSGPACK",
109112
readOnly: false,
110113
binary: true,
114+
htmlOutput: false,
111115

112116
getFormatted: function (raw) {
113117
try {
@@ -140,17 +144,19 @@ var msgpack = {
140144
**/
141145
var phpserialized = {
142146
title: "PHP Serializer",
143-
readOnly: false,
147+
readOnly: true,
148+
binary: false,
149+
htmlOutput: false,
144150

145151
getFormatted: function (raw) {
146152

147153
try {
148154
var parsed = PHPUnserialize.unserialize(raw)
149-
console.log('parsed php serialized:', parsed)
155+
console.log('parsed php serialized:', JSON.stringify(parsed))
150156
return JSON.stringify(parsed, undefined, 4)
151157

152158
} catch (e) {
153-
return "Error: Invalid PHP Serialized String: " + e
159+
return "Error: Invalid PHP Serialized String: " + JSON.stringify(e)
154160
}
155161
},
156162

@@ -172,11 +178,14 @@ var phpserialized = {
172178
var defaultFormatterIndex = 0;
173179
var enabledFormatters = [plain, json, msgpack, hex, hexTable, phpserialized]
174180

175-
function guessFormatter(isBinary, val)
181+
function guessFormatter(isBinary, value)
176182
{
177-
var tryFormatters = isBinary? [2, 3, 4] : [1, 5, 2, 0]
183+
var tryFormatters = isBinary? [2, 5, 3, 4] : [1, 5, 2]
178184

179185
for (var index in tryFormatters) {
186+
var val = (enabledFormatters[tryFormatters[index]].binary) ?
187+
binaryUtils.valueToBinary(value) : binaryUtils.toUtf(value)
188+
180189
if (enabledFormatters[tryFormatters[index]].isValid(val)){
181190
return tryFormatters[index]
182191
}

0 commit comments

Comments
 (0)