HAL
hal::FileManager Class Reference

Stores information about the currently opened netlist. More...

#include <file_manager.h>

Inheritance diagram for hal::FileManager:
Inheritance graph
Collaboration diagram for hal::FileManager:
Collaboration graph

Public Types

enum  DirectoryStatus {
  ProjectDirectory =2 , OtherDirectory =1 , IsFile =0 , NotExisting =-1 ,
  InvalidExtension =-2 , ParseError =-3 , NetlistError =-4 , GatelibError =-5 ,
  UnknownDirectoryEntry =-6
}
 

Public Slots

bool deprecatedOpenFile (QString filename, QString gatelibraryPath)
 
void importFile (QString filename)
 
void newProject ()
 
void openProject (QString projPath)
 
void closeFile ()
 
void autosave ()
 

Signals

void fileOpened (const QString &fileName)
 
void projectOpened (QString projectDir, QString fileName)
 
void projectSaved (QString projectDir, QString fileName)
 
void fileChanged (const QString &path)
 
void fileDirectoryChanged (const QString &path)
 
void fileClosed ()
 
void fileAboutToClose (const QString &fileName)
 

Public Member Functions

QString fileName () const
 
bool fileOpen () const
 
void watchFile (const QString &fileName)
 
void emitProjectSaved (QString &projectDir, QString &file)
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 QObject (QObject *parent)
 
virtual ~QObject ()
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectListchildren () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

Static Public Member Functions

static FileManagerget_instance ()
 
static DirectoryStatus directoryStatus (const QString &pathname)
 
static QString directoryStatusText (DirectoryStatus stat)
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Stores information about the currently opened netlist.

The FileManager handles the status and information of the currently opened netlist file including whether a file is opened or not. This class is implemented with a singleton pattern.

Definition at line 47 of file file_manager.h.

Member Enumeration Documentation

◆ DirectoryStatus

Return values for static method directoryStatus

Enumerator
ProjectDirectory 
OtherDirectory 
IsFile 
NotExisting 
InvalidExtension 
ParseError 
NetlistError 
GatelibError 
UnknownDirectoryEntry 

Definition at line 93 of file file_manager.h.

Member Function Documentation

◆ autosave

void hal::FileManager::autosave ( )
slot

Serializes the project to the shadowfile. Called in regular intervals that can be set via the settings.

Definition at line 91 of file file_manager.cpp.

References hal::ProjectManager::get_project_directory(), hal::ProjectManager::get_project_status(), hal::ProjectDirectory::get_shadow_dir(), hal::gNetlist, hal::gPythonContext, log_info, and log_warning.

◆ closeFile

void hal::FileManager::closeFile ( )
slot

Closes the file and resets all information regarding the closed file.

Definition at line 668 of file file_manager.cpp.

References hal::NetlistRelay::debugHandleFileClosed(), hal::gNetlist, hal::gNetlistOwner, hal::gNetlistRelay, and hal::NetlistRelay::unregisterNetlistCallbacks().

◆ deprecatedOpenFile

bool hal::FileManager::deprecatedOpenFile ( QString  filename,
QString  gatelibraryPath 
)
slot

◆ directoryStatus()

FileManager::DirectoryStatus hal::FileManager::directoryStatus ( const QString pathname)
static

◆ directoryStatusText()

QString hal::FileManager::directoryStatusText ( DirectoryStatus  stat)
static

This function returns a text explaining the DirectoryStatus value when searchin for HAL project directories

Parameters
statDirectoryStatus value as returned by directoryStatus()
Returns
Text for status message or message box.

Definition at line 224 of file file_manager.cpp.

Referenced by hal::ProjectDirDialog::accept(), and hal::ProjectDirDialogStatus::setMessage().

◆ emitProjectSaved()

void hal::FileManager::emitProjectSaved ( QString projectDir,
QString file 
)

This function is called by openDirectory when the hal was saved.

Parameters
projectDir- the project directory
file- the file name

Definition at line 147 of file file_manager.cpp.

References file.

◆ fileAboutToClose

void hal::FileManager::fileAboutToClose ( const QString fileName)
signal

Q_SIGNAL that is emitted when the file is about to be closed.

Parameters
fileName- The name of the file that will be closed.

Referenced by hal::PythonEditor::PythonEditor().

◆ fileChanged

