logic: implemented handling of non-ascii characters in screen search
This commit is contained in:
@@ -54,7 +54,7 @@ void ScreenSearchController::addResponder(ScreenSearchResponder* responder)
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSearchController::search(const std::string& query, const std::set<std::string>& responderNames)
|
||||
void ScreenSearchController::search(const std::wstring& query, const std::set<std::string>& responderNames)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_matchMutex);
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
virtual void foundMatches(ScreenSearchResponder* responder, size_t matchCount);
|
||||
|
||||
void addResponder(ScreenSearchResponder* responder);
|
||||
void search(const std::string& query, const std::set<std::string>& responderNames);
|
||||
void search(const std::wstring& query, const std::set<std::string>& responderNames);
|
||||
void activateMatch(bool next);
|
||||
void clearMatches();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
virtual std::string getName() const = 0;
|
||||
virtual bool isVisible() const = 0;
|
||||
|
||||
virtual void findMatches(ScreenSearchSender* sender, const std::string& query) = 0;
|
||||
virtual void findMatches(ScreenSearchSender* sender, const std::wstring& query) = 0;
|
||||
virtual void activateMatch(size_t matchIndex) = 0;
|
||||
virtual void deactivateMatch(size_t matchIndex) = 0;
|
||||
virtual void clearMatches() = 0;
|
||||
|
||||
@@ -13,19 +13,20 @@
|
||||
#include <QToolTip>
|
||||
|
||||
#include "data/location/SourceLocationFile.h"
|
||||
#include "qt/element/QtCodeNavigator.h"
|
||||
#include "qt/utility/QtContextMenu.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/messaging/type/MessageMoveIDECursor.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
#include "utility/TextCodec.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityApp.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "qt/element/QtCodeNavigator.h"
|
||||
#include "qt/utility/QtContextMenu.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
MouseWheelOverScrollbarFilter::MouseWheelOverScrollbarFilter()
|
||||
{
|
||||
}
|
||||
@@ -399,9 +400,10 @@ QRectF QtCodeArea::getLineRectForLineNumber(uint lineNumber) const
|
||||
return blockBoundingGeometry(block);
|
||||
}
|
||||
|
||||
void QtCodeArea::findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
void QtCodeArea::findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
{
|
||||
const std::string& code = utility::toLowerCase(getCode());
|
||||
TextCodec codec(ApplicationSettings::getInstance()->getTextEncoding());
|
||||
const std::wstring& code = utility::toLowerCase(codec.decode(getCode()));
|
||||
size_t pos = 0;
|
||||
while (pos != std::string::npos)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
QRectF getLineRectForLineNumber(uint lineNumber) const;
|
||||
|
||||
void findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
void clearScreenMatches();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -393,7 +393,7 @@ void QtCodeFile::updateTitleBar()
|
||||
m_titleBar->getTitleButton()->updateTexts();
|
||||
}
|
||||
|
||||
void QtCodeFile::findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
void QtCodeFile::findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
{
|
||||
if (m_fileSnippet && m_fileSnippet->isVisible())
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
void updateSnippets();
|
||||
void updateTitleBar();
|
||||
|
||||
void findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
|
||||
public slots:
|
||||
void clickedMinimizeButton();
|
||||
|
||||
@@ -246,7 +246,7 @@ void QtCodeFileList::onWindowFocus()
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFileList::findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
void QtCodeFileList::findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
{
|
||||
for (QtCodeFile* file : m_files)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
virtual void onWindowFocus();
|
||||
|
||||
virtual void findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
virtual void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
|
||||
void setFileMinimized(const FilePath path);
|
||||
void setFileSnippets(const FilePath path);
|
||||
|
||||
@@ -215,7 +215,7 @@ void QtCodeFileSingle::onWindowFocus()
|
||||
m_titleBar->getTitleButton()->updateTexts();
|
||||
}
|
||||
|
||||
void QtCodeFileSingle::findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
void QtCodeFileSingle::findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
{
|
||||
if (m_area)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual void onWindowFocus() override;
|
||||
|
||||
virtual void findScreenMatches(
|
||||
const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches) override;
|
||||
const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches) override;
|
||||
|
||||
const FilePath& getCurrentFilePath() const;
|
||||
bool hasFileCached(const FilePath& filePath) const;
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
|
||||
virtual void onWindowFocus() = 0;
|
||||
|
||||
virtual void findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches) = 0;
|
||||
virtual void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches) = 0;
|
||||
|
||||
protected:
|
||||
void ensureWidgetVisibleAnimated(const QWidget* parentWidget, const QWidget *childWidget, QRectF rect, bool animated, ScrollTarget target);
|
||||
|
||||
@@ -596,7 +596,7 @@ void QtCodeNavigator::refreshStyle()
|
||||
clearCaches();
|
||||
}
|
||||
|
||||
size_t QtCodeNavigator::findScreenMatches(const std::string& query)
|
||||
size_t QtCodeNavigator::findScreenMatches(const std::wstring& query)
|
||||
{
|
||||
clearScreenMatches();
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
void refreshStyle();
|
||||
|
||||
size_t findScreenMatches(const std::string& query);
|
||||
size_t findScreenMatches(const std::wstring& query);
|
||||
void activateScreenMatch(size_t matchIndex);
|
||||
void deactivateScreenMatch(size_t matchIndex);
|
||||
void clearScreenMatches();
|
||||
|
||||
@@ -187,7 +187,7 @@ std::string QtCodeSnippet::getCode() const
|
||||
return m_codeArea->getCode();
|
||||
}
|
||||
|
||||
void QtCodeSnippet::findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
void QtCodeSnippet::findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||
{
|
||||
m_codeArea->findScreenMatches(query, screenMatches);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
std::string getCode() const;
|
||||
|
||||
void findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
|
||||
private slots:
|
||||
void clickedTitle();
|
||||
|
||||
@@ -206,7 +206,7 @@ void QtScreenSearchBox::findMatches()
|
||||
}
|
||||
}
|
||||
|
||||
controller->search(m_searchBox->text().toLower().toStdString(), responderNames);
|
||||
controller->search(m_searchBox->text().toLower().toStdWString(), responderNames);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ bool QtCodeView::isVisible() const
|
||||
return m_widget->isVisible();
|
||||
}
|
||||
|
||||
void QtCodeView::findMatches(ScreenSearchSender* sender, const std::string& query)
|
||||
void QtCodeView::findMatches(ScreenSearchSender* sender, const std::wstring& query)
|
||||
{
|
||||
m_onQtThread(
|
||||
[sender, query, this]()
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
// ScreenSearchResponder implementation
|
||||
virtual bool isVisible() const;
|
||||
virtual void findMatches(ScreenSearchSender* sender, const std::string& query);
|
||||
virtual void findMatches(ScreenSearchSender* sender, const std::wstring& query);
|
||||
virtual void activateMatch(size_t matchIndex);
|
||||
virtual void deactivateMatch(size_t matchIndex);
|
||||
virtual void clearMatches();
|
||||
|
||||
@@ -189,7 +189,7 @@ bool QtGraphView::isVisible() const
|
||||
return QtViewWidgetWrapper::getWidgetOfView(this)->isVisible();
|
||||
}
|
||||
|
||||
void QtGraphView::findMatches(ScreenSearchSender* sender, const std::string& query)
|
||||
void QtGraphView::findMatches(ScreenSearchSender* sender, const std::wstring& query)
|
||||
{
|
||||
m_onQtThread(
|
||||
[sender, query, this]()
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
// ScreenSearchResponder implementation
|
||||
virtual bool isVisible() const;
|
||||
virtual void findMatches(ScreenSearchSender* sender, const std::string& query);
|
||||
virtual void findMatches(ScreenSearchSender* sender, const std::wstring& query);
|
||||
virtual void activateMatch(size_t matchIndex);
|
||||
virtual void deactivateMatch(size_t matchIndex);
|
||||
virtual void clearMatches();
|
||||
|
||||
@@ -271,7 +271,7 @@ void QtGraphNode::showNodeRecursive()
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphNode::matchNameRecursive(const std::string& query, std::vector<QtGraphNode*>* matchedNodes)
|
||||
void QtGraphNode::matchNameRecursive(const std::wstring& query, std::vector<QtGraphNode*>* matchedNodes)
|
||||
{
|
||||
matchName(query, matchedNodes);
|
||||
|
||||
@@ -473,10 +473,10 @@ void QtGraphNode::notifyEdgesAfterMove()
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphNode::matchName(const std::string& query, std::vector<QtGraphNode*>* matchedNodes)
|
||||
void QtGraphNode::matchName(const std::wstring& query, std::vector<QtGraphNode*>* matchedNodes)
|
||||
{
|
||||
m_isActiveMatch = false;
|
||||
std::string name = utility::encodeToUtf8(getName());
|
||||
const std::wstring name = getName();
|
||||
size_t pos = utility::toLowerCase(name).find(query);
|
||||
|
||||
if (pos != std::string::npos)
|
||||
@@ -490,9 +490,9 @@ void QtGraphNode::matchName(const std::string& query, std::vector<QtGraphNode*>*
|
||||
m_matchRect->show();
|
||||
m_matchText->show();
|
||||
|
||||
std::string matchName(name.length(), ' ');
|
||||
std::wstring matchName(name.length(), L' ');
|
||||
matchName.replace(pos, query.length(), name.substr(pos, query.length()));
|
||||
m_matchText->setText(matchName.c_str());
|
||||
m_matchText->setText(QString::fromStdWString(matchName));
|
||||
|
||||
matchedNodes->push_back(this);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
|
||||
void showNodeRecursive();
|
||||
|
||||
void matchNameRecursive(const std::string& query, std::vector<QtGraphNode*>* matchedNodes);
|
||||
void matchNameRecursive(const std::wstring& query, std::vector<QtGraphNode*>* matchedNodes);
|
||||
void removeNameMatch();
|
||||
void setActiveMatch(bool active);
|
||||
|
||||
@@ -107,7 +107,7 @@ protected:
|
||||
|
||||
void notifyEdgesAfterMove();
|
||||
|
||||
virtual void matchName(const std::string& query, std::vector<QtGraphNode*>* matchedNodes);
|
||||
virtual void matchName(const std::wstring& query, std::vector<QtGraphNode*>* matchedNodes);
|
||||
|
||||
void setStyle(const GraphViewStyle::NodeStyle& style);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
void hideLabel();
|
||||
|
||||
protected:
|
||||
virtual void matchName(const std::string& query, std::vector<QtGraphNode*>* matchedNodes) override {}
|
||||
virtual void matchName(const std::wstring& query, std::vector<QtGraphNode*>* matchedNodes) override {}
|
||||
|
||||
private:
|
||||
AccessKind m_accessKind;
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
virtual void updateStyle();
|
||||
|
||||
protected:
|
||||
virtual void matchName(const std::string& query, std::vector<QtGraphNode*>* matchedNodes) {}
|
||||
virtual void matchName(const std::wstring& query, std::vector<QtGraphNode*>* matchedNodes) {}
|
||||
|
||||
private:
|
||||
QGraphicsPixmapItem* m_icon;
|
||||
|
||||
@@ -26,7 +26,7 @@ protected:
|
||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
|
||||
|
||||
virtual void matchName(const std::string& query, std::vector<QtGraphNode*>* matchedNodes) {}
|
||||
virtual void matchName(const std::wstring& query, std::vector<QtGraphNode*>* matchedNodes) {}
|
||||
|
||||
private:
|
||||
const NameHierarchy m_qualifierName;
|
||||
|
||||
Reference in New Issue
Block a user