forked from qt-creator/qt-creator
Find implementations now tell what find flags are actually supported.
This commit is contained in:
@@ -63,6 +63,11 @@ public:
|
|||||||
~BinEditorFind() {}
|
~BinEditorFind() {}
|
||||||
|
|
||||||
bool supportsReplace() const { return false; }
|
bool supportsReplace() const { return false; }
|
||||||
|
IFindSupport::FindFlags supportedFindFlags() const
|
||||||
|
{
|
||||||
|
return IFindSupport::FindBackward | IFindSupport::FindCaseSensitively;
|
||||||
|
}
|
||||||
|
|
||||||
void resetIncrementalSearch() { m_incrementalStartPos = -1; }
|
void resetIncrementalSearch() { m_incrementalStartPos = -1; }
|
||||||
void clearResults() { m_editor->highlightSearchResults(QByteArray()); }
|
void clearResults() { m_editor->highlightSearchResults(QByteArray()); }
|
||||||
QString currentFindString() const { return QString(); }
|
QString currentFindString() const { return QString(); }
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ bool BaseTextFind::supportsReplace() const
|
|||||||
return !isReadOnly();
|
return !isReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IFindSupport::FindFlags BaseTextFind::supportedFindFlags() const
|
||||||
|
{
|
||||||
|
return IFindSupport::FindBackward | IFindSupport::FindCaseSensitively
|
||||||
|
| IFindSupport::FindRegularExpression | IFindSupport::FindWholeWords;
|
||||||
|
}
|
||||||
|
|
||||||
void BaseTextFind::resetIncrementalSearch()
|
void BaseTextFind::resetIncrementalSearch()
|
||||||
{
|
{
|
||||||
m_incrementalStartPos = -1;
|
m_incrementalStartPos = -1;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
BaseTextFind(QTextEdit *editor);
|
BaseTextFind(QTextEdit *editor);
|
||||||
|
|
||||||
bool supportsReplace() const;
|
bool supportsReplace() const;
|
||||||
|
IFindSupport::FindFlags supportedFindFlags() const;
|
||||||
void resetIncrementalSearch();
|
void resetIncrementalSearch();
|
||||||
void clearResults();
|
void clearResults();
|
||||||
QString currentFindString() const;
|
QString currentFindString() const;
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ bool CurrentDocumentFind::supportsReplace() const
|
|||||||
return m_currentFind->supportsReplace();
|
return m_currentFind->supportsReplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IFindSupport::FindFlags CurrentDocumentFind::supportedFindFlags() const
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_currentFind, return 0);
|
||||||
|
return m_currentFind->supportedFindFlags();
|
||||||
|
}
|
||||||
|
|
||||||
QString CurrentDocumentFind::currentFindString() const
|
QString CurrentDocumentFind::currentFindString() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_currentFind, return QString());
|
QTC_ASSERT(m_currentFind, return QString());
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
void resetIncrementalSearch();
|
void resetIncrementalSearch();
|
||||||
void clearResults();
|
void clearResults();
|
||||||
bool supportsReplace() const;
|
bool supportsReplace() const;
|
||||||
|
IFindSupport::FindFlags supportedFindFlags() const;
|
||||||
QString currentFindString() const;
|
QString currentFindString() const;
|
||||||
QString completedFindString() const;
|
QString completedFindString() const;
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
|
|||||||
|
|
||||||
connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateActions()));
|
connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateActions()));
|
||||||
updateActions();
|
updateActions();
|
||||||
updateIcons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FindToolBar::~FindToolBar()
|
FindToolBar::~FindToolBar()
|
||||||
@@ -300,6 +299,8 @@ void FindToolBar::updateActions()
|
|||||||
m_ui.replaceLabel->setEnabled(replaceEnabled);
|
m_ui.replaceLabel->setEnabled(replaceEnabled);
|
||||||
if (!replaceEnabled && enabled && replaceFocus)
|
if (!replaceEnabled && enabled && replaceFocus)
|
||||||
m_ui.findEdit->setFocus();
|
m_ui.findEdit->setFocus();
|
||||||
|
updateIcons();
|
||||||
|
updateFlagMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindToolBar::invokeFindEnter()
|
void FindToolBar::invokeFindEnter()
|
||||||
@@ -365,7 +366,7 @@ void FindToolBar::invokeFindStep()
|
|||||||
{
|
{
|
||||||
if (m_currentDocumentFind->isEnabled()) {
|
if (m_currentDocumentFind->isEnabled()) {
|
||||||
m_plugin->updateFindCompletion(getFindText());
|
m_plugin->updateFindCompletion(getFindText());
|
||||||
m_currentDocumentFind->findStep(getFindText(), m_findFlags);
|
m_currentDocumentFind->findStep(getFindText(), effectiveFindFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +374,7 @@ void FindToolBar::invokeFindIncremental()
|
|||||||
{
|
{
|
||||||
if (m_currentDocumentFind->isEnabled()) {
|
if (m_currentDocumentFind->isEnabled()) {
|
||||||
QString text = getFindText();
|
QString text = getFindText();
|
||||||
m_currentDocumentFind->findIncremental(text, m_findFlags);
|
m_currentDocumentFind->findIncremental(text, effectiveFindFlags());
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
m_currentDocumentFind->clearResults();
|
m_currentDocumentFind->clearResults();
|
||||||
}
|
}
|
||||||
@@ -396,7 +397,7 @@ void FindToolBar::invokeReplaceStep()
|
|||||||
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
||||||
m_plugin->updateFindCompletion(getFindText());
|
m_plugin->updateFindCompletion(getFindText());
|
||||||
m_plugin->updateReplaceCompletion(getReplaceText());
|
m_plugin->updateReplaceCompletion(getReplaceText());
|
||||||
m_currentDocumentFind->replaceStep(getFindText(), getReplaceText(), m_findFlags);
|
m_currentDocumentFind->replaceStep(getFindText(), getReplaceText(), effectiveFindFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +406,7 @@ void FindToolBar::invokeReplaceAll()
|
|||||||
m_plugin->updateFindCompletion(getFindText());
|
m_plugin->updateFindCompletion(getFindText());
|
||||||
m_plugin->updateReplaceCompletion(getReplaceText());
|
m_plugin->updateReplaceCompletion(getReplaceText());
|
||||||
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
||||||
m_currentDocumentFind->replaceAll(getFindText(), getReplaceText(), m_findFlags);
|
m_currentDocumentFind->replaceAll(getFindText(), getReplaceText(), effectiveFindFlags());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,9 +443,10 @@ void FindToolBar::findFlagsChanged()
|
|||||||
|
|
||||||
void FindToolBar::updateIcons()
|
void FindToolBar::updateIcons()
|
||||||
{
|
{
|
||||||
bool casesensitive = m_findFlags & IFindSupport::FindCaseSensitively;
|
IFindSupport::FindFlags effectiveFlags = effectiveFindFlags();
|
||||||
bool wholewords = m_findFlags & IFindSupport::FindWholeWords;
|
bool casesensitive = effectiveFlags & IFindSupport::FindCaseSensitively;
|
||||||
bool regexp = m_findFlags & IFindSupport::FindRegularExpression;
|
bool wholewords = effectiveFlags & IFindSupport::FindWholeWords;
|
||||||
|
bool regexp = effectiveFlags & IFindSupport::FindRegularExpression;
|
||||||
QPixmap pixmap(17, 17);
|
QPixmap pixmap(17, 17);
|
||||||
QPainter painter(&pixmap);
|
QPainter painter(&pixmap);
|
||||||
painter.eraseRect(0, 0, 17, 17);
|
painter.eraseRect(0, 0, 17, 17);
|
||||||
@@ -468,6 +470,16 @@ void FindToolBar::updateIcons()
|
|||||||
m_ui.findEdit->setPixmap(pixmap);
|
m_ui.findEdit->setPixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IFindSupport::FindFlags FindToolBar::effectiveFindFlags()
|
||||||
|
{
|
||||||
|
IFindSupport::FindFlags supportedFlags;
|
||||||
|
if (m_currentDocumentFind->isEnabled())
|
||||||
|
supportedFlags = m_currentDocumentFind->supportedFindFlags();
|
||||||
|
else
|
||||||
|
supportedFlags = (IFindSupport::FindFlags)0xFFFFFF;
|
||||||
|
return supportedFlags & m_findFlags;
|
||||||
|
}
|
||||||
|
|
||||||
void FindToolBar::updateFlagMenus()
|
void FindToolBar::updateFlagMenus()
|
||||||
{
|
{
|
||||||
bool wholeOnly = ((m_findFlags & IFindSupport::FindWholeWords));
|
bool wholeOnly = ((m_findFlags & IFindSupport::FindWholeWords));
|
||||||
@@ -479,6 +491,12 @@ void FindToolBar::updateFlagMenus()
|
|||||||
m_caseSensitiveAction->setChecked(sensitive);
|
m_caseSensitiveAction->setChecked(sensitive);
|
||||||
if (m_regularExpressionAction->isChecked() != regexp)
|
if (m_regularExpressionAction->isChecked() != regexp)
|
||||||
m_regularExpressionAction->setChecked(regexp);
|
m_regularExpressionAction->setChecked(regexp);
|
||||||
|
IFindSupport::FindFlags supportedFlags;
|
||||||
|
if (m_currentDocumentFind->isEnabled())
|
||||||
|
supportedFlags = m_currentDocumentFind->supportedFindFlags();
|
||||||
|
m_wholeWordAction->setEnabled(supportedFlags & IFindSupport::FindWholeWords);
|
||||||
|
m_caseSensitiveAction->setEnabled(supportedFlags & IFindSupport::FindCaseSensitively);
|
||||||
|
m_regularExpressionAction->setEnabled(supportedFlags & IFindSupport::FindRegularExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FindToolBar::setFocusToCurrentFindSupport()
|
bool FindToolBar::setFocusToCurrentFindSupport()
|
||||||
@@ -509,7 +527,7 @@ void FindToolBar::openFind()
|
|||||||
if (!text.isEmpty())
|
if (!text.isEmpty())
|
||||||
setFindText(text);
|
setFindText(text);
|
||||||
m_currentDocumentFind->defineFindScope();
|
m_currentDocumentFind->defineFindScope();
|
||||||
m_currentDocumentFind->highlightAll(getFindText(), m_findFlags);
|
m_currentDocumentFind->highlightAll(getFindText(), effectiveFindFlags());
|
||||||
selectFindText();
|
selectFindText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ private:
|
|||||||
bool setFocusToCurrentFindSupport();
|
bool setFocusToCurrentFindSupport();
|
||||||
void setFindFlag(IFindSupport::FindFlag flag, bool enabled);
|
void setFindFlag(IFindSupport::FindFlag flag, bool enabled);
|
||||||
bool hasFindFlag(IFindSupport::FindFlag flag);
|
bool hasFindFlag(IFindSupport::FindFlag flag);
|
||||||
|
IFindSupport::FindFlags effectiveFindFlags();
|
||||||
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
void setFindText(const QString &text);
|
void setFindText(const QString &text);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public:
|
|||||||
virtual ~IFindSupport() {}
|
virtual ~IFindSupport() {}
|
||||||
|
|
||||||
virtual bool supportsReplace() const = 0;
|
virtual bool supportsReplace() const = 0;
|
||||||
|
virtual FindFlags supportedFindFlags() const = 0;
|
||||||
virtual void resetIncrementalSearch() = 0;
|
virtual void resetIncrementalSearch() = 0;
|
||||||
virtual void clearResults() = 0;
|
virtual void clearResults() = 0;
|
||||||
virtual QString currentFindString() const = 0;
|
virtual QString currentFindString() const = 0;
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ bool HelpFindSupport::isEnabled() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Find::IFindSupport::FindFlags HelpFindSupport::supportedFindFlags() const
|
||||||
|
{
|
||||||
|
return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively
|
||||||
|
| Find::IFindSupport::FindWholeWords;
|
||||||
|
}
|
||||||
|
|
||||||
QString HelpFindSupport::currentFindString() const
|
QString HelpFindSupport::currentFindString() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_centralWidget, return QString());
|
QTC_ASSERT(m_centralWidget, return QString());
|
||||||
@@ -84,6 +90,12 @@ HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Find::IFindSupport::FindFlags HelpViewerFindSupport::supportedFindFlags() const
|
||||||
|
{
|
||||||
|
return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively
|
||||||
|
| Find::IFindSupport::FindWholeWords;
|
||||||
|
}
|
||||||
|
|
||||||
QString HelpViewerFindSupport::currentFindString() const
|
QString HelpViewerFindSupport::currentFindString() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_viewer, return QString());
|
QTC_ASSERT(m_viewer, return QString());
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ public:
|
|||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
bool supportsReplace() const { return false; }
|
bool supportsReplace() const { return false; }
|
||||||
|
IFindSupport::FindFlags supportedFindFlags() const;
|
||||||
|
|
||||||
void resetIncrementalSearch() {}
|
void resetIncrementalSearch() {}
|
||||||
void clearResults() {}
|
void clearResults() {}
|
||||||
QString currentFindString() const;
|
QString currentFindString() const;
|
||||||
@@ -76,6 +78,7 @@ public:
|
|||||||
|
|
||||||
bool isEnabled() const { return true; }
|
bool isEnabled() const { return true; }
|
||||||
bool supportsReplace() const { return false; }
|
bool supportsReplace() const { return false; }
|
||||||
|
IFindSupport::FindFlags supportedFindFlags() const;
|
||||||
void resetIncrementalSearch() {}
|
void resetIncrementalSearch() {}
|
||||||
void clearResults() {}
|
void clearResults() {}
|
||||||
QString currentFindString() const;
|
QString currentFindString() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user