HAL
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 SettingsItemCheckbox;
39  class SettingsItemSpinbox;
47  class FileManager : public QObject
48  {
49  Q_OBJECT
50 
51  public:
57  static FileManager* get_instance();
58 
64  QString fileName() const;
65 
71  bool fileOpen() const;
72 
80  void watchFile(const QString& fileName);
81 
88  void emitProjectSaved(QString& projectDir, QString& file);
89 
95 
101  static DirectoryStatus directoryStatus(const QString& pathname);
102 
109  Q_SIGNALS:
116 
124 
132 
138  void fileChanged(const QString& path);
139 
145  void fileDirectoryChanged(const QString& path);
146 
150  void fileClosed();
151 
158 
159  public Q_SLOTS:
160 
168  bool deprecatedOpenFile(QString filename, QString gatelibraryPath);
169 
170 
176  void importFile(QString filename);
177 
181  void newProject();
182 
188  void openProject(QString projPath);
189 
193  void closeFile();
194 
198  void autosave();
199 
200  private Q_SLOTS:
201  void handleFileChanged(const QString& path);
202  void handleDirectoryChanged(const QString& path);
203 
204  private:
210  FileManager(QObject* parent = nullptr);
211 
217  void fileSuccessfullyLoaded(QString file);
218 
225  void projectSuccessfullyLoaded(QString& projectDir, QString& file);
226 
233  void updateRecentFiles(const QString& file) const;
234 
240  void displayErrorMessage(QString error_message);
241 
245  void removeShadowDirectory();
246 
251  void moveShadowToProject(const QDir& shDir) const;
252 
253  QString mFileName;
254  QFileSystemWatcher* mFileWatcher;
255  bool mFileOpen;
256  QTimer* mTimer;
257  bool mAutosaveEnabled;
258  int mAutosaveInterval;
259 
260  SettingsItemCheckbox* mSettingAutosave;
261  SettingsItemSpinbox* mSettingAutosaveInterval;
262  };
263 }
then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file
Stores information about the currently opened netlist.
Definition: file_manager.h:48
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)
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.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const