Commit 7c0bb193 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools/QmlJSEditor: Hide "Preserve Case" for Replace Symbol Under Cursor

...since it does not make sense for symbols.

Task-number: QTCREATORBUG-11669
Change-Id: Ic249cb15cdb3b324a9b215323acd802a33797100
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent 906b8136
......@@ -81,6 +81,7 @@ using namespace Core::Internal;
SearchResultWidget::SearchResultWidget(QWidget *parent) :
QWidget(parent),
m_count(0),
m_preserveCaseSupported(true),
m_isShowingReplaceUI(false),
m_searchAgainSupported(false)
{
......@@ -294,13 +295,18 @@ QString SearchResultWidget::textToReplace() const
return m_replaceTextEdit->text();
}
void SearchResultWidget::setSupportPreserveCase(bool enabled)
{
m_preserveCaseSupported = enabled;
}
void SearchResultWidget::setShowReplaceUI(bool visible)
{
m_searchResultTreeView->model()->setShowReplaceUI(visible);
m_replaceLabel->setVisible(visible);
m_replaceTextEdit->setVisible(visible);
m_replaceButton->setVisible(visible);
m_preserveCaseCheck->setVisible(visible);
m_preserveCaseCheck->setVisible(visible && m_preserveCaseSupported);
m_isShowingReplaceUI = visible;
}
......@@ -446,7 +452,8 @@ void SearchResultWidget::handleReplaceButton()
// by pressing return in replace line edit
if (m_replaceButton->isEnabled()) {
m_infoBar.clear();
emit replaceButtonClicked(m_replaceTextEdit->text(), checkedItems(), m_preserveCaseCheck->isChecked());
emit replaceButtonClicked(m_replaceTextEdit->text(), checkedItems(),
m_preserveCaseSupported && m_preserveCaseCheck->isChecked());
}
}
......
......@@ -70,6 +70,7 @@ public:
void setTextToReplace(const QString &textToReplace);
QString textToReplace() const;
void setSupportPreserveCase(bool enabled);
void setShowReplaceUI(bool visible);
bool hasFocusInternally() const;
......@@ -123,6 +124,7 @@ private:
SearchResultTreeView *m_searchResultTreeView;
int m_count;
QString m_dontAskAgainGroup;
bool m_preserveCaseSupported;
QFrame *m_messageWidget;
Core::InfoBar m_infoBar;
Core::InfoBarDisplay m_infoBarDisplay;
......
......@@ -375,6 +375,7 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label,
const QString &toolTip,
const QString &searchTerm,
SearchMode searchOrSearchAndReplace,
PreserveCaseMode preserveCaseMode,
const QString &cfgGroup)
{
if (d->m_searchResults.size() >= MAX_SEARCH_HISTORY) {
......@@ -395,6 +396,7 @@ SearchResult *SearchResultWindow::startNewSearch(const QString &label,
connect(widget, SIGNAL(restarted()), d, SLOT(moveWidgetToTop()));
connect(widget, SIGNAL(requestPopup(bool)), d, SLOT(popupRequested(bool)));
widget->setTextEditorFont(d->m_font, d->m_color);
widget->setSupportPreserveCase(preserveCaseMode == PreserveCaseEnabled);
widget->setShowReplaceUI(searchOrSearchAndReplace != SearchOnly);
widget->setAutoExpandResults(d->m_expandCollapseAction->isChecked());
widget->setInfo(label, toolTip, searchTerm);
......
......@@ -137,6 +137,11 @@ public:
SearchAndReplace
};
enum PreserveCaseMode {
PreserveCaseEnabled,
PreserveCaseDisabled
};
SearchResultWindow(QWidget *newSearchPanel);
virtual ~SearchResultWindow();
......@@ -173,6 +178,7 @@ public:
const QString &toolTip,
const QString &searchTerm,
SearchMode searchOrSearchAndReplace = SearchOnly,
PreserveCaseMode preserveCaseMode = PreserveCaseEnabled,
const QString &cfgGroup = QString());
public slots:
......
......@@ -330,6 +330,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
overview.prettyName(context.fullyQualifiedName(symbol)),
replace ? Core::SearchResultWindow::SearchAndReplace
: Core::SearchResultWindow::SearchOnly,
Core::SearchResultWindow::PreserveCaseDisabled,
QLatin1String("CppEditor"));
search->setTextToReplace(replacement);
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
......@@ -640,6 +641,7 @@ void CppFindReferences::findMacroUses(const Macro &macro, const QString &replace
QString::fromUtf8(macro.name()),
replace ? Core::SearchResultWindow::SearchAndReplace
: Core::SearchResultWindow::SearchOnly,
Core::SearchResultWindow::PreserveCaseDisabled,
QLatin1String("CppEditor"));
search->setTextToReplace(replacement);
......
......@@ -929,7 +929,8 @@ void FindReferences::displayResults(int first, int last)
label, QString(), symbolName, Core::SearchResultWindow::SearchOnly);
} else {
m_currentSearch = Core::SearchResultWindow::instance()->startNewSearch(
label, QString(), symbolName, Core::SearchResultWindow::SearchAndReplace);
label, QString(), symbolName, Core::SearchResultWindow::SearchAndReplace,
Core::SearchResultWindow::PreserveCaseDisabled);
m_currentSearch->setTextToReplace(replacement);
connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
......
......@@ -132,7 +132,8 @@ void BaseFileFind::runNewSearch(const QString &txt, Core::FindFlags findFlags,
updateComboEntries(d->m_filterCombo, true);
SearchResult *search = Core::SearchResultWindow::instance()->startNewSearch(label(),
toolTip().arg(Core::IFindFilter::descriptionForFindFlags(findFlags)),
txt, searchMode, QString::fromLatin1("TextEditor"));
txt, searchMode, Core::SearchResultWindow::PreserveCaseEnabled,
QString::fromLatin1("TextEditor"));
search->setTextToReplace(txt);
search->setSearchAgainSupported(true);
FileFindParameters parameters;
......
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