Commit ef0e1a64 authored by Roberto Raggi's avatar Roberto Raggi

Show a warning message when using global renaming.

parent c70f968f
......@@ -869,6 +869,16 @@ void CPPEditor::findUsages()
void CPPEditor::renameUsages()
{
Core::EditorManager::instance()->showEditorInfoBar(QLatin1String("CppEditor.Rename"),
tr("This change cannot be undone."),
tr("Yes, I know what I am doing."),
this, SLOT(renameUsagesNow()));
}
void CPPEditor::renameUsagesNow()
{
Core::EditorManager::instance()->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
m_currentRenameSelection = -1;
QList<QTextEdit::ExtraSelection> selections;
......
......@@ -192,6 +192,7 @@ public Q_SLOTS:
void renameSymbolUnderCursor();
void renameUsages();
void findUsages();
void renameUsagesNow();
void moveToPreviousToken();
void moveToNextToken();
......
......@@ -58,7 +58,7 @@
#include <QtCore/QTime>
#include <QtCore/QtConcurrentRun>
#include <QtCore/QDir>
#include <QtGui/QApplication>
#include <qtconcurrent/runextensions.h>
using namespace CppTools::Internal;
......@@ -545,15 +545,20 @@ void CppFindReferences::findUsages(Symbol *symbol)
void CppFindReferences::renameUsages(Symbol *symbol)
{
Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
if (Identifier *id = symbol->identifier()) {
const QString textToReplace = QString::fromUtf8(id->chars(), id->size());
connect(search, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem)));
Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
_resultWindow->setTextToReplace(textToReplace);
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
connect(search, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem)));
findAll_helper(symbol);
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
findAll_helper(symbol);
}
}
void CppFindReferences::findAll_helper(Symbol *symbol)
......@@ -651,6 +656,7 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text,
const QStringList fileNames = changes.keys();
_modelManager->updateSourceFiles(fileNames);
_resultWindow->hide();
}
void CppFindReferences::displayResult(int index)
......
......@@ -104,6 +104,17 @@ SearchResultWindow::~SearchResultWindow()
m_items.clear();
}
void SearchResultWindow::setTextToReplace(const QString &textToReplace)
{
m_replaceTextEdit->setText(textToReplace);
m_replaceTextEdit->selectAll();
}
QString SearchResultWindow::textToReplace() const
{
return m_replaceTextEdit->text();
}
void SearchResultWindow::setShowReplaceUI(bool show)
{
m_searchResultTreeView->model()->setShowReplaceUI(show);
......@@ -169,6 +180,7 @@ SearchResult *SearchResultWindow::startNewSearch(SearchMode searchOrSearchAndRep
void SearchResultWindow::clearContents()
{
setReplaceUIEnabled(false);
m_replaceTextEdit->clear();
m_searchResultTreeView->clear();
m_items.clear();
m_widget->setCurrentWidget(m_searchResultTreeView);
......
......@@ -106,6 +106,9 @@ public:
void setShowReplaceUI(bool show);
bool isShowingReplaceUI() const;
void setTextToReplace(const QString &textToReplace);
QString textToReplace() const;
// search result object only lives till next startnewsearch call
SearchResult *startNewSearch(SearchMode searchOrSearchAndReplace = SearchOnly);
......
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