CppEditorWidget: Get rid of unused methods

Change-Id: Idb3b14089b8eb833530834ffb5583dda0b8917de
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2022-06-02 00:50:44 +02:00
parent 62f330219a
commit 170527ae23
3 changed files with 0 additions and 72 deletions

View File

@@ -714,76 +714,6 @@ static QTextDocument *getOpenDocument(const QString &path)
return {};
}
static void addSearchResults(Usages usages, SearchResult &search, const QString &text)
{
std::sort(usages.begin(), usages.end());
std::unique_ptr<QTextDocument> currentDocument;
QString lastPath;
for (const Usage &usage : usages) {
QTextDocument *document = getOpenDocument(usage.path);
if (!document) {
if (usage.path != lastPath) {
currentDocument = getCurrentDocument(usage.path);
lastPath = usage.path;
}
document = currentDocument.get();
}
const QString lineContent = getDocumentLine(document, usage.line);
if (!lineContent.isEmpty()) {
Search::TextRange range{Search::TextPosition(usage.line, usage.column - 1),
Search::TextPosition(usage.line, usage.column + text.length() - 1)};
SearchResultItem item;
item.setFilePath(FilePath::fromString(usage.path));
item.setLineText(lineContent);
item.setMainRange(range);
item.setUseTextEditorFont(true);
search.addResult(item);
}
}
}
static void findRenameCallback(CppEditorWidget *widget,
const QTextCursor &baseCursor,
const Usages &usages,
bool rename = false,
const QString &replacement = QString())
{
QTextCursor cursor = Utils::Text::wordStartCursor(baseCursor);
cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
const QString text = cursor.selectedText();
SearchResultWindow::SearchMode mode = SearchResultWindow::SearchOnly;
if (rename)
mode = SearchResultWindow::SearchAndReplace;
SearchResult *search = SearchResultWindow::instance()->startNewSearch(
QObject::tr("C++ Usages:"),
QString(),
text,
mode,
SearchResultWindow::PreserveCaseDisabled,
QLatin1String("CppEditor"));
search->setTextToReplace(replacement);
search->setSearchAgainSupported(true);
QObject::connect(search, &SearchResult::replaceButtonClicked, &onReplaceUsagesClicked);
QObject::connect(search, &SearchResult::searchAgainRequested,
[widget, rename, replacement, baseCursor]() {
rename ? widget->renameUsages(replacement, baseCursor) : widget->findUsages(baseCursor);
});
addSearchResults(usages, *search, text);
search->finishSearch(false);
QObject::connect(search, &SearchResult::activated,
[](const Core::SearchResultItem& item) {
Core::EditorManager::openEditorAtSearchResult(item);
});
search->popup();
}
void CppEditorWidget::findUsages()
{
findUsages(textCursor());

View File

@@ -30,7 +30,6 @@
#include "cursorineditor.h"
#include "projectinfo.h"
#include "projectpart.h"
#include "usages.h"
#include <cplusplus/cppmodelmanagerbase.h>
#include <coreplugin/find/ifindfilter.h>

View File

@@ -27,7 +27,6 @@
#include "cppeditor_global.h"
#include "cursorineditor.h"
#include "usages.h"
#include <utils/link.h>