data: saving for projectsettings
<description>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageLoadSource.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageSaveProject.h"
|
||||
|
||||
QtMainWindow::QtMainWindow()
|
||||
{
|
||||
@@ -71,6 +72,22 @@ void QtMainWindow::openProject(const QString &path)
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::saveProject()
|
||||
{
|
||||
MessageSaveProject("").dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::saveAsProject()
|
||||
{
|
||||
QString filename = "";
|
||||
filename = QFileDialog::getSaveFileName(this, "Save File as", "", "XML Files(*.xml)");
|
||||
|
||||
if(!filename.isEmpty())
|
||||
{
|
||||
MessageSaveProject(filename.toStdString()).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::find()
|
||||
{
|
||||
MessageFind().dispatch();
|
||||
@@ -184,6 +201,8 @@ void QtMainWindow::setupProjectMenu()
|
||||
|
||||
menu->addAction(tr("&New"), this, SLOT(newProject()), QKeySequence::New);
|
||||
menu->addAction(tr("&Open..."), this, SLOT(openProject()), QKeySequence::Open);
|
||||
menu->addAction(tr("&Save"), this, SLOT(saveProject()), QKeySequence::Save);
|
||||
menu->addAction(tr("Save as"), this, SLOT(saveAsProject()), QKeySequence::SaveAs);
|
||||
menu->addAction(tr("E&xit"), QCoreApplication::instance(), SLOT(quit()), QKeySequence::Quit);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ public slots:
|
||||
void find();
|
||||
void closeWindow();
|
||||
void refresh();
|
||||
void saveProject();
|
||||
void saveAsProject();
|
||||
|
||||
private:
|
||||
void setupProjectMenu();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "component/view/ViewFactory.h"
|
||||
#include "data/access/GraphAccessProxy.h"
|
||||
#include "data/access/LocationAccessProxy.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
|
||||
@@ -67,6 +68,14 @@ void Application::reloadProject()
|
||||
MessageActivateToken(1).dispatch();
|
||||
}
|
||||
|
||||
void Application::saveProject(const std::string& projectSettingsFilePath)
|
||||
{
|
||||
if(!m_project->saveProjectSettings(projectSettingsFilePath))
|
||||
{
|
||||
LOG_ERROR("No Project Settings File defined");
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageLoadProject* message)
|
||||
{
|
||||
loadProject(message->projectSettingsFilePath);
|
||||
@@ -81,3 +90,8 @@ void Application::handleMessage(MessageRefresh* message)
|
||||
{
|
||||
reloadProject();
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageSaveProject* message)
|
||||
{
|
||||
saveProject(message->projectSettingsFilePath);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageLoadSource.h"
|
||||
#include "utility/messaging/type/MessageSaveProject.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
|
||||
class ViewFactory;
|
||||
@@ -19,6 +20,7 @@ class Application
|
||||
: public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageLoadSource>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageSaveProject>
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Application> create(ViewFactory* viewFactory);
|
||||
@@ -27,6 +29,7 @@ public:
|
||||
|
||||
void loadProject(const std::string& projectSettingsFilePath);
|
||||
void loadSource(const std::string& sourceDirectoryPath);
|
||||
void saveProject(const std::string& projectSettingsFilePath);
|
||||
void reloadProject();
|
||||
|
||||
private:
|
||||
@@ -35,6 +38,7 @@ private:
|
||||
virtual void handleMessage(MessageLoadProject* message);
|
||||
virtual void handleMessage(MessageLoadSource* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
virtual void handleMessage(MessageSaveProject* message);
|
||||
|
||||
std::shared_ptr<Project> m_project;
|
||||
std::shared_ptr<GraphAccessProxy> m_graphAccessProxy;
|
||||
|
||||
+28
-1
@@ -10,6 +10,7 @@
|
||||
#include "data/parser/cxx/CxxParser.h"
|
||||
#include "utility/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
std::shared_ptr<Project> Project::create(GraphAccessProxy* graphAccessProxy, LocationAccessProxy* locationAccessProxy)
|
||||
{
|
||||
@@ -24,16 +25,42 @@ Project::~Project()
|
||||
|
||||
bool Project::loadProjectSettings(const std::string& projectSettingsFile)
|
||||
{
|
||||
return ProjectSettings::getInstance()->load(projectSettingsFile);
|
||||
bool success = ProjectSettings::getInstance()->load(projectSettingsFile);
|
||||
if(success)
|
||||
{
|
||||
m_projectSettingsFilepath = projectSettingsFile;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Project::saveProjectSettings( const std::string& projectSettingsFile )
|
||||
{
|
||||
if(!projectSettingsFile.empty())
|
||||
{
|
||||
m_projectSettingsFilepath = projectSettingsFile;
|
||||
ProjectSettings::getInstance()->save(projectSettingsFile);
|
||||
}
|
||||
else if (!m_projectSettingsFilepath.empty())
|
||||
{
|
||||
ProjectSettings::getInstance()->save(m_projectSettingsFilepath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
LOG_INFO_STREAM(<< "Projectsettings saved in File: " << m_projectSettingsFilepath);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::clearProjectSettings()
|
||||
{
|
||||
m_projectSettingsFilepath.clear();
|
||||
ProjectSettings::getInstance()->clear();
|
||||
}
|
||||
|
||||
bool Project::setSourceDirectoryPath(const std::string& sourceDirectoryPath)
|
||||
{
|
||||
m_projectSettingsFilepath = sourceDirectoryPath + "/ProjectSettings.xml";
|
||||
return ProjectSettings::getInstance()->setSourcePath(sourceDirectoryPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
~Project();
|
||||
|
||||
bool loadProjectSettings(const std::string& projectSettingsFile);
|
||||
bool saveProjectSettings(const std::string& projectSettingsFile);
|
||||
void clearProjectSettings();
|
||||
|
||||
bool setSourceDirectoryPath(const std::string& sourceDirectoryPath);
|
||||
@@ -29,6 +30,8 @@ private:
|
||||
Project(const Project&);
|
||||
Project operator=(const Project&);
|
||||
|
||||
std::string m_projectSettingsFilepath;
|
||||
|
||||
GraphAccessProxy* const m_graphAccessProxy;
|
||||
LocationAccessProxy* const m_locationAccessProxy;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef MESSAGE_SAVE_PROJECT_H
|
||||
#define MESSAGE_SAVE_PROJECT_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageSaveProject: public Message<MessageSaveProject>
|
||||
{
|
||||
public:
|
||||
MessageSaveProject(const std::string& filePath)
|
||||
: projectSettingsFilePath(filePath)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageSaveProject";
|
||||
}
|
||||
|
||||
const std::string projectSettingsFilePath;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SAVE_PROJECT_H
|
||||
Reference in New Issue
Block a user