summaryrefslogtreecommitdiffstats
path: root/src/serialport/qserialportinfo.h
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2013-03-23 18:45:26 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-25 10:27:50 +0100
commit23f8a58652e3ac4398d508691d227b3c75811e8f (patch)
tree0347d6caa4d0cc2333c87c8aface2e3d13dd3b73 /src/serialport/qserialportinfo.h
parent43d137e4b2023e6b5d9df9b89281eca4b70eecf8 (diff)
Change the return type of the vendor/productIdentifier() API
The API was established with a bit of insanity, namely: it returns raw strings for the 16-bit vendor and product _numbers_. This brings lots of limitations into the system aside from its silly nature, like how to handle lower and upper case hex letters (a-f, A-F) and so forth. Also, it is not clear whether the API should return zero aligned strings, or whether or not to return the leading indicator of the hex format (0x). This is now all being eliminated by switching to the 16-bit unsigned integer use. There are mostly two use cases for the usage of this: a) Comparison or mapping to find the requested port and device This is getting very simple because it will mean a simple 16-bit unsigned integer comparison which is cross-platform by its nature for sure. b) Display the string to the end user This is for instance with an enumerator or terminal emulator application, but in this special case the user can format the output of the integer as wished. Then, it can easily become a cross-platform display. Even customizing is simple enough to provide the native look'n feel without the library forcing one particular type. The documentation is being changed correspondingly. As for the future, if the need even arises, the following methods could be considered for the info provider class (QSerialPortInfo): bool hasVendorIdentifier() const; bool hasProductIdentifier() const; ... both can be added without any issues (i.e. in a binary compatible way). The examples are updated now as well with presenting the usage of the new API. The GUI emulator example got the string management a bit updated to be in line with the console based emulator (cenumerator). In general, it is also a way more reasonable way of putting a string together with so many placeholders. Also, the argument and list management got a bit nicer formatting style per line break. Testing: the change has been tested on Linux with Qt4 and Qt5. Task-number: QTPLAYGROUND-21 Change-Id: I33683061787af94a797685794be9ebcfa90c499a Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src/serialport/qserialportinfo.h')
-rw-r--r--src/serialport/qserialportinfo.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/serialport/qserialportinfo.h b/src/serialport/qserialportinfo.h
index 96d48d78..19fd5b7e 100644
--- a/src/serialport/qserialportinfo.h
+++ b/src/serialport/qserialportinfo.h
@@ -71,8 +71,8 @@ public:
QString systemLocation() const;
QString description() const;
QString manufacturer() const;
- QString vendorIdentifier() const;
- QString productIdentifier() const;
+ quint16 vendorIdentifier() const;
+ quint16 productIdentifier() const;
bool isNull() const;
bool isBusy() const;