From d31fdad8ab28ae71ceb7414ee12692bd57bb3a7e Mon Sep 17 00:00:00 2001 From: Inoki Date: Thu, 21 Apr 2022 20:16:54 +0200 Subject: [PATCH] Fix build from const ref required by Qt6 qMakePair --- helpers.cpp | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/helpers.cpp b/helpers.cpp index bdc79a6..6ef7bdb 100644 --- a/helpers.cpp +++ b/helpers.cpp @@ -316,11 +316,12 @@ QList> convert_device_path_attrs(QEFIDevicePath *dp) dynamic_cast(dp); list << qMakePair("GUID", dpVendor->vendorGuid().toString()); - list << qMakePair("Data", - dpVendor->vendorData().size() < DISPLAY_DATA_LIMIT ? - dpVendor->vendorData().toHex() : - QString(dpVendor->vendorData() - .left(DISPLAY_DATA_LIMIT).toHex()) + "..."); + QByteArray data = dpVendor->vendorData().toHex(); + if (data.size() > DISPLAY_DATA_LIMIT * 2) { + data.truncate(DISPLAY_DATA_LIMIT * 2); + data += "..."; + } + list << qMakePair("Data", data); } break; case QEFIDevicePathMediaSubType::MEDIA_Protocol: @@ -336,11 +337,13 @@ QList> convert_device_path_attrs(QEFIDevicePath *dp) QEFIDevicePathMediaFirmwareFile *dpFile = (QEFIDevicePathMediaFirmwareFile *) dynamic_cast(dp); - list << qMakePair("PI Info", - dpFile->piInfo().size() < DISPLAY_DATA_LIMIT ? - dpFile->piInfo().toHex() : - QString(dpFile->piInfo() - .left(DISPLAY_DATA_LIMIT).toHex()) + "..."); + + QByteArray data = dpFile->piInfo().toHex(); + if (data.size() > DISPLAY_DATA_LIMIT * 2) { + data.truncate(DISPLAY_DATA_LIMIT * 2); + data += "..."; + } + list << qMakePair("PI Info", data); } break; case QEFIDevicePathMediaSubType::MEDIA_FirmwareVolume: @@ -348,11 +351,12 @@ QList> convert_device_path_attrs(QEFIDevicePath *dp) QEFIDevicePathMediaFirmwareVolume *dpFV = (QEFIDevicePathMediaFirmwareVolume *) dynamic_cast(dp); - list << qMakePair("PI Info", - dpFV->piInfo().size() < DISPLAY_DATA_LIMIT ? - dpFV->piInfo().toHex() : - QString(dpFV->piInfo() - .left(DISPLAY_DATA_LIMIT).toHex()) + "..."); + QByteArray data = dpFV->piInfo().toHex(); + if (data.size() > DISPLAY_DATA_LIMIT * 2) { + data.truncate(DISPLAY_DATA_LIMIT * 2); + data += "..."; + } + list << qMakePair("PI Info", data); } break; case QEFIDevicePathMediaSubType::MEDIA_RelativeOffset: @@ -387,16 +391,17 @@ QList> convert_device_path_attrs(QEFIDevicePath *dp) if (dynamic_cast(dp)) { QEFIDevicePathBIOSBoot *dpBIOSBoot = (QEFIDevicePathBIOSBoot *) dynamic_cast(dp); - QByteArray description = dpBIOSBoot->description(); + QByteArray description = dpBIOSBoot->description().toHex(); list << qMakePair("Device Type", QString::number(dpBIOSBoot->deviceType())); list << qMakePair("Status", QString::number(dpBIOSBoot->status())); - list << qMakePair("Description", - description.size() < DISPLAY_DATA_LIMIT ? - description.toHex() : - QString(description.left(DISPLAY_DATA_LIMIT).toHex()) - + "..."); + + if (description.size() > DISPLAY_DATA_LIMIT * 2) { + description.truncate(DISPLAY_DATA_LIMIT * 2); + description += "..."; + } + list << qMakePair("Description", description); } break; }