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