From 058d2e8cb54d1f5e5c409182ae72fbbd1c96c3cc Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Fri, 30 Nov 2012 16:15:07 +0100 Subject: Support preserving case when replacing. When making a case insensitive search, try to keep the string capitalization when doing the replace: - All upper-case matches are replaced with the upper-case new text. - All lower-case matches are replaced with the lower-case new text. - Capitalized matches are replace with the capitalized new text. - Other matches are replaced with the new text as provided. Note: this does not work with regexp replace, only plain text. Change-Id: I87cbc28eb64688bdf3c8c6ec173fcb22f91abcd0 Reviewed-by: Cristian Tibirna Reviewed-by: Leena Miettinen Reviewed-by: Eike Ziller --- src/plugins/cpptools/cppfindreferences.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/plugins/cpptools/cppfindreferences.cpp') diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 173ed20222..c782f1a5ed 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -255,8 +255,8 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol, : Find::SearchResultWindow::SearchOnly, QLatin1String("CppEditor")); search->setTextToReplace(replacement); - connect(search, SIGNAL(replaceButtonClicked(QString,QList)), - SLOT(onReplaceButtonClicked(QString,QList))); + connect(search, SIGNAL(replaceButtonClicked(QString,QList,bool)), + SLOT(onReplaceButtonClicked(QString,QList,bool))); connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool))); search->setSearchAgainSupported(true); connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain())); @@ -303,9 +303,10 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search) } void CppFindReferences::onReplaceButtonClicked(const QString &text, - const QList &items) + const QList &items, + bool preserveCase) { - const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items); + const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase); if (!fileNames.isEmpty()) { _modelManager->updateSourceFiles(fileNames); Find::SearchResultWindow::instance()->hide(); -- cgit v1.2.1