qmlengine.h 5.42 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 37
#include "debuggerengine.h"

con's avatar
con committed
38
#include <utils/outputformat.h>
hjk's avatar
hjk committed
39

40
#include <QtNetwork/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

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

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

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

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

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

75
    bool canDisplayTooltip() const;
76

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

81
    void filterApplicationMessage(const QString &msg, int channel);
82 83 84
    QString toFileInProject(const QUrl &fileUrl);
    void inferiorSpontaneousStop();

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

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

90 91
    QmlAdapter *adapter() const;

92 93
public slots:
    void disconnected();
94

95
private slots:
96
    void retryMessageBoxFinished(int result);
97
    void wrongSetupMessageBox(const QString &errorMessage);
98
    void wrongSetupMessageBoxFinished(int result);
99

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

hjk's avatar
hjk committed
109
    void setupEngine();
hjk's avatar
hjk committed
110 111 112 113 114
    void setupInferior();
    void runEngine();
    void shutdownInferior();
    void shutdownEngine();

115
    bool setToolTipExpression(const QPoint &mousePos,
116
        TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
117 118 119 120

    void continueInferior();
    void interruptInferior();

121
    void executeRunToLine(const ContextData &data);
122
    void executeRunToFunction(const QString &functionName);
123
    void executeJumpToLine(const ContextData &data);
124 125 126 127 128

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

    void attemptBreakpointSynchronization();
129 130 131
    void insertBreakpoint(BreakpointModelId id);
    void removeBreakpoint(BreakpointModelId id);
    void changeBreakpoint(BreakpointModelId id);
132
    bool acceptsBreakpoint(BreakpointModelId id) const;
133

134
    void assignValueInDebugger(const WatchData *data,
hjk's avatar
hjk committed
135
        const QString &expr, const QVariant &value);
136 137


138 139 140 141 142
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();
    void requestModuleSymbols(const QString &moduleName);
    void reloadModules();
    void reloadRegisters() {}
143
    void reloadSourceFiles();
144 145
    void reloadFullStack() {}

Olivier Goffart's avatar
Olivier Goffart committed
146
    bool supportsThreads() const { return false; }
147 148
    void updateWatchData(const WatchData &data,
        const WatchUpdateFlags &flags);
hjk's avatar
hjk committed
149
    void executeDebuggerCommand(const QString &command);
150

151 152
    unsigned int debuggerCapabilities() const;

153
signals:
hjk's avatar
hjk committed
154 155
    void tooltipRequested(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
156

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

165 166
    void synchronizeWatchers();

167
private:
168 169 170 171
    void closeConnection();
    void startApplicationLauncher();
    void stopApplicationLauncher();

172 173
    bool isShadowBuildProject() const;
    QString fromShadowBuildFilename(const QString &filename) const;
hjk's avatar
hjk committed
174 175
    QString mangleFilenamePaths(const QString &filename,
        const QString &oldBasePath, const QString &newBasePath) const;
176 177
    QString qmlImportPath() const;

178 179
    void updateEditor(Core::IEditor *editor, const QTextDocument *document);

Lasse Holmstedt's avatar
Lasse Holmstedt committed
180
private:
181
    friend class QmlCppEngine;
hjk's avatar
hjk committed
182
    QmlEnginePrivate *d;
183 184
};

185
} // namespace Internal
186 187 188
} // namespace Debugger

#endif // DEBUGGER_QMLENGINE_H