summaryrefslogtreecommitdiffstats
path: root/src/plugins/canbus/peakcan
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2021-01-06 19:00:57 +0100
committerAndre Hartmann <aha_1980@gmx.de>2021-02-03 14:57:12 +0100
commit227060f8c17aaf90fe542ad6079a6badaf410a0d (patch)
tree4c6e441c846a199a4e436f0a4fea07eeca9fa292 /src/plugins/canbus/peakcan
parentc990bdbf8ec922dd7702a2a0e33b9b70db3ac6ee (diff)
QCanBusDevice: Replace int parameter with ConfigurationKey
They only place where this might break user code, is for custom plugins using custom configuration parameters. For most users however, this type safety makes the API easier to use. [ChangeLog][QCanBusDevice] All functions dealing with configuration parameters now take a QCanBusDevice::ConfigurationKey instead an int. Fixes: QTBUG-89839 Change-Id: I0a1de5fdcfc4292b23599d4770102740a2df1601 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/plugins/canbus/peakcan')
-rw-r--r--src/plugins/canbus/peakcan/peakcanbackend.cpp7
-rw-r--r--src/plugins/canbus/peakcan/peakcanbackend.h2
-rw-r--r--src/plugins/canbus/peakcan/peakcanbackend_p.h2
3 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp
index 1f9afab..68552ae 100644
--- a/src/plugins/canbus/peakcan/peakcanbackend.cpp
+++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp
@@ -496,7 +496,8 @@ void PeakCanBackendPrivate::close()
isOpen = false;
}
-bool PeakCanBackendPrivate::setConfigurationParameter(int key, const QVariant &value)
+bool PeakCanBackendPrivate::setConfigurationParameter(QCanBusDevice::ConfigurationKey key,
+ const QVariant &value)
{
Q_Q(PeakCanBackend);
@@ -816,7 +817,7 @@ bool PeakCanBackend::open()
// Apply all stored configurations except bitrate, because
// the bitrate cannot be changed after opening the device
const auto keys = configurationKeys();
- for (int key : keys) {
+ for (ConfigurationKey key : keys) {
if (key == QCanBusDevice::BitRateKey || key == QCanBusDevice::DataBitRateKey)
continue;
const QVariant param = configurationParameter(key);
@@ -841,7 +842,7 @@ void PeakCanBackend::close()
setState(QCanBusDevice::UnconnectedState);
}
-void PeakCanBackend::setConfigurationParameter(int key, const QVariant &value)
+void PeakCanBackend::setConfigurationParameter(ConfigurationKey key, const QVariant &value)
{
Q_D(PeakCanBackend);
diff --git a/src/plugins/canbus/peakcan/peakcanbackend.h b/src/plugins/canbus/peakcan/peakcanbackend.h
index df76e5c..5bedd29 100644
--- a/src/plugins/canbus/peakcan/peakcanbackend.h
+++ b/src/plugins/canbus/peakcan/peakcanbackend.h
@@ -61,7 +61,7 @@ public:
bool open() override;
void close() override;
- void setConfigurationParameter(int key, const QVariant &value) override;
+ void setConfigurationParameter(ConfigurationKey key, const QVariant &value) override;
bool writeFrame(const QCanBusFrame &newData) override;
diff --git a/src/plugins/canbus/peakcan/peakcanbackend_p.h b/src/plugins/canbus/peakcan/peakcanbackend_p.h
index 96d7ad3..ef57ad6 100644
--- a/src/plugins/canbus/peakcan/peakcanbackend_p.h
+++ b/src/plugins/canbus/peakcan/peakcanbackend_p.h
@@ -72,7 +72,7 @@ public:
bool open();
void close();
- bool setConfigurationParameter(int key, const QVariant &value);
+ bool setConfigurationParameter(QCanBusDevice::ConfigurationKey key, const QVariant &value);
void setupChannel(const QByteArray &interfaceName);
void setupDefaultConfigurations();
QString systemErrorString(TPCANStatus errorCode);