HAL  v4.5.0-255-g8271db4e6
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
file_manager.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
29 
30 #include <QObject>
31 #include <QTimer>
32 #include <QDir>
33 
34 class QFileSystemWatcher;
35 
36 namespace hal
37 {
38  class GateLibrary;
39  class SettingsItemCheckbox;
40  class SettingsItemSpinbox;
48  class FileManager : public QObject
49  {
50  Q_OBJECT
51 
52  public:
58  static FileManager* get_instance();
59 
65  QString fileName() const;
66 
72  bool fileOpen() const;
73 
81  void watchFile(const QString& fileName);
82 
89  void emitProjectSaved(QString& projectDir, QString& file);
90 
96 
102  static DirectoryStatus directoryStatus(const QString& pathname);
103 
110 
117  static GateLibrary* loadGateLibrary(const QString& path);
118  Q_SIGNALS:
125 
133 
141 
147  void fileChanged(const QString& path);
148 
154  void fileDirectoryChanged(const QString& path);
155 
159  void fileClosed();
160 
167 
168  public Q_SLOTS:
169 
177  bool deprecatedOpenFile(QString filename, QString gatelibraryPath);
178 
179 
185  void importFile(QString filename);
186 
190  void newProject();
191 
197  void openProject(QString projPath);
198 
202  void closeFile();
203 
207  void autosave();
208 
209  private Q_SLOTS:
210  void handleFileChanged(const QString& path);
211  void handleDirectoryChanged(const QString& path);
212 
213  private:
219  FileManager(QObject* parent = nullptr);
220 
226  void fileSuccessfullyLoaded(QString file);
227 
234  void projectSuccessfullyLoaded(QString& projectDir, QString& file);
235 
242  void updateRecentFiles(const QString& file) const;
243 
249  void displayErrorMessage(QString error_message);
250 
254  void removeShadowDirectory();
255 
260  void moveShadowToProject(const QDir& shDir) const;
261 
262  QString mFileName;
263  QFileSystemWatcher* mFileWatcher;
264  bool mFileOpen;
265  QTimer* mTimer;
266  bool mAutosaveEnabled;
267  int mAutosaveInterval;
268 
269  SettingsItemCheckbox* mSettingAutosave;
270  SettingsItemSpinbox* mSettingAutosaveInterval;
271  };
272 }
Stores information about the currently opened netlist.
Definition: file_manager.h:49
void importFile(QString filename)
void fileDirectoryChanged(const QString &path)
bool deprecatedOpenFile(QString filename, QString gatelibraryPath)
void openProject(QString projPath)
static FileManager * get_instance()
static DirectoryStatus directoryStatus(const QString &pathname)
void emitProjectSaved(QString &projectDir, QString &file)
void watchFile(const QString &fileName)
void fileChanged(const QString &path)
void projectSaved(QString projectDir, QString fileName)
bool fileOpen() const
QString fileName() const
void fileAboutToClose(const QString &fileName)
static GateLibrary * loadGateLibrary(const QString &path)
void projectOpened(QString projectDir, QString fileName)
void fileOpened(const QString &fileName)
static QString directoryStatusText(DirectoryStatus stat)
A SettingsItem representing a Checkbox.
A SettingsItem that represents a spinbox.
Definition: defines.h:45
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const