Commit c0e7cc85 authored by Eike Ziller's avatar Eike Ziller

Find: Document contents should be retrieved from the documents directly

Instead of through an arbitrary set of editors on these documents.

Change-Id: I9de731b6e6edfc52fe5199b1f47456a3a8701d9a
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 7808266f
...@@ -85,7 +85,7 @@ Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFi ...@@ -85,7 +85,7 @@ Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFi
foreach (const QString &filter, nameFilters) { foreach (const QString &filter, nameFilters) {
filterRegs << QRegExp(filter, Qt::CaseInsensitive, QRegExp::Wildcard); filterRegs << QRegExp(filter, Qt::CaseInsensitive, QRegExp::Wildcard);
} }
QMap<QString, QTextCodec *> openEditorEncodings = TextEditor::ITextEditor::openedTextEditorsEncodings(); QMap<QString, QTextCodec *> openEditorEncodings = TextEditor::ITextEditor::openedTextDocumentEncodings();
QMap<QString, QTextCodec *> encodings; QMap<QString, QTextCodec *> encodings;
foreach (const Project *project, projects) { foreach (const Project *project, projects) {
QStringList projectFiles = project->files(Project::AllFiles); QStringList projectFiles = project->files(Project::AllFiles);
......
...@@ -173,12 +173,12 @@ void BaseFileFind::runSearch(Find::SearchResult *search) ...@@ -173,12 +173,12 @@ void BaseFileFind::runSearch(Find::SearchResult *search)
watcher->setFuture(Utils::findInFilesRegExp(parameters.text, watcher->setFuture(Utils::findInFilesRegExp(parameters.text,
files(parameters.nameFilters, parameters.additionalParameters), files(parameters.nameFilters, parameters.additionalParameters),
textDocumentFlagsForFindFlags(parameters.flags), textDocumentFlagsForFindFlags(parameters.flags),
ITextEditor::openedTextEditorsContents())); ITextEditor::openedTextDocumentContents()));
} else { } else {
watcher->setFuture(Utils::findInFiles(parameters.text, watcher->setFuture(Utils::findInFiles(parameters.text,
files(parameters.nameFilters, parameters.additionalParameters), files(parameters.nameFilters, parameters.additionalParameters),
textDocumentFlagsForFindFlags(parameters.flags), textDocumentFlagsForFindFlags(parameters.flags),
ITextEditor::openedTextEditorsContents())); ITextEditor::openedTextDocumentContents()));
} }
Core::FutureProgress *progress = Core::FutureProgress *progress =
Core::ICore::progressManager()->addTask(watcher->future(), Core::ICore::progressManager()->addTask(watcher->future(),
......
...@@ -64,7 +64,7 @@ Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters, ...@@ -64,7 +64,7 @@ Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters,
{ {
Q_UNUSED(nameFilters) Q_UNUSED(nameFilters)
QString fileName = additionalParameters.toString(); QString fileName = additionalParameters.toString();
QMap<QString, QTextCodec *> openEditorEncodings = ITextEditor::openedTextEditorsEncodings(); QMap<QString, QTextCodec *> openEditorEncodings = ITextEditor::openedTextDocumentEncodings();
QTextCodec *codec = openEditorEncodings.value(fileName); QTextCodec *codec = openEditorEncodings.value(fileName);
if (!codec) if (!codec)
codec = Core::EditorManager::instance()->defaultTextCodec(); codec = Core::EditorManager::instance()->defaultTextCodec();
......
...@@ -64,7 +64,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters, ...@@ -64,7 +64,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
{ {
Q_UNUSED(nameFilters) Q_UNUSED(nameFilters)
Q_UNUSED(additionalParameters) Q_UNUSED(additionalParameters)
QMap<QString, QTextCodec *> openEditorEncodings = ITextEditor::openedTextEditorsEncodings(); QMap<QString, QTextCodec *> openEditorEncodings = ITextEditor::openedTextDocumentEncodings();
QStringList fileNames; QStringList fileNames;
QList<QTextCodec *> codecs; QList<QTextCodec *> codecs;
foreach (Core::DocumentModel::Entry *entry, foreach (Core::DocumentModel::Entry *entry,
......
...@@ -38,28 +38,28 @@ ITextEditorDocument::ITextEditorDocument(QObject *parent) ...@@ -38,28 +38,28 @@ ITextEditorDocument::ITextEditorDocument(QObject *parent)
{ {
} }
QMap<QString, QString> ITextEditor::openedTextEditorsContents() QMap<QString, QString> ITextEditor::openedTextDocumentContents()
{ {
QMap<QString, QString> workingCopy; QMap<QString, QString> workingCopy;
foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors()) { foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor); ITextEditorDocument *textEditorDocument = qobject_cast<ITextEditorDocument *>(document);
if (!textEditor) if (!textEditorDocument)
continue; continue;
QString fileName = textEditor->document()->filePath(); QString fileName = textEditorDocument->filePath();
workingCopy[fileName] = textEditor->textDocument()->contents(); workingCopy[fileName] = textEditorDocument->contents();
} }
return workingCopy; return workingCopy;
} }
QMap<QString, QTextCodec *> TextEditor::ITextEditor::openedTextEditorsEncodings() QMap<QString, QTextCodec *> TextEditor::ITextEditor::openedTextDocumentEncodings()
{ {
QMap<QString, QTextCodec *> workingCopy; QMap<QString, QTextCodec *> workingCopy;
foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors()) { foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor); ITextEditorDocument *textEditorDocument = qobject_cast<ITextEditorDocument *>(document);
if (!textEditor) if (!textEditorDocument)
continue; continue;
QString fileName = textEditor->document()->filePath(); QString fileName = textEditorDocument->filePath();
workingCopy[fileName] = const_cast<QTextCodec *>(textEditor->textDocument()->codec()); workingCopy[fileName] = const_cast<QTextCodec *>(textEditorDocument->codec());
} }
return workingCopy; return workingCopy;
} }
......
...@@ -111,8 +111,8 @@ public: ...@@ -111,8 +111,8 @@ public:
virtual const Utils::CommentDefinition* commentDefinition() const = 0; virtual const Utils::CommentDefinition* commentDefinition() const = 0;
static QMap<QString, QString> openedTextEditorsContents(); static QMap<QString, QString> openedTextDocumentContents();
static QMap<QString, QTextCodec *> openedTextEditorsEncodings(); static QMap<QString, QTextCodec *> openedTextDocumentEncodings();
enum MarkRequestKind { enum MarkRequestKind {
BreakpointRequest, BreakpointRequest,
......
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