Files
Sourcetrail/src/lib/component/controller/SearchController.cpp
T
Eberhard Graether a527a3c34d logic: rewrote messages handling token activation for correct restoring on undo
* saving search query to undo stack with MessageSearch
* saving node and edge with name to undo stack with MessageActivateNode and MessageActivateEdge
* added FeatureController that handels distribution of MessageActivateTokens
* clearing views when refreshing or changing project
* clearing undo stack when changing project
* added StorageCache derived from StorageAccessProxy
2015-06-19 00:20:50 +02:00

73 lines
1.9 KiB
C++

#include "component/controller/SearchController.h"
#include "component/view/SearchView.h"
#include "data/access/StorageAccess.h"
SearchController::SearchController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
{
}
SearchController::~SearchController()
{
}
void SearchController::handleMessage(MessageActivateEdge* message)
{
SearchMatch match;
match.fullName = message->name;
match.nodeType = Node::NODE_CLASS;
match.tokenIds.insert(message->tokenId);
match.queryNodeType = QueryNode::QUERYNODETYPE_TOKEN;
getView()->setMatches(std::deque<SearchMatch>(1, match));
}
void SearchController::handleMessage(MessageActivateFile* message)
{
SearchMatch match;
match.fullName = message->filePath.fileName();
match.nodeType = Node::NODE_FILE;
match.tokenIds.insert(m_storageAccess->getTokenIdForFileNode(message->filePath));
match.queryNodeType = QueryNode::QUERYNODETYPE_TOKEN;
getView()->setMatches(std::deque<SearchMatch>(1, match));
}
void SearchController::handleMessage(MessageActivateNode* message)
{
SearchMatch match;
match.fullName = message->name;
match.nodeType = message->type;
match.tokenIds.insert(message->tokenId);
match.queryNodeType = QueryNode::QUERYNODETYPE_TOKEN;
getView()->setMatches(std::deque<SearchMatch>(1, match));
}
void SearchController::handleMessage(MessageFind* message)
{
getView()->setFocus();
}
void SearchController::handleMessage(MessageFinishedParsing* message)
{
getView()->setMatches(std::deque<SearchMatch>());
}
void SearchController::handleMessage(MessageSearch* message)
{
getView()->setMatches(message->getMatches());
}
void SearchController::handleMessage(MessageSearchAutocomplete* message)
{
LOG_INFO("autocomplete string: \"" + message->word + "\"");
getView()->setAutocompletionList(m_storageAccess->getAutocompletionMatches(message->query, message->word));
}
SearchView* SearchController::getView()
{
return Controller::getView<SearchView>();
}