From affd326dbba01fd2ea23fa87c7c165bc07bd08fe Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Sat, 23 Nov 2013 17:59:34 +0000 Subject: Replace the silly empty output with a reasonable "N/A" placeholder Change-Id: Iad5076e9a192f5a07e41314d286bc02e46ea92c8 Reviewed-by: Sergey Belyashov Reviewed-by: Denis Shienkov --- examples/serialport/cenumerator/main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'examples/serialport/cenumerator') diff --git a/examples/serialport/cenumerator/main.cpp b/examples/serialport/cenumerator/main.cpp index f55b92d9..2d770e81 100644 --- a/examples/serialport/cenumerator/main.cpp +++ b/examples/serialport/cenumerator/main.cpp @@ -53,14 +53,20 @@ int main(int argc, char *argv[]) out << QObject::tr("Total number of ports available: ") << serialPortInfoList.count() << endl; + const QString blankString = QObject::tr("N/A"); + QString description; + QString manufacturer; + foreach (const QSerialPortInfo &serialPortInfo, serialPortInfoList) { + description = serialPortInfo.description(); + manufacturer = serialPortInfo.manufacturer(); out << endl << QObject::tr("Port: ") << serialPortInfo.portName() << endl << QObject::tr("Location: ") << serialPortInfo.systemLocation() << endl - << QObject::tr("Description: ") << serialPortInfo.description() << endl - << QObject::tr("Manufacturer: ") << serialPortInfo.manufacturer() << endl - << QObject::tr("Vendor Identifier: ") << (serialPortInfo.hasVendorIdentifier() ? QByteArray::number(serialPortInfo.vendorIdentifier(), 16) : QByteArray()) << endl - << QObject::tr("Product Identifier: ") << (serialPortInfo.hasProductIdentifier() ? QByteArray::number(serialPortInfo.productIdentifier(), 16) : QByteArray()) << endl + << QObject::tr("Description: ") << (!description.isEmpty() ? description : blankString) << endl + << QObject::tr("Manufacturer: ") << (!manufacturer.isEmpty() ? manufacturer : blankString) << endl + << QObject::tr("Vendor Identifier: ") << (serialPortInfo.hasVendorIdentifier() ? QByteArray::number(serialPortInfo.vendorIdentifier(), 16) : blankString) << endl + << QObject::tr("Product Identifier: ") << (serialPortInfo.hasProductIdentifier() ? QByteArray::number(serialPortInfo.productIdentifier(), 16) : blankString) << endl << QObject::tr("Busy: ") << (serialPortInfo.isBusy() ? QObject::tr("Yes") : QObject::tr("No")) << endl; } -- cgit v1.2.3