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