File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -74,12 +74,17 @@ QVariant QmlUtils::binaryListToValue(const QVariantList &binaryList) {
74
74
return value;
75
75
}
76
76
77
- QVariant QmlUtils::printable (const QVariant &value, bool htmlEscaped) {
77
+ QVariant QmlUtils::printable (const QVariant &value, bool htmlEscaped, int maxLength ) {
78
78
if (!value.canConvert (QVariant::ByteArray)) {
79
79
return QVariant ();
80
80
}
81
+
81
82
QByteArray val = value.toByteArray ();
82
83
84
+ if (maxLength > 0 && val.size () > maxLength) {
85
+ val.truncate (maxLength);
86
+ }
87
+
83
88
if (htmlEscaped) {
84
89
return printableString (val).toHtmlEscaped ();
85
90
} else {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class QmlUtils : public QObject
20
20
Q_INVOKABLE QString humanSize (long size);
21
21
Q_INVOKABLE QVariant valueToBinary (const QVariant &value);
22
22
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 );
24
24
Q_INVOKABLE QVariant printableToValue (const QVariant &printable);
25
25
Q_INVOKABLE QVariant toUtf (const QVariant &value);
26
26
Q_INVOKABLE QString getPathFromUrl (const QUrl &url);
Original file line number Diff line number Diff line change @@ -302,8 +302,7 @@ Repeater {
302
302
itemDelegate: Item {
303
303
Text {
304
304
anchors .fill : parent
305
- color: styleData .textColor
306
- elide: styleData .elideMode
305
+ color: styleData .textColor
307
306
text: {
308
307
309
308
if (styleData .value === " " || ! isMultiRow) {
@@ -314,9 +313,14 @@ Repeater {
314
313
return parseFloat (Number (styleData .value ).toFixed (20 ))
315
314
}
316
315
316
+ if (qmlUtils .binaryStringLength (styleData .value ) > 1000 ) {
317
+ return qmlUtils .printable (styleData .value , false , 1000 ) + " ..."
318
+ }
319
+
317
320
return qmlUtils .printable (styleData .value )
318
321
+ (lineCount > 1 ? ' ...' : ' ' )
319
322
}
323
+ elide: Text .ElideRight
320
324
wrapMode: Text .WrapAnywhere
321
325
maximumLineCount: 1
322
326
}
@@ -351,7 +355,7 @@ Repeater {
351
355
}
352
356
}
353
357
354
- onTotalRowCountChanged: {
358
+ onTotalRowCountChanged: {
355
359
keyTab .keyModel .loadRows (table .currentStart , table .maxItemsOnPage )
356
360
}
357
361
@@ -363,7 +367,7 @@ Repeater {
363
367
keyTab .searchModel = keyTab .searchModelComponent .createObject (keyTab)
364
368
365
369
if (isMultiRow) {
366
- var columns = keyTab .keyModel .columnNames
370
+ var columns = keyTab .keyModel .columnNames
367
371
368
372
for (var index = 0 ; index < 3 ; index++ )
369
373
{
You can’t perform that action at this time.
0 commit comments