ui: Changed full text search character to ? and added shortcut CTRL+SHIFT+F
This commit is contained in:
@@ -47,7 +47,14 @@ void SearchController::handleMessage(MessageActivateTokens* message)
|
|||||||
|
|
||||||
void SearchController::handleMessage(MessageFind* message)
|
void SearchController::handleMessage(MessageFind* message)
|
||||||
{
|
{
|
||||||
getView()->setFocus();
|
if (message->findFulltext)
|
||||||
|
{
|
||||||
|
getView()->findFulltext();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getView()->setFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchController::handleMessage(MessageSearchAutocomplete* message)
|
void SearchController::handleMessage(MessageSearchAutocomplete* message)
|
||||||
@@ -59,11 +66,8 @@ void SearchController::handleMessage(MessageSearchAutocomplete* message)
|
|||||||
void SearchController::handleMessage(MessageSearchFullText* message)
|
void SearchController::handleMessage(MessageSearchFullText* message)
|
||||||
{
|
{
|
||||||
LOG_INFO("fulltext string: \"" + message->searchTerm + "\"");
|
LOG_INFO("fulltext string: \"" + message->searchTerm + "\"");
|
||||||
std::string prefix = "@";
|
std::string prefix(message->caseSensitive ? 2 : 1, SearchMatch::FULLTEXT_SEARCH_CHARACTER);
|
||||||
if (message->caseSensitive)
|
|
||||||
{
|
|
||||||
prefix += "@";
|
|
||||||
}
|
|
||||||
SearchMatch match(prefix + message->searchTerm);
|
SearchMatch match(prefix + message->searchTerm);
|
||||||
match.searchType = SearchMatch::SEARCH_FULLTEXT;
|
match.searchType = SearchMatch::SEARCH_FULLTEXT;
|
||||||
getView()->setMatches(std::vector<SearchMatch>(1, match));
|
getView()->setMatches(std::vector<SearchMatch>(1, match));
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ public:
|
|||||||
virtual std::string getName() const;
|
virtual std::string getName() const;
|
||||||
|
|
||||||
virtual void setMatches(const std::vector<SearchMatch>& matches) = 0;
|
virtual void setMatches(const std::vector<SearchMatch>& matches) = 0;
|
||||||
|
|
||||||
virtual void setFocus() = 0;
|
virtual void setFocus() = 0;
|
||||||
|
virtual void findFulltext() = 0;
|
||||||
|
|
||||||
virtual void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList) = 0;
|
virtual void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ struct SearchMatch
|
|||||||
static SearchMatch createCommand(CommandType type);
|
static SearchMatch createCommand(CommandType type);
|
||||||
static std::string getCommandName(CommandType type);
|
static std::string getCommandName(CommandType type);
|
||||||
|
|
||||||
|
static const char FULLTEXT_SEARCH_CHARACTER = '?';
|
||||||
|
|
||||||
SearchMatch();
|
SearchMatch();
|
||||||
SearchMatch(const std::string& query);
|
SearchMatch(const std::string& query);
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
#include "utility/messaging/Message.h"
|
#include "utility/messaging/Message.h"
|
||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
|
|
||||||
class MessageFind: public Message<MessageFind>
|
class MessageFind
|
||||||
|
: public Message<MessageFind>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MessageFind()
|
MessageFind(bool fulltext = false)
|
||||||
|
: findFulltext(fulltext)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,6 +17,8 @@ public:
|
|||||||
{
|
{
|
||||||
return "MessageFind";
|
return "MessageFind";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool findFulltext;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_FIND_H
|
#endif // MESSAGE_FIND_H
|
||||||
|
|||||||
@@ -77,6 +77,11 @@ void QtSearchBar::setFocus()
|
|||||||
m_searchBox->setFocus();
|
m_searchBox->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtSearchBar::findFulltext()
|
||||||
|
{
|
||||||
|
m_searchBox->findFulltext();
|
||||||
|
}
|
||||||
|
|
||||||
void QtSearchBar::setAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
|
void QtSearchBar::setAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
|
||||||
{
|
{
|
||||||
m_searchBox->setAutocompletionList(autocompletionList);
|
m_searchBox->setAutocompletionList(autocompletionList);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
void setMatches(const std::vector<SearchMatch>& matches);
|
void setMatches(const std::vector<SearchMatch>& matches);
|
||||||
void setFocus();
|
void setFocus();
|
||||||
|
void findFulltext();
|
||||||
void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||||
|
|
||||||
QAbstractItemView* getCompleterPopup();
|
QAbstractItemView* getCompleterPopup();
|
||||||
|
|||||||
@@ -37,25 +37,21 @@ void QtSmartSearchBox::search()
|
|||||||
|
|
||||||
std::vector<SearchMatch> matches = utility::toVector(m_matches);
|
std::vector<SearchMatch> matches = utility::toVector(m_matches);
|
||||||
|
|
||||||
LOG_INFO_STREAM(<< "Search query: " << SearchMatch::searchMatchesToString(matches) << text().toStdString());
|
|
||||||
|
|
||||||
MessageSearch(matches).dispatch();
|
MessageSearch(matches).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtSmartSearchBox::fullTextSearch()
|
void QtSmartSearchBox::fullTextSearch()
|
||||||
{
|
{
|
||||||
std::string term = text().toStdString().substr(1);
|
std::string term = text().toStdString().substr(1);
|
||||||
if (term.at(0) == '@')
|
bool caseSensitive = false;
|
||||||
|
|
||||||
|
if (term.at(0) == SearchMatch::FULLTEXT_SEARCH_CHARACTER)
|
||||||
{
|
{
|
||||||
term = term.substr(1);
|
term = term.substr(1);
|
||||||
LOG_INFO_STREAM(<< "FullTextsearch(case sensitive): " << term);
|
caseSensitive = true;
|
||||||
MessageSearchFullText(term, true).dispatch();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_INFO_STREAM(<< "FullTextsearch: " << term);
|
|
||||||
MessageSearchFullText(term).dispatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageSearchFullText(term, caseSensitive).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtSmartSearchBox::QtSmartSearchBox(QWidget* parent)
|
QtSmartSearchBox::QtSmartSearchBox(QWidget* parent)
|
||||||
@@ -126,6 +122,15 @@ void QtSmartSearchBox::setFocus()
|
|||||||
layoutElements();
|
layoutElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtSmartSearchBox::findFulltext()
|
||||||
|
{
|
||||||
|
QLineEdit::setFocus(Qt::ShortcutFocusReason);
|
||||||
|
selectAllElementsWith(true);
|
||||||
|
deleteSelectedElements();
|
||||||
|
|
||||||
|
setEditText(QChar(SearchMatch::FULLTEXT_SEARCH_CHARACTER));
|
||||||
|
}
|
||||||
|
|
||||||
bool QtSmartSearchBox::event(QEvent *event)
|
bool QtSmartSearchBox::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::KeyPress)
|
if (event->type() == QEvent::KeyPress)
|
||||||
@@ -160,7 +165,7 @@ void QtSmartSearchBox::keyPressEvent(QKeyEvent* event)
|
|||||||
|
|
||||||
if (event->key() == Qt::Key_Return)
|
if (event->key() == Qt::Key_Return)
|
||||||
{
|
{
|
||||||
if (text().startsWith('@'))
|
if (text().startsWith(SearchMatch::FULLTEXT_SEARCH_CHARACTER))
|
||||||
{
|
{
|
||||||
fullTextSearch();
|
fullTextSearch();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public:
|
|||||||
void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||||
void setMatches(const std::vector<SearchMatch>& matches);
|
void setMatches(const std::vector<SearchMatch>& matches);
|
||||||
void setFocus();
|
void setFocus();
|
||||||
|
void findFulltext();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool event(QEvent *event);
|
virtual bool event(QEvent *event);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ QtSearchView::QtSearchView(ViewLayout* viewLayout)
|
|||||||
, m_refreshViewFunctor(std::bind(&QtSearchView::doRefreshView, this))
|
, m_refreshViewFunctor(std::bind(&QtSearchView::doRefreshView, this))
|
||||||
, m_setMatchesFunctor(std::bind(&QtSearchView::doSetMatches, this, std::placeholders::_1))
|
, m_setMatchesFunctor(std::bind(&QtSearchView::doSetMatches, this, std::placeholders::_1))
|
||||||
, m_setFocusFunctor(std::bind(&QtSearchView::doSetFocus, this))
|
, m_setFocusFunctor(std::bind(&QtSearchView::doSetFocus, this))
|
||||||
|
, m_findFulltextFunctor(std::bind(&QtSearchView::doFindFulltext, this))
|
||||||
, m_setAutocompletionListFunctor(std::bind(&QtSearchView::doSetAutocompletionList, this, std::placeholders::_1))
|
, m_setAutocompletionListFunctor(std::bind(&QtSearchView::doSetAutocompletionList, this, std::placeholders::_1))
|
||||||
{
|
{
|
||||||
m_widget = new QtSearchBar();
|
m_widget = new QtSearchBar();
|
||||||
@@ -46,6 +47,11 @@ void QtSearchView::setFocus()
|
|||||||
m_setFocusFunctor();
|
m_setFocusFunctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtSearchView::findFulltext()
|
||||||
|
{
|
||||||
|
m_findFulltextFunctor();
|
||||||
|
}
|
||||||
|
|
||||||
void QtSearchView::setAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
|
void QtSearchView::setAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
|
||||||
{
|
{
|
||||||
m_setAutocompletionListFunctor(autocompletionList);
|
m_setAutocompletionListFunctor(autocompletionList);
|
||||||
@@ -69,6 +75,12 @@ void QtSearchView::doSetFocus()
|
|||||||
m_widget->setFocus();
|
m_widget->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtSearchView::doFindFulltext()
|
||||||
|
{
|
||||||
|
getViewLayout()->showView(this);
|
||||||
|
m_widget->findFulltext();
|
||||||
|
}
|
||||||
|
|
||||||
void QtSearchView::doSetAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
|
void QtSearchView::doSetAutocompletionList(const std::vector<SearchMatch>& autocompletionList)
|
||||||
{
|
{
|
||||||
m_widget->setAutocompletionList(autocompletionList);
|
m_widget->setAutocompletionList(autocompletionList);
|
||||||
|
|||||||
@@ -21,12 +21,14 @@ public:
|
|||||||
// SearchView implementation
|
// SearchView implementation
|
||||||
virtual void setMatches(const std::vector<SearchMatch>& matches);
|
virtual void setMatches(const std::vector<SearchMatch>& matches);
|
||||||
virtual void setFocus();
|
virtual void setFocus();
|
||||||
|
virtual void findFulltext();
|
||||||
virtual void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
virtual void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void doRefreshView();
|
void doRefreshView();
|
||||||
void doSetMatches(const std::vector<SearchMatch>& matches);
|
void doSetMatches(const std::vector<SearchMatch>& matches);
|
||||||
void doSetFocus();
|
void doSetFocus();
|
||||||
|
void doFindFulltext();
|
||||||
void doSetAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
void doSetAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||||
|
|
||||||
void setStyleSheet();
|
void setStyleSheet();
|
||||||
@@ -34,6 +36,7 @@ private:
|
|||||||
QtThreadedFunctor<> m_refreshViewFunctor;
|
QtThreadedFunctor<> m_refreshViewFunctor;
|
||||||
QtThreadedFunctor<const std::vector<SearchMatch>&> m_setMatchesFunctor;
|
QtThreadedFunctor<const std::vector<SearchMatch>&> m_setMatchesFunctor;
|
||||||
QtThreadedFunctor<> m_setFocusFunctor;
|
QtThreadedFunctor<> m_setFocusFunctor;
|
||||||
|
QtThreadedFunctor<> m_findFulltextFunctor;
|
||||||
QtThreadedFunctor<const std::vector<SearchMatch>&> m_setAutocompletionListFunctor;
|
QtThreadedFunctor<const std::vector<SearchMatch>&> m_setAutocompletionListFunctor;
|
||||||
|
|
||||||
QtSearchBar* m_widget;
|
QtSearchBar* m_widget;
|
||||||
|
|||||||
@@ -406,6 +406,11 @@ void QtMainWindow::find()
|
|||||||
MessageFind().dispatch();
|
MessageFind().dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtMainWindow::findFulltext()
|
||||||
|
{
|
||||||
|
MessageFind(true).dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
void QtMainWindow::overview()
|
void QtMainWindow::overview()
|
||||||
{
|
{
|
||||||
MessageSearch(std::vector<SearchMatch>(1, SearchMatch::createCommand(SearchMatch::COMMAND_ALL))).dispatch();
|
MessageSearch(std::vector<SearchMatch>(1, SearchMatch::createCommand(SearchMatch::COMMAND_ALL))).dispatch();
|
||||||
@@ -600,7 +605,10 @@ void QtMainWindow::setupEditMenu()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->addAction(tr("&Find"), this, SLOT(find()), QKeySequence::Find);
|
menu->addSeparator();
|
||||||
|
|
||||||
|
menu->addAction(tr("&Find Symbol"), this, SLOT(find()), QKeySequence::Find);
|
||||||
|
menu->addAction(tr("&Find Text"), this, SLOT(findFulltext()), QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_F));
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ public slots:
|
|||||||
void openRecentProject();
|
void openRecentProject();
|
||||||
|
|
||||||
void find();
|
void find();
|
||||||
|
void findFulltext();
|
||||||
void overview();
|
void overview();
|
||||||
|
|
||||||
void closeWindow();
|
void closeWindow();
|
||||||
|
|||||||
Reference in New Issue
Block a user