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:
@@ -22,6 +22,18 @@ Q_LOGGING_CATEGORY(searchLog, "qtc.utils.filesearch", QtWarningMsg)
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
QTextDocument::FindFlags Utils::textDocumentFlagsForFindFlags(FindFlags flags)
|
||||
{
|
||||
QTextDocument::FindFlags textDocFlags;
|
||||
if (flags & FindBackward)
|
||||
textDocFlags |= QTextDocument::FindBackward;
|
||||
if (flags & FindCaseSensitively)
|
||||
textDocFlags |= QTextDocument::FindCaseSensitively;
|
||||
if (flags & FindWholeWords)
|
||||
textDocFlags |= QTextDocument::FindWholeWords;
|
||||
return textDocFlags;
|
||||
}
|
||||
|
||||
static inline QString msgCanceled(const QString &searchTerm, int numMatches, int numFilesSearched)
|
||||
{
|
||||
return Tr::tr("%1: canceled. %n occurrences found in %2 files.",
|
||||
|
||||
@@ -23,6 +23,18 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
|
||||
enum FindFlag {
|
||||
FindBackward = 0x01,
|
||||
FindCaseSensitively = 0x02,
|
||||
FindWholeWords = 0x04,
|
||||
FindRegularExpression = 0x08,
|
||||
FindPreserveCase = 0x10
|
||||
};
|
||||
Q_DECLARE_FLAGS(FindFlags, FindFlag)
|
||||
|
||||
QTCREATOR_UTILS_EXPORT
|
||||
QTextDocument::FindFlags textDocumentFlagsForFindFlags(FindFlags flags);
|
||||
|
||||
QTCREATOR_UTILS_EXPORT
|
||||
std::function<FilePaths(const FilePaths &)> filterFilesFunction(const QStringList &filters,
|
||||
const QStringList &exclusionFilters);
|
||||
@@ -170,3 +182,6 @@ QTCREATOR_UTILS_EXPORT QString matchCaseReplacement(const QString &originalText,
|
||||
const QString &replaceText);
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Utils::FindFlags)
|
||||
Q_DECLARE_METATYPE(Utils::FindFlags)
|
||||
|
||||
@@ -71,7 +71,8 @@ public:
|
||||
|
||||
void highlightAll(const QString &txt, FindFlags findFlags) override
|
||||
{
|
||||
m_widget->highlightSearchResults(txt.toLatin1(), textDocumentFlagsForFindFlags(findFlags));
|
||||
m_widget->highlightSearchResults(txt.toLatin1(),
|
||||
Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
}
|
||||
|
||||
void clearHighlights() override
|
||||
@@ -88,10 +89,10 @@ public:
|
||||
return pos;
|
||||
}
|
||||
|
||||
int res = m_widget->find(pattern, pos, textDocumentFlagsForFindFlags(findFlags));
|
||||
int res = m_widget->find(pattern, pos, Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
if (res < 0) {
|
||||
pos = (findFlags & FindBackward) ? -1 : 0;
|
||||
res = m_widget->find(pattern, pos, textDocumentFlagsForFindFlags(findFlags));
|
||||
res = m_widget->find(pattern, pos, Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
if (res < 0)
|
||||
return res;
|
||||
if (wrapped)
|
||||
@@ -119,7 +120,8 @@ public:
|
||||
Result result;
|
||||
if (found >= 0) {
|
||||
result = Found;
|
||||
m_widget->highlightSearchResults(pattern, textDocumentFlagsForFindFlags(findFlags));
|
||||
m_widget->highlightSearchResults(pattern,
|
||||
Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
m_contPos = -1;
|
||||
} else {
|
||||
if (found == -2) {
|
||||
@@ -154,8 +156,10 @@ public:
|
||||
result = Found;
|
||||
m_incrementalStartPos = found;
|
||||
m_contPos = -1;
|
||||
if (wasReset)
|
||||
m_widget->highlightSearchResults(pattern, textDocumentFlagsForFindFlags(findFlags));
|
||||
if (wasReset) {
|
||||
m_widget->highlightSearchResults(pattern,
|
||||
Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
}
|
||||
} else if (found == -2) {
|
||||
result = NotYetFound;
|
||||
m_contPos += findFlags & FindBackward
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <QTextBlock>
|
||||
#include <QTextCursor>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Core {
|
||||
|
||||
QRegularExpression BaseTextFind::regularExpression(const QString &txt, FindFlags flags)
|
||||
@@ -73,7 +75,7 @@ BaseTextFindPrivate::BaseTextFindPrivate(QPlainTextEdit *editor)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void Core::BaseTextFind::highlightAllRequested(const QString &txt, Core::FindFlags findFlags)
|
||||
\fn void Core::BaseTextFind::highlightAllRequested(const QString &txt, Utils::FindFlags findFlags)
|
||||
|
||||
This signal is emitted when the search results for \a txt using the given
|
||||
\a findFlags should be highlighted in the editor widget.
|
||||
@@ -329,7 +331,8 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after, FindFl
|
||||
bool usesRegExp = (findFlags & FindRegularExpression);
|
||||
bool preserveCase = (findFlags & FindPreserveCase);
|
||||
QRegularExpression regexp = regularExpression(before, findFlags);
|
||||
QTextCursor found = findOne(regexp, editCursor, textDocumentFlagsForFindFlags(findFlags));
|
||||
QTextCursor found = findOne(regexp, editCursor,
|
||||
Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
bool first = true;
|
||||
while (!found.isNull()) {
|
||||
if (found == editCursor && !first) {
|
||||
@@ -342,7 +345,7 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after, FindFl
|
||||
newPosCursor.movePosition(findFlags & FindBackward ?
|
||||
QTextCursor::PreviousCharacter :
|
||||
QTextCursor::NextCharacter);
|
||||
found = findOne(regexp, newPosCursor, textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, newPosCursor, Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
continue;
|
||||
}
|
||||
if (first)
|
||||
@@ -360,7 +363,7 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after, FindFl
|
||||
else
|
||||
realAfter = after;
|
||||
insertTextAfterSelection(realAfter, editCursor);
|
||||
found = findOne(regexp, editCursor, textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, editCursor, Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
}
|
||||
editCursor.endEditBlock();
|
||||
return count;
|
||||
@@ -373,7 +376,7 @@ bool BaseTextFind::find(const QString &txt, FindFlags findFlags, QTextCursor sta
|
||||
return true;
|
||||
}
|
||||
QRegularExpression regexp = regularExpression(txt, findFlags);
|
||||
QTextCursor found = findOne(regexp, start, textDocumentFlagsForFindFlags(findFlags));
|
||||
QTextCursor found = findOne(regexp, start, Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
if (wrapped)
|
||||
*wrapped = false;
|
||||
|
||||
@@ -382,7 +385,7 @@ bool BaseTextFind::find(const QString &txt, FindFlags findFlags, QTextCursor sta
|
||||
start.movePosition(QTextCursor::Start);
|
||||
else
|
||||
start.movePosition(QTextCursor::End);
|
||||
found = findOne(regexp, start, textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, start, Utils::textDocumentFlagsForFindFlags(findFlags));
|
||||
if (found.isNull())
|
||||
return false;
|
||||
if (wrapped)
|
||||
|
||||
@@ -28,43 +28,47 @@ public:
|
||||
~BaseTextFind() override;
|
||||
|
||||
bool supportsReplace() const override;
|
||||
FindFlags supportedFindFlags() const override;
|
||||
Utils::FindFlags supportedFindFlags() const override;
|
||||
void resetIncrementalSearch() override;
|
||||
void clearHighlights() override;
|
||||
QString currentFindString() const override;
|
||||
QString completedFindString() const override;
|
||||
|
||||
Result findIncremental(const QString &txt, FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, FindFlags findFlags) override;
|
||||
void replace(const QString &before, const QString &after, FindFlags findFlags) override;
|
||||
bool replaceStep(const QString &before, const QString &after, FindFlags findFlags) override;
|
||||
int replaceAll(const QString &before, const QString &after, FindFlags findFlags) override;
|
||||
Result findIncremental(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
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;
|
||||
|
||||
void highlightAll(const QString &txt, FindFlags findFlags) override;
|
||||
void highlightAll(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
|
||||
using CursorProvider = std::function<Utils::MultiTextCursor ()>;
|
||||
void setMultiTextCursorProvider(const CursorProvider &provider);
|
||||
bool inScope(const QTextCursor &candidate) const;
|
||||
|
||||
static QRegularExpression regularExpression(const QString &txt, FindFlags flags);
|
||||
static QRegularExpression regularExpression(const QString &txt, Utils::FindFlags flags);
|
||||
|
||||
signals:
|
||||
void highlightAllRequested(const QString &txt, Core::FindFlags findFlags);
|
||||
void highlightAllRequested(const QString &txt, Utils::FindFlags findFlags);
|
||||
void findScopeChanged(const Utils::MultiTextCursor &cursor);
|
||||
|
||||
private:
|
||||
bool find(const QString &txt, FindFlags findFlags, QTextCursor start, bool *wrapped);
|
||||
QTextCursor replaceInternal(const QString &before, const QString &after, FindFlags findFlags);
|
||||
bool find(const QString &txt, Utils::FindFlags findFlags, QTextCursor start, bool *wrapped);
|
||||
QTextCursor replaceInternal(const QString &before, const QString &after,
|
||||
Utils::FindFlags findFlags);
|
||||
|
||||
Utils::MultiTextCursor multiTextCursor() const;
|
||||
QTextCursor textCursor() const;
|
||||
void setTextCursor(const QTextCursor&);
|
||||
QTextDocument *document() const;
|
||||
bool isReadOnly() const;
|
||||
QTextCursor findOne(const QRegularExpression &expr, QTextCursor from, QTextDocument::FindFlags options) const;
|
||||
QTextCursor findOne(const QRegularExpression &expr, QTextCursor from,
|
||||
QTextDocument::FindFlags options) const;
|
||||
|
||||
BaseTextFindPrivate *d;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Core::Internal {
|
||||
|
||||
CurrentDocumentFind::CurrentDocumentFind()
|
||||
@@ -126,9 +128,8 @@ int CurrentDocumentFind::replaceAll(const QString &before, const QString &after,
|
||||
QTC_ASSERT(m_currentFind, return 0);
|
||||
QTC_CHECK(m_currentWidget);
|
||||
int count = m_currentFind->replaceAll(before, after, findFlags);
|
||||
Utils::FadingIndicator::showText(m_currentWidget,
|
||||
Tr::tr("%n occurrences replaced.", nullptr, count),
|
||||
Utils::FadingIndicator::SmallText);
|
||||
FadingIndicator::showText(m_currentWidget, Tr::tr("%n occurrences replaced.", nullptr, count),
|
||||
FadingIndicator::SmallText);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "ifindsupport.h"
|
||||
|
||||
#include <utils/filesearch.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace Core {
|
||||
@@ -21,19 +23,19 @@ public:
|
||||
void clearHighlights();
|
||||
bool supportsReplace() const;
|
||||
bool supportsSelectAll() const;
|
||||
FindFlags supportedFindFlags() const;
|
||||
Utils::FindFlags supportedFindFlags() const;
|
||||
QString currentFindString() const;
|
||||
QString completedFindString() const;
|
||||
|
||||
bool isEnabled() const;
|
||||
IFindSupport *candidate() const;
|
||||
void highlightAll(const QString &txt, FindFlags findFlags);
|
||||
IFindSupport::Result findIncremental(const QString &txt, FindFlags findFlags);
|
||||
IFindSupport::Result findStep(const QString &txt, FindFlags findFlags);
|
||||
void selectAll(const QString &txt, FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after, FindFlags findFlags);
|
||||
bool replaceStep(const QString &before, const QString &after, FindFlags findFlags);
|
||||
int replaceAll(const QString &before, const QString &after, FindFlags findFlags);
|
||||
void highlightAll(const QString &txt, Utils::FindFlags findFlags);
|
||||
IFindSupport::Result findIncremental(const QString &txt, Utils::FindFlags findFlags);
|
||||
IFindSupport::Result findStep(const QString &txt, Utils::FindFlags findFlags);
|
||||
void selectAll(const QString &txt, Utils::FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
bool replaceStep(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
int replaceAll(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
void defineFindScope();
|
||||
void clearFindScope();
|
||||
void acceptCandidate();
|
||||
|
||||
@@ -156,7 +156,7 @@ class FindPrivate : public QObject
|
||||
public:
|
||||
bool isAnyFilterEnabled() const;
|
||||
void writeSettings();
|
||||
void setFindFlag(Core::FindFlag flag, bool enabled);
|
||||
void setFindFlag(FindFlag flag, bool enabled);
|
||||
static void updateCompletion(const QString &text, QStringList &completions,
|
||||
QStringListModel *model);
|
||||
void setupMenu();
|
||||
@@ -452,17 +452,4 @@ QStringListModel *Find::replaceCompletionModel()
|
||||
return &(d->m_replaceCompletionModel);
|
||||
}
|
||||
|
||||
// declared in textfindconstants.h
|
||||
QTextDocument::FindFlags textDocumentFlagsForFindFlags(FindFlags flags)
|
||||
{
|
||||
QTextDocument::FindFlags textDocFlags;
|
||||
if (flags & FindBackward)
|
||||
textDocFlags |= QTextDocument::FindBackward;
|
||||
if (flags & FindCaseSensitively)
|
||||
textDocFlags |= QTextDocument::FindCaseSensitively;
|
||||
if (flags & FindWholeWords)
|
||||
textDocFlags |= QTextDocument::FindWholeWords;
|
||||
return textDocFlags;
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "textfindconstants.h"
|
||||
|
||||
#include <utils/filesearch.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -30,9 +32,9 @@ public:
|
||||
|
||||
enum { CompletionModelFindFlagsRole = Qt::UserRole + 1 };
|
||||
|
||||
static FindFlags findFlags();
|
||||
static bool hasFindFlag(FindFlag flag);
|
||||
static void updateFindCompletion(const QString &text, FindFlags flags = {});
|
||||
static Utils::FindFlags findFlags();
|
||||
static bool hasFindFlag(Utils::FindFlag flag);
|
||||
static void updateFindCompletion(const QString &text, Utils::FindFlags flags = {});
|
||||
static void updateReplaceCompletion(const QString &text);
|
||||
static QAbstractListModel *findCompletionModel();
|
||||
static QStringListModel *replaceCompletionModel();
|
||||
|
||||
@@ -111,9 +111,9 @@ private:
|
||||
|
||||
void installEventFilters();
|
||||
void invokeClearResults();
|
||||
void setFindFlag(FindFlag flag, bool enabled);
|
||||
bool hasFindFlag(FindFlag flag);
|
||||
FindFlags effectiveFindFlags();
|
||||
void setFindFlag(Utils::FindFlag flag, bool enabled);
|
||||
bool hasFindFlag(Utils::FindFlag flag);
|
||||
Utils::FindFlags effectiveFindFlags();
|
||||
static FindToolBarPlaceHolder *findToolBarPlaceHolder();
|
||||
bool toolBarHasFocus() const;
|
||||
ControlStyle controlStyle(bool replaceIsVisible);
|
||||
@@ -174,7 +174,7 @@ private:
|
||||
QToolButton *m_replaceNextButton;
|
||||
QToolButton *m_replaceAllButton;
|
||||
QToolButton *m_advancedButton;
|
||||
FindFlags m_findFlags;
|
||||
Utils::FindFlags m_findFlags;
|
||||
|
||||
QTimer m_findIncrementalTimer;
|
||||
QTimer m_findStepTimer;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
/*!
|
||||
\class Core::IFindFilter
|
||||
\inheaderfile coreplugin/find/ifindfilter.h
|
||||
@@ -130,7 +132,7 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void Core::IFindFilter::findAll(const QString &txt, Core::FindFlags findFlags)
|
||||
\fn void Core::IFindFilter::findAll(const QString &txt, Utils::FindFlags findFlags)
|
||||
This function is called when the user selected this find scope and
|
||||
initiated a search.
|
||||
|
||||
@@ -147,7 +149,7 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void Core::IFindFilter::replaceAll(const QString &txt, Core::FindFlags findFlags)
|
||||
\fn void Core::IFindFilter::replaceAll(const QString &txt, Utils::FindFlags findFlags)
|
||||
Override this function if you want to support search and replace.
|
||||
|
||||
This function is called when the user selected this find scope and
|
||||
@@ -252,8 +254,8 @@ QKeySequence IFindFilter::defaultShortcut() const
|
||||
|
||||
Depending on the returned value, the default find option widgets are
|
||||
enabled or disabled.
|
||||
The default is Core::FindCaseSensitively, Core::FindRegularExpression
|
||||
and Core::FindWholeWords.
|
||||
The default is Utils::FindCaseSensitively, Utils::FindRegularExpression
|
||||
and Uitls::FindWholeWords.
|
||||
*/
|
||||
FindFlags IFindFilter::supportedFindFlags() const
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "textfindconstants.h"
|
||||
|
||||
#include <utils/filesearch.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
class QSettings;
|
||||
@@ -32,18 +34,18 @@ public:
|
||||
virtual QKeySequence defaultShortcut() const;
|
||||
virtual bool isReplaceSupported() const { return false; }
|
||||
virtual bool showSearchTermInput() const { return true; }
|
||||
virtual FindFlags supportedFindFlags() const;
|
||||
virtual Utils::FindFlags supportedFindFlags() const;
|
||||
|
||||
virtual void findAll(const QString &txt, FindFlags findFlags) = 0;
|
||||
virtual void replaceAll(const QString &txt, FindFlags findFlags)
|
||||
virtual void findAll(const QString &txt, Utils::FindFlags findFlags) = 0;
|
||||
virtual void replaceAll(const QString &txt, Utils::FindFlags findFlags)
|
||||
{ Q_UNUSED(txt) Q_UNUSED(findFlags) }
|
||||
|
||||
virtual QWidget *createConfigWidget() { return nullptr; }
|
||||
virtual void writeSettings(QSettings *settings) { Q_UNUSED(settings) }
|
||||
virtual void readSettings(QSettings *settings) { Q_UNUSED(settings) }
|
||||
|
||||
static QPixmap pixmapForFindFlags(FindFlags flags);
|
||||
static QString descriptionForFindFlags(FindFlags flags);
|
||||
static QPixmap pixmapForFindFlags(Utils::FindFlags flags);
|
||||
static QString descriptionForFindFlags(Utils::FindFlags flags);
|
||||
signals:
|
||||
void enabledChanged(bool enabled);
|
||||
void validChanged(bool valid);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
/*!
|
||||
\class Core::IFindSupport
|
||||
@@ -54,16 +55,16 @@ bool IFindSupport::supportsSelectAll() const
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn Core::FindFlags Core::IFindSupport::supportedFindFlags() const
|
||||
\fn Utils::FindFlags Core::IFindSupport::supportedFindFlags() const
|
||||
Returns the find flags, such as whole words or regular expressions,
|
||||
that this find filter supports.
|
||||
|
||||
Depending on the returned value, the default find option widgets are
|
||||
enabled or disabled.
|
||||
|
||||
The default is Core::FindBackward, Core::FindCaseSensitively,
|
||||
Core::FindRegularExpression, Core::FindWholeWords, and
|
||||
Core::FindPreserveCase.
|
||||
The default is Uitls::FindBackward, Utils::FindCaseSensitively,
|
||||
Uitls::FindRegularExpression, Uitls::FindWholeWords, and
|
||||
Uitls::FindPreserveCase.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -87,17 +88,17 @@ bool IFindSupport::supportsSelectAll() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void Core::IFindSupport::highlightAll(const QString &txt, Core::FindFlags findFlags)
|
||||
\fn void Core::IFindSupport::highlightAll(const QString &txt, Utils::FindFlags findFlags)
|
||||
Highlights all search hits for \a txt when using \a findFlags.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Core::IFindSupport::Result Core::IFindSupport::findIncremental(const QString &txt, Core::FindFlags findFlags)
|
||||
\fn Core::IFindSupport::Result Core::IFindSupport::findIncremental(const QString &txt, Utils::FindFlags findFlags)
|
||||
Performs an incremental search of the search term \a txt using \a findFlags.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Core::IFindSupport::Result Core::IFindSupport::findStep(const QString &txt, Core::FindFlags findFlags)
|
||||
\fn Core::IFindSupport::Result Core::IFindSupport::findStep(const QString &txt, Utils::FindFlags findFlags)
|
||||
Searches for \a txt using \a findFlags.
|
||||
*/
|
||||
|
||||
@@ -166,6 +167,6 @@ void IFindSupport::selectAll(const QString &txt, FindFlags findFlags)
|
||||
*/
|
||||
void IFindSupport::showWrapIndicator(QWidget *parent)
|
||||
{
|
||||
Utils::FadingIndicator::showPixmap(parent, Utils::StyleHelper::dpiSpecificImageFile(
|
||||
QLatin1String(":/find/images/wrapindicator.png")));
|
||||
FadingIndicator::showPixmap(parent, StyleHelper::dpiSpecificImageFile(
|
||||
":/find/images/wrapindicator.png"));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "textfindconstants.h"
|
||||
|
||||
#include <utils/filesearch.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
@@ -22,25 +24,23 @@ public:
|
||||
|
||||
virtual bool supportsReplace() const = 0;
|
||||
virtual bool supportsSelectAll() const;
|
||||
virtual FindFlags supportedFindFlags() const = 0;
|
||||
virtual Utils::FindFlags supportedFindFlags() const = 0;
|
||||
virtual void resetIncrementalSearch() = 0;
|
||||
virtual void clearHighlights() = 0;
|
||||
virtual QString currentFindString() const = 0;
|
||||
virtual QString completedFindString() const = 0;
|
||||
|
||||
virtual void highlightAll(const QString &, FindFlags) {}
|
||||
virtual Result findIncremental(const QString &txt, FindFlags findFlags) = 0;
|
||||
virtual Result findStep(const QString &txt, FindFlags findFlags) = 0;
|
||||
virtual void replace(const QString &before, const QString &after,
|
||||
FindFlags findFlags);
|
||||
virtual void highlightAll(const QString &, Utils::FindFlags) {}
|
||||
virtual Result findIncremental(const QString &txt, Utils::FindFlags findFlags) = 0;
|
||||
virtual Result findStep(const QString &txt, Utils::FindFlags findFlags) = 0;
|
||||
virtual void replace(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
virtual bool replaceStep(const QString &before, const QString &after,
|
||||
FindFlags findFlags);
|
||||
virtual int replaceAll(const QString &before, const QString &after,
|
||||
FindFlags findFlags);
|
||||
virtual void selectAll(const QString &txt, FindFlags findFlags);
|
||||
Utils::FindFlags findFlags);
|
||||
virtual int replaceAll(const QString &before, const QString &after, Utils::FindFlags findFlags);
|
||||
virtual void selectAll(const QString &txt, Utils::FindFlags findFlags);
|
||||
|
||||
virtual void defineFindScope(){}
|
||||
virtual void clearFindScope(){}
|
||||
virtual void defineFindScope() {}
|
||||
virtual void clearFindScope() {}
|
||||
|
||||
static void showWrapIndicator(QWidget *parent);
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Core {
|
||||
|
||||
/*!
|
||||
@@ -163,7 +165,7 @@ IFindSupport::Result ItemViewFind::find(const QString &searchTxt,
|
||||
QModelIndex currentIndex = d->m_view->currentIndex();
|
||||
if (!currentIndex.isValid()) // nothing selected, start from top
|
||||
currentIndex = d->m_view->model()->index(0, 0);
|
||||
QTextDocument::FindFlags flags = textDocumentFlagsForFindFlags(findFlags);
|
||||
QTextDocument::FindFlags flags = Utils::textDocumentFlagsForFindFlags(findFlags);
|
||||
QModelIndex resultIndex;
|
||||
QModelIndex index = currentIndex;
|
||||
int currentRow = currentIndex.row();
|
||||
|
||||
@@ -33,22 +33,22 @@ public:
|
||||
~ItemViewFind() override;
|
||||
|
||||
bool supportsReplace() const override;
|
||||
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, FindFlags findFlags) override;
|
||||
Result findIncremental(const QString &txt, FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, FindFlags findFlags) override;
|
||||
void highlightAll(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
Result findIncremental(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
|
||||
static QFrame *createSearchableWrapper(QAbstractItemView *treeView, ColorOption colorOption = DarkColored,
|
||||
FetchOption option = DoNotFetchMoreWhileSearching);
|
||||
static QFrame *createSearchableWrapper(ItemViewFind *finder, ColorOption colorOption = DarkColored);
|
||||
|
||||
private:
|
||||
Result find(const QString &txt, FindFlags findFlags,
|
||||
Result find(const QString &txt, Utils::FindFlags findFlags,
|
||||
bool startFromCurrentIndex, bool *wrapped);
|
||||
QModelIndex nextIndex(const QModelIndex &idx, bool *wrapped) const;
|
||||
QModelIndex prevIndex(const QModelIndex &idx, bool *wrapped) const;
|
||||
|
||||
@@ -40,19 +40,4 @@ const char TASK_SEARCH[] = "Find.Task.Search";
|
||||
|
||||
} // namespace Constants
|
||||
|
||||
enum FindFlag {
|
||||
FindBackward = 0x01,
|
||||
FindCaseSensitively = 0x02,
|
||||
FindWholeWords = 0x04,
|
||||
FindRegularExpression = 0x08,
|
||||
FindPreserveCase = 0x10
|
||||
};
|
||||
Q_DECLARE_FLAGS(FindFlags, FindFlag)
|
||||
|
||||
// defined in findplugin.cpp
|
||||
QTextDocument::FindFlags CORE_EXPORT textDocumentFlagsForFindFlags(FindFlags flags);
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::FindFlags)
|
||||
Q_DECLARE_METATYPE(Core::FindFlags)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum Core::FindFlag
|
||||
\enum Utils::FindFlag
|
||||
This enum holds the find flags.
|
||||
|
||||
\value FindBackward
|
||||
|
||||
@@ -251,11 +251,11 @@ void SymbolSearcher::runSearch(QPromise<SearchResultItem> &promise)
|
||||
search.setSymbolsToSearchFor(m_parameters.types);
|
||||
CPlusPlus::Snapshot::const_iterator it = m_snapshot.begin();
|
||||
|
||||
QString findString = (m_parameters.flags & Core::FindRegularExpression
|
||||
QString findString = (m_parameters.flags & FindRegularExpression
|
||||
? m_parameters.text : QRegularExpression::escape(m_parameters.text));
|
||||
if (m_parameters.flags & Core::FindWholeWords)
|
||||
if (m_parameters.flags & FindWholeWords)
|
||||
findString = QString::fromLatin1("\\b%1\\b").arg(findString);
|
||||
QRegularExpression matcher(findString, (m_parameters.flags & Core::FindCaseSensitively
|
||||
QRegularExpression matcher(findString, (m_parameters.flags & FindCaseSensitively
|
||||
? QRegularExpression::NoPatternOption
|
||||
: QRegularExpression::CaseInsensitiveOption));
|
||||
matcher.optimize();
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
struct Parameters
|
||||
{
|
||||
QString text;
|
||||
Core::FindFlags flags;
|
||||
Utils::FindFlags flags;
|
||||
SymbolTypes types;
|
||||
SearchScope scope;
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
QString displayName() const override;
|
||||
bool isEnabled() const override;
|
||||
|
||||
void findAll(const QString &txt, Core::FindFlags findFlags) override;
|
||||
void findAll(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
|
||||
QWidget *createConfigWidget() override;
|
||||
void writeSettings(QSettings *settings) override;
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
void onAllTasksFinished(Utils::Id type);
|
||||
|
||||
QString label() const;
|
||||
QString toolTip(Core::FindFlags findFlags) const;
|
||||
QString toolTip(Utils::FindFlags findFlags) const;
|
||||
void startSearch(Core::SearchResult *search);
|
||||
|
||||
CppModelManager *m_manager;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
using namespace Core;
|
||||
using namespace Help::Internal;
|
||||
using namespace Utils;
|
||||
|
||||
HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
|
||||
: m_viewer(viewer)
|
||||
|
||||
@@ -17,17 +17,17 @@ public:
|
||||
HelpViewerFindSupport(HelpViewer *viewer);
|
||||
|
||||
bool supportsReplace() const override { return false; }
|
||||
Core::FindFlags supportedFindFlags() const override;
|
||||
Utils::FindFlags supportedFindFlags() const override;
|
||||
void resetIncrementalSearch() override {}
|
||||
void clearHighlights() override {}
|
||||
QString currentFindString() const override;
|
||||
QString completedFindString() const override { return QString(); }
|
||||
|
||||
Result findIncremental(const QString &txt, Core::FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, Core::FindFlags findFlags) override;
|
||||
Result findIncremental(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
|
||||
private:
|
||||
bool find(const QString &ttf, Core::FindFlags findFlags, bool incremental);
|
||||
bool find(const QString &ttf, Utils::FindFlags findFlags, bool incremental);
|
||||
HelpViewer *m_viewer;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <coreplugin/find/textfindconstants.h>
|
||||
|
||||
#include <utils/filesearch.h>
|
||||
|
||||
#include <QFont>
|
||||
#include <QMenu>
|
||||
#include <QPrinter>
|
||||
@@ -52,7 +54,7 @@ public:
|
||||
void setActionVisible(Action action, bool visible);
|
||||
bool isActionVisible(Action action);
|
||||
|
||||
virtual bool findText(const QString &text, Core::FindFlags flags,
|
||||
virtual bool findText(const QString &text, Utils::FindFlags flags,
|
||||
bool incremental, bool fromSearch, bool *wrapped = nullptr) = 0;
|
||||
|
||||
bool handleForwardBackwardMouseButtons(QMouseEvent *e);
|
||||
|
||||
@@ -209,11 +209,11 @@ void LiteHtmlHelpViewer::addForwardHistoryItems(QMenu *forwardMenu)
|
||||
}
|
||||
|
||||
bool LiteHtmlHelpViewer::findText(
|
||||
const QString &text, Core::FindFlags flags, bool incremental, bool fromSearch, bool *wrapped)
|
||||
const QString &text, Utils::FindFlags flags, bool incremental, bool fromSearch, bool *wrapped)
|
||||
{
|
||||
Q_UNUSED(fromSearch)
|
||||
return m_viewer->findText(text,
|
||||
Core::textDocumentFlagsForFindFlags(flags),
|
||||
Utils::textDocumentFlagsForFindFlags(flags),
|
||||
incremental,
|
||||
wrapped);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
void addBackHistoryItems(QMenu *backMenu) override;
|
||||
void addForwardHistoryItems(QMenu *forwardMenu) override;
|
||||
|
||||
bool findText(const QString &text, Core::FindFlags flags,
|
||||
bool findText(const QString &text, Utils::FindFlags flags,
|
||||
bool incremental, bool fromSearch, bool *wrapped = nullptr) override;
|
||||
|
||||
void copy() override;
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
void addForwardHistoryItems(QMenu *forwardMenu) override;
|
||||
void setActionVisible(bool visible);
|
||||
|
||||
bool findText(const QString &text, Core::FindFlags flags,
|
||||
bool findText(const QString &text, Utils::FindFlags flags,
|
||||
bool incremental, bool fromSearch, bool *wrapped = nullptr) override;
|
||||
|
||||
MacWebKitHelpWidget *widget() const { return m_widget; }
|
||||
|
||||
@@ -700,7 +700,7 @@ DOMRange *MacWebKitHelpViewer::findText(NSString *text, bool forward, bool caseS
|
||||
return nil;
|
||||
}
|
||||
|
||||
bool MacWebKitHelpViewer::findText(const QString &text, Core::FindFlags flags, bool incremental,
|
||||
bool MacWebKitHelpViewer::findText(const QString &text, FindFlags flags, bool incremental,
|
||||
bool fromSearch, bool *wrapped)
|
||||
{
|
||||
Q_UNUSED(incremental);
|
||||
@@ -708,8 +708,8 @@ bool MacWebKitHelpViewer::findText(const QString &text, Core::FindFlags flags, b
|
||||
@autoreleasepool {
|
||||
if (wrapped)
|
||||
*wrapped = false;
|
||||
bool forward = !(flags & Core::FindBackward);
|
||||
bool caseSensitive = (flags & Core::FindCaseSensitively);
|
||||
bool forward = !(flags & FindBackward);
|
||||
bool caseSensitive = (flags & FindCaseSensitively);
|
||||
WebView *webView = m_widget->webView();
|
||||
|
||||
// WebView searchFor:.... grabs first responder, and when losing first responder afterwards,
|
||||
|
||||
@@ -143,7 +143,7 @@ void TextBrowserHelpViewer::addForwardHistoryItems(QMenu *forwardMenu)
|
||||
}
|
||||
}
|
||||
|
||||
bool TextBrowserHelpViewer::findText(const QString &text, Core::FindFlags flags,
|
||||
bool TextBrowserHelpViewer::findText(const QString &text, Utils::FindFlags flags,
|
||||
bool incremental, bool fromSearch, bool *wrapped)
|
||||
{
|
||||
if (wrapped)
|
||||
@@ -157,10 +157,10 @@ bool TextBrowserHelpViewer::findText(const QString &text, Core::FindFlags flags,
|
||||
if (incremental)
|
||||
cursor.setPosition(position);
|
||||
|
||||
QTextDocument::FindFlags f = Core::textDocumentFlagsForFindFlags(flags);
|
||||
QTextDocument::FindFlags f = Utils::textDocumentFlagsForFindFlags(flags);
|
||||
QTextCursor found = doc->find(text, cursor, f);
|
||||
if (found.isNull()) {
|
||||
if ((flags & Core::FindBackward) == 0)
|
||||
if ((flags & Utils::FindBackward) == 0)
|
||||
cursor.movePosition(QTextCursor::Start);
|
||||
else
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
void addBackHistoryItems(QMenu *backMenu) override;
|
||||
void addForwardHistoryItems(QMenu *forwardMenu) override;
|
||||
|
||||
bool findText(const QString &text, Core::FindFlags flags,
|
||||
bool findText(const QString &text, Utils::FindFlags flags,
|
||||
bool incremental, bool fromSearch, bool *wrapped = nullptr) override;
|
||||
|
||||
void copy() override;
|
||||
|
||||
@@ -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());
|
||||
FindFlags(macroEvent.value(FLAGS).toInt()));
|
||||
break;
|
||||
case REPLACEALL:
|
||||
currentFind->replaceAll(macroEvent.value(BEFORE).toString(),
|
||||
macroEvent.value(AFTER).toString(),
|
||||
(Core::FindFlags)macroEvent.value(FLAGS).toInt());
|
||||
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;
|
||||
|
||||
@@ -298,10 +298,10 @@ bool TraceViewFindSupport::supportsReplace() const
|
||||
return false;
|
||||
}
|
||||
|
||||
Core::FindFlags TraceViewFindSupport::supportedFindFlags() const
|
||||
Utils::FindFlags TraceViewFindSupport::supportedFindFlags() const
|
||||
{
|
||||
return Core::FindBackward | Core::FindCaseSensitively | Core::FindRegularExpression
|
||||
| Core::FindWholeWords;
|
||||
return Utils::FindBackward | Utils::FindCaseSensitively | Utils::FindRegularExpression
|
||||
| Utils::FindWholeWords;
|
||||
}
|
||||
|
||||
void TraceViewFindSupport::resetIncrementalSearch()
|
||||
@@ -325,7 +325,7 @@ QString TraceViewFindSupport::completedFindString() const
|
||||
}
|
||||
|
||||
Core::IFindSupport::Result TraceViewFindSupport::findIncremental(const QString &txt,
|
||||
Core::FindFlags findFlags)
|
||||
Utils::FindFlags findFlags)
|
||||
{
|
||||
if (m_incrementalStartPos < 0)
|
||||
m_incrementalStartPos = qMax(m_currentPosition, 0);
|
||||
@@ -339,9 +339,9 @@ Core::IFindSupport::Result TraceViewFindSupport::findIncremental(const QString &
|
||||
}
|
||||
|
||||
Core::IFindSupport::Result TraceViewFindSupport::findStep(const QString &txt,
|
||||
Core::FindFlags findFlags)
|
||||
Utils::FindFlags findFlags)
|
||||
{
|
||||
int start = (findFlags & Core::FindBackward) ? m_currentPosition : m_currentPosition + 1;
|
||||
int start = (findFlags & Utils::FindBackward) ? m_currentPosition : m_currentPosition + 1;
|
||||
bool wrapped;
|
||||
bool found = find(txt, findFlags, start, &wrapped);
|
||||
if (wrapped)
|
||||
@@ -355,14 +355,14 @@ Core::IFindSupport::Result TraceViewFindSupport::findStep(const QString &txt,
|
||||
|
||||
// "start" is the model index that is searched first in a forward search, i.e. as if the
|
||||
// "cursor" were between start-1 and start
|
||||
bool TraceViewFindSupport::find(const QString &txt, Core::FindFlags findFlags, int start,
|
||||
bool TraceViewFindSupport::find(const QString &txt, Utils::FindFlags findFlags, int start,
|
||||
bool *wrapped)
|
||||
{
|
||||
if (wrapped)
|
||||
*wrapped = false;
|
||||
if (!findOne(txt, findFlags, start)) {
|
||||
int secondStart;
|
||||
if (findFlags & Core::FindBackward)
|
||||
if (findFlags & Utils::FindBackward)
|
||||
secondStart = m_modelManager->notesModel()->count();
|
||||
else
|
||||
secondStart = 0;
|
||||
@@ -376,19 +376,19 @@ bool TraceViewFindSupport::find(const QString &txt, Core::FindFlags findFlags, i
|
||||
|
||||
// "start" is the model index that is searched first in a forward search, i.e. as if the
|
||||
// "cursor" were between start-1 and start
|
||||
bool TraceViewFindSupport::findOne(const QString &txt, Core::FindFlags findFlags, int start)
|
||||
bool TraceViewFindSupport::findOne(const QString &txt, Utils::FindFlags findFlags, int start)
|
||||
{
|
||||
bool caseSensitiveSearch = (findFlags & Core::FindCaseSensitively);
|
||||
bool regexSearch = (findFlags & Core::FindRegularExpression);
|
||||
bool caseSensitiveSearch = (findFlags & Utils::FindCaseSensitively);
|
||||
bool regexSearch = (findFlags & Utils::FindRegularExpression);
|
||||
QRegularExpression regexp(regexSearch ? txt : QRegularExpression::escape(txt),
|
||||
caseSensitiveSearch ? QRegularExpression::NoPatternOption
|
||||
: QRegularExpression::CaseInsensitiveOption);
|
||||
QTextDocument::FindFlags flags;
|
||||
if (caseSensitiveSearch)
|
||||
flags |= QTextDocument::FindCaseSensitively;
|
||||
if (findFlags & Core::FindWholeWords)
|
||||
if (findFlags & Utils::FindWholeWords)
|
||||
flags |= QTextDocument::FindWholeWords;
|
||||
bool forwardSearch = !(findFlags & Core::FindBackward);
|
||||
bool forwardSearch = !(findFlags & Utils::FindBackward);
|
||||
int increment = forwardSearch ? +1 : -1;
|
||||
int current = forwardSearch ? start : start - 1;
|
||||
Timeline::TimelineNotesModel *model = m_modelManager->notesModel();
|
||||
|
||||
@@ -61,17 +61,17 @@ public:
|
||||
TraceViewFindSupport(QmlProfilerTraceView *view, QmlProfilerModelManager *manager);
|
||||
|
||||
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;
|
||||
Result findIncremental(const QString &txt, Core::FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, Core::FindFlags findFlags) override;
|
||||
Result findIncremental(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
|
||||
private:
|
||||
bool find(const QString &txt, Core::FindFlags findFlags, int start, bool *wrapped);
|
||||
bool findOne(const QString &txt, Core::FindFlags findFlags, int start);
|
||||
bool find(const QString &txt, Utils::FindFlags findFlags, int start, bool *wrapped);
|
||||
bool findOne(const QString &txt, Utils::FindFlags findFlags, int start);
|
||||
|
||||
QmlProfilerTraceView *m_view;
|
||||
QmlProfilerModelManager *m_modelManager;
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
Q_LOGGING_CATEGORY(terminalSearchLog, "qtc.terminal.search", QtWarningMsg)
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace Terminal {
|
||||
@@ -44,7 +46,7 @@ void TerminalSearch::setCurrentSelection(std::optional<SearchHitWithText> select
|
||||
m_currentSelection = selection;
|
||||
}
|
||||
|
||||
void TerminalSearch::setSearchString(const QString &searchString, Core::FindFlags findFlags)
|
||||
void TerminalSearch::setSearchString(const QString &searchString, FindFlags findFlags)
|
||||
{
|
||||
if (m_currentSearchString != searchString || m_findFlags != findFlags) {
|
||||
m_currentSearchString = searchString;
|
||||
@@ -99,7 +101,7 @@ QList<SearchHit> TerminalSearch::search()
|
||||
|
||||
std::function<bool(char32_t, char32_t)> compare;
|
||||
|
||||
if (m_findFlags.testFlag(Core::FindFlag::FindCaseSensitively)) {
|
||||
if (m_findFlags.testFlag(FindFlag::FindCaseSensitively)) {
|
||||
compare = [](char32_t a, char32_t b) { return a == b || isSpace(a, b); };
|
||||
} else {
|
||||
compare = [](char32_t a, char32_t b) {
|
||||
@@ -111,7 +113,7 @@ QList<SearchHit> TerminalSearch::search()
|
||||
const QList<uint> asUcs4 = m_currentSearchString.toUcs4();
|
||||
std::u32string searchString(asUcs4.begin(), asUcs4.end());
|
||||
|
||||
if (m_findFlags.testFlag(Core::FindFlag::FindWholeWords)) {
|
||||
if (m_findFlags.testFlag(FindFlag::FindWholeWords)) {
|
||||
searchString.push_back(std::numeric_limits<char32_t>::max());
|
||||
searchString.insert(searchString.begin(), std::numeric_limits<char32_t>::max());
|
||||
}
|
||||
@@ -123,7 +125,7 @@ QList<SearchHit> TerminalSearch::search()
|
||||
if (it != m_surface->end()) {
|
||||
auto hit = SearchHit{it.position(),
|
||||
static_cast<int>(it.position() + searchString.size())};
|
||||
if (m_findFlags.testFlag(Core::FindFlag::FindWholeWords)) {
|
||||
if (m_findFlags.testFlag(FindFlag::FindWholeWords)) {
|
||||
hit.start++;
|
||||
hit.end--;
|
||||
}
|
||||
@@ -153,7 +155,7 @@ QList<SearchHit> TerminalSearch::searchRegex()
|
||||
}
|
||||
|
||||
QRegularExpression re(m_currentSearchString,
|
||||
m_findFlags.testFlag(Core::FindFlag::FindCaseSensitively)
|
||||
m_findFlags.testFlag(FindFlag::FindCaseSensitively)
|
||||
? QRegularExpression::NoPatternOption
|
||||
: QRegularExpression::CaseInsensitiveOption);
|
||||
|
||||
@@ -191,7 +193,7 @@ void TerminalSearch::debouncedUpdateHits()
|
||||
|
||||
m_currentHit = -1;
|
||||
|
||||
const bool regex = m_findFlags.testFlag(Core::FindFlag::FindRegularExpression);
|
||||
const bool regex = m_findFlags.testFlag(FindFlag::FindRegularExpression);
|
||||
|
||||
QList<SearchHit> hits = regex ? searchRegex() : search();
|
||||
|
||||
@@ -212,10 +214,10 @@ void TerminalSearch::debouncedUpdateHits()
|
||||
qCDebug(terminalSearchLog) << "Search took" << t.elapsed() << "ms";
|
||||
}
|
||||
|
||||
Core::FindFlags TerminalSearch::supportedFindFlags() const
|
||||
FindFlags TerminalSearch::supportedFindFlags() const
|
||||
{
|
||||
return Core::FindFlag::FindCaseSensitively | Core::FindFlag::FindBackward
|
||||
| Core::FindFlag::FindRegularExpression | Core::FindFlag::FindWholeWords;
|
||||
return FindFlag::FindCaseSensitively | FindFlag::FindBackward
|
||||
| FindFlag::FindRegularExpression | FindFlag::FindWholeWords;
|
||||
}
|
||||
|
||||
void TerminalSearch::resetIncrementalSearch()
|
||||
@@ -241,8 +243,7 @@ QString TerminalSearch::completedFindString() const
|
||||
return {};
|
||||
}
|
||||
|
||||
Core::IFindSupport::Result TerminalSearch::findIncremental(const QString &txt,
|
||||
Core::FindFlags findFlags)
|
||||
Core::IFindSupport::Result TerminalSearch::findIncremental(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
if (txt == m_currentSearchString) {
|
||||
if (m_debounceTimer.isActive())
|
||||
@@ -257,7 +258,7 @@ Core::IFindSupport::Result TerminalSearch::findIncremental(const QString &txt,
|
||||
return Result::NotYetFound;
|
||||
}
|
||||
|
||||
Core::IFindSupport::Result TerminalSearch::findStep(const QString &txt, Core::FindFlags findFlags)
|
||||
Core::IFindSupport::Result TerminalSearch::findStep(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
if (txt == m_currentSearchString) {
|
||||
if (m_debounceTimer.isActive())
|
||||
@@ -265,7 +266,7 @@ Core::IFindSupport::Result TerminalSearch::findStep(const QString &txt, Core::Fi
|
||||
else if (m_hits.isEmpty())
|
||||
return Result::NotFound;
|
||||
|
||||
if (findFlags.testFlag(Core::FindFlag::FindBackward))
|
||||
if (findFlags.testFlag(FindFlag::FindBackward))
|
||||
previousHit();
|
||||
else
|
||||
nextHit();
|
||||
@@ -276,7 +277,7 @@ Core::IFindSupport::Result TerminalSearch::findStep(const QString &txt, Core::Fi
|
||||
return findIncremental(txt, findFlags);
|
||||
}
|
||||
|
||||
void TerminalSearch::highlightAll(const QString &txt, Core::FindFlags findFlags)
|
||||
void TerminalSearch::highlightAll(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
setSearchString(txt, findFlags);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
TerminalSearch(Internal::TerminalSurface *surface);
|
||||
|
||||
void setCurrentSelection(std::optional<SearchHitWithText> selection);
|
||||
void setSearchString(const QString &searchString, Core::FindFlags findFlags);
|
||||
void setSearchString(const QString &searchString, Utils::FindFlags findFlags);
|
||||
void nextHit();
|
||||
void previousHit();
|
||||
|
||||
@@ -48,15 +48,15 @@ public:
|
||||
|
||||
public:
|
||||
bool supportsReplace() const override { return false; }
|
||||
Core::FindFlags supportedFindFlags() const override;
|
||||
Utils::FindFlags supportedFindFlags() const override;
|
||||
void resetIncrementalSearch() override;
|
||||
void clearHighlights() override;
|
||||
QString currentFindString() const override;
|
||||
QString completedFindString() const override;
|
||||
Result findIncremental(const QString &txt, Core::FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, Core::FindFlags findFlags) override;
|
||||
Result findIncremental(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
Result findStep(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
|
||||
void highlightAll(const QString &, Core::FindFlags) override;
|
||||
void highlightAll(const QString &, Utils::FindFlags) override;
|
||||
|
||||
signals:
|
||||
void hitsChanged();
|
||||
@@ -71,7 +71,7 @@ protected:
|
||||
private:
|
||||
std::optional<SearchHitWithText> m_currentSelection;
|
||||
QString m_currentSearchString;
|
||||
Core::FindFlags m_findFlags;
|
||||
Utils::FindFlags m_findFlags;
|
||||
Internal::TerminalSurface *m_surface;
|
||||
|
||||
int m_currentHit{-1};
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
return func(parameters.text,
|
||||
baseFileFind->files(parameters.nameFilters, parameters.exclusionFilters,
|
||||
parameters.additionalParameters),
|
||||
textDocumentFlagsForFindFlags(parameters.flags),
|
||||
Utils::textDocumentFlagsForFindFlags(parameters.flags),
|
||||
TextDocument::openedTextDocumentContents());
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
QVariant additionalParameters;
|
||||
QVariant searchEngineParameters;
|
||||
int searchEngineIndex;
|
||||
Core::FindFlags flags;
|
||||
Utils::FindFlags flags;
|
||||
};
|
||||
|
||||
class BaseFileFind;
|
||||
@@ -80,8 +80,8 @@ public:
|
||||
|
||||
bool isEnabled() const override;
|
||||
bool isReplaceSupported() const override { return true; }
|
||||
void findAll(const QString &txt, Core::FindFlags findFlags) override;
|
||||
void replaceAll(const QString &txt, Core::FindFlags findFlags) override;
|
||||
void findAll(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
void replaceAll(const QString &txt, Utils::FindFlags findFlags) override;
|
||||
void addSearchEngine(SearchEngine *searchEngine);
|
||||
|
||||
/* returns the list of unique files that were passed in items */
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
void searchAgain(Core::SearchResult *search);
|
||||
virtual void recheckEnabled(Core::SearchResult *search);
|
||||
|
||||
void runNewSearch(const QString &txt, Core::FindFlags findFlags,
|
||||
void runNewSearch(const QString &txt, Utils::FindFlags findFlags,
|
||||
Core::SearchResultWindow::SearchMode searchMode);
|
||||
void runSearch(Core::SearchResult *search);
|
||||
|
||||
|
||||
@@ -902,7 +902,7 @@ void TextEditorWidgetFind::selectAll(const QString &txt, FindFlags findFlags)
|
||||
FileListIterator *it = new FileListIterator({fileName},
|
||||
{const_cast<QTextCodec *>(
|
||||
m_editor->textDocument()->codec())});
|
||||
const QTextDocument::FindFlags findFlags2 = textDocumentFlagsForFindFlags(findFlags);
|
||||
const QTextDocument::FindFlags findFlags2 = Utils::textDocumentFlagsForFindFlags(findFlags);
|
||||
|
||||
if (findFlags & FindRegularExpression)
|
||||
m_selectWatcher->setFuture(findInFilesRegExp(txt, it, findFlags2, fileToContentsMap));
|
||||
@@ -6744,7 +6744,7 @@ void TextEditorWidgetPrivate::highlightSearchResultsInScrollBar()
|
||||
this, &TextEditorWidgetPrivate::searchFinished);
|
||||
m_searchWatcher->setPendingResultsLimit(10);
|
||||
|
||||
const QTextDocument::FindFlags findFlags = textDocumentFlagsForFindFlags(m_findFlags);
|
||||
const QTextDocument::FindFlags findFlags = Utils::textDocumentFlagsForFindFlags(m_findFlags);
|
||||
|
||||
const FilePath &fileName = m_document->filePath();
|
||||
FileListIterator *it =
|
||||
@@ -7291,7 +7291,7 @@ void TextEditorWidgetPrivate::addSelectionNextFindMatch()
|
||||
return;
|
||||
}
|
||||
|
||||
const QTextDocument::FindFlags findFlags = textDocumentFlagsForFindFlags(m_findFlags);
|
||||
const QTextDocument::FindFlags findFlags = Utils::textDocumentFlagsForFindFlags(m_findFlags);
|
||||
|
||||
int searchFrom = cursors.last().selectionEnd();
|
||||
while (true) {
|
||||
|
||||
@@ -48,13 +48,13 @@ void tst_treeviewfind::wrapping()
|
||||
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("FOO2"));
|
||||
|
||||
// forward
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindFlags());
|
||||
findSupport->findStep(QLatin1String("FOO"), {});
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(0)->child(0));
|
||||
|
||||
// backward
|
||||
tree->setCurrentItem(toplevelitems.at(0)->child(0));
|
||||
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("FOO1"));
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
|
||||
findSupport->findStep(QLatin1String("FOO"), Utils::FindBackward);
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(2)->child(0));
|
||||
|
||||
// clean up
|
||||
@@ -93,31 +93,31 @@ void tst_treeviewfind::columns()
|
||||
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("HEADER1"));
|
||||
|
||||
// find in first column
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindFlags());
|
||||
findSupport->findStep(QLatin1String("FOO"), {});
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(0)->child(0));
|
||||
// find in second column of node with children
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindFlags());
|
||||
findSupport->findStep(QLatin1String("FOO"), {});
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(1));
|
||||
// again find in first column
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindFlags());
|
||||
findSupport->findStep(QLatin1String("FOO"), {});
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(1)->child(0));
|
||||
// don't stay in item if multiple columns match, and find in second column
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindFlags());
|
||||
findSupport->findStep(QLatin1String("FOO"), {});
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(2)->child(0));
|
||||
// wrap
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindFlags());
|
||||
findSupport->findStep(QLatin1String("FOO"), {});
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(0)->child(0));
|
||||
|
||||
// backwards
|
||||
tree->setCurrentItem(toplevelitems.at(2)->child(0));
|
||||
QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("A"));
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
|
||||
findSupport->findStep(QLatin1String("FOO"), Utils::FindBackward);
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(1)->child(0));
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
|
||||
findSupport->findStep(QLatin1String("FOO"), Utils::FindBackward);
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(1));
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
|
||||
findSupport->findStep(QLatin1String("FOO"), Utils::FindBackward);
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(0)->child(0));
|
||||
findSupport->findStep(QLatin1String("FOO"), Core::FindBackward);
|
||||
findSupport->findStep(QLatin1String("FOO"), Utils::FindBackward);
|
||||
QCOMPARE(tree->currentItem(), toplevelitems.at(2)->child(0));
|
||||
|
||||
// clean up
|
||||
|
||||
Reference in New Issue
Block a user