HAL
graph_context_serializer.cpp
Go to the documentation of this file.
3 #include "gui/gui_globals.h"
4 #include <QString>
5 
6 namespace hal
7 {
8 
9  void GraphContextSerializer::deserialize(Netlist* netlist, const std::filesystem::path& loaddir)
10  {
11  Q_UNUSED(netlist);
12  restore(loaddir);
13  }
14 
15  bool GraphContextSerializer::restore(const std::filesystem::path& loaddir)
16  {
18  std::string relname = pm->get_filename(m_name);
19  if (relname.empty()) return false;
20  std::filesystem::path filename = loaddir.empty() ? pm->get_project_directory() : loaddir;
21  filename.append(relname);
22  mSelectedContext = gGraphContextManager->restoreFromFile(QString::fromStdString(filename.string()));
23  return (mSelectedContext != nullptr);
24  }
25 
26  std::string GraphContextSerializer::serialize(Netlist* netlist, const std::filesystem::path& savedir, bool isAutoSave)
27  {
28  Q_UNUSED(netlist);
29  Q_UNUSED(isAutoSave);
30  std::string ctxFile("views.json");
31  std::filesystem::path ctxPath(savedir);
32  ctxPath.append(ctxFile);
34  return std::string();
35  return ctxFile;
36  }
37 }
38 
bool handleSaveTriggered(const QString &filename)
GraphContext * restoreFromFile(const QString &filename)
bool restore(const std::filesystem::path &loaddir=std::filesystem::path())
void deserialize(Netlist *netlist, const std::filesystem::path &loaddir)
std::string serialize(Netlist *netlist, const std::filesystem::path &savedir, bool isAutoSave)
static ProjectManager * instance()
std::string get_filename(const std::string &serializer_name)
const ProjectDirectory & get_project_directory() const
GraphContextManager * gGraphContextManager
Definition: plugin_gui.cpp:85
QString fromStdString(const std::string &str)