ui: basic search view
- Added a basic SearchView (+ controller and qt implementation) - SearchView can set the active element of other views by dispatching a message. - SearchView adjusts its text when the active element is changed by other views. - Added wrappers for Button and EditBox that allow the usage of simple callback functions.
This commit is contained in:
@@ -17,7 +17,9 @@ struct AnnotatedText
|
||||
Id tokenId;
|
||||
};
|
||||
|
||||
class CodeController: public Controller, public MessageListener<MessageActivateToken>
|
||||
class CodeController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateToken>
|
||||
{
|
||||
public:
|
||||
CodeController(std::shared_ptr<LocationAccess> locationAccess);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "component/controller/SearchController.h"
|
||||
|
||||
#include "component/view/SearchView.h"
|
||||
#include "data/access/GraphAccess.h"
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
|
||||
SearchController::SearchController(std::shared_ptr<GraphAccess> graphAccess)
|
||||
: m_graphAccess(graphAccess)
|
||||
{
|
||||
}
|
||||
|
||||
SearchController::~SearchController()
|
||||
{
|
||||
}
|
||||
|
||||
void SearchController::search(const std::string& s)
|
||||
{
|
||||
LOG_INFO("searching string: \"" + s + "\"");
|
||||
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));
|
||||
}
|
||||
|
||||
SearchView* SearchController::getView()
|
||||
{
|
||||
return Controller::getView<SearchView>();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef SEARCH_CONTROLLER_H
|
||||
#define SEARCH_CONTROLLER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
|
||||
class GraphAccess;
|
||||
class SearchView;
|
||||
|
||||
class SearchController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateToken>
|
||||
{
|
||||
public:
|
||||
SearchController(std::shared_ptr<GraphAccess> graphAccess);
|
||||
~SearchController();
|
||||
|
||||
void search(const std::string& s);
|
||||
//void autocomplete(const std::string& s);
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageActivateToken* message);
|
||||
SearchView* getView();
|
||||
|
||||
std::shared_ptr<GraphAccess> m_graphAccess;
|
||||
};
|
||||
|
||||
#endif // SEARCH_CONTROLLER_H
|
||||
Reference in New Issue
Block a user