qmlengine.h 6.02 KB
Newer Older
1 2 3 4 5 6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
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.
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.
30 31 32 33 34 35
**
**************************************************************************/

#ifndef DEBUGGER_QMLENGINE_H
#define DEBUGGER_QMLENGINE_H

36
#include "debuggerengine.h"
37
#include <qmljsdebugclient/qdeclarativeenginedebug.h>
38
#include <qmljsdebugclient/qdebugmessageclient.h>
con's avatar
con committed
39
#include <utils/outputformat.h>
hjk's avatar
hjk committed
40

41
#include <QAbstractSocket>
42

hjk's avatar
hjk committed
43
QT_BEGIN_NAMESPACE
44
class QTextDocument;
hjk's avatar
hjk committed
45
QT_END_NAMESPACE
46 47 48 49 50

namespace Core {
class IEditor;
}

51
namespace Debugger {
52 53 54

class QmlAdapter;

55
namespace Internal {
56

57
class QtMessageLogItem;
Tobias Hunger's avatar
Tobias Hunger committed
58
class QmlEnginePrivate;
59

60
class QmlEngine : public DebuggerEngine
61 62 63 64
{
    Q_OBJECT

public:
65 66 67 68 69
    enum LogDirection {
        LogSend,
        LogReceive
    };

70 71
    QmlEngine(const DebuggerStartParameters &startParameters,
        DebuggerEngine *masterEngine);
72
    ~QmlEngine();
73

Christian Kandeler's avatar
Christian Kandeler committed
74
    void handleRemoteSetupDone(int gdbServerPort, int qmlPort);
75 76
    void handleRemoteSetupFailed(const QString &message);

77
    bool canDisplayTooltip() const;
78

79 80
    void showMessage(const QString &msg, int channel = LogDebug,
                     int timeout = -1) const;
81 82
    void gotoLocation(const Internal::Location &location);

83
    void filterApplicationMessage(const QString &msg, int channel);
84 85
    void inferiorSpontaneousStop();

86
    void logMessage(const QString &service, LogDirection direction, const QString &str);
87

88 89 90
    void setSourceFiles(const QStringList &fileNames);
    void updateScriptSource(const QString &fileName, int lineOffset, int columnOffset, const QString &source);

91 92
    QmlAdapter *adapter() const;

93 94
public slots:
    void disconnected();
95

96
private slots:
97
    void retryMessageBoxFinished(int result);
98
    void wrongSetupMessageBox(const QString &errorMessage);
99
    void wrongSetupMessageBoxFinished(int result);
100
    void updateCurrentContext();
101 102
    void appendDebugOutput(QtMsgType type, const QString &message,
                           const QmlJsDebugClient::QDebugContextInfo &info);
103

104
private:
105
    // DebuggerEngine implementation.
hjk's avatar
hjk committed
106
    bool isSynchronous() const { return false; }
107 108 109 110 111 112
    void executeStep();
    void executeStepOut();
    void executeNext();
    void executeStepI();
    void executeNextI();

hjk's avatar
hjk committed
113
    void setupEngine();
hjk's avatar
hjk committed
114 115 116 117 118
    void setupInferior();
    void runEngine();
    void shutdownInferior();
    void shutdownEngine();

119
    bool setToolTipExpression(const QPoint &mousePos,
120
        TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
121 122 123 124

    void continueInferior();
    void interruptInferior();

125
    void executeRunToLine(const ContextData &data);
126
    void executeRunToFunction(const QString &functionName);
127
    void executeJumpToLine(const ContextData &data);
128 129 130 131 132

    void activateFrame(int index);
    void selectThread(int index);

    void attemptBreakpointSynchronization();
133 134 135
    void insertBreakpoint(BreakpointModelId id);
    void removeBreakpoint(BreakpointModelId id);
    void changeBreakpoint(BreakpointModelId id);
136
    bool acceptsBreakpoint(BreakpointModelId id) const;
137

138
    void assignValueInDebugger(const WatchData *data,
hjk's avatar
hjk committed
139
        const QString &expr, const QVariant &value);
140 141


142 143 144 145 146
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();
    void requestModuleSymbols(const QString &moduleName);
    void reloadModules();
    void reloadRegisters() {}
147
    void reloadSourceFiles();
148 149
    void reloadFullStack() {}

Olivier Goffart's avatar
Olivier Goffart committed
150
    bool supportsThreads() const { return false; }
151 152
    void updateWatchData(const WatchData &data,
        const WatchUpdateFlags &flags);
hjk's avatar
hjk committed
153
    void executeDebuggerCommand(const QString &command);
154
    bool evaluateScriptExpression(const QString &expression);
155

156
    bool hasCapability(unsigned) const;
157

158
signals:
hjk's avatar
hjk committed
159 160
    void tooltipRequested(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
161

Lasse Holmstedt's avatar
Lasse Holmstedt committed
162
private slots:
163
    void beginConnection(quint16 port = 0);
Lasse Holmstedt's avatar
Lasse Holmstedt committed
164 165
    void connectionEstablished();
    void connectionStartupFailed();
166
    void connectionError(QAbstractSocket::SocketError error);
167
    void serviceConnectionError(const QString &service);
con's avatar
con committed
168
    void appendMessage(const QString &msg, Utils::OutputFormat);
Lasse Holmstedt's avatar
Lasse Holmstedt committed
169

170
    void synchronizeWatchers();
171 172
    void onDebugQueryStateChanged(
            QmlJsDebugClient::QDeclarativeDebugQuery::State state);
173

174
private:
175 176 177 178
    void closeConnection();
    void startApplicationLauncher();
    void stopApplicationLauncher();

179 180
    bool isShadowBuildProject() const;
    QString fromShadowBuildFilename(const QString &filename) const;
hjk's avatar
hjk committed
181 182
    QString mangleFilenamePaths(const QString &filename,
        const QString &oldBasePath, const QString &newBasePath) const;
183 184
    QString qmlImportPath() const;

185
    void updateEditor(Core::IEditor *editor, const QTextDocument *document);
186
    bool canEvaluateScript(const QString &script);
187 188
    QtMessageLogItem *constructLogItemTree(const QVariant &result,
                                           const QString &key = QString());
189

Lasse Holmstedt's avatar
Lasse Holmstedt committed
190
private:
191
    friend class QmlCppEngine;
hjk's avatar
hjk committed
192
    QmlEnginePrivate *d;
193 194
};

195
} // namespace Internal
196 197 198
} // namespace Debugger

#endif // DEBUGGER_QMLENGINE_H