qmlengine.h 5.93 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>
con's avatar
con committed
38
#include <utils/outputformat.h>
hjk's avatar
hjk committed
39

40
#include <QAbstractSocket>
41

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

namespace Core {
class IEditor;
}

50
namespace Debugger {
51 52 53

class QmlAdapter;

54
namespace Internal {
55

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

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

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

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

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

76
    bool canDisplayTooltip() const;
77

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

82
    void filterApplicationMessage(const QString &msg, int channel);
83 84 85
    QString toFileInProject(const QUrl &fileUrl);
    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 101
    void updateCurrentContext();
    void appendDebugOutput(QtMsgType type, const QString &message);
102

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

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

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

    void continueInferior();
    void interruptInferior();

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

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

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

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


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

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

155
    bool hasCapability(unsigned) const;
156

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

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

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

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

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

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

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

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

#endif // DEBUGGER_QMLENGINE_H