ui: load project via MenuBar

This change adds a MenuBar to QtMainWindow and adds an action for opening a different project settings XML file. The
message MessageLoadProject is thereon used to load a new project in the Application and clearing the Storage.
This commit is contained in:
Eberhard Graether
2014-07-09 15:22:41 +02:00
parent 37f5579649
commit 2009b7526a
13 changed files with 156 additions and 27 deletions
+10 -3
View File
@@ -23,6 +23,8 @@ std::shared_ptr<Application> Application::create(GuiFactory* guiFactory)
ptr->m_componentManager =
ComponentManager::create(guiFactory, ptr->m_mainView.get(), ptr->m_storage, ptr->m_storage);
ptr->m_componentManager->setup();
return ptr;
}
@@ -36,14 +38,19 @@ Application::~Application()
MessageQueue::getInstance()->stopMessageLoop();
}
void Application::loadProject()
void Application::loadProject(const std::string& projectSettingsFilePath)
{
m_componentManager->setup();
m_storage->clear();
m_project = Project::create(m_storage);
m_project->loadProjectSettings("data/ProjectSettings.xml");
m_project->loadProjectSettings(projectSettingsFilePath);
m_project->parseCode();
MessageActivateToken message(1);
message.dispatch();
}
void Application::handleMessage(MessageLoadProject* message)
{
loadProject(message->projectSettingsFilePath);
}
+6 -2
View File
@@ -5,23 +5,27 @@
#include "component/ComponentManager.h"
#include "Project.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageLoadProject.h"
class GuiFactory;
class MainView;
class Storage;
class Application
class Application: public MessageListener<MessageLoadProject>
{
public:
static std::shared_ptr<Application> create(GuiFactory* guiFactory);
~Application();
void loadProject();
void loadProject(const std::string& projectSettingsFilePath);
private:
Application();
virtual void handleMessage(MessageLoadProject* message);
std::shared_ptr<Project> m_project;
std::shared_ptr<Storage> m_storage;
+2
View File
@@ -130,6 +130,8 @@ add_files(
utility/math/VectorBase.h
utility/messaging/type/MessageActivateToken.h
utility/messaging/type/MessageFinishedParsing.h
utility/messaging/type/MessageLoadProject.h
utility/messaging/Message.h
utility/messaging/MessageBase.h
+21 -14
View File
@@ -18,6 +18,27 @@ Storage::~Storage()
{
}
void Storage::clear()
{
m_graph.clear();
m_locationCollection.clear();
}
void Storage::logGraph() const
{
std::stringstream str;
str << "\n" << m_graph;
LOG_INFO(str.str());
}
void Storage::logLocations() const
{
std::stringstream str;
str << "\n" << m_locationCollection;
LOG_INFO(str.str());
}
void Storage::onTypedefParsed(
const ParseLocation& location, const std::string& fullName, const std::string& underlyingFullName,
AccessType access
@@ -188,20 +209,6 @@ void Storage::onCallParsed(const ParseLocation& location, const std::string& cal
addTokenLocation(edge, location);
}
void Storage::logGraph() const
{
std::stringstream str;
str << "\n" << m_graph;
LOG_INFO(str.str());
}
void Storage::logLocations() const
{
std::stringstream str;
str << "\n" << m_locationCollection;
LOG_INFO(str.str());
}
Id Storage::getIdForNodeWithName(const std::string& name) const
{
+6 -3
View File
@@ -19,6 +19,12 @@ public:
Storage();
virtual ~Storage();
void clear();
void logGraph() const;
void logLocations() const;
// ParserClient implementation
virtual void onTypedefParsed(
const ParseLocation& location, const std::string& fullName, const std::string& underlyingFullName,
AccessType access
@@ -47,9 +53,6 @@ public:
virtual void onCallParsed(
const ParseLocation& location, const std::string& callerName, const std::string& calleeName);
void logGraph() const;
void logLocations() const;
// GraphAccess implementation
virtual Id getIdForNodeWithName(const std::string& name) const;
virtual std::string getNameForNodeWithId(Id id) const;
+6
View File
@@ -223,6 +223,12 @@ void Graph::forEachToken(std::function<void(Token*)> func) const
forEachEdge(func);
}
void Graph::clear()
{
m_edges.clear();
m_nodes.clear();
}
const std::vector<std::shared_ptr<Node> >& Graph::getNodes() const
{
return m_nodes;
+2
View File
@@ -38,6 +38,8 @@ public:
Node* addNodeAsPlainCopy(Node* node);
Edge* addEdgeAsPlainCopy(Edge* edge);
void clear();
protected:
const std::vector<std::shared_ptr<Node> >& getNodes() const;
const std::vector<std::shared_ptr<Edge> >& getEdges() const;
@@ -129,6 +129,12 @@ TokenLocation* TokenLocationCollection::addTokenLocationAsPlainCopy(const TokenL
return copy;
}
void TokenLocationCollection::clear()
{
m_locations.clear();
m_files.clear();
}
TokenLocationFile* TokenLocationCollection::createTokenLocationFile(const std::string& filePath)
{
TokenLocationFile* file = findTokenLocationFileByPath(filePath);
@@ -43,6 +43,8 @@ public:
TokenLocation* addTokenLocationAsPlainCopy(const TokenLocation* location);
void clear();
private:
TokenLocationFile* createTokenLocationFile(const std::string& filePath);
@@ -0,0 +1,22 @@
#ifndef MESSAGE_LOAD_PROJECT_H
#define MESSAGE_LOAD_PROJECT_H
#include "utility/messaging/Message.h"
class MessageLoadProject: public Message<MessageLoadProject>
{
public:
MessageLoadProject(const std::string& filePath)
: projectSettingsFilePath(filePath)
{
}
static const std::string getStaticType()
{
return "MessageLoadProject";
}
const std::string projectSettingsFilePath;
};
#endif // MESSAGE_LOAD_PROJECT_H