QAbstractSocket: Resolve remaining Qt6 TODOs

Change-Id: Id257f0721c1cd5fcbafa9297bae0251a2d68e366
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Mårten Nordheim 2020-08-19 16:42:58 +02:00
parent 081207dc37
commit 0011a45102
5 changed files with 11 additions and 60 deletions

View File

@ -397,12 +397,11 @@ bool PeerWireClient::canTransferMore() const
|| !outgoingBuffer.isEmpty() || !pendingBlocks.isEmpty();
}
void PeerWireClient::connectToHost(const QHostAddress &address,
quint16 port, OpenMode openMode)
void PeerWireClient::connectToHost(const QString &address, quint16 port, OpenMode openMode,
NetworkLayerProtocol protocol)
{
setOpenMode(openMode);
socket.connectToHost(address, port, openMode);
socket.connectToHost(address, port, openMode, protocol);
}
void PeerWireClient::diconnectFromHost()

View File

@ -128,8 +128,9 @@ public:
void setReadBufferSize(qint64 size) override;
void connectToHost(const QHostAddress &address,
quint16 port, OpenMode openMode = ReadWrite) override;
using QTcpSocket::connectToHost;
void connectToHost(const QString &address, quint16 port, OpenMode openMode = ReadWrite,
NetworkLayerProtocol protocol = AnyIPProtocol) override;
void diconnectFromHost();
signals:

View File

@ -65,17 +65,5 @@ if (socket->state() == QAbstractSocket::UnconnectedState
//! [2]
// This slot is connected to QAbstractSocket::readyRead()
void SocketClass::readyReadSlot()
{
while (!socket.atEnd()) {
QByteArray data = socket.read(100);
....
}
}
//! [2]
//! [3]
socket->setProxy(QNetworkProxy::NoProxy);
//! [3]
//! [2]

View File

@ -1864,22 +1864,6 @@ QString QAbstractSocket::peerName() const
return d->peerName.isEmpty() ? d->hostName : d->peerName;
}
/*!
Returns \c true if a line of data can be read from the socket;
otherwise returns \c false.
\sa readLine()
*/
bool QAbstractSocket::canReadLine() const
{
bool hasLine = QIODevice::canReadLine();
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::canReadLine() == %s, buffer size = %lld, size = %lld",
hasLine ? "true" : "false", d_func()->buffer.size(), d_func()->buffer.size());
#endif
return hasLine;
}
/*!
Returns the native socket descriptor of the QAbstractSocket object
if this is available; otherwise returns -1.
@ -2413,23 +2397,6 @@ bool QAbstractSocket::isSequential() const
return true;
}
/*! \reimp
Returns \c true if no more data is currently
available for reading; otherwise returns \c false.
This function is most commonly used when reading data from the
socket in a loop. For example:
\snippet code/src_network_socket_qabstractsocket.cpp 2
\sa bytesAvailable(), readyRead()
*/
bool QAbstractSocket::atEnd() const
{
return QIODevice::atEnd();
}
/*!
This function writes as much as possible from the internal write buffer to
the underlying network socket, without blocking. If any data was written,
@ -2882,7 +2849,7 @@ void QAbstractSocket::setSocketError(SocketError socketError)
To disable the use of a proxy for this socket, use the
QNetworkProxy::NoProxy proxy type:
\snippet code/src_network_socket_qabstractsocket.cpp 3
\snippet code/src_network_socket_qabstractsocket.cpp 2
The default value for the proxy is QNetworkProxy::DefaultProxy,
which means the socket will use the application settings: if a

View File

@ -146,13 +146,12 @@ public:
PauseModes pauseMode() const;
void setPauseMode(PauseModes pauseMode);
// ### Qt6: make the first one virtual
bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform);
virtual bool bind(const QHostAddress &address, quint16 port = 0,
BindMode mode = DefaultForPlatform);
bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform);
// ### Qt6: de-virtualize connectToHost(QHostAddress) overload
virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
virtual void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
virtual void disconnectFromHost();
bool isValid() const;
@ -160,8 +159,6 @@ public:
qint64 bytesAvailable() const override;
qint64 bytesToWrite() const override;
bool canReadLine() const override; // ### Qt6: remove me
quint16 localPort() const;
QHostAddress localAddress() const;
quint16 peerPort() const;
@ -187,7 +184,6 @@ public:
// from QIODevice
void close() override;
bool isSequential() const override;
bool atEnd() const override; // ### Qt6: remove me
bool flush();
// for synchronous access