From 27c0dc578676e7951b92da1f282ac0177edbe9b3 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Wed, 27 Sep 2017 19:35:33 +0300 Subject: Revamp the Console Enumerator Example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update includes to common style. * Split very long lines. * Remove QT_USE_NAMESPACE macro. * Remove QObject::tr() calls. Task-number: QTBUG-60652 Change-Id: I76105da84b8b89e76b723208600604bca6edd8a5 Reviewed-by: André Hartmann Reviewed-by: Alex Blasche --- examples/serialport/cenumerator/main.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/examples/serialport/cenumerator/main.cpp b/examples/serialport/cenumerator/main.cpp index f805021..af6d7e4 100644 --- a/examples/serialport/cenumerator/main.cpp +++ b/examples/serialport/cenumerator/main.cpp @@ -48,21 +48,19 @@ ** ****************************************************************************/ -#include #include -#include - -QT_USE_NAMESPACE +#include +#include int main(int argc, char *argv[]) { - QCoreApplication a(argc, argv); + QCoreApplication coreApplication(argc, argv); QTextStream out(stdout); const auto serialPortInfos = QSerialPortInfo::availablePorts(); - out << QObject::tr("Total number of ports available: ") << serialPortInfos.count() << endl; + out << "Total number of ports available: " << serialPortInfos.count() << endl; - const QString blankString = QObject::tr("N/A"); + const QString blankString = "N/A"; QString description; QString manufacturer; QString serialNumber; @@ -72,14 +70,18 @@ int main(int argc, char *argv[]) manufacturer = serialPortInfo.manufacturer(); serialNumber = serialPortInfo.serialNumber(); out << endl - << QObject::tr("Port: ") << serialPortInfo.portName() << endl - << QObject::tr("Location: ") << serialPortInfo.systemLocation() << endl - << QObject::tr("Description: ") << (!description.isEmpty() ? description : blankString) << endl - << QObject::tr("Manufacturer: ") << (!manufacturer.isEmpty() ? manufacturer : blankString) << endl - << QObject::tr("Serial number: ") << (!serialNumber.isEmpty() ? serialNumber : 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; + << "Port: " << serialPortInfo.portName() << endl + << "Location: " << serialPortInfo.systemLocation() << endl + << "Description: " << (!description.isEmpty() ? description : blankString) << endl + << "Manufacturer: " << (!manufacturer.isEmpty() ? manufacturer : blankString) << endl + << "Serial number: " << (!serialNumber.isEmpty() ? serialNumber : blankString) << endl + << "Vendor Identifier: " << (serialPortInfo.hasVendorIdentifier() + ? QByteArray::number(serialPortInfo.vendorIdentifier(), 16) + : blankString) << endl + << "Product Identifier: " << (serialPortInfo.hasProductIdentifier() + ? QByteArray::number(serialPortInfo.productIdentifier(), 16) + : blankString) << endl + << "Busy: " << (serialPortInfo.isBusy() ? "Yes" : "No") << endl; } return 0; -- cgit v1.2.1