From d55eb62bca39a4ef408ba3aceeb6f4c24699e8e8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 12 May 2018 12:47:58 +0200 Subject: Add initial project serialisation/deserialisation. --- src/mainwindow.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/mainwindow.cc') diff --git a/src/mainwindow.cc b/src/mainwindow.cc index ea86b3c..9dabde1 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -26,6 +26,8 @@ */ #include "mainwindow.h" +#include + #include #include @@ -52,6 +54,7 @@ #include "zoomslider.h" #include "settings.h" #include "projectdialog.h" +#include "projectserialiser.h" #define MAXVAL 10000000L @@ -107,6 +110,14 @@ MainWindow::MainWindow(Settings& settings) fileMenu->addAction(act_new_project); connect(act_new_project, SIGNAL(triggered()), this, SLOT(newProject())); + QAction* act_load_project = new QAction(tr("&Load Project..."), this); + fileMenu->addAction(act_load_project); + connect(act_load_project, SIGNAL(triggered()), this, SLOT(loadProject())); + + QAction* act_save_project = new QAction(tr("&Save Project..."), this); + fileMenu->addAction(act_save_project); + connect(act_save_project, SIGNAL(triggered()), this, SLOT(saveProject())); + QAction* act_quit = new QAction(tr("&Quit"), this); fileMenu->addAction(act_quit); connect(act_quit, SIGNAL(triggered()), this, SLOT(close())); @@ -457,6 +468,31 @@ void MainWindow::newProject() dlg.exec(); } +void MainWindow::loadProject() +{ + QFile file("test.dgedit"); + if(!file.open(QIODevice::ReadOnly)) + { + return; + } + + QString xml(file.readAll()); + file.close(); + + ProjectSerialiser ser; + ser.deserialise(xml, project); + + std::cout << project.getProjectName().toStdString() << std::endl; + std::cout << project.getRawFileRoot().toStdString() << std::endl; +} + +void MainWindow::saveProject() +{ + ProjectSerialiser ser; + auto xml = ser.serialise(project); + std::cout << xml.toStdString() << std::endl; +} + void MainWindow::projectChanged() { statusBar()->showMessage(tr("Unsaved")); -- cgit v1.2.3