From f0e2e15329ff8e852417e516fd55b492424d9e57 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 4 Jan 2016 15:08:36 -0200 Subject: [PATCH] Modernize Qt connections First commit of modernizarion of Qt signal connections, the new signal connection is very userfull because of a few nice things: - it's checked at compile time instead of runtime - it can connect to any function or method, so we don't need to use slots anymore - it's way faster because it doesn't need to work with string comparisson, but it's basically a direct call. Signed-off-by: Tomaz Canabrava --- src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc | 11 +++++------ src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc b/src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc index 8b4834dbc..8ab34de35 100644 --- a/src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc +++ b/src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc @@ -69,9 +69,8 @@ void APMRemoteParamsDownloader::refreshParamList() QUrl url = FRAME_PARAMS_LIST; m_networkReply->deleteLater(); m_networkReply = m_networkAccessManager.get(QNetworkRequest(url)); - connect(m_networkReply, SIGNAL(finished()), this, SLOT(httpParamListFinished())); - connect(m_networkReply, SIGNAL(downloadProgress(qint64,qint64)), - this, SLOT(updateDataReadProgress(qint64,qint64))); + connect(m_networkReply, &QNetworkReply::finished, this, &APMRemoteParamsDownloader::httpParamListFinished); + connect(m_networkReply, &QNetworkReply::downloadProgress, this, &APMRemoteParamsDownloader::updateDataReadProgress); } /* Returned Json Example @@ -120,9 +119,9 @@ void APMRemoteParamsDownloader::startFileDownloadRequest() m_downloadedParamFile->open(QIODevice::WriteOnly); m_networkReply = m_networkAccessManager.get(QNetworkRequest(url)); - connect(m_networkReply, SIGNAL(finished()), this, SLOT(httpFinished())); - connect(m_networkReply, SIGNAL(readyRead()), this, SLOT(httpReadyRead())); - connect(m_networkReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(updateDataReadProgress(qint64,qint64))); + connect(m_networkReply, &QNetworkReply::finished, this, &APMRemoteParamsDownloader::httpFinished); + connect(m_networkReply, &QNetworkReply::readyRead, this, &APMRemoteParamsDownloader::httpReadyRead); + connect(m_networkReply, &QNetworkReply::downloadProgress, this, &APMRemoteParamsDownloader::updateDataReadProgress); curr++; } diff --git a/src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h b/src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h index b635cc77e..e22a4b137 100644 --- a/src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h +++ b/src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h @@ -17,18 +17,19 @@ class APMRemoteParamsDownloader : public QObject public: explicit APMRemoteParamsDownloader(const QString& file); QString statusText() const; -public slots: void refreshParamList(); void httpParamListFinished(); void httpFinished(); void httpReadyRead(); void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes); + private: void setStatusText(const QString& text); void startFileDownloadRequest(); void manualListSetup(); void processDownloadedVersionObject(const QByteArray& listObject); void startDownloadingRemoteParams(); + signals: void finished(); private: -- 2.22.0