lowenergyscanner: Use new connect syntax

Change-Id: I87047bbc8b777f597ac4843c0c5466489d764f46
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Oliver Wolff 2017-07-04 08:15:09 +02:00
parent 2337dc7793
commit b211fa43a0
1 changed files with 18 additions and 18 deletions

View File

@ -55,11 +55,11 @@ Device::Device():
//! [les-devicediscovery-1] //! [les-devicediscovery-1]
discoveryAgent = new QBluetoothDeviceDiscoveryAgent(); discoveryAgent = new QBluetoothDeviceDiscoveryAgent();
discoveryAgent->setLowEnergyDiscoveryTimeout(5000); discoveryAgent->setLowEnergyDiscoveryTimeout(5000);
connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)), connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,
this, SLOT(addDevice(const QBluetoothDeviceInfo&))); this, &Device::addDevice);
connect(discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), connect(discoveryAgent, QOverload<QBluetoothDeviceDiscoveryAgent::Error>::of(&QBluetoothDeviceDiscoveryAgent::error),
this, SLOT(deviceScanError(QBluetoothDeviceDiscoveryAgent::Error))); this, &Device::deviceScanError);
connect(discoveryAgent, SIGNAL(finished()), this, SLOT(deviceScanFinished())); connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, this, &Device::deviceScanFinished);
//! [les-devicediscovery-1] //! [les-devicediscovery-1]
setUpdate("Search"); setUpdate("Search");
@ -169,16 +169,16 @@ void Device::scanServices(const QString &address)
if (!controller) { if (!controller) {
// Connecting signals and slots for connecting to LE services. // Connecting signals and slots for connecting to LE services.
controller = new QLowEnergyController(currentDevice.getDevice()); controller = new QLowEnergyController(currentDevice.getDevice());
connect(controller, SIGNAL(connected()), connect(controller, &QLowEnergyController::connected,
this, SLOT(deviceConnected())); this, &Device::deviceConnected);
connect(controller, SIGNAL(error(QLowEnergyController::Error)), connect(controller, QOverload<QLowEnergyController::Error>::of(&QLowEnergyController::error),
this, SLOT(errorReceived(QLowEnergyController::Error))); this, &Device::errorReceived);
connect(controller, SIGNAL(disconnected()), connect(controller, &QLowEnergyController::disconnected,
this, SLOT(deviceDisconnected())); this, &Device::deviceDisconnected);
connect(controller, SIGNAL(serviceDiscovered(QBluetoothUuid)), connect(controller, &QLowEnergyController::serviceDiscovered,
this, SLOT(addLowEnergyService(QBluetoothUuid))); this, &Device::addLowEnergyService);
connect(controller, SIGNAL(discoveryFinished()), connect(controller, &QLowEnergyController::discoveryFinished,
this, SLOT(serviceScanDone())); this, &Device::serviceScanDone);
} }
if (isRandomAddress()) if (isRandomAddress())
@ -235,8 +235,8 @@ void Device::connectToService(const QString &uuid)
if (service->state() == QLowEnergyService::DiscoveryRequired) { if (service->state() == QLowEnergyService::DiscoveryRequired) {
//! [les-service-3] //! [les-service-3]
connect(service, SIGNAL(stateChanged(QLowEnergyService::ServiceState)), connect(service, &QLowEnergyService::stateChanged,
this, SLOT(serviceDetailsDiscovered(QLowEnergyService::ServiceState))); this, &Device::serviceDetailsDiscovered);
service->discoverDetails(); service->discoverDetails();
setUpdate("Back\n(Discovering details...)"); setUpdate("Back\n(Discovering details...)");
//! [les-service-3] //! [les-service-3]
@ -250,7 +250,7 @@ void Device::connectToService(const QString &uuid)
m_characteristics.append(cInfo); m_characteristics.append(cInfo);
} }
QTimer::singleShot(0, this, SIGNAL(characteristicsUpdated())); QTimer::singleShot(0, this, &Device::characteristicsUpdated);
} }
void Device::deviceConnected() void Device::deviceConnected()