diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-07-17 11:27:46 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-07-17 12:09:05 +0200 |
commit | 890bb77f82029eb7deb9f6560da383f09bf5b41e (patch) | |
tree | 54b09821820f7e36e42d52bf307e8f5a211cddc6 /src/plugins/qmljstools | |
parent | a6eefb1ae04f28277d14e8cad86b3a14b5dd1ba3 (diff) | |
download | qt-creator-890bb77f82029eb7deb9f6560da383f09bf5b41e.tar.gz |
Update the Qml working copy from the documents, not editors.
Unfortunately the language is still checked by using an editor property.
Change-Id: I3b54624e60b65c48b154c405f66d04b74be5be3e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/qmljstools')
-rw-r--r-- | src/plugins/qmljstools/qmljsmodelmanager.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index a93af2bf89..7b864263dc 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -39,7 +39,7 @@ #include <coreplugin/messagemanager.h> #include <cpptools/cppmodelmanagerinterface.h> #include <qmljs/qmljsbind.h> -#include <texteditor/basetexteditor.h> +#include <texteditor/basetextdocument.h> #include <projectexplorer/buildconfiguration.h> #include <projectexplorer/project.h> #include <projectexplorer/projectexplorer.h> @@ -55,6 +55,7 @@ #include <QFile> #include <QFileInfo> #include <utils/runextensions.h> +#include <QTextDocument> #include <QTextStream> #include <QTimer> #include <QRegExp> @@ -326,17 +327,13 @@ void ModelManager::loadQmlTypeDescriptions(const QString &resourcePath) ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const { WorkingCopy workingCopy; - if (!Core::ICore::instance()) - return workingCopy; - - foreach (Core::IEditor *editor, Core::ICore::editorManager()->openedEditors()) { - const QString key = editor->document()->filePath(); - - if (TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor)) { - if (textEditor->context().contains(ProjectExplorer::Constants::LANG_QMLJS)) { - if (TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(textEditor->widget())) - workingCopy.insert(key, ed->toPlainText(), ed->document()->revision()); - } + Core::DocumentModel *documentModel = Core::EditorManager::documentModel(); + foreach (Core::IDocument *document, documentModel->openedDocuments()) { + const QString key = document->filePath(); + if (TextEditor::BaseTextDocument *textDocument = qobject_cast<TextEditor::BaseTextDocument *>(document)) { + // TODO the language should be a property on the document, not the editor + if (documentModel->editorsForDocument(document).first()->context().contains(ProjectExplorer::Constants::LANG_QMLJS)) + workingCopy.insert(key, textDocument->contents(), textDocument->document()->revision()); } } |