From ff3fd7b0330cb76772066ce7162320f4dc1a5c28 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 30 Mar 2020 15:01:44 +0200 Subject: Remove deprecated QTextStream operators from examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use '\n' instead. Task-number: QTBUG-82532 Change-Id: I97aec4076bd46f23644099158f346a6ca32a4a0e Reviewed-by: Topi Reiniƶ --- examples/serialport/cenumerator/main.cpp | 21 ++++++++++----------- examples/serialport/creaderasync/main.cpp | 4 ++-- .../serialport/creaderasync/serialportreader.cpp | 8 ++++---- examples/serialport/creadersync/main.cpp | 16 ++++++++++------ examples/serialport/cwriterasync/main.cpp | 8 +++++--- .../serialport/cwriterasync/serialportwriter.cpp | 10 +++++----- examples/serialport/cwritersync/main.cpp | 21 +++++++++++++-------- 7 files changed, 49 insertions(+), 39 deletions(-) (limited to 'examples') diff --git a/examples/serialport/cenumerator/main.cpp b/examples/serialport/cenumerator/main.cpp index 902a7935..344551e0 100644 --- a/examples/serialport/cenumerator/main.cpp +++ b/examples/serialport/cenumerator/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) QTextStream out(stdout); const auto serialPortInfos = QSerialPortInfo::availablePorts(); - out << "Total number of ports available: " << serialPortInfos.count() << endl; + out << "Total number of ports available: " << serialPortInfos.count() << "\n"; const QString blankString = "N/A"; QString description; @@ -69,18 +69,17 @@ int main(int argc, char *argv[]) description = serialPortInfo.description(); manufacturer = serialPortInfo.manufacturer(); serialNumber = serialPortInfo.serialNumber(); - out << endl - << "Port: " << serialPortInfo.portName() << endl - << "Location: " << serialPortInfo.systemLocation() << endl - << "Description: " << (!description.isEmpty() ? description : blankString) << endl - << "Manufacturer: " << (!manufacturer.isEmpty() ? manufacturer : blankString) << endl - << "Serial number: " << (!serialNumber.isEmpty() ? serialNumber : blankString) << endl - << "Vendor Identifier: " << (serialPortInfo.hasVendorIdentifier() + out << "\nPort: " << serialPortInfo.portName() + << "\nLocation: " << serialPortInfo.systemLocation() + << "\nDescription: " << (!description.isEmpty() ? description : blankString) + << "\nManufacturer: " << (!manufacturer.isEmpty() ? manufacturer : blankString) + << "\nSerial number: " << (!serialNumber.isEmpty() ? serialNumber : blankString) + << "\nVendor Identifier: " << (serialPortInfo.hasVendorIdentifier() ? QByteArray::number(serialPortInfo.vendorIdentifier(), 16) - : blankString) << endl - << "Product Identifier: " << (serialPortInfo.hasProductIdentifier() + : blankString) + << "\nProduct Identifier: " << (serialPortInfo.hasProductIdentifier() ? QByteArray::number(serialPortInfo.productIdentifier(), 16) - : blankString) << endl; + : blankString) << "\n"; } return 0; diff --git a/examples/serialport/creaderasync/main.cpp b/examples/serialport/creaderasync/main.cpp index 6c669ceb..8fc43577 100644 --- a/examples/serialport/creaderasync/main.cpp +++ b/examples/serialport/creaderasync/main.cpp @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) if (argumentCount == 1) { standardOutput << QObject::tr("Usage: %1 [baudrate]") .arg(argumentList.first()) - << endl; + << "\n"; return 1; } @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) standardOutput << QObject::tr("Failed to open port %1, error: %2") .arg(serialPortName) .arg(serialPort.errorString()) - << endl; + << "\n"; return 1; } diff --git a/examples/serialport/creaderasync/serialportreader.cpp b/examples/serialport/creaderasync/serialportreader.cpp index a701839b..83ea53cd 100644 --- a/examples/serialport/creaderasync/serialportreader.cpp +++ b/examples/serialport/creaderasync/serialportreader.cpp @@ -78,12 +78,12 @@ void SerialPortReader::handleTimeout() m_standardOutput << QObject::tr("No data was currently available " "for reading from port %1") .arg(m_serialPort->portName()) - << endl; + << "\n"; } else { m_standardOutput << QObject::tr("Data successfully received from port %1") .arg(m_serialPort->portName()) - << endl; - m_standardOutput << m_readData << endl; + << "\n"; + m_standardOutput << m_readData << "\n"; } QCoreApplication::quit(); @@ -96,7 +96,7 @@ void SerialPortReader::handleError(QSerialPort::SerialPortError serialPortError) "the data from port %1, error: %2") .arg(m_serialPort->portName()) .arg(m_serialPort->errorString()) - << endl; + << "\n"; QCoreApplication::exit(1); } } diff --git a/examples/serialport/creadersync/main.cpp b/examples/serialport/creadersync/main.cpp index 845a5fb2..863ae014 100644 --- a/examples/serialport/creadersync/main.cpp +++ b/examples/serialport/creadersync/main.cpp @@ -63,7 +63,8 @@ int main(int argc, char *argv[]) if (argumentCount == 1) { standardOutput << QObject::tr("Usage: %1 [baudrate]") - .arg(argumentList.first()) << endl; + .arg(argumentList.first()) + << "\n"; return 1; } @@ -77,7 +78,8 @@ int main(int argc, char *argv[]) if (!serialPort.open(QIODevice::ReadOnly)) { standardOutput << QObject::tr("Failed to open port %1, error: %2") - .arg(serialPortName).arg(serialPort.error()) << endl; + .arg(serialPortName).arg(serialPort.error()) + << "\n"; return 1; } @@ -87,18 +89,20 @@ int main(int argc, char *argv[]) if (serialPort.error() == QSerialPort::ReadError) { standardOutput << QObject::tr("Failed to read from port %1, error: %2") - .arg(serialPortName).arg(serialPort.errorString()) << endl; + .arg(serialPortName).arg(serialPort.errorString()) + << "\n"; return 1; } else if (serialPort.error() == QSerialPort::TimeoutError && readData.isEmpty()) { standardOutput << QObject::tr("No data was currently available" " for reading from port %1") - .arg(serialPortName) << endl; + .arg(serialPortName) + << "\n"; return 0; } standardOutput << QObject::tr("Data successfully received from port %1") - .arg(serialPortName) << endl; - standardOutput << readData << endl; + .arg(serialPortName); + standardOutput << "\n" << readData << "\n"; return 0; } diff --git a/examples/serialport/cwriterasync/main.cpp b/examples/serialport/cwriterasync/main.cpp index 4d65e0a6..f9cbfce6 100644 --- a/examples/serialport/cwriterasync/main.cpp +++ b/examples/serialport/cwriterasync/main.cpp @@ -66,7 +66,8 @@ int main(int argc, char *argv[]) if (argumentCount == 1) { standardOutput << QObject::tr("Usage: %1 [baudrate]") - .arg(argumentList.first()) << endl; + .arg(argumentList.first()) + << "\n"; return 1; } @@ -82,7 +83,7 @@ int main(int argc, char *argv[]) QFile dataFile; if (!dataFile.open(stdin, QIODevice::ReadOnly)) { - standardOutput << QObject::tr("Failed to open stdin for reading") << endl; + standardOutput << QObject::tr("Failed to open stdin for reading") << "\n"; return 1; } @@ -93,7 +94,8 @@ int main(int argc, char *argv[]) standardOutput << QObject::tr("Either no data was currently available on " "the standard input for reading, " "or an error occurred for port %1, error: %2") - .arg(serialPortName).arg(serialPort.errorString()) << endl; + .arg(serialPortName).arg(serialPort.errorString()) + << "\n"; return 1; } diff --git a/examples/serialport/cwriterasync/serialportwriter.cpp b/examples/serialport/cwriterasync/serialportwriter.cpp index c2916bb2..1f2fedc2 100644 --- a/examples/serialport/cwriterasync/serialportwriter.cpp +++ b/examples/serialport/cwriterasync/serialportwriter.cpp @@ -71,7 +71,7 @@ void SerialPortWriter::handleBytesWritten(qint64 bytes) if (m_bytesWritten == m_writeData.size()) { m_bytesWritten = 0; m_standardOutput << QObject::tr("Data successfully sent to port %1") - .arg(m_serialPort->portName()) << endl; + .arg(m_serialPort->portName()) << "\n"; QCoreApplication::quit(); } } @@ -81,7 +81,7 @@ void SerialPortWriter::handleTimeout() m_standardOutput << QObject::tr("Operation timed out for port %1, error: %2") .arg(m_serialPort->portName()) .arg(m_serialPort->errorString()) - << endl; + << "\n"; QCoreApplication::exit(1); } @@ -92,7 +92,7 @@ void SerialPortWriter::handleError(QSerialPort::SerialPortError serialPortError) " the data to port %1, error: %2") .arg(m_serialPort->portName()) .arg(m_serialPort->errorString()) - << endl; + << "\n"; QCoreApplication::exit(1); } } @@ -107,13 +107,13 @@ void SerialPortWriter::write(const QByteArray &writeData) m_standardOutput << QObject::tr("Failed to write the data to port %1, error: %2") .arg(m_serialPort->portName()) .arg(m_serialPort->errorString()) - << endl; + << "\n"; QCoreApplication::exit(1); } else if (bytesWritten != m_writeData.size()) { m_standardOutput << QObject::tr("Failed to write all the data to port %1, error: %2") .arg(m_serialPort->portName()) .arg(m_serialPort->errorString()) - << endl; + << "\n"; QCoreApplication::exit(1); } diff --git a/examples/serialport/cwritersync/main.cpp b/examples/serialport/cwritersync/main.cpp index 125c111c..0fd8fdc6 100644 --- a/examples/serialport/cwritersync/main.cpp +++ b/examples/serialport/cwritersync/main.cpp @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) if (argumentCount == 1) { standardOutput << QObject::tr("Usage: %1 [baudrate]") - .arg(argumentList.first()) << endl; + .arg(argumentList.first()) << "\n"; return 1; } @@ -79,14 +79,14 @@ int main(int argc, char *argv[]) if (!serialPort.open(QIODevice::WriteOnly)) { standardOutput << QObject::tr("Failed to open port %1, error: %2") .arg(serialPortName).arg(serialPort.errorString()) - << endl; + << "\n"; return 1; } QFile dataFile; if (!dataFile.open(stdin, QIODevice::ReadOnly)) { standardOutput << QObject::tr("Failed to open stdin for reading") - << endl; + << "\n"; return 1; } @@ -97,7 +97,8 @@ int main(int argc, char *argv[]) standardOutput << QObject::tr("Either no data was currently available on " "the standard input for reading, or an error " "occurred for port %1, error: %2") - .arg(serialPortName).arg(serialPort.errorString()) << endl; + .arg(serialPortName).arg(serialPort.errorString()) + << "\n"; return 1; } @@ -105,21 +106,25 @@ int main(int argc, char *argv[]) if (bytesWritten == -1) { standardOutput << QObject::tr("Failed to write the data to port %1, error: %2") - .arg(serialPortName).arg(serialPort.errorString()) << endl; + .arg(serialPortName).arg(serialPort.errorString()) + << "\n"; return 1; } else if (bytesWritten != writeData.size()) { standardOutput << QObject::tr("Failed to write all the data to port %1, error: %2") - .arg(serialPortName).arg(serialPort.errorString()) << endl; + .arg(serialPortName).arg(serialPort.errorString()) + << "\n"; return 1; } else if (!serialPort.waitForBytesWritten(5000)) { standardOutput << QObject::tr("Operation timed out or an error " "occurred for port %1, error: %2") - .arg(serialPortName).arg(serialPort.errorString()) << endl; + .arg(serialPortName).arg(serialPort.errorString()) + << "\n"; return 1; } standardOutput << QObject::tr("Data successfully sent to port %1") - .arg(serialPortName) << endl; + .arg(serialPortName) + << "\n"; return 0; } -- cgit v1.2.3