Commit dbec9e98 authored by Patrick José Pereira's avatar Patrick José Pereira

comm: Change from foreach to c++11 for

Signed-off-by: 's avatarPatrick José Pereira <patrickelectric@gmail.com>
parent f1ed746d
...@@ -340,7 +340,7 @@ void BluetoothConfiguration::deviceDiscovered(QBluetoothDeviceInfo info) ...@@ -340,7 +340,7 @@ void BluetoothConfiguration::deviceDiscovered(QBluetoothDeviceInfo info)
qDebug() << "Address: " << info.address().toString(); qDebug() << "Address: " << info.address().toString();
qDebug() << "Service Classes:" << info.serviceClasses(); qDebug() << "Service Classes:" << info.serviceClasses();
QList<QBluetoothUuid> uuids = info.serviceUuids(); QList<QBluetoothUuid> uuids = info.serviceUuids();
foreach (QBluetoothUuid uuid, uuids) { for (QBluetoothUuid uuid: uuids) {
qDebug() << "Service UUID: " << uuid.toString(); qDebug() << "Service UUID: " << uuid.toString();
} }
#endif #endif
...@@ -373,7 +373,7 @@ void BluetoothConfiguration::doneScanning() ...@@ -373,7 +373,7 @@ void BluetoothConfiguration::doneScanning()
void BluetoothConfiguration::setDevName(const QString &name) void BluetoothConfiguration::setDevName(const QString &name)
{ {
foreach(const BluetoothData& data, _deviceList) for(const BluetoothData& data: _deviceList)
{ {
if(data.name == name) if(data.name == name)
{ {
......
...@@ -497,7 +497,7 @@ void LinkManager::_updateAutoConnectLinks(void) ...@@ -497,7 +497,7 @@ void LinkManager::_updateAutoConnectLinks(void)
#endif #endif
// Iterate Comm Ports // Iterate Comm Ports
foreach (QGCSerialPortInfo portInfo, portList) { for (QGCSerialPortInfo portInfo: portList) {
qCDebug(LinkManagerVerboseLog) << "-----------------------------------------------------"; qCDebug(LinkManagerVerboseLog) << "-----------------------------------------------------";
qCDebug(LinkManagerVerboseLog) << "portName: " << portInfo.portName(); qCDebug(LinkManagerVerboseLog) << "portName: " << portInfo.portName();
qCDebug(LinkManagerVerboseLog) << "systemLocation: " << portInfo.systemLocation(); qCDebug(LinkManagerVerboseLog) << "systemLocation: " << portInfo.systemLocation();
...@@ -638,7 +638,7 @@ void LinkManager::_updateAutoConnectLinks(void) ...@@ -638,7 +638,7 @@ void LinkManager::_updateAutoConnectLinks(void)
} }
// Now remove all configs that are gone // Now remove all configs that are gone
foreach (LinkConfiguration* pDeleteConfig, _confToDelete) { for (LinkConfiguration* pDeleteConfig: _confToDelete) {
qCDebug(LinkManagerLog) << "Removing unused autoconnect config" << pDeleteConfig->name(); qCDebug(LinkManagerLog) << "Removing unused autoconnect config" << pDeleteConfig->name();
if (pDeleteConfig->link()) { if (pDeleteConfig->link()) {
disconnectLink(pDeleteConfig->link()); disconnectLink(pDeleteConfig->link());
...@@ -703,7 +703,7 @@ void LinkManager::_updateSerialPorts() ...@@ -703,7 +703,7 @@ void LinkManager::_updateSerialPorts()
_commPortDisplayList.clear(); _commPortDisplayList.clear();
#ifndef NO_SERIAL_LINK #ifndef NO_SERIAL_LINK
QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts(); QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts();
foreach (const QSerialPortInfo &info, portList) for (const QSerialPortInfo &info: portList)
{ {
QString port = info.systemLocation().trimmed(); QString port = info.systemLocation().trimmed();
_commPortList += port; _commPortList += port;
......
...@@ -453,7 +453,7 @@ void MAVLinkProtocol::checkForLostLogFiles(void) ...@@ -453,7 +453,7 @@ void MAVLinkProtocol::checkForLostLogFiles(void)
QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files); QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files);
//qDebug() << "Orphaned log file count" << fileInfoList.count(); //qDebug() << "Orphaned log file count" << fileInfoList.count();
foreach(const QFileInfo fileInfo, fileInfoList) { for(const QFileInfo fileInfo: fileInfoList) {
//qDebug() << "Orphaned log file" << fileInfo.filePath(); //qDebug() << "Orphaned log file" << fileInfo.filePath();
if (fileInfo.size() == 0) { if (fileInfo.size() == 0) {
// Delete all zero length files // Delete all zero length files
...@@ -476,7 +476,7 @@ void MAVLinkProtocol::deleteTempLogFiles(void) ...@@ -476,7 +476,7 @@ void MAVLinkProtocol::deleteTempLogFiles(void)
QString filter(QString("*.%1").arg(_logFileExtension)); QString filter(QString("*.%1").arg(_logFileExtension));
QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files); QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files);
foreach(const QFileInfo fileInfo, fileInfoList) { for(const QFileInfo fileInfo: fileInfoList) {
QFile::remove(fileInfo.filePath()); QFile::remove(fileInfo.filePath());
} }
} }
......
...@@ -956,7 +956,7 @@ void QGCFlightGearLink::_printFgfsOutput(void) ...@@ -956,7 +956,7 @@ void QGCFlightGearLink::_printFgfsOutput(void)
QByteArray byteArray = _fgProcess->readAllStandardOutput(); QByteArray byteArray = _fgProcess->readAllStandardOutput();
QStringList strLines = QString(byteArray).split("\n"); QStringList strLines = QString(byteArray).split("\n");
foreach (const QString &line, strLines){ for (const QString &line: strLines){
qDebug() << line; qDebug() << line;
} }
} }
...@@ -968,7 +968,7 @@ void QGCFlightGearLink::_printFgfsError(void) ...@@ -968,7 +968,7 @@ void QGCFlightGearLink::_printFgfsError(void)
QByteArray byteArray = _fgProcess->readAllStandardError(); QByteArray byteArray = _fgProcess->readAllStandardError();
QStringList strLines = QString(byteArray).split("\n"); QStringList strLines = QString(byteArray).split("\n");
foreach (const QString &line, strLines){ for (const QString &line: strLines){
qDebug() << line; qDebug() << line;
} }
} }
......
...@@ -252,7 +252,7 @@ QList<QGCSerialPortInfo> QGCSerialPortInfo::availablePorts(void) ...@@ -252,7 +252,7 @@ QList<QGCSerialPortInfo> QGCSerialPortInfo::availablePorts(void)
{ {
QList<QGCSerialPortInfo> list; QList<QGCSerialPortInfo> list;
foreach(QSerialPortInfo portInfo, QSerialPortInfo::availablePorts()) { for(QSerialPortInfo portInfo: QSerialPortInfo::availablePorts()) {
if (!isSystemPort(&portInfo)) { if (!isSystemPort(&portInfo)) {
list << *((QGCSerialPortInfo*)&portInfo); list << *((QGCSerialPortInfo*)&portInfo);
} }
......
...@@ -65,7 +65,7 @@ bool SerialLink::_isBootloader() ...@@ -65,7 +65,7 @@ bool SerialLink::_isBootloader()
if( portList.count() == 0){ if( portList.count() == 0){
return false; return false;
} }
foreach (const QSerialPortInfo &info, portList) for (const QSerialPortInfo &info: portList)
{ {
qCDebug(SerialLinkLog) << "PortName : " << info.portName() << "Description : " << info.description(); qCDebug(SerialLinkLog) << "PortName : " << info.portName() << "Description : " << info.description();
qCDebug(SerialLinkLog) << "Manufacturer: " << info.manufacturer(); qCDebug(SerialLinkLog) << "Manufacturer: " << info.manufacturer();
......
...@@ -70,7 +70,7 @@ static QString get_ip_address(const QString& address) ...@@ -70,7 +70,7 @@ static QString get_ip_address(const QString& address)
static bool contains_target(const QList<UDPCLient*> list, const QHostAddress& address, quint16 port) static bool contains_target(const QList<UDPCLient*> list, const QHostAddress& address, quint16 port)
{ {
foreach(UDPCLient* target, list) { for(UDPCLient* target: list) {
if(target->address == address && target->port == port) { if(target->address == address && target->port == port) {
return true; return true;
} }
...@@ -91,7 +91,7 @@ UDPLink::UDPLink(SharedLinkConfigurationPointer& config) ...@@ -91,7 +91,7 @@ UDPLink::UDPLink(SharedLinkConfigurationPointer& config)
if (!_udpConfig) { if (!_udpConfig) {
qWarning() << "Internal error"; qWarning() << "Internal error";
} }
foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) { for (const QHostAddress &address: QNetworkInterface::allAddresses()) {
_localAddress.append(QHostAddress(address)); _localAddress.append(QHostAddress(address));
} }
moveToThread(this); moveToThread(this);
...@@ -156,7 +156,7 @@ bool UDPLink::_isIpLocal(const QHostAddress& add) ...@@ -156,7 +156,7 @@ bool UDPLink::_isIpLocal(const QHostAddress& add)
// On Windows, this is a very expensive call only Redmond would know // On Windows, this is a very expensive call only Redmond would know
// why. As such, we make it once and keep the list locally. If a new // why. As such, we make it once and keep the list locally. If a new
// interface shows up after we start, it won't be on this list. // interface shows up after we start, it won't be on this list.
foreach (const QHostAddress &address, _localAddress) { for (const QHostAddress &address: _localAddress) {
if (address == add) { if (address == add) {
// This is a local address of the same host // This is a local address of the same host
return true; return true;
...@@ -171,14 +171,14 @@ void UDPLink::_writeBytes(const QByteArray data) ...@@ -171,14 +171,14 @@ void UDPLink::_writeBytes(const QByteArray data)
return; return;
} }
// Send to all manually targeted systems // Send to all manually targeted systems
foreach(UDPCLient* target, _udpConfig->targetHosts()) { for(UDPCLient* target: _udpConfig->targetHosts()) {
// Skip it if it's part of the session clients below // Skip it if it's part of the session clients below
if(!contains_target(_sessionTargets, target->address, target->port)) { if(!contains_target(_sessionTargets, target->address, target->port)) {
_writeDataGram(data, target); _writeDataGram(data, target);
} }
} }
// Send to all connected systems // Send to all connected systems
foreach(UDPCLient* target, _sessionTargets) { for(UDPCLient* target: _sessionTargets) {
_writeDataGram(data, target); _writeDataGram(data, target);
} }
} }
...@@ -401,7 +401,7 @@ void UDPConfiguration::_copyFrom(LinkConfiguration *source) ...@@ -401,7 +401,7 @@ void UDPConfiguration::_copyFrom(LinkConfiguration *source)
if (usource) { if (usource) {
_localPort = usource->localPort(); _localPort = usource->localPort();
_clearTargetHosts(); _clearTargetHosts();
foreach(UDPCLient* target, usource->targetHosts()) { for(UDPCLient* target: usource->targetHosts()) {
if(!contains_target(_targetHosts, target->address, target->port)) { if(!contains_target(_targetHosts, target->address, target->port)) {
UDPCLient* newTarget = new UDPCLient(target); UDPCLient* newTarget = new UDPCLient(target);
_targetHosts.append(newTarget); _targetHosts.append(newTarget);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment