qmlengine.h 6.26 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/qdebugmessageclient.h>
con's avatar
con committed
38
#include <utils/outputformat.h>
39
#include <qmljs/qmljsdocument.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 DEBUGGER_EXPORT 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
    void insertBreakpoint(BreakpointModelId id);

95 96
public slots:
    void disconnected();
97
    void documentUpdated(QmlJS::Document::Ptr doc);
98
    void expressionEvaluated(quint32 queryId, const QVariant &result);
99

100
private slots:
101
    void errorMessageBoxFinished(int result);
102
    void updateCurrentContext();
103 104
    void appendDebugOutput(QtMsgType type, const QString &message,
                           const QmlJsDebugClient::QDebugContextInfo &info);
105

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

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

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

    void continueInferior();
    void interruptInferior();

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

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

    void attemptBreakpointSynchronization();
135 136
    void removeBreakpoint(BreakpointModelId id);
    void changeBreakpoint(BreakpointModelId id);
137
    bool acceptsBreakpoint(BreakpointModelId id) const;
138

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


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

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

157
    bool hasCapability(unsigned) const;
158

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

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

173 174
    void synchronizeWatchers();

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

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

186
    void updateEditor(Core::IEditor *editor, const QTextDocument *document);
187
    bool canEvaluateScript(const QString &script);
Aurindam Jana's avatar
Aurindam Jana committed
188 189
    QtMessageLogItem *constructLogItemTree(QtMessageLogItem *parent,
                                           const QVariant &result,
190
                                           const QString &key = QString());
191 192
    bool adjustBreakpointLineAndColumn(const QString &filePath, quint32 *line,
                                       quint32 *column, bool *valid);
193

Lasse Holmstedt's avatar
Lasse Holmstedt committed
194
private:
195
    friend class QmlCppEngine;
hjk's avatar
hjk committed
196
    QmlEnginePrivate *d;
197 198
};

199
} // namespace Internal
200 201 202
} // namespace Debugger

#endif // DEBUGGER_QMLENGINE_H