summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2013-11-23 17:59:34 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-24 16:56:16 +0100
commitaffd326dbba01fd2ea23fa87c7c165bc07bd08fe (patch)
tree76f97b5bd859a09e4a335221d24adee3514447f1 /examples
parentd4d79896db4f6c4d3eca39a57e7bec29f43e206d (diff)
downloadqtserialport-affd326dbba01fd2ea23fa87c7c165bc07bd08fe.tar.gz
Replace the silly empty output with a reasonable "N/A" placeholder
Change-Id: Iad5076e9a192f5a07e41314d286bc02e46ea92c8 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/serialport/cenumerator/main.cpp14
-rw-r--r--examples/serialport/terminal/settingsdialog.cpp13
2 files changed, 19 insertions, 8 deletions
diff --git a/examples/serialport/cenumerator/main.cpp b/examples/serialport/cenumerator/main.cpp
index f55b92d..2d770e8 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;
}
diff --git a/examples/serialport/terminal/settingsdialog.cpp b/examples/serialport/terminal/settingsdialog.cpp
index ad32824..923f000 100644
--- a/examples/serialport/terminal/settingsdialog.cpp
+++ b/examples/serialport/terminal/settingsdialog.cpp
@@ -151,14 +151,19 @@ void SettingsDialog::fillPortsParameters()
void SettingsDialog::fillPortsInfo()
{
ui->serialPortInfoListBox->clear();
+ static const QString blankString = QObject::tr("N/A");
+ QString description;
+ QString manufacturer;
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
QStringList list;
+ description = info.description();
+ manufacturer = info.manufacturer();
list << info.portName()
- << info.description()
- << info.manufacturer()
+ << (!description.isEmpty() ? description : blankString)
+ << (!manufacturer.isEmpty() ? manufacturer : blankString)
<< info.systemLocation()
- << (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString())
- << (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : QString());
+ << (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : blankString)
+ << (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : blankString);
ui->serialPortInfoListBox->addItem(list.first(), list);
}