void hal::FileManager::fileChanged ( const QString path)
signal

Q_SIGNAL that is emitted when the file changed.

Parameters
path- The new file.

◆ fileClosed

void hal::FileManager::fileClosed ( )
signal

Q_SIGNAL that is emitted when the file was successfully closed.

◆ fileDirectoryChanged

void hal::FileManager::fileDirectoryChanged ( const QString path)
signal

Q_SIGNAL that is emitted when the file directory changed.

Parameters
path- The new directory.

◆ fileName()

QString hal::FileManager::fileName ( ) const

Get the filename of the currently opened file. When no file is open an empty string is returned.

Returns
The filename.

Definition at line 107 of file file_manager.cpp.

Referenced by hal::SpecialLogContentManager::safePythonEditor(), and hal::SpecialLogContentManager::safeScreenshot().

◆ fileOpen()

bool hal::FileManager::fileOpen ( ) const

Get the status if a file is currently open or not.

Returns
True when a file is open.

Definition at line 86 of file file_manager.cpp.

◆ fileOpened

void hal::FileManager::fileOpened ( const QString fileName)
signal

Q_SIGNAL that is emitted when a file is successfully opened.

Parameters
fileName- The filename.

Referenced by hal::ContentManager::ContentManager(), hal::NetlistRelay::NetlistRelay(), and hal::PythonEditor::PythonEditor().

◆ get_instance()

◆ importFile

void hal::FileManager::importFile ( QString  filename)
slot

Imports the netlist file into a new hal project. User will be queried for project directory.

Parameters
filename- The netlist file to be imported.

Definition at line 328 of file file_manager.cpp.

References QDir::absoluteFilePath(), QDir::absolutePath(), QDialog::Accepted, QMessageBox::ActionRole, QMessageBox::addButton(), QGridLayout::addItem(), QMessageBox::clickedButton(), QGridLayout::columnCount(), QFile::copy(), hal::ProjectManager::create_project_directory(), QDialog::exec(), QMessageBox::exec(), QSizePolicy::Expanding, QFileInfo::fileName(), QString::fromStdString(), hal::ImportNetlistDialog::gateLibraryPath(), hal::ProjectDirectory::get_default_filename(), hal::ProjectManager::get_netlist_filename(), hal::ProjectManager::get_project_directory(), hal::gFileStatusManager, hal::gNetlist, hal::ImportNetlistDialog::isCopyGatelibChecked(), QString::isEmpty(), hal::ImportNetlistDialog::isMoveNetlistChecked(), QWidget::layout(), log_info, log_warning, QSizePolicy::Minimum, hal::FileStatusManager::netlistChanged(), hal::FileStatusManager::netlistSaved(), hal::ImportNetlistDialog::projectDirectory(), QMessageBox::Question, QMessageBox::RejectRole, QString::remove(), hal::ProjectManager::remove_project_directory(), QDir::rename(), QGridLayout::rowCount(), hal::ProjectManager::serialize_project(), QMessageBox::setIcon(), QMessageBox::setText(), QMessageBox::setWindowTitle(), QString::toStdString(), and QMessageBox::warning().

Referenced by hal::OpenFileWidget::dropEvent(), and hal::ActionOpenNetlistFile::exec().

◆ newProject

◆ openProject

◆ projectOpened

void hal::FileManager::projectOpened ( QString  projectDir,
QString  fileName 
)
signal

Q_SIGNAL that is emitted when a project is successfully opened.

Parameters
projectDir- The project directory
fileName- The filename.

Referenced by hal::RecentFilesWidget::RecentFilesWidget().

◆ projectSaved

void hal::FileManager::projectSaved ( QString  projectDir,
QString  fileName 
)
signal

Q_SIGNAL that is emitted when a project gets saved.

Parameters
projectDir- The project directory
fileName- The filename.

Referenced by hal::RecentFilesWidget::RecentFilesWidget().

◆ watchFile()

void hal::FileManager::watchFile ( const QString fileName)

Watches the given file so that it is possible to notice modifications if changes were made outside of hal. This function call also sets all important information about the file as well as starts the timer to save the project in regular intervals.

Parameters
fileName- The file to be watched.

Definition at line 115 of file file_manager.cpp.

References QString::isEmpty(), log_info, and QString::toStdString().


The documentation for this class was generated from the following files: