From 641438a6e6d42c30c47d469716e212ba1bfca641 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 4 Jan 2016 18:28:57 -0200 Subject: [PATCH] More signals converted to the new style Signed-off-by: Tomaz Canabrava --- src/VehicleSetup/FirmwareUpgradeController.cc | 6 ++-- src/comm/BluetoothLink.cc | 16 ++++----- src/comm/QGCFlightGearLink.cc | 47 +++++++++++++-------------- src/comm/QGCJSBSimLink.cc | 19 +++++------ 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/VehicleSetup/FirmwareUpgradeController.cc b/src/VehicleSetup/FirmwareUpgradeController.cc index 3434028..034a718 100644 --- a/src/VehicleSetup/FirmwareUpgradeController.cc +++ b/src/VehicleSetup/FirmwareUpgradeController.cc @@ -469,9 +469,9 @@ void FirmwareUpgradeController::_downloadFirmware(void) Q_ASSERT(_downloadNetworkReply); connect(_downloadNetworkReply, &QNetworkReply::downloadProgress, this, &FirmwareUpgradeController::_downloadProgress); connect(_downloadNetworkReply, &QNetworkReply::finished, this, &FirmwareUpgradeController::_downloadFinished); - // FIXME - //connect(_downloadNetworkReply, &QNetworkReply::error, this, &FirmwareUpgradeController::_downloadError); - connect(_downloadNetworkReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(_downloadError(QNetworkReply::NetworkError))); + + connect(_downloadNetworkReply, static_cast(&QNetworkReply::error), + this, &FirmwareUpgradeController::_downloadError); } /// @brief Updates the progress indicator while downloading diff --git a/src/comm/BluetoothLink.cc b/src/comm/BluetoothLink.cc index 85df752..1ab35f5 100644 --- a/src/comm/BluetoothLink.cc +++ b/src/comm/BluetoothLink.cc @@ -158,10 +158,10 @@ bool BluetoothLink::_hardwareConnect() _discoveryAgent = NULL; } _discoveryAgent = new QBluetoothServiceDiscoveryAgent(this); - QObject::connect(_discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(serviceDiscovered(QBluetoothServiceInfo))); - QObject::connect(_discoveryAgent, SIGNAL(finished()), this, SLOT(discoveryFinished())); - QObject::connect(_discoveryAgent, SIGNAL(canceled()), this, SLOT(discoveryFinished())); - QObject::connect(_discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)),this, SLOT(discoveryError(QBluetoothServiceDiscoveryAgent::Error))); + connect(_discoveryAgent, &QBluetoothServiceDiscoveryAgent::serviceDiscovered, this, &BluetoothLink::serviceDiscovered); + connect(_discoveryAgent, &QBluetoothServiceDiscoveryAgent::finished, this, &BluetoothLink::discoveryFinished); + connect(_discoveryAgent, &QBluetoothServiceDiscoveryAgent::canceled, this, &BluetoothLink::discoveryFinished); + connect(_discoveryAgent, &QBluetoothServiceDiscoveryAgent::error,this, BluetoothLink::discoveryError); _shutDown = false; _discoveryAgent->start(); #else @@ -179,10 +179,10 @@ void BluetoothLink::_createSocket() _targetSocket = NULL; } _targetSocket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this); - QObject::connect(_targetSocket, SIGNAL(connected()), this, SLOT(deviceConnected())); - QObject::connect(_targetSocket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(deviceError(QBluetoothSocket::SocketError))); - QObject::connect(_targetSocket, SIGNAL(readyRead()), this, SLOT(readBytes())); - QObject::connect(_targetSocket, SIGNAL(disconnected()), this, SLOT(deviceDisconnected())); + QObject::connect(_targetSocket, &QBluetoothSocket::connected, this, &BluetoothLink::deviceConnected); + QObject::connect(_targetSocket, &QBluetoothSocket::error, this, &BluetoothLink::deviceError); + QObject::connect(_targetSocket, &QBluetoothSocket::readyRead, this, &BluetoothLink::readBytes); + QObject::connect(_targetSocket, &QBluetoothSocket::disconnected, this, &BluetoothLink::deviceDisconnected); } #ifdef __ios__ diff --git a/src/comm/QGCFlightGearLink.cc b/src/comm/QGCFlightGearLink.cc index 3287f57..35c2d03 100644 --- a/src/comm/QGCFlightGearLink.cc +++ b/src/comm/QGCFlightGearLink.cc @@ -98,31 +98,29 @@ void QGCFlightGearLink::run() Q_CHECK_PTR(_udpCommSocket); _udpCommSocket->moveToThread(this); _udpCommSocket->bind(host, port, QAbstractSocket::ReuseAddressHint); - QObject::connect(_udpCommSocket, SIGNAL(readyRead()), this, SLOT(readBytes())); + QObject::connect(_udpCommSocket, &QUdpSocket::readyRead, this, &QGCFlightGearLink::readBytes); // Connect to the various HIL signals that we use to then send information across the UDP protocol to FlightGear. - connect(_vehicle->uas(), SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), - this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8))); - connect(this, SIGNAL(hilStateChanged(quint64, float, float, float, float,float, float, double, double, double, float, float, float, float, float, float, float, float)), - _vehicle->uas(), SLOT(sendHilState(quint64, float, float, float, float,float, float, double, double, double, float, float, float, float, float, float, float, float))); - connect(this, SIGNAL(sensorHilGpsChanged(quint64, double, double, double, int, float, float, float, float, float, float, float, int)), - _vehicle->uas(), SLOT(sendHilGps(quint64, double, double, double, int, float, float, float, float, float, float, float, int))); - connect(this, SIGNAL(sensorHilRawImuChanged(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32)), - _vehicle->uas(), SLOT(sendHilSensors(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32))); - connect(this, SIGNAL(sensorHilOpticalFlowChanged(quint64, qint16, qint16, float,float, quint8, float)), - _vehicle->uas(), SLOT(sendHilOpticalFlow(quint64, qint16, qint16, float, float, quint8, float))); + connect(_vehicle->uas(), &UAS::hilControlsChanged, this, &QGCFlightGearLink::updateControls); + + connect(this, &QGCFlightGearLink::hilStateChanged, _vehicle->uas(), &UAS::sendHilState); + connect(this, &QGCFlightGearLink::sensorHilGpsChanged, _vehicle->uas(), &UAS::sendHilGps); + connect(this, &QGCFlightGearLink::sensorHilRawImuChanged, _vehicle->uas(), &UAS::sendHilSensors); + connect(this, &QGCFlightGearLink::sensorHilOpticalFlowChanged, _vehicle->uas(), &UAS::sendHilOpticalFlow); // Start a new QProcess to run FlightGear in _fgProcess = new QProcess(this); Q_CHECK_PTR(_fgProcess); _fgProcess->moveToThread(this); - connect(_fgProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); -#ifdef DEBUG_FLIGHTGEAR_CONNECT - connect(_fgProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(_printFgfsOutput())); - connect(_fgProcess, SIGNAL(readyReadStandardError()), this, SLOT(_printFgfsError())); -#endif + connect(_fgProcess, static_cast(&QProcess::error), + this, &QGCFlightGearLink::processError); + +//#ifdef DEBUG_FLIGHTGEAR_CONNECT + connect(_fgProcess, &QProcess::readyReadStandardOutput, this, &QGCFlightGearLink::_printFgfsOutput); + connect(_fgProcess, &QProcess::readyReadStandardError, this, &QGCFlightGearLink::_printFgfsError); +//#endif if (!_fgProcessWorkingDirPath.isEmpty()) { _fgProcess->setWorkingDirectory(_fgProcessWorkingDirPath); @@ -491,14 +489,15 @@ qint64 QGCFlightGearLink::bytesAvailable() **/ bool QGCFlightGearLink::disconnectSimulation() { - disconnect(_fgProcess, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); - disconnect(_vehicle->uas(), SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8))); - disconnect(this, SIGNAL(hilStateChanged(quint64, float, float, float, float,float, float, double, double, double, float, float, float, float, float, float, float, float)), _vehicle->uas(), SLOT(sendHilState(quint64, float, float, float, float,float, float, double, double, double, float, float, float, float, float, float, float, float))); - disconnect(this, SIGNAL(sensorHilGpsChanged(quint64, double, double, double, int, float, float, float, float, float, float, float, int)), _vehicle->uas(), SLOT(sendHilGps(quint64, double, double, double, int, float, float, float, float, float, float, float, int))); - disconnect(this, SIGNAL(sensorHilRawImuChanged(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32)), _vehicle->uas(), SLOT(sendHilSensors(quint64,float,float,float,float,float,float,float,float,float,float,float,float,float,quint32))); - disconnect(this, SIGNAL(sensorHilOpticalFlowChanged(quint64, qint16, qint16, float,float, quint8, float)), - _vehicle->uas(), SLOT(sendHilOpticalFlow(quint64, qint16, qint16, float, float, quint8, float))); + disconnect(_fgProcess, static_cast(&QProcess::error), + this, &QGCFlightGearLink::processError); + + disconnect(_vehicle->uas(), &UAS::hilControlsChanged, this, &QGCFlightGearLink::updateControls); + + disconnect(this, &QGCFlightGearLink::hilStateChanged, _vehicle->uas(), &UAS::sendHilState); + disconnect(this, &QGCFlightGearLink::sensorHilGpsChanged, _vehicle->uas(), &UAS::sendHilGps); + disconnect(this, &QGCFlightGearLink::sensorHilRawImuChanged, _vehicle->uas(), &UAS::sendHilSensors); + disconnect(this, &QGCFlightGearLink::sensorHilOpticalFlowChanged, _vehicle->uas(), &UAS::sendHilOpticalFlow); if (_fgProcess) { diff --git a/src/comm/QGCJSBSimLink.cc b/src/comm/QGCJSBSimLink.cc index bf5c77f..065442f 100644 --- a/src/comm/QGCJSBSimLink.cc +++ b/src/comm/QGCJSBSimLink.cc @@ -80,20 +80,19 @@ void QGCJSBSimLink::run() socket->moveToThread(this); connectState = socket->bind(host, port, QAbstractSocket::ReuseAddressHint); - QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(readBytes())); + QObject::connect(socket, &QUdpSocket::readyRead, this, &QGCJSBSimLink::readBytes); process = new QProcess(this); - connect(_vehicle->uas(), SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8))); - connect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), _vehicle->uas(), SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); - + connect(_vehicle->uas(), &UAS::hilControlsChanged, this, &QGCJSBSimLink::updateControls); + connect(this, &QGCJSBSimLink::hilStateChanged, _vehicle->uas(), &UAS::sendHilState); _vehicle->uas()->startHil(); //connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(sendUAVUpdate())); // Catch process error - QObject::connect( process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); + connect(process, static_cast(&QProcess::error), + this, &QGCJSBSimLink::processError); // Start Flightgear QStringList arguments; @@ -358,10 +357,10 @@ qint64 QGCJSBSimLink::bytesAvailable() **/ bool QGCJSBSimLink::disconnectSimulation() { - disconnect(process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); - disconnect(_vehicle->uas(), SIGNAL(hilControlsChanged(quint64, float, float, float, float, quint8, quint8)), this, SLOT(updateControls(quint64,float,float,float,float,quint8,quint8))); - disconnect(this, SIGNAL(hilStateChanged(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float)), _vehicle->uas(), SLOT(sendHilState(quint64,float,float,float,float,float,float,double,double,double,float,float,float,float,float,float,float,float))); + disconnect(_vehicle->uas(), &UAS::hilControlsChanged, this, &QGCJSBSimLink::updateControls); + disconnect(this, &QGCJSBSimLink::hilStateChanged, _vehicle->uas(), &UAS::sendHilState); + disconnect(process, static_cast(&QProcess::error), + this, &QGCJSBSimLink::processError); if (process) {