Skip to content

Commit 33730c1

Browse files
committed
Fix 'String'-format of data view item displaying
1 parent 00c0bcb commit 33730c1

File tree

13 files changed

+172
-24
lines changed

13 files changed

+172
-24
lines changed

bin/Ubuntu/x64/libcore.so

8.43 KB
Binary file not shown.

bin/Ubuntu/x64/libcore.so.0

8.43 KB
Binary file not shown.

bin/Ubuntu/x64/libcore.so.0.1

8.43 KB
Binary file not shown.

bin/Ubuntu/x64/libcore.so.0.1.4

-970 KB
Binary file not shown.

bin/Ubuntu/x64/libcore.so.0.1.5

979 KB
Binary file not shown.

bin/Windows/x64/client.exe

0 Bytes
Binary file not shown.

bin/Windows/x64/core.dll

2.5 KB
Binary file not shown.

bin/Windows/x64/modbus.dll

0 Bytes
Binary file not shown.

bin/Windows/x64/server.exe

0 Bytes
Binary file not shown.

src/core/project/core_dataview.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ static inline mb::DataOrder getRegisterOrder(mb::DataOrder order, mbCoreDevice *
3737
return order;
3838
}
3939

40+
static inline mb::StringEncoding getStringEncoding(mb::StringEncoding encoding, mbCoreDevice *device)
41+
{
42+
if (encoding == mb::DefaultStringEncoding)
43+
{
44+
if (device && (device->stringEncoding() != mb::DefaultStringEncoding))
45+
return device->stringEncoding();
46+
return mb::Utf8;
47+
}
48+
return encoding;
49+
}
50+
51+
static inline mb::StringLengthType getStringLengthType(mb::StringLengthType lengthType, mbCoreDevice *device)
52+
{
53+
if (lengthType == mb::DefaultStringLengthType)
54+
{
55+
if (device && (device->stringLengthType() != mb::DefaultStringLengthType))
56+
return device->stringLengthType();
57+
return mb::ZerroEnded;
58+
}
59+
return lengthType;
60+
}
61+
4062
mbCoreDataViewItem::Strings::Strings() :
4163
device (QStringLiteral("device")),
4264
address (QStringLiteral("address")),
@@ -397,8 +419,8 @@ QByteArray mbCoreDataViewItem::toByteArray(const QVariant &value) const
397419
m_byteOrder,
398420
getRegisterOrder(m_registerOrder, m_device),
399421
m_byteArrayFormat,
400-
m_stringEncoding,
401-
m_stringLengthType,
422+
getStringEncoding(m_stringEncoding, m_device),
423+
getStringLengthType(m_stringLengthType, m_device),
402424
byteArraySeparator(),
403425
m_variableLength);
404426
}
@@ -415,8 +437,8 @@ QVariant mbCoreDataViewItem::toVariant(const QByteArray &v) const
415437
m_byteOrder,
416438
getRegisterOrder(m_registerOrder, m_device),
417439
m_byteArrayFormat,
418-
m_stringEncoding,
419-
m_stringLengthType,
440+
getStringEncoding(m_stringEncoding, m_device),
441+
getStringLengthType(m_stringLengthType, m_device),
420442
byteArraySeparator(),
421443
m_variableLength);
422444
}

0 commit comments

Comments
 (0)