Skip to content

Commit c4cd462

Browse files
committed
Fix stucks on large values in multi-row keys
1 parent ddf9a22 commit c4cd462

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/app/qmlutils.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ QVariant QmlUtils::binaryListToValue(const QVariantList &binaryList) {
7474
return value;
7575
}
7676

77-
QVariant QmlUtils::printable(const QVariant &value, bool htmlEscaped) {
77+
QVariant QmlUtils::printable(const QVariant &value, bool htmlEscaped, int maxLength) {
7878
if (!value.canConvert(QVariant::ByteArray)) {
7979
return QVariant();
8080
}
81+
8182
QByteArray val = value.toByteArray();
8283

84+
if (maxLength > 0 && val.size() > maxLength) {
85+
val.truncate(maxLength);
86+
}
87+
8388
if (htmlEscaped) {
8489
return printableString(val).toHtmlEscaped();
8590
} else {

src/app/qmlutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class QmlUtils : public QObject
2020
Q_INVOKABLE QString humanSize(long size);
2121
Q_INVOKABLE QVariant valueToBinary(const QVariant &value);
2222
Q_INVOKABLE QVariant binaryListToValue(const QVariantList& binaryList);
23-
Q_INVOKABLE QVariant printable(const QVariant &value, bool htmlEscaped=false);
23+
Q_INVOKABLE QVariant printable(const QVariant &value, bool htmlEscaped=false, int maxLength=-1);
2424
Q_INVOKABLE QVariant printableToValue(const QVariant &printable);
2525
Q_INVOKABLE QVariant toUtf(const QVariant &value);
2626
Q_INVOKABLE QString getPathFromUrl(const QUrl &url);

src/qml/value-editor/ValueTabs.qml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ Repeater {
302302
itemDelegate: Item {
303303
Text {
304304
anchors.fill: parent
305-
color: styleData.textColor
306-
elide: styleData.elideMode
305+
color: styleData.textColor
307306
text: {
308307

309308
if (styleData.value === "" || !isMultiRow) {
@@ -314,9 +313,14 @@ Repeater {
314313
return parseFloat(Number(styleData.value).toFixed(20))
315314
}
316315

316+
if (qmlUtils.binaryStringLength(styleData.value) > 1000) {
317+
return qmlUtils.printable(styleData.value, false, 1000) + "..."
318+
}
319+
317320
return qmlUtils.printable(styleData.value)
318321
+ (lineCount > 1 ? '...' : '')
319322
}
323+
elide: Text.ElideRight
320324
wrapMode: Text.WrapAnywhere
321325
maximumLineCount: 1
322326
}
@@ -351,7 +355,7 @@ Repeater {
351355
}
352356
}
353357

354-
onTotalRowCountChanged: {
358+
onTotalRowCountChanged: {
355359
keyTab.keyModel.loadRows(table.currentStart, table.maxItemsOnPage)
356360
}
357361

@@ -363,7 +367,7 @@ Repeater {
363367
keyTab.searchModel = keyTab.searchModelComponent.createObject(keyTab)
364368

365369
if (isMultiRow) {
366-
var columns = keyTab.keyModel.columnNames
370+
var columns = keyTab.keyModel.columnNames
367371

368372
for (var index = 0; index < 3; index++)
369373
{

0 commit comments

Comments
 (0)