From: Soeren Apel <soe...@apelpie.net>

Bug #285 is about showing the version/serial_num/conn_id information
in the dropdown box only when there is a need to do so. This patch
introduces the required logic.
---
 pv/devicemanager.cpp |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp
index c06fd79..0fefe06 100644
--- a/pv/devicemanager.cpp
+++ b/pv/devicemanager.cpp
@@ -174,6 +174,7 @@ const shared_ptr<HardwareDevice> 
DeviceManager::find_device_from_info(
 string DeviceManager::device_description(shared_ptr<Device> device)
 {
        auto session_device = dynamic_pointer_cast<SessionDevice>(device);
+       auto hardware_device = dynamic_pointer_cast<HardwareDevice>(device);
 
        if (session_device)
                return boost::filesystem::path(
@@ -181,23 +182,30 @@ string 
DeviceManager::device_description(shared_ptr<Device> device)
 
        ostringstream s;
 
-       vector<string> parts = {device->vendor(), device->model(),
-               device->version(), device->serial_number()};
+       int device_count = 1;
 
-       for (size_t i = 0; i < parts.size(); i++)
-       {
-               if (parts[i].length() > 0)
-               {
+       if (hardware_device)
+               device_count = hardware_device->driver()->device_count();
+
+       vector<string> parts = {device->vendor(), device->model()};
+
+       if (device_count > 1) {
+               parts.push_back(device->version());
+               parts.push_back(device->serial_number());
+
+               if (device->serial_number().length() == 0 &&
+                               device->connection_id().length() > 0)
+                       parts.push_back("("+device->connection_id()+")");
+       }
+
+       for (size_t i = 0; i < parts.size(); i++) {
+               if (parts[i].length() > 0) {
                        if (i != 0)
                                s << " ";
                        s << parts[i];
                }
        }
 
-       if (device->serial_number().length() == 0 &&
-                       device->connection_id().length() > 0)
-               s << " " << device->connection_id();
-
        return s.str();
 }
 
-- 
1.7.8.6


------------------------------------------------------------------------------
_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to