summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@qt.io>2020-03-30 15:01:44 +0200
committerTopi Reinio <topi.reinio@qt.io>2020-04-06 10:32:07 +0200
commitff3fd7b0330cb76772066ce7162320f4dc1a5c28 (patch)
tree7fe2f0d11e600a6d0e7d375a781c30e7e7c30045
parentb30052fa41f6332f20ec440dcdbcd06b41a954f5 (diff)
Remove deprecated QTextStream operators from examplesv5.15.0-beta4
Use '\n' instead. Task-number: QTBUG-82532 Change-Id: I97aec4076bd46f23644099158f346a6ca32a4a0e Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--examples/serialport/cenumerator/main.cpp21
-rw-r--r--examples/serialport/creaderasync/main.cpp4
-rw-r--r--examples/serialport/creaderasync/serialportreader.cpp8
-rw-r--r--examples/serialport/creadersync/main.cpp16
-rw-r--r--examples/serialport/cwriterasync/main.cpp8
-rw-r--r--examples/serialport/cwriterasync/serialportwriter.cpp10
-rw-r--r--examples/serialport/cwritersync/main.cpp21
7 files changed, 49 insertions, 39 deletions
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 <serialportname> [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 <serialportname> [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 <serialportname> [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 <serialportname> [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;
}