Commit a2d5cb35 authored by Aurindam Jana's avatar Aurindam Jana
Browse files

QmlEngine: Source Files



Check for open editors with same display name before creating
a new editor to show the internal sources.

Change-Id: I53b365fb6c29d33922936bb4eb4dfb9476d5978e
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 4ebc7a30
......@@ -348,23 +348,27 @@ void QmlEngine::gotoLocation(const Location &location)
// TODO: QUrl::isLocalFile() once we depend on Qt 4.8
if (QUrl(fileName).scheme().compare(QLatin1String("file"), Qt::CaseInsensitive) == 0) {
// internal file from source files -> show generated .js
QString fileName = location.fileName();
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();
QList<Core::IEditor *> editors = editorManager->editorsForFileName(location.fileName());
if (editors.isEmpty()) {
QString titlePattern = tr("JS Source for %1").arg(fileName);
//Check if there are open editors with the same title
QList<Core::IEditor *> editors = editorManager->openedEditors();
foreach (Core::IEditor *ed, editors) {
if (ed->displayName() == titlePattern) {
editor = ed;
break;
}
}
if (!editor) {
editor = editorManager->openEditorWithContents(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
&titlePattern);
if (editor) {
editor->setProperty(Constants::OPENED_BY_DEBUGGER, true);
}
} else {
editor = editors.back();
}
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
......
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