qmladapter.h 3.68 KB
Newer Older
Lasse Holmstedt's avatar
Lasse Holmstedt committed
1 2 3 4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
Lasse Holmstedt's avatar
Lasse Holmstedt committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
Lasse Holmstedt's avatar
Lasse Holmstedt committed
8 9 10 11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
Lasse Holmstedt's avatar
Lasse Holmstedt committed
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
Lasse Holmstedt's avatar
Lasse Holmstedt committed
30 31 32
**
**************************************************************************/

hjk's avatar
hjk committed
33 34
#ifndef DEBGUGGER_QMLADAPTER_H
#define DEBGUGGER_QMLADAPTER_H
Lasse Holmstedt's avatar
Lasse Holmstedt committed
35 36

#include "debugger_global.h"
hjk's avatar
hjk committed
37
#include "qmldebuggerclient.h"
Lasse Holmstedt's avatar
Lasse Holmstedt committed
38

39 40
#include <QObject>
#include <QAbstractSocket>
41 42 43 44

namespace QmlJsDebugClient {
class QDeclarativeEngineDebug;
class QDeclarativeDebugConnection;
45
class QDebugMessageClient;
46
}
Lasse Holmstedt's avatar
Lasse Holmstedt committed
47 48

namespace Debugger {
49

Lasse Holmstedt's avatar
Lasse Holmstedt committed
50
class DebuggerEngine;
51 52

namespace Internal {
Lasse Holmstedt's avatar
Lasse Holmstedt committed
53
class QmlDebuggerClient;
hjk's avatar
hjk committed
54
class QmlAdapterPrivate;
55
} // namespace Internal
Lasse Holmstedt's avatar
Lasse Holmstedt committed
56 57 58 59

class DEBUGGER_EXPORT QmlAdapter : public QObject
{
    Q_OBJECT
hjk's avatar
hjk committed
60

Lasse Holmstedt's avatar
Lasse Holmstedt committed
61 62
public:
    explicit QmlAdapter(DebuggerEngine *engine, QObject *parent = 0);
63 64
    virtual ~QmlAdapter();

65 66
    void beginConnectionTcp(const QString &address, quint16 port);
    void beginConnectionOst(const QString &port);
67
    void closeConnection();
Lasse Holmstedt's avatar
Lasse Holmstedt committed
68 69 70

    bool isConnected() const;

71
    QmlJsDebugClient::QDeclarativeDebugConnection *connection() const;
72
    DebuggerEngine *debuggerEngine() const;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
73

74 75
    bool disableJsDebugging(bool block);

76 77 78
    Internal::QmlDebuggerClient *activeDebuggerClient();
    QHash<QString, Internal::QmlDebuggerClient*> debuggerClients();

79 80 81
    QmlJsDebugClient::QDeclarativeEngineDebug *engineDebugClient() const;
    void setEngineDebugClient(QmlJsDebugClient::QDeclarativeEngineDebug *client);

82 83
    QDebugMessageClient *messageClient() const;

84 85 86 87
    int currentSelectedDebugId() const;
    QString currentSelectedDisplayName() const;
    void setCurrentSelectedDebugInfo(int debugId, const QString &displayName = QString());

88 89 90
public slots:
    void logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus);    
    void logServiceActivity(const QString &service, const QString &logMessage);
91

Lasse Holmstedt's avatar
Lasse Holmstedt committed
92 93 94 95
signals:
    void connected();
    void disconnected();
    void connectionStartupFailed();
96
    void connectionError(QAbstractSocket::SocketError socketError);
97
    void serviceConnectionError(const QString serviceName);
98
    void selectionChanged();
Lasse Holmstedt's avatar
Lasse Holmstedt committed
99 100

private slots:
101
    void connectionErrorOccurred(QAbstractSocket::SocketError socketError);
102
    void clientStatusChanged(QDeclarativeDebugClient::Status status);
103
    void debugClientStatusChanged(QDeclarativeDebugClient::Status status);
Lasse Holmstedt's avatar
Lasse Holmstedt committed
104
    void connectionStateChanged();
105
    void checkConnectionState();
Lasse Holmstedt's avatar
Lasse Holmstedt committed
106 107

private:
108
    void createDebuggerClients();
Lasse Holmstedt's avatar
Lasse Holmstedt committed
109 110 111 112
    void showConnectionStatusMessage(const QString &message);
    void showConnectionErrorMessage(const QString &message);

private:
hjk's avatar
hjk committed
113
    Internal::QmlAdapterPrivate *d;
Lasse Holmstedt's avatar
Lasse Holmstedt committed
114 115 116 117
};

} // namespace Debugger

hjk's avatar
hjk committed
118
#endif // DEBGUGGER_QMLADAPTER_H