diff options
| author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2023-05-05 14:05:10 +0200 |
|---|---|---|
| committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2023-05-09 11:03:48 +0000 |
| commit | 936086745ab826932f6559cc51f49ba20718f56a (patch) | |
| tree | 5acc6d4a5043b8c1ff6e5f80465db5d1f08403f8 /src/plugins/git/gitgrep.cpp | |
| parent | 1d4228dfda8137920523c242c17e59451bcb937b (diff) | |
FileSearch: Get rid of FileSearchResult
Use SearchResultItem instead.
This change should reduce the remaining freeze described in
a9eb732ce6763e22badd92fc8523cebe84b09a84 even more.
Change-Id: I102b82ed5677360ccd9e425dd0bdd941d87116f0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/git/gitgrep.cpp')
| -rw-r--r-- | src/plugins/git/gitgrep.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/plugins/git/gitgrep.cpp b/src/plugins/git/gitgrep.cpp index edd042c9b9c..2161cbbf68e 100644 --- a/src/plugins/git/gitgrep.cpp +++ b/src/plugins/git/gitgrep.cpp @@ -45,7 +45,7 @@ public: class GitGrepRunner { - using PromiseType = QPromise<FileSearchResultList>; + using PromiseType = QPromise<SearchResultItems>; public: GitGrepRunner(const TextEditor::FileFindParameters ¶meters) @@ -67,23 +67,23 @@ public: QStringList regexpCapturedTexts; }; - void processLine(const QString &line, FileSearchResultList *resultList) const + void processLine(const QString &line, SearchResultItems *resultList) const { if (line.isEmpty()) return; static const QLatin1String boldRed("\x1b[1;31m"); static const QLatin1String resetColor("\x1b[m"); - FileSearchResult single; + SearchResultItem result; const int lineSeparator = line.indexOf(QChar::Null); QString filePath = line.left(lineSeparator); if (!m_ref.isEmpty() && filePath.startsWith(m_ref)) filePath.remove(0, m_ref.length()); - single.fileName = m_directory.pathAppended(filePath); + result.setFilePath(m_directory.pathAppended(filePath)); const int textSeparator = line.indexOf(QChar::Null, lineSeparator + 1); - single.lineNumber = line.mid(lineSeparator + 1, textSeparator - lineSeparator - 1).toInt(); + const int lineNumber = line.mid(lineSeparator + 1, textSeparator - lineSeparator - 1).toInt(); QString text = line.mid(textSeparator + 1); QRegularExpression regexp; - QVector<Match> matches; + QList<Match> matches; if (m_parameters.flags & FindRegularExpression) { const QRegularExpression::PatternOptions patternOptions = (m_parameters.flags & FindCaseSensitively) @@ -106,19 +106,18 @@ public: matches.append(match); text = text.left(matchStart) + matchText + text.mid(matchEnd + resetColor.size()); } - single.matchingLine = text; + result.setDisplayText(text); for (const auto &match : std::as_const(matches)) { - single.matchStart = match.matchStart; - single.matchLength = match.matchLength; - single.regexpCapturedTexts = match.regexpCapturedTexts; - resultList->append(single); + result.setMainRange(lineNumber, match.matchStart, match.matchLength); + result.setUserData(match.regexpCapturedTexts); + resultList->append(result); } } void read(PromiseType &fi, const QString &text) { - FileSearchResultList resultList; + SearchResultItems resultList; QString t = text; QTextStream stream(&t); while (!stream.atEnd() && !fi.isCanceled()) @@ -272,7 +271,7 @@ void GitGrep::writeSettings(QSettings *settings) const settings->setValue(GitGrepRef, m_treeLineEdit->text()); } -QFuture<FileSearchResultList> GitGrep::executeSearch(const TextEditor::FileFindParameters ¶meters, +QFuture<SearchResultItems> GitGrep::executeSearch(const TextEditor::FileFindParameters ¶meters, TextEditor::BaseFileFind * /*baseFileFind*/) { return Utils::asyncRun(GitGrepRunner(parameters)); |
