logic: code controller communication
- Replaced CodeAccess with LocationAccess. - Implemented basic functionality for CodeController. - Added messaging to the project. - Added QtThreadedFunctor to enable our Messaging thread to invoke calls on the QtThread. - Added GraphController. fortune cookie message = Good news from someone dear is coming soon.
This commit is contained in:
@@ -1 +1,39 @@
|
||||
#include "component/controller/CodeController.h"
|
||||
|
||||
#include "component/view/CodeView.h"
|
||||
#include "data/access/LocationAccess.h"
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
|
||||
CodeController::CodeController(std::shared_ptr<LocationAccess> locationAccess)
|
||||
: m_locationAccess(locationAccess)
|
||||
{
|
||||
}
|
||||
|
||||
CodeController::~CodeController()
|
||||
{
|
||||
}
|
||||
|
||||
void CodeController::setActiveTokenLocationId(Id id)
|
||||
{
|
||||
TokenLocation* tokenLocation = m_locationAccess->getTokenLocation(id);
|
||||
if (tokenLocation)
|
||||
{
|
||||
getView()->clearCodeSnippets();
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(tokenLocation->getFilePath());
|
||||
getView()->addCodeSnippet(textAccess->getText());
|
||||
}
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageActivateTokenLocation* message)
|
||||
{
|
||||
setActiveTokenLocationId(1);
|
||||
}
|
||||
|
||||
CodeView* CodeController::getView()
|
||||
{
|
||||
return Controller::getView<CodeView>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,35 @@
|
||||
#ifndef CODE_CONTROLLER_H
|
||||
#define CODE_CONTROLLER_H
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include <string>
|
||||
|
||||
class CodeController: public Controller
|
||||
#include "component/controller/Controller.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenLocation.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class CodeView;
|
||||
class LocationAccess;
|
||||
|
||||
struct AnnotatedText
|
||||
{
|
||||
std::string text;
|
||||
Id tokenId;
|
||||
};
|
||||
|
||||
class CodeController: public Controller, public MessageListener<MessageActivateTokenLocation>
|
||||
{
|
||||
public:
|
||||
CodeController(std::shared_ptr<LocationAccess> locationAccess);
|
||||
~CodeController();
|
||||
|
||||
void setActiveTokenLocationId(Id id);
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageActivateTokenLocation* message);
|
||||
CodeView* getView();
|
||||
|
||||
std::shared_ptr<LocationAccess> m_locationAccess;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
#include "component/controller/Controller.h"
|
||||
|
||||
Controller::Controller()
|
||||
{
|
||||
}
|
||||
|
||||
Controller::~Controller()
|
||||
{
|
||||
}
|
||||
|
||||
void Controller::setComponent(Component* component)
|
||||
{
|
||||
m_component = component;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,32 @@
|
||||
#ifndef CONTROLLER_H
|
||||
#define CONTROLLER_H
|
||||
|
||||
#include "component/Component.h"
|
||||
|
||||
class Controller
|
||||
{
|
||||
public:
|
||||
Controller();
|
||||
virtual ~Controller();
|
||||
|
||||
void setComponent(Component* component);
|
||||
|
||||
protected:
|
||||
template <typename ViewType>
|
||||
ViewType* getView();
|
||||
|
||||
private:
|
||||
Component* m_component;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <typename ViewType>
|
||||
ViewType* Controller::getView()
|
||||
{
|
||||
if (m_component)
|
||||
return m_component->getView<ViewType>();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // CONTROLLER_H
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "component/controller/GraphController.h"
|
||||
|
||||
#include "component/view/GraphView.h"
|
||||
#include "data/access/GraphAccess.h"
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
|
||||
GraphController::GraphController(std::shared_ptr<GraphAccess> graphAccess)
|
||||
: m_graphAccess(graphAccess)
|
||||
{
|
||||
}
|
||||
|
||||
GraphController::~GraphController()
|
||||
{
|
||||
}
|
||||
|
||||
GraphView* GraphController::getView()
|
||||
{
|
||||
return Controller::getView<GraphView>();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef GRAPH_CONTROLLER_H
|
||||
#define GRAPH_CONTROLLER_H
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
|
||||
class GraphView;
|
||||
class GraphAccess;
|
||||
|
||||
class GraphController: public Controller
|
||||
{
|
||||
public:
|
||||
GraphController(std::shared_ptr<GraphAccess> graphAccess);
|
||||
~GraphController();
|
||||
|
||||
private:
|
||||
GraphView* getView();
|
||||
|
||||
std::shared_ptr<GraphAccess> m_graphAccess;
|
||||
};
|
||||
|
||||
|
||||
#endif // GRAPH_CONTROLLER_H
|
||||
Reference in New Issue
Block a user