ui: integrated autocompletion and filtering into SearchView

- QtSearchView was split into QtSearchView and QtSearchBox.
- QtSearchBox contains all Qt elements and can use them purely
- QtSearchView forwards calls from the SearchController to QtSearchBox
- Searching is initiated with MessageSearch to the SearchController
- Autocompletion is initiated with MessageSearchAutocomplete to the SearchController
- The search field is able to create filter queries by only giving autocompletions for the last token in the query
- For named tokens the search field adds their token ids to the query in the form of "A,25" for faster lookup

bug id = #21
This commit is contained in:
Eberhard Graether
2014-09-11 14:53:03 +02:00
parent 760e5ffafd
commit fec7abbc9b
48 changed files with 786 additions and 391 deletions
@@ -13,30 +13,6 @@ SearchController::~SearchController()
{
}
void SearchController::search(const std::string& s)
{
LOG_INFO("searching string: \"" + s + "\"");
std::vector<Id> ids = m_graphAccess->getTokenIdsForQuery(s);
if (ids.size())
{
MessageActivateTokens(ids).dispatch();
return;
}
Id nodeId = m_graphAccess->getIdForNodeWithName(s);
if (nodeId > 0)
{
LOG_INFO("Node with name \"" + s + "\" found.");
MessageActivateToken message(nodeId);
message.dispatch();
}
else
{
LOG_INFO("Node with name \"" + s + "\" not found.");
}
}
void SearchController::handleMessage(MessageActivateToken* message)
{
getView()->setText(m_graphAccess->getNameForNodeWithId(message->tokenId));
@@ -47,16 +23,38 @@ void SearchController::handleMessage(MessageFind* message)
getView()->setFocus();
}
void SearchController::handleMessage(MessageFinishedParsing* message)
{
getView()->setAutocompletionList(m_graphAccess->getNamesForNodesWithNamePrefix(":"));
}
void SearchController::handleMessage(MessageRefresh* message)
{
getView()->refreshView();
}
void SearchController::handleMessage(MessageSearch* message)
{
const std::string& query = message->query;
LOG_INFO("search string: \"" + query + "\"");
std::vector<Id> ids = m_graphAccess->getTokenIdsForQuery(query);
if (ids.size())
{
MessageActivateTokens(ids).dispatch();
return;
}
Id nodeId = m_graphAccess->getIdForNodeWithName(query);
if (nodeId > 0)
{
MessageActivateToken message(nodeId);
message.dispatch();
}
}
void SearchController::handleMessage(MessageSearchAutocomplete* message)
{
LOG_INFO("autocomplete string: \"" + message->query + "\"");
getView()->setAutocompletionList(m_graphAccess->getAutocompletionMatches(message->query));
}
SearchView* SearchController::getView()
{
return Controller::getView<SearchView>();
@@ -7,8 +7,9 @@
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageActivateToken.h"
#include "utility/messaging/type/MessageFind.h"
#include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageSearch.h"
#include "utility/messaging/type/MessageSearchAutocomplete.h"
class GraphAccess;
class SearchView;
@@ -17,21 +18,21 @@ class SearchController
: public Controller
, public MessageListener<MessageActivateToken>
, public MessageListener<MessageFind>
, public MessageListener<MessageFinishedParsing>
, public MessageListener<MessageRefresh>
, public MessageListener<MessageSearch>
, public MessageListener<MessageSearchAutocomplete>
{
public:
SearchController(GraphAccess* graphAccess);
~SearchController();
void search(const std::string& s);
//void autocomplete(const std::string& s);
private:
virtual void handleMessage(MessageActivateToken* message);
virtual void handleMessage(MessageFind* message);
virtual void handleMessage(MessageFinishedParsing* message);
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageSearch* message);
virtual void handleMessage(MessageSearchAutocomplete* message);
SearchView* getView();
GraphAccess* m_graphAccess;