forked from qt-creator/qt-creator
Editor: implement find next/previous selected text.
Add actions to search next/previous occurence of the selected text/text under the cursor, like in Visual Studio (ctrl+F3 and ctrl+shift+F3). Task-number: QTCREATORBUG-464 Change-Id: I0bf44e386b91fce4b26c6e3864e6df484f2e3556 Reviewed-by: Andre Hartmann <aha_1980@gmx.de> Reviewed-by: Leandro Melo <leandro.melo@nokia.com> Reviewed-by: Yuchen Deng <loaden@gmail.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
committed by
Eike Ziller
parent
d1eefacd55
commit
3f4a9548be
@@ -417,6 +417,12 @@
|
||||
\row
|
||||
\o Find previous
|
||||
\o Shift+F3
|
||||
\row
|
||||
\o Find next occurence of selected text
|
||||
\o Ctrl+F3
|
||||
\row
|
||||
\o Find previous occurence of selected text
|
||||
\o Ctrl+Shift+F3
|
||||
\row
|
||||
\o Replace next
|
||||
\o Ctrl+=
|
||||
|
||||
@@ -183,6 +183,18 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
|
||||
connect(m_findPreviousAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious()));
|
||||
m_ui.findPreviousButton->setDefaultAction(cmd->action());
|
||||
|
||||
m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this);
|
||||
cmd = am->registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED, globalcontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F3")));
|
||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
||||
connect(m_findNextSelectedAction, SIGNAL(triggered()), this, SLOT(findNextSelected()));
|
||||
|
||||
m_findPreviousSelectedAction = new QAction(tr("Find Previous (Selected)"), this);
|
||||
cmd = am->registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED, globalcontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F3")));
|
||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
||||
connect(m_findPreviousSelectedAction, SIGNAL(triggered()), this, SLOT(findPreviousSelected()));
|
||||
|
||||
m_replaceAction = new QAction(tr("Replace"), this);
|
||||
cmd = am->registerAction(m_replaceAction, Constants::REPLACE, globalcontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence());
|
||||
@@ -327,7 +339,10 @@ void FindToolBar::adaptToCandidate()
|
||||
|
||||
void FindToolBar::updateFindAction()
|
||||
{
|
||||
m_findInDocumentAction->setEnabled(m_currentDocumentFind->candidateIsEnabled());
|
||||
bool enabled = m_currentDocumentFind->candidateIsEnabled();
|
||||
m_findInDocumentAction->setEnabled(enabled);
|
||||
m_findNextSelectedAction->setEnabled(enabled);
|
||||
m_findPreviousSelectedAction->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void FindToolBar::updateToolBar()
|
||||
@@ -605,13 +620,13 @@ Core::FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FindToolBar::openFind()
|
||||
void FindToolBar::openFind(bool focus)
|
||||
{
|
||||
setBackward(false);
|
||||
openFindToolBar();
|
||||
openFindToolBar(focus);
|
||||
}
|
||||
|
||||
void FindToolBar::openFindToolBar()
|
||||
void FindToolBar::openFindToolBar(bool focus)
|
||||
{
|
||||
installEventFilters();
|
||||
if (!m_currentDocumentFind->candidateIsEnabled())
|
||||
@@ -627,15 +642,29 @@ void FindToolBar::openFindToolBar()
|
||||
holder->setWidget(this);
|
||||
holder->setVisible(true);
|
||||
setVisible(true);
|
||||
if (focus)
|
||||
setFocus();
|
||||
QString text = m_currentDocumentFind->currentFindString();
|
||||
if (!text.isEmpty())
|
||||
setFindText(text);
|
||||
m_currentDocumentFind->defineFindScope();
|
||||
m_currentDocumentFind->highlightAll(getFindText(), effectiveFindFlags());
|
||||
if (focus)
|
||||
selectFindText();
|
||||
}
|
||||
|
||||
void FindToolBar::findNextSelected()
|
||||
{
|
||||
openFind(false);
|
||||
invokeFindNext();
|
||||
}
|
||||
|
||||
void FindToolBar::findPreviousSelected()
|
||||
{
|
||||
openFind(false);
|
||||
invokeFindPrevious();
|
||||
}
|
||||
|
||||
bool FindToolBar::focusNextPrevChild(bool next)
|
||||
{
|
||||
// close tab order change
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
void openFindToolBar();
|
||||
void openFindToolBar(bool focus = true);
|
||||
void setUseFakeVim(bool on);
|
||||
|
||||
public slots:
|
||||
@@ -84,7 +84,9 @@ private slots:
|
||||
void updateFromFindClipboard();
|
||||
|
||||
void hideAndResetFocus();
|
||||
void openFind();
|
||||
void openFind(bool focus = true);
|
||||
void findNextSelected();
|
||||
void findPreviousSelected();
|
||||
void updateFindAction();
|
||||
void updateToolBar();
|
||||
void findFlagsChanged();
|
||||
@@ -121,6 +123,8 @@ private:
|
||||
QCompleter *m_findCompleter;
|
||||
QCompleter *m_replaceCompleter;
|
||||
QAction *m_findInDocumentAction;
|
||||
QAction *m_findNextSelectedAction;
|
||||
QAction *m_findPreviousSelectedAction;
|
||||
QAction *m_enterFindStringAction;
|
||||
QAction *m_findNextAction;
|
||||
QAction *m_findPreviousAction;
|
||||
|
||||
@@ -51,6 +51,8 @@ const char G_FIND_ACTIONS[] = "Find.FindMenu.Actions";
|
||||
|
||||
const char ADVANCED_FIND[] = "Find.Dialog";
|
||||
const char FIND_IN_DOCUMENT[] = "Find.FindInCurrentDocument";
|
||||
const char FIND_NEXT_SELECTED[]= "Find.FindNextSelected";
|
||||
const char FIND_PREV_SELECTED[]= "Find.FindPreviousSelected";
|
||||
const char FIND_NEXT[] = "Find.FindNext";
|
||||
const char FIND_PREVIOUS[] = "Find.FindPrevious";
|
||||
const char REPLACE[] = "Find.Replace";
|
||||
|
||||
Reference in New Issue
Block a user