forked from qt-creator/qt-creator
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 <tibirna@kde.org>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
committed by
Eike Ziller
parent
a8a33b9a3b
commit
058d2e8cb5
@@ -255,8 +255,8 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
|
||||
: Find::SearchResultWindow::SearchOnly,
|
||||
QLatin1String("CppEditor"));
|
||||
search->setTextToReplace(replacement);
|
||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
||||
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
|
||||
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
|
||||
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>,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<Find::SearchResultItem> &items)
|
||||
const QList<Find::SearchResultItem> &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();
|
||||
|
||||
@@ -89,7 +89,7 @@ private Q_SLOTS:
|
||||
void cancel();
|
||||
void setPaused(bool paused);
|
||||
void openEditor(const Find::SearchResultItem &item);
|
||||
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items);
|
||||
void onReplaceButtonClicked(const QString &text, const QList<Find::SearchResultItem> &items, bool preserveCase);
|
||||
void searchAgain();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user