From: Uwe Hermann Date: Tue, 24 Jul 2018 20:07:25 +0000 (+0200) Subject: HardwareDevice: Only show non-empty device name components. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2a09e77148279258c347f8cf9c55daa667a034f8;p=pulseview.git HardwareDevice: Only show non-empty device name components. Fields such as vendor, version, serial number etc. are not always provided by drivers. Avoid printing them, since it causes stray whitespace to be added to the displayed strings. --- diff --git a/pv/devices/hardwaredevice.cpp b/pv/devices/hardwaredevice.cpp index 50cab7b0..a3d84d6f 100644 --- a/pv/devices/hardwaredevice.cpp +++ b/pv/devices/hardwaredevice.cpp @@ -54,8 +54,13 @@ HardwareDevice::~HardwareDevice() string HardwareDevice::full_name() const { - vector parts = {device_->vendor(), device_->model(), - device_->version()}; + vector parts = {}; + if (device_->vendor().length() > 0) + parts.push_back(device_->vendor()); + if (device_->model().length() > 0) + parts.push_back(device_->model()); + if (device_->version().length() > 0) + parts.push_back(device_->version()); if (device_->serial_number().length() > 0) parts.push_back("[S/N: " + device_->serial_number() + "]"); if (device_->connection_id().length() > 0) @@ -86,11 +91,17 @@ string HardwareDevice::display_name( dev->device_ != device_; }); - vector parts = {device_->vendor(), device_->model()}; + vector parts = {}; + if (device_->vendor().length() > 0) + parts.push_back(device_->vendor()); + if (device_->model().length() > 0) + parts.push_back(device_->model()); if (multiple_dev) { - parts.push_back(device_->version()); - parts.push_back("[S/N: " + device_->serial_number() + "]"); + if (device_->version().length() > 0) + parts.push_back(device_->version()); + if (device_->serial_number().length() > 0) + parts.push_back("[S/N: " + device_->serial_number() + "]"); if ((device_->serial_number().length() == 0) && (device_->connection_id().length() > 0))