Commit 19b539c9 authored by Aurindam Jana's avatar Aurindam Jana

Debugging: Reload Script Scources

Update open editors when internal sources are reloaded.

Change-Id: If0780ac5fbbcd2a19c95dd5647d47cb70a9135e0
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent a2d5cb35
......@@ -349,8 +349,6 @@ void QmlEngine::gotoLocation(const Location &location)
if (QUrl(fileName).scheme().compare(QLatin1String("file"), Qt::CaseInsensitive) == 0) {
// internal file from source files -> show generated .js
QTC_ASSERT(d->m_sourceDocuments.contains(fileName), return);
const QString jsSource = d->m_sourceDocuments.value(fileName)->toPlainText();
Core::IEditor *editor = 0;
Core::EditorManager *editorManager = Core::EditorManager::instance();
......@@ -369,19 +367,11 @@ void QmlEngine::gotoLocation(const Location &location)
if (editor) {
editor->setProperty(Constants::OPENED_BY_DEBUGGER, true);
}
}
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
if (!textEditor)
return;
QPlainTextEdit *plainTextEdit =
qobject_cast<QPlainTextEdit *>(editor->widget());
if (!plainTextEdit)
return;
plainTextEdit->setPlainText(jsSource);
plainTextEdit->setReadOnly(true);
updateEditor(editor, d->m_sourceDocuments.value(fileName));
}
editorManager->activateEditor(editor);
} else {
DebuggerEngine::gotoLocation(location);
}
......@@ -865,6 +855,8 @@ void QmlEngine::setSourceFiles(const QStringList &fileNames)
}
sourceFilesHandler()->setSourceFiles(files);
//update open editors
}
void QmlEngine::updateScriptSource(const QString &fileName, int lineOffset, int columnOffset,
......@@ -908,6 +900,31 @@ void QmlEngine::updateScriptSource(const QString &fileName, int lineOffset, int
if (!cursor.movePosition(QTextCursor::NextBlock))
cursor.insertBlock();
}
//update open editors
QString titlePattern = tr("JS Source for %1").arg(fileName);
//Check if there are open editors with the same title
QList<Core::IEditor *> editors = Core::EditorManager::instance()->openedEditors();
foreach (Core::IEditor *editor, editors) {
if (editor->displayName() == titlePattern) {
updateEditor(editor, document);
break;
}
}
}
void QmlEngine::updateEditor(Core::IEditor *editor, const QTextDocument *document)
{
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
if (!textEditor)
return;
QPlainTextEdit *plainTextEdit =
qobject_cast<QPlainTextEdit *>(editor->widget());
if (!plainTextEdit)
return;
plainTextEdit->setPlainText(document->toPlainText());
plainTextEdit->setReadOnly(true);
}
QmlAdapter *QmlEngine::adapter() const
......
......@@ -39,6 +39,12 @@
#include <QtNetwork/QAbstractSocket>
class QTextDocument;
namespace Core {
class IEditor;
}
namespace Debugger {
class QmlAdapter;
......@@ -167,6 +173,8 @@ private:
const QString &oldBasePath, const QString &newBasePath) const;
QString qmlImportPath() const;
void updateEditor(Core::IEditor *editor, const QTextDocument *document);
private:
friend class QmlCppEngine;
QmlEnginePrivate *d;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment