forked from qt-creator/qt-creator
FindFlags: Move it into Utils lib
It's going to be reused in filesearch.h API. Change-Id: I7ef133368536a647e19949ba8623134cf078a87d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
using namespace Macros;
|
||||
using namespace Macros::Internal;
|
||||
using namespace Utils;
|
||||
|
||||
static const char EVENTNAME[] = "Find";
|
||||
static const quint8 TYPE = 0;
|
||||
@@ -59,26 +60,26 @@ bool FindMacroHandler::executeEvent(const MacroEvent ¯oEvent)
|
||||
switch (macroEvent.value(TYPE).toInt()) {
|
||||
case FINDINCREMENTAL:
|
||||
currentFind->findIncremental(macroEvent.value(BEFORE).toString(),
|
||||
(Core::FindFlags)macroEvent.value(FLAGS).toInt());
|
||||
FindFlags(macroEvent.value(FLAGS).toInt()));
|
||||
break;
|
||||
case FINDSTEP:
|
||||
currentFind->findStep(macroEvent.value(BEFORE).toString(),
|
||||
(Core::FindFlags)macroEvent.value(FLAGS).toInt());
|
||||
FindFlags(macroEvent.value(FLAGS).toInt()));
|
||||
break;
|
||||
case REPLACE:
|
||||
currentFind->replace(macroEvent.value(BEFORE).toString(),
|
||||
macroEvent.value(AFTER).toString(),
|
||||
(Core::FindFlags)macroEvent.value(FLAGS).toInt());
|
||||
FindFlags(macroEvent.value(FLAGS).toInt()));
|
||||
break;
|
||||
case REPLACESTEP:
|
||||
currentFind->replaceStep(macroEvent.value(BEFORE).toString(),
|
||||
macroEvent.value(AFTER).toString(),
|
||||
(Core::FindFlags)macroEvent.value(FLAGS).toInt());
|
||||
macroEvent.value(AFTER).toString(),
|
||||
FindFlags(macroEvent.value(FLAGS).toInt()));
|
||||
break;
|
||||
case REPLACEALL:
|
||||
currentFind->replaceAll(macroEvent.value(BEFORE).toString(),
|
||||
macroEvent.value(AFTER).toString(),
|
||||
(Core::FindFlags)macroEvent.value(FLAGS).toInt());
|
||||
macroEvent.value(AFTER).toString(),
|
||||
FindFlags(macroEvent.value(FLAGS).toInt()));
|
||||
break;
|
||||
case RESET:
|
||||
currentFind->resetIncrementalSearch();
|
||||
@@ -87,31 +88,31 @@ bool FindMacroHandler::executeEvent(const MacroEvent ¯oEvent)
|
||||
return true;
|
||||
}
|
||||
|
||||
void FindMacroHandler::findIncremental(const QString &txt, Core::FindFlags findFlags)
|
||||
void FindMacroHandler::findIncremental(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
if (!isRecording())
|
||||
return;
|
||||
MacroEvent e;
|
||||
e.setId(EVENTNAME);
|
||||
e.setValue(BEFORE, txt);
|
||||
e.setValue(FLAGS, (int)findFlags);
|
||||
e.setValue(FLAGS, int(findFlags));
|
||||
e.setValue(TYPE, FINDINCREMENTAL);
|
||||
addMacroEvent(e);
|
||||
}
|
||||
|
||||
void FindMacroHandler::findStep(const QString &txt, Core::FindFlags findFlags)
|
||||
void FindMacroHandler::findStep(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
if (!isRecording())
|
||||
return;
|
||||
MacroEvent e;
|
||||
e.setId(EVENTNAME);
|
||||
e.setValue(BEFORE, txt);
|
||||
e.setValue(FLAGS, (int)findFlags);
|
||||
e.setValue(FLAGS, int(findFlags));
|
||||
e.setValue(TYPE, FINDSTEP);
|
||||
addMacroEvent(e);
|
||||
}
|
||||
|
||||
void FindMacroHandler::replace(const QString &before, const QString &after, Core::FindFlags findFlags)
|
||||
void FindMacroHandler::replace(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
if (!isRecording())
|
||||
return;
|
||||
@@ -119,12 +120,12 @@ void FindMacroHandler::replace(const QString &before, const QString &after, Core
|
||||
e.setId(EVENTNAME);
|
||||
e.setValue(BEFORE, before);
|
||||
e.setValue(AFTER, after);
|
||||
e.setValue(FLAGS, (int)findFlags);
|
||||
e.setValue(FLAGS, int(findFlags));
|
||||
e.setValue(TYPE, REPLACE);
|
||||
addMacroEvent(e);
|
||||
}
|
||||
|
||||
void FindMacroHandler::replaceStep(const QString &before, const QString &after, Core::FindFlags findFlags)
|
||||
void FindMacroHandler::replaceStep(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
if (!isRecording())
|
||||
return;
|
||||
@@ -132,12 +133,12 @@ void FindMacroHandler::replaceStep(const QString &before, const QString &after,
|
||||
e.setId(EVENTNAME);
|
||||
e.setValue(BEFORE, before);
|
||||
e.setValue(AFTER, after);
|
||||
e.setValue(FLAGS, (int)findFlags);
|
||||
e.setValue(FLAGS, int(findFlags));
|
||||
e.setValue(TYPE, REPLACESTEP);
|
||||
addMacroEvent(e);
|
||||
}
|
||||
|
||||
void FindMacroHandler::replaceAll(const QString &before, const QString &after, Core::FindFlags findFlags)
|
||||
void FindMacroHandler::replaceAll(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
if (!isRecording())
|
||||
return;
|
||||
@@ -145,7 +146,7 @@ void FindMacroHandler::replaceAll(const QString &before, const QString &after, C
|
||||
e.setId(EVENTNAME);
|
||||
e.setValue(BEFORE, before);
|
||||
e.setValue(AFTER, after);
|
||||
e.setValue(FLAGS, (int)findFlags);
|
||||
e.setValue(FLAGS, int(findFlags));
|
||||
e.setValue(TYPE, REPLACEALL);
|
||||
addMacroEvent(e);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "imacrohandler.h"
|
||||
|
||||
#include <coreplugin/find/textfindconstants.h>
|
||||
#include <utils/filesearch.h>
|
||||
|
||||
namespace Core { class IEditor; }
|
||||
|
||||
@@ -24,11 +25,11 @@ public:
|
||||
bool canExecuteEvent(const MacroEvent ¯oEvent) override;
|
||||
bool executeEvent(const MacroEvent ¯oEvent) override;
|
||||
|
||||
void findIncremental(const QString &txt, Core::FindFlags findFlags);
|
||||
void findStep(const QString &txt, Core::FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after, Core::FindFlags findFlags);
|
||||
void replaceStep(const QString &before, const QString &after, Core::FindFlags findFlags);
|
||||
void replaceAll(const QString &before, const QString &after, Core::FindFlags findFlags);
|
||||
void findIncremental(const QString &txt, Utils::FindFlags findFlags);
|
||||
void findStep(const QString &txt, Utils::FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
void replaceStep(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
void replaceAll(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
void resetIncrementalSearch();
|
||||
|
||||
private:
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
using namespace Macros;
|
||||
using namespace Macros::Internal;
|
||||
using namespace Utils;
|
||||
|
||||
MacroTextFind::MacroTextFind(Core::IFindSupport *currentFind):
|
||||
Core::IFindSupport(),
|
||||
@@ -20,7 +21,7 @@ bool MacroTextFind::supportsReplace() const
|
||||
return m_currentFind->supportsReplace();
|
||||
}
|
||||
|
||||
Core::FindFlags MacroTextFind::supportedFindFlags() const
|
||||
FindFlags MacroTextFind::supportedFindFlags() const
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return {});
|
||||
return m_currentFind->supportedFindFlags();
|
||||
@@ -51,13 +52,13 @@ QString MacroTextFind::completedFindString() const
|
||||
return m_currentFind->completedFindString();
|
||||
}
|
||||
|
||||
void MacroTextFind::highlightAll(const QString &txt, Core::FindFlags findFlags)
|
||||
void MacroTextFind::highlightAll(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return);
|
||||
m_currentFind->highlightAll(txt, findFlags);
|
||||
}
|
||||
|
||||
Core::IFindSupport::Result MacroTextFind::findIncremental(const QString &txt, Core::FindFlags findFlags)
|
||||
Core::IFindSupport::Result MacroTextFind::findIncremental(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return IFindSupport::NotFound);
|
||||
Core::IFindSupport::Result result = m_currentFind->findIncremental(txt, findFlags);
|
||||
@@ -66,7 +67,7 @@ Core::IFindSupport::Result MacroTextFind::findIncremental(const QString &txt, Co
|
||||
return result;
|
||||
}
|
||||
|
||||
Core::IFindSupport::Result MacroTextFind::findStep(const QString &txt, Core::FindFlags findFlags)
|
||||
Core::IFindSupport::Result MacroTextFind::findStep(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return IFindSupport::NotFound);
|
||||
Core::IFindSupport::Result result = m_currentFind->findStep(txt, findFlags);
|
||||
@@ -75,14 +76,14 @@ Core::IFindSupport::Result MacroTextFind::findStep(const QString &txt, Core::Fin
|
||||
return result;
|
||||
}
|
||||
|
||||
void MacroTextFind::replace(const QString &before, const QString &after, Core::FindFlags findFlags)
|
||||
void MacroTextFind::replace(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return);
|
||||
m_currentFind->replace(before, after, findFlags);
|
||||
emit replaced(before, after, findFlags);
|
||||
}
|
||||
|
||||
bool MacroTextFind::replaceStep(const QString &before, const QString &after, Core::FindFlags findFlags)
|
||||
bool MacroTextFind::replaceStep(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return false);
|
||||
bool result = m_currentFind->replaceStep(before, after, findFlags);
|
||||
@@ -90,7 +91,7 @@ bool MacroTextFind::replaceStep(const QString &before, const QString &after, Cor
|
||||
return result;
|
||||
}
|
||||
|
||||
int MacroTextFind::replaceAll(const QString &before, const QString &after, Core::FindFlags findFlags)
|
||||
int MacroTextFind::replaceAll(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return 0);
|
||||
int result = m_currentFind->replaceAll(before, after, findFlags);
|
||||
|
||||
@@ -18,32 +18,29 @@ public:
|
||||
MacroTextFind(Core::IFindSupport *currentFind);
|
||||
|
||||
bool supportsReplace() const override;
|
||||
Core::FindFlags supportedFindFlags() const override;
|
||||
Utils::FindFlags supportedFindFlags() const override;
|
||||
void resetIncrementalSearch() override;
|
||||
void clearHighlights() override;
|
||||
QString currentFindString() const override;
|
||||
QString completedFindString() const override;
|
||||
|
||||
void highlightAll(const QString &txt, Core::FindFlags findFlags) override;
|
||||
Core::IFindSupport::Result findIncremental(const QString &txt, Core::FindFlags findFlags) override;
|
||||
Core::IFindSupport::Result findStep(const QString &txt, Core::FindFlags findFlags) override;
|
||||
void replace(const QString &before, const QString &after, Core::FindFlags findFlags) override;
|
||||
bool replaceStep(const QString &before, const QString &after, Core::FindFlags findFlags) override;
|
||||
int replaceAll(const QString &before, const QString &after, Core::FindFlags findFlags) override;
|
||||
void highlightAll(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
Core::IFindSupport::Result findIncremental(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
Core::IFindSupport::Result findStep(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
void replace(const QString &before, const QString &after, Utils::FindFlags findFlags) override;
|
||||
bool replaceStep(const QString &before, const QString &after, Utils::FindFlags findFlags) override;
|
||||
int replaceAll(const QString &before, const QString &after, Utils::FindFlags findFlags) override;
|
||||
|
||||
void defineFindScope() override;
|
||||
void clearFindScope() override;
|
||||
|
||||
signals:
|
||||
void incrementalSearchReseted();
|
||||
void incrementalFound(const QString &txt, Core::FindFlags findFlags);
|
||||
void stepFound(const QString &txt, Core::FindFlags findFlags);
|
||||
void replaced(const QString &before, const QString &after,
|
||||
Core::FindFlags findFlags);
|
||||
void stepReplaced(const QString &before, const QString &after,
|
||||
Core::FindFlags findFlags);
|
||||
void allReplaced(const QString &before, const QString &after,
|
||||
Core::FindFlags findFlags);
|
||||
void incrementalFound(const QString &txt, Utils::FindFlags findFlags);
|
||||
void stepFound(const QString &txt, Utils::FindFlags findFlags);
|
||||
void replaced(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
void stepReplaced(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
void allReplaced(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
|
||||
private:
|
||||
QPointer<Core::IFindSupport> m_currentFind;
|
||||
|
||||
Reference in New Issue
Block a user