OSDN Git Service

remove the client/server mode of designer
authorIvailo Monev <xakepa10@laimg.moc>
Sun, 16 Oct 2016 18:56:27 +0000 (18:56 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Sun, 16 Oct 2016 18:56:27 +0000 (18:56 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/tools/designer/CMakeLists.txt
src/tools/designer/qdesigner.cpp
src/tools/designer/qdesigner.h
src/tools/designer/qdesigner_server.cpp [deleted file]
src/tools/designer/qdesigner_server.h [deleted file]

index 8746fd7..6dae58e 100644 (file)
@@ -38,7 +38,6 @@ set(DESIGNERBIN_HEADERS
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_workbench.h
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_settings.h
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_actions.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_server.h
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_appearanceoptions.h
     ${CMAKE_CURRENT_SOURCE_DIR}/saveformastemplate.h
     ${CMAKE_CURRENT_SOURCE_DIR}/newform.h
@@ -59,7 +58,6 @@ set(DESIGNERBIN_SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_formwindow.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_workbench.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_settings.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_server.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_actions.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/qdesigner_appearanceoptions.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/saveformastemplate.cpp
index 043463e..c0a890b 100644 (file)
@@ -42,7 +42,6 @@
 // designer
 #include "qdesigner.h"
 #include "qdesigner_actions.h"
-#include "qdesigner_server.h"
 #include "qdesigner_settings.h"
 #include "qdesigner_workbench.h"
 #include "mainwindow.h"
@@ -85,8 +84,6 @@ static void designerMessageHandler(QtMsgType type, const char *msg)
 
 QDesigner::QDesigner(int &argc, char **argv)
     : QApplication(argc, argv),
-      m_server(0),
-      m_client(0),
       m_workbench(0), m_suppressNewFormShow(false)
 {
     setOrganizationName(QLatin1String("Trolltech"));
@@ -101,10 +98,6 @@ QDesigner::~QDesigner()
 {
     if (m_workbench)
         delete m_workbench;
-    if (m_server)
-        delete m_server;
-    if (m_client)
-        delete m_client;
 }
 
 void QDesigner::showErrorMessage(const char *message)
@@ -150,11 +143,6 @@ QDesignerWorkbench *QDesigner::workbench() const
     return m_workbench;
 }
 
-QDesignerServer *QDesigner::server() const
-{
-    return m_server;
-}
-
 bool QDesigner::parseCommandLineArgs(QStringList &fileNames, QString &resourceDir)
 {
     const QStringList args = arguments();
@@ -170,27 +158,6 @@ bool QDesigner::parseCommandLineArgs(QStringList &fileNames, QString &resourceDi
                 break;
             }
             // Options
-            if (argument == QLatin1String("-server")) {
-                m_server = new QDesignerServer();
-                printf("%d\n", m_server->serverPort());
-                fflush(stdout);
-                break;
-            }
-            if (argument == QLatin1String("-client")) {
-                bool ok = true;
-                if (++it == acend) {
-                    qWarning("** WARNING The option -client requires an argument");
-                    return false;
-                }
-                const quint16 port = it->toUShort(&ok);
-                if (ok) {
-                    m_client = new QDesignerClient(port, this);
-                } else {
-                    qWarning("** WARNING Non-numeric argument specified for -client");
-                    return false;
-                }
-                break;
-            }
             if (argument == QLatin1String("-resourcedir")) {
                 if (++it == acend) {
                     qWarning("** WARNING The option -resourcedir requires an argument");
index 37bf872..7844c2c 100644 (file)
@@ -53,8 +53,6 @@ QT_BEGIN_NAMESPACE
 class QDesignerWorkbench;
 class QDesignerToolWindow;
 class MainWindowBase;
-class QDesignerServer;
-class QDesignerClient;
 class QErrorMessage;
 
 class QDesigner: public QApplication
@@ -65,7 +63,6 @@ public:
     virtual ~QDesigner();
 
     QDesignerWorkbench *workbench() const;
-    QDesignerServer *server() const;
     MainWindowBase *mainWindow() const;
     void setMainWindow(MainWindowBase *tw);
 
@@ -86,8 +83,6 @@ private:
     bool parseCommandLineArgs(QStringList &fileNames, QString &resourceDir);
     void showErrorMessageBox(const QString &);
 
-    QDesignerServer *m_server;
-    QDesignerClient *m_client;
     QDesignerWorkbench *m_workbench;
     QPointer<MainWindowBase> m_mainWindow;
     QPointer<QErrorMessage> m_errorMessageDialog;
diff --git a/src/tools/designer/qdesigner_server.cpp b/src/tools/designer/qdesigner_server.cpp
deleted file mode 100644 (file)
index 52a6107..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Designer of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/QFileInfo>
-#include <QtCore/QStringList>
-
-#include <QtNetwork/QHostAddress>
-#include <QtNetwork/QTcpServer>
-#include <QtNetwork/QTcpSocket>
-
-#include "qdesigner.h"
-#include "qdesigner_server.h"
-
-#include <qevent.h>
-
-QT_BEGIN_NAMESPACE
-
-// ### review
-
-QDesignerServer::QDesignerServer(QObject *parent)
-    : QObject(parent)
-{
-    m_socket = 0;
-    m_server = new QTcpServer(this);
-    m_server->listen(QHostAddress::LocalHost, 0);
-    if (m_server->isListening())
-    {
-        connect(m_server, SIGNAL(newConnection()),
-                this, SLOT(handleNewConnection()));
-    }
-}
-
-QDesignerServer::~QDesignerServer()
-{
-}
-
-quint16 QDesignerServer::serverPort() const
-{
-    return m_server ? m_server->serverPort() : 0;
-}
-
-void QDesignerServer::sendOpenRequest(int port, const QStringList &files)
-{
-    QTcpSocket *sSocket = new QTcpSocket();
-    sSocket->connectToHost(QHostAddress::LocalHost, port);
-    if(sSocket->waitForConnected(3000))
-    {
-        foreach(const QString &file, files)
-        {
-            QFileInfo fi(file);
-            sSocket->write(fi.absoluteFilePath().toUtf8() + '\n');
-        }
-        sSocket->waitForBytesWritten(3000);
-        sSocket->close();
-    }
-    delete sSocket;
-}
-
-void QDesignerServer::readFromClient()
-{
-    while (m_socket->canReadLine()) {
-        QString file = QString::fromUtf8(m_socket->readLine());
-        if (!file.isNull()) {
-            file.remove(QLatin1Char('\n'));
-            file.remove(QLatin1Char('\r'));
-            qDesigner->postEvent(qDesigner, new QFileOpenEvent(file));
-        }
-    }
-}
-
-void QDesignerServer::socketClosed()
-{
-    m_socket = 0;
-}
-
-void QDesignerServer::handleNewConnection()
-{
-    // no need for more than one connection
-    if (m_socket == 0) {
-        m_socket = m_server->nextPendingConnection();
-        connect(m_socket, SIGNAL(readyRead()),
-                this, SLOT(readFromClient()));
-        connect(m_socket, SIGNAL(disconnected()),
-                this, SLOT(socketClosed()));
-    }
-}
-
-
-QDesignerClient::QDesignerClient(quint16 port, QObject *parent)
-: QObject(parent)
-{
-    m_socket = new QTcpSocket(this);
-    m_socket->connectToHost(QHostAddress::LocalHost, port);
-    connect(m_socket, SIGNAL(readyRead()),
-                this, SLOT(readFromSocket()));
-}
-
-QDesignerClient::~QDesignerClient()
-{
-    m_socket->close();
-    m_socket->flush();
-}
-
-void QDesignerClient::readFromSocket()
-{
-    while (m_socket->canReadLine()) {
-        QString file = QString::fromUtf8(m_socket->readLine());
-        if (!file.isNull()) {
-            file.remove(QLatin1Char('\n'));
-            file.remove(QLatin1Char('\r'));
-            if (QFile::exists(file))
-                qDesigner->postEvent(qDesigner, new QFileOpenEvent(file));
-        }
-    }
-}
-
-QT_END_NAMESPACE
-#include <moc_qdesigner_server.h>
diff --git a/src/tools/designer/qdesigner_server.h b/src/tools/designer/qdesigner_server.h
deleted file mode 100644 (file)
index 8b9ec51..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Designer of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDESIGNER_SERVER_H
-#define QDESIGNER_SERVER_H
-
-#include <QtCore/QObject>
-
-QT_BEGIN_NAMESPACE
-
-class QTcpServer;
-class QTcpSocket;
-
-class QDesignerServer: public QObject
-{
-    Q_OBJECT
-public:
-    explicit QDesignerServer(QObject *parent = 0);
-    virtual ~QDesignerServer();
-
-    quint16 serverPort() const;
-
-    static void sendOpenRequest(int port, const QStringList &files);
-
-private slots:
-    void handleNewConnection();
-    void readFromClient();
-    void socketClosed();
-
-private:
-    QTcpServer *m_server;
-    QTcpSocket *m_socket;
-};
-
-class QDesignerClient: public QObject
-{
-    Q_OBJECT
-public:
-    explicit QDesignerClient(quint16 port, QObject *parent = 0);
-    virtual ~QDesignerClient();
-
-private slots:
-    void readFromSocket();
-
-private:
-    QTcpSocket *m_socket;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDESIGNER_SERVER_H