Use new connect syntax
authorKurt Pattyn <pattyn.kurt@gmail.com>
Mon, 13 Jan 2014 10:20:39 +0000 (11:20 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 13 Jan 2014 10:21:36 +0000 (11:21 +0100)
Change-Id: Idd002ff72d27e5b549600704ae0e857bd021f5d1
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
src/imports/qmlwebsockets/qqmlwebsocket.cpp
src/websockets/qsslserver_p.cpp
src/websockets/qwebsocketserver_p.cpp

index f48b4b3..d2f1016 100644 (file)
@@ -168,9 +168,13 @@ void QQmlWebSocket::componentComplete()
 {
     m_webSocket.reset(new (std::nothrow) QWebSocket());
     if (Q_LIKELY(m_webSocket)) {
-        connect(m_webSocket.data(), SIGNAL(textMessageReceived(QString)), this, SIGNAL(textMessageReceived(QString)));
-        connect(m_webSocket.data(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onError(QAbstractSocket::SocketError)));
-        connect(m_webSocket.data(), SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(onStateChanged(QAbstractSocket::SocketState)));
+        connect(m_webSocket.data(), &QWebSocket::textMessageReceived,
+                this, &QQmlWebSocket::textMessageReceived);
+        typedef void (QWebSocket::* ErrorSignal)(QAbstractSocket::SocketError);
+        connect(m_webSocket.data(), static_cast<ErrorSignal>(&QWebSocket::error),
+                this, &QQmlWebSocket::onError);
+        connect(m_webSocket.data(), &QWebSocket::stateChanged,
+                this, &QQmlWebSocket::onStateChanged);
 
         m_componentCompleted = true;
 
index c4474d8..c5c2112 100644 (file)
@@ -74,11 +74,12 @@ void QSslServer::incomingConnection(qintptr socket)
         pSslSocket->setSslConfiguration(m_sslConfiguration);
 
         if (Q_LIKELY(pSslSocket->setSocketDescriptor(socket))) {
-            connect(pSslSocket, SIGNAL(peerVerifyError(QSslError)),
-                    this, SIGNAL(peerVerifyError(QSslError)));
-            connect(pSslSocket, SIGNAL(sslErrors(QList<QSslError>)),
-                    this, SIGNAL(sslErrors(QList<QSslError>)));
-            connect(pSslSocket, SIGNAL(encrypted()), this, SIGNAL(newEncryptedConnection()));
+            connect(pSslSocket, &QSslSocket::peerVerifyError, this, &QSslServer::peerVerifyError);
+
+            typedef void (QSslSocket::* sslErrorsSignal)(const QList<QSslError> &);
+            connect(pSslSocket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors),
+                    this, &QSslServer::sslErrors);
+            connect(pSslSocket, &QSslSocket::encrypted, this, &QSslServer::newEncryptedConnection);
 
             addPendingConnection(pSslSocket);
 
index 0eecd15..cb811c2 100644 (file)
@@ -77,7 +77,8 @@ QWebSocketServerPrivate::QWebSocketServerPrivate(const QString &serverName,
     if (m_secureMode == NON_SECURE_MODE) {
         m_pTcpServer = new QTcpServer(this);
         if (Q_LIKELY(m_pTcpServer))
-            connect(m_pTcpServer, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
+            connect(m_pTcpServer, &QTcpServer::newConnection,
+                    this, &QWebSocketServerPrivate::onNewConnection);
         else
             qFatal("Could not allocate memory for tcp server.");
     } else {
@@ -85,18 +86,18 @@ QWebSocketServerPrivate::QWebSocketServerPrivate(const QString &serverName,
         QSslServer *pSslServer = new QSslServer(this);
         m_pTcpServer = pSslServer;
         if (Q_LIKELY(m_pTcpServer)) {
-            connect(pSslServer, SIGNAL(newEncryptedConnection()), this, SLOT(onNewConnection()));
-            connect(pSslServer, SIGNAL(peerVerifyError(QSslError)), q_ptr,
-                    SIGNAL(peerVerifyError(QSslError)));
-            connect(pSslServer, SIGNAL(sslErrors(QList<QSslError>)), q_ptr,
-                    SIGNAL(sslErrors(QList<QSslError>)));
+            connect(pSslServer, &QSslServer::newEncryptedConnection,
+                    this, &QWebSocketServerPrivate::onNewConnection);
+            connect(pSslServer, &QSslServer::peerVerifyError,
+                    q_ptr, &QWebSocketServer::peerVerifyError);
+            connect(pSslServer, &QSslServer::sslErrors,
+                    q_ptr, &QWebSocketServer::sslErrors);
         }
 #else
         qFatal("SSL not supported on this platform.");
 #endif
     }
-    connect(m_pTcpServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), q_ptr,
-            SIGNAL(acceptError(QAbstractSocket::SocketError)));
+    connect(m_pTcpServer, &QTcpServer::acceptError, q_ptr, &QWebSocketServer::acceptError);
 }
 
 /*!
@@ -356,7 +357,7 @@ void QWebSocketServerPrivate::setError(QWebSocketProtocol::CloseCode code, QStri
 void QWebSocketServerPrivate::onNewConnection()
 {
     QTcpSocket *pTcpSocket = m_pTcpServer->nextPendingConnection();
-    connect(pTcpSocket, SIGNAL(readyRead()), this, SLOT(handshakeReceived()));
+    connect(pTcpSocket, &QTcpSocket::readyRead, this, &QWebSocketServerPrivate::handshakeReceived);
 }
 
 /*!
@@ -380,7 +381,8 @@ void QWebSocketServerPrivate::handshakeReceived()
         bool success = false;
         bool isSecure = false;
 
-        disconnect(pTcpSocket, SIGNAL(readyRead()), this, SLOT(handshakeReceived()));
+        disconnect(pTcpSocket, &QTcpSocket::readyRead,
+                   this, &QWebSocketServerPrivate::handshakeReceived);
 
         if (m_pendingConnections.length() >= maxPendingConnections()) {
             pTcpSocket->close();