Browse Source

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 <tomaz.canabrava@intel.com>
QGC4.4
Tomaz Canabrava 9 years ago
parent
commit
f0e2e15329
  1. 11
      src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc
  2. 3
      src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h

11
src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc

@ -69,9 +69,8 @@ void APMRemoteParamsDownloader::refreshParamList() @@ -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() @@ -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++;
}

3
src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h

@ -17,18 +17,19 @@ class APMRemoteParamsDownloader : public QObject @@ -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:

Loading…
Cancel
Save