summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-01-28 15:31:49 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-01-29 12:22:23 +0100
commitd7c9ef9f3f4ddc6b7578a0da41532c210f208f5b (patch)
treeb420cc2c3edf7d48147f21c2c8ecf281d6d9ad16
parent0d64ca4bd66a5740e48ba0d7744ed090f3a9986b (diff)
downloadqtconnectivity-d7c9ef9f3f4ddc6b7578a0da41532c210f208f5b.tar.gz
QBluetoothDeviceInfo: Use a QMultiHash internally
In Qt 5, this fixes the warning qbluetoothdeviceinfo.cpp:705:57: warning: 'QHash<K, V>::iterator QHash<K, V>::insertMulti(const Key&, const T&) [with Key = short unsigned int; T = QByteArray]' is deprecated: Use QMultiHash for hashes storing multiple values with the same key. [-Wdeprecated-declarations] Returning a QHash still works in Qt 5 due to the inheritance. In Qt 6, the return type needs to be adapted since QMultiHash and QHash will be split. Change-Id: I876fce5d61cacdc84db5b9f72b78ee7608385c6c Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp6
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.h6
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo_p.h2
3 files changed, 6 insertions, 8 deletions
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index a5bc7b81..fae7faa4 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -695,14 +695,14 @@ QByteArray QBluetoothDeviceInfo::manufacturerData(quint16 manufacturerId) const
bool QBluetoothDeviceInfo::setManufacturerData(quint16 manufacturerId, const QByteArray &data)
{
Q_D(QBluetoothDeviceInfo);
- QHash<quint16, QByteArray>::const_iterator it = d->manufacturerData.find(manufacturerId);
- while (it != d->manufacturerData.end() && it.key() == manufacturerId) {
+ auto it = d->manufacturerData.constFind(manufacturerId);
+ while (it != d->manufacturerData.cend() && it.key() == manufacturerId) {
if (*it == data)
return false;
it++;
}
- d->manufacturerData.insertMulti(manufacturerId, data);
+ d->manufacturerData.insert(manufacturerId, data);
return true;
}
diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h
index c4fa01ec..f9da3b4d 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.h
+++ b/src/bluetooth/qbluetoothdeviceinfo.h
@@ -262,10 +262,8 @@ public:
#endif
void setServiceUuids(const QVector<QBluetoothUuid> &uuids);
- // TODO Qt6 manufacturerData()
- // manufacturerData() and manufacturerData(quint16) return types should be modified to
- // cope with multiple data entires per manufacturer ID. QHash<quint16, QByteArray>
- // may stay though if it retains insertMulti() in Qt 6.
+ // TODO Qt6 manufacturerData() need to be changed to return
+ // QMultiHash<quint16, QByteArray>
QVector<quint16> manufacturerIds() const;
QByteArray manufacturerData(quint16 manufacturerId) const;
bool setManufacturerData(quint16 manufacturerId, const QByteArray &data);
diff --git a/src/bluetooth/qbluetoothdeviceinfo_p.h b/src/bluetooth/qbluetoothdeviceinfo_p.h
index 80fd1472..61295c10 100644
--- a/src/bluetooth/qbluetoothdeviceinfo_p.h
+++ b/src/bluetooth/qbluetoothdeviceinfo_p.h
@@ -81,7 +81,7 @@ public:
QBluetoothDeviceInfo::DataCompleteness serviceUuidsCompleteness;
#endif
QVector<QBluetoothUuid> serviceUuids;
- QHash<quint16, QByteArray> manufacturerData;
+ QMultiHash<quint16, QByteArray> manufacturerData;
QBluetoothDeviceInfo::CoreConfigurations deviceCoreConfiguration;
QBluetoothUuid deviceUuid;