HAL
file_status_manager.cpp
Go to the documentation of this file.
3 
4 #include "gui/gui_globals.h"
5 
6 namespace hal
7 {
9  mModifiedFilesUuid(QSet<QUuid>()), mModifiedFilesDescriptors(QMap<QUuid, QString>()),
10  mNetlistModified(false), mGatelibModified(false)
11  {;}
12 
14  {;}
15 
16  void FileStatusManager::fileChanged(const QUuid uuid, const QString& descriptor)
17  {
18  bool before = modifiedFilesExisting();
19  mModifiedFilesUuid.insert(uuid);
20  mModifiedFilesDescriptors.insert(uuid, descriptor);
21  if (before != modifiedFilesExisting())
22  Q_EMIT status_changed(false, true);
23  }
24 
26  {
27  bool before = modifiedFilesExisting();
28  mModifiedFilesUuid.remove(uuid);
29  mModifiedFilesDescriptors.remove(uuid);
30  if (before != modifiedFilesExisting())
31  Q_EMIT status_changed(false, false);
32  }
33 
35  {
36  if (!FileManager::get_instance()->fileOpen())
37  return false;
38 
39  return !mModifiedFilesUuid.empty() || mNetlistModified;
40  }
41 
43  {
44  bool before = modifiedFilesExisting();
45  mNetlistModified = true;
46  if (before != modifiedFilesExisting())
47  Q_EMIT status_changed(false, true);
48  }
49 
51  {
52  bool before = modifiedFilesExisting();
53  mNetlistModified = false;
54  if (before != modifiedFilesExisting())
55  Q_EMIT status_changed(false, false);
56  }
57 
59  {
60  mNetlistModified = false;
61  mModifiedFilesUuid.clear();
62  mModifiedFilesDescriptors.clear();
63  Q_EMIT status_changed(false, false);
64  }
65 
67  {
68  mGatelibModified = true;
69  Q_EMIT status_changed(true, true);
70  }
71 
73  {
74  mGatelibModified = false;
75  Q_EMIT status_changed(true, false);
76  }
77 
79  {
80  return mGatelibModified;
81  }
82 
84  {
85  QList<QString> unsaved_changes_descriptors;
86 
87  if(mNetlistModified)
88  {
89  unsaved_changes_descriptors.append("Netlist modifications");
90  }
91 
92  for(QUuid uuid : mModifiedFilesUuid)
93  {
94  unsaved_changes_descriptors.append(mModifiedFilesDescriptors.value(uuid));
95  }
96 
97  return unsaved_changes_descriptors;
98  }
99 }
static FileManager * get_instance()
void fileChanged(const QUuid uuid, const QString &descriptor)
FileStatusManager(QObject *parent=nullptr)
QList< QString > getUnsavedChangeDescriptors() const
void fileSaved(const QUuid uuid)
void status_changed(bool gateLibrary, bool isDirty)
void append(const T &value)
void clear()
QMap::iterator insert(const Key &key, const T &value)
int remove(const Key &key)
const T value(const Key &key, const T &defaultValue) const const
Q_EMITQ_EMIT
void clear()
bool empty() const const
QSet::iterator insert(const T &value)
bool remove(const T &value)