summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/coreplugin/editormanager/documentmodel.cpp10
-rw-r--r--src/plugins/coreplugin/editormanager/documentmodel.h2
-rw-r--r--src/plugins/debugger/qml/qmlv8debuggerclient.cpp58
3 files changed, 36 insertions, 34 deletions
diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp
index f4191105fd..f4eb1fef3a 100644
--- a/src/plugins/coreplugin/editormanager/documentmodel.cpp
+++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp
@@ -163,7 +163,7 @@ void DocumentModel::addEntry(Entry *entry)
QString fileName = entry->fileName();
// replace a non-loaded entry (aka 'restored') if possible
- int previousIndex = indexofFileName(fileName);
+ int previousIndex = indexOfFilePath(fileName);
if (previousIndex >= 0) {
if (entry->document && d->m_documents.at(previousIndex)->document == 0) {
Entry *previousEntry = d->m_documents.at(previousIndex);
@@ -190,12 +190,12 @@ void DocumentModel::addEntry(Entry *entry)
endInsertRows();
}
-int DocumentModel::indexofFileName(const QString &filename) const
+int DocumentModel::indexOfFilePath(const QString &filePath) const
{
- if (filename.isEmpty())
+ if (filePath.isEmpty())
return -1;
for (int i = 0; i < d->m_documents.count(); ++i) {
- if (d->m_documents.at(i)->fileName() == filename)
+ if (d->m_documents.at(i)->fileName() == filePath)
return i;
}
return -1;
@@ -226,7 +226,7 @@ void DocumentModel::removeEditor(IEditor *editor, bool *lastOneForDocument)
void DocumentModel::removeDocument(const QString &fileName)
{
- int index = indexofFileName(fileName);
+ int index = indexOfFilePath(fileName);
QTC_ASSERT(!d->m_documents.at(index)->document, return); // we wouldn't know what to do with the associated editors
removeDocument(index);
}
diff --git a/src/plugins/coreplugin/editormanager/documentmodel.h b/src/plugins/coreplugin/editormanager/documentmodel.h
index e2e5c309c6..929298d16f 100644
--- a/src/plugins/coreplugin/editormanager/documentmodel.h
+++ b/src/plugins/coreplugin/editormanager/documentmodel.h
@@ -77,6 +77,7 @@ public:
int documentCount() const;
QList<Entry *> documents() const;
int indexOfDocument(IDocument *document) const;
+ int indexOfFilePath(const QString &filePath) const;
Entry *entryForDocument(IDocument *document) const;
QList<IDocument *> openedDocuments() const;
@@ -98,7 +99,6 @@ private slots:
private:
void addEntry(Entry *entry);
- int indexofFileName(const QString &filename) const;
void removeDocument(int idx);
DocumentModelPrivate *d;
diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
index 02b10ea546..361d83d081 100644
--- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
+++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
@@ -1993,50 +1993,52 @@ void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber,
const QString &filePath,
const QString &errorMessage)
{
- EditorManager *editorManager = EditorManager::instance();
- QList<IEditor *> openedEditors = editorManager->openedEditors();
+ DocumentModel *documentModel = EditorManager::documentModel();
+ int index = documentModel->indexOfFilePath(filePath);
+ if (index < 0 || !documentModel->documents().at(index)->document)
+ return;
+ QList<IEditor *> editors = documentModel->editorsForDocument(
+ documentModel->documents().at(index)->document);
// set up the format for the errors
QTextCharFormat errorFormat;
errorFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
errorFormat.setUnderlineColor(Qt::red);
- foreach (IEditor *editor, openedEditors) {
- if (editor->document()->filePath() == filePath) {
- TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
- if (!ed)
- continue;
+ foreach (IEditor *editor, editors) {
+ TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
+ if (!ed)
+ continue;
- QList<QTextEdit::ExtraSelection> selections;
- QTextEdit::ExtraSelection sel;
- sel.format = errorFormat;
- QTextCursor c(ed->document()->findBlockByNumber(lineNumber - 1));
- const QString text = c.block().text();
- for (int i = 0; i < text.size(); ++i) {
- if (! text.at(i).isSpace()) {
- c.setPosition(c.position() + i);
- break;
- }
+ QList<QTextEdit::ExtraSelection> selections;
+ QTextEdit::ExtraSelection sel;
+ sel.format = errorFormat;
+ QTextCursor c(ed->document()->findBlockByNumber(lineNumber - 1));
+ const QString text = c.block().text();
+ for (int i = 0; i < text.size(); ++i) {
+ if (! text.at(i).isSpace()) {
+ c.setPosition(c.position() + i);
+ break;
}
- c.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
- sel.cursor = c;
+ }
+ c.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+ sel.cursor = c;
- sel.format.setToolTip(errorMessage);
+ sel.format.setToolTip(errorMessage);
- selections.append(sel);
- ed->setExtraSelections(TextEditor::BaseTextEditorWidget::DebuggerExceptionSelection, selections);
+ selections.append(sel);
+ ed->setExtraSelections(TextEditor::BaseTextEditorWidget::DebuggerExceptionSelection, selections);
- QString message = QString(_("%1: %2: %3")).arg(filePath).arg(lineNumber)
- .arg(errorMessage);
- d->engine->showMessage(message, ConsoleOutput);
- }
+ QString message = QString(_("%1: %2: %3")).arg(filePath).arg(lineNumber)
+ .arg(errorMessage);
+ d->engine->showMessage(message, ConsoleOutput);
}
}
void QmlV8DebuggerClient::clearExceptionSelection()
{
- EditorManager *editorManager = EditorManager::instance();
- QList<IEditor *> openedEditors = editorManager->openedEditors();
+ DocumentModel *documentModel = EditorManager::documentModel();
+ QList<IEditor *> openedEditors = documentModel->editorsForDocuments(documentModel->openedDocuments());
QList<QTextEdit::ExtraSelection> selections;
foreach (IEditor *editor, openedEditors) {