diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-07-15 15:42:10 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-08-04 13:34:55 +0000 |
commit | 07f19d36347d69c330e092e3cb4fc351a8815d5c (patch) | |
tree | 621e882a9f11d8d89760e327e32d1a3574404394 /src/plugins/qmltooling/qmldbg_local | |
parent | 2f190e21c82c7b20f6cf1b9e5671316cd831f684 (diff) |
Remove pimpl from debug server connections
Now that they are self-contained plugins there is no reason for the
indirection anymore.
Change-Id: Ic2e2fe2075796c758057235e12981c8d40ce97c2
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_local')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp | 95 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h (renamed from src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.h) | 36 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro | 2 |
3 files changed, 55 insertions, 78 deletions
diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp index 993bafcf9f..057bf9523e 100644 --- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp +++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp @@ -31,7 +31,7 @@ ** ****************************************************************************/ -#include "qlocalclientconnection.h" +#include "qlocalclientconnectionfactory.h" #include "qpacketprotocol.h" #include "qqmldebugserver.h" @@ -40,25 +40,42 @@ QT_BEGIN_NAMESPACE -class QLocalClientConnectionPrivate { + +class QLocalClientConnection : public QQmlDebugServerConnection +{ + Q_OBJECT + Q_DISABLE_COPY(QLocalClientConnection) + public: - QLocalClientConnectionPrivate(); + QLocalClientConnection(); + ~QLocalClientConnection(); - bool block; - QString filename; - QLocalSocket *socket; - QQmlDebugServer *debugServer; -}; + void setServer(QQmlDebugServer *server); + bool setPortRange(int portFrom, int portTo, bool block, const QString &hostaddress); + bool setFileName(const QString &filename, bool block); -QLocalClientConnectionPrivate::QLocalClientConnectionPrivate() : - block(false), - socket(0), - debugServer(0) -{ -} + bool isConnected() const; + void disconnect(); + + void waitForConnection(); + void flush(); + +private slots: + void connectionEstablished(); + +private: + bool connectToServer(); + + bool m_block; + QString m_filename; + QLocalSocket *m_socket; + QQmlDebugServer *m_debugServer; +}; QLocalClientConnection::QLocalClientConnection() : - d_ptr(new QLocalClientConnectionPrivate) + m_block(false), + m_socket(0), + m_debugServer(0) { } @@ -66,30 +83,25 @@ QLocalClientConnection::~QLocalClientConnection() { if (isConnected()) disconnect(); - delete d_ptr; } void QLocalClientConnection::setServer(QQmlDebugServer *server) { - Q_D(QLocalClientConnection); - d->debugServer = server; + m_debugServer = server; } bool QLocalClientConnection::isConnected() const { - Q_D(const QLocalClientConnection); - return d->socket && d->socket->state() == QLocalSocket::ConnectedState; + return m_socket && m_socket->state() == QLocalSocket::ConnectedState; } void QLocalClientConnection::disconnect() { - Q_D(QLocalClientConnection); - - while (d->socket && d->socket->bytesToWrite() > 0) - d->socket->waitForBytesWritten(); + while (m_socket && m_socket->bytesToWrite() > 0) + m_socket->waitForBytesWritten(); - d->socket->deleteLater(); - d->socket = 0; + m_socket->deleteLater(); + m_socket = 0; } bool QLocalClientConnection::setPortRange(int portFrom, int portTo, bool block, @@ -104,42 +116,35 @@ bool QLocalClientConnection::setPortRange(int portFrom, int portTo, bool block, bool QLocalClientConnection::setFileName(const QString &filename, bool block) { - Q_D(QLocalClientConnection); - d->filename = filename; - d->block = block; + m_filename = filename; + m_block = block; return connectToServer(); } void QLocalClientConnection::waitForConnection() { - Q_D(QLocalClientConnection); - d->socket->waitForConnected(-1); + m_socket->waitForConnected(-1); } bool QLocalClientConnection::connectToServer() { - Q_D(QLocalClientConnection); - - d->socket = new QLocalSocket; - d->socket->setParent(this); - QObject::connect(d->socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); - d->socket->connectToServer(d->filename); - qDebug("QML Debugger: Connecting to socket %s...", - d->filename.toLatin1().constData()); + m_socket = new QLocalSocket; + m_socket->setParent(this); + QObject::connect(m_socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); + m_socket->connectToServer(m_filename); + qDebug("QML Debugger: Connecting to socket %s...", m_filename.toLatin1().constData()); return true; } void QLocalClientConnection::flush() { - Q_D(QLocalClientConnection); - if (d->socket) - d->socket->flush(); + if (m_socket) + m_socket->flush(); } void QLocalClientConnection::connectionEstablished() { - Q_D(QLocalClientConnection); - d->debugServer->setDevice(d->socket); + m_debugServer->setDevice(m_socket); } QQmlDebugServerConnection *QLocalClientConnectionFactory::create(const QString &key) @@ -148,3 +153,5 @@ QQmlDebugServerConnection *QLocalClientConnectionFactory::create(const QString & } QT_END_NAMESPACE + +#include "qlocalclientconnection.moc" diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.h b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h index 119f29921b..110e0c2395 100644 --- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.h +++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h @@ -31,43 +31,13 @@ ** ****************************************************************************/ -#ifndef QLOCALCLIENTCONNECTION_H -#define QLOCALCLIENTCONNECTION_H +#ifndef QLOCALCLIENTCONNECTIONFACTORY_H +#define QLOCALCLIENTCONNECTIONFACTORY_H #include "qqmldebugserverconnection.h" QT_BEGIN_NAMESPACE -class QLocalClientConnectionPrivate; -class QLocalClientConnection : public QObject, public QQmlDebugServerConnection -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QLocalClientConnection) - Q_DISABLE_COPY(QLocalClientConnection) - -public: - QLocalClientConnection(); - ~QLocalClientConnection(); - - void setServer(QQmlDebugServer *server); - bool setPortRange(int portFrom, int portTo, bool bock, const QString &hostaddress); - bool setFileName(const QString &filename, bool block); - - bool isConnected() const; - void disconnect(); - - void waitForConnection(); - void flush(); - -private Q_SLOTS: - void connectionEstablished(); - -private: - bool connectToServer(); - - QLocalClientConnectionPrivate *d_ptr; -}; - class QLocalClientConnectionFactory : public QQmlDebugServerConnectionFactory { Q_OBJECT @@ -79,4 +49,4 @@ public: QT_END_NAMESPACE -#endif // QLOCALCLIENTCONNECTION_H +#endif // QLOCALCLIENTCONNECTIONFACTORY_H diff --git a/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro b/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro index f190368441..491be04b15 100644 --- a/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro +++ b/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro @@ -9,7 +9,7 @@ SOURCES += \ $$PWD/qlocalclientconnection.cpp HEADERS += \ - $$PWD/qlocalclientconnection.h \ + $$PWD/qlocalclientconnectionfactory.h \ $$PWD/../shared/qqmldebugserver.h \ $$PWD/../shared/qqmldebugserverconnection.h |