HAL
content_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 
28 #include <QGraphicsScene>
29 #include <QObject>
30 #include <QStringList>
31 #include <QMap>
32 
35 #include "hal_config.h"
36 
37 namespace hal
38 {
39  class MainWindow;
40  class ContentWidget;
41  class PythonConsoleWidget;
42  class PythonEditor;
43  class GraphTabWidget;
44  class GraphContext;
45  class GroupingManagerWidget;
46  class ContextManagerWidget;
47  class SelectionDetailsWidget;
48  class ModuleWidget;
49  class LoggerWidget;
50  class SettingsItemDropdown;
51  class SettingsItemKeybind;
52  class GraphContextSerializer;
53 
54  class ExternalContentWidget;
55 
57  {
58  QString mPluginName;
59  public:
60  ContentFactory(const QString& nam=QString()) : mPluginName(nam) {;}
61  QString name() const {return mPluginName; }
62  virtual ExternalContentWidget* contentFactory() const = 0;
63  };
64 
65  class ExternalContent : public QList<ContentFactory*>
66  {
67  static ExternalContent* inst;
68  ExternalContent() {;}
69  public:
70  static ExternalContent* instance();
71  void removePlugin(const QString& pluginName);
73  };
74 
76  {
77  Q_OBJECT
78  QString mPluginName;
79  public:
80  ExternalContentWidget(const QString& pluginName, const QString& windowName, QWidget* parent=nullptr);
81  virtual ~ExternalContentWidget();
82  QString pluginName() const { return mPluginName; }
83  };
84 
92  class ContentManager : public QObject
93  {
94  Q_OBJECT
95 
96  public:
103  explicit ContentManager(MainWindow* parent);
104  ~ContentManager();
105 
109  void deleteContent();
110 
117 
124 
131 
138 
145 
152 
158  void setWindowTitle(const QString& filename);
159 
160  public Q_SLOTS:
161 
168  void handleOpenDocument(const QString& fileName);
169 
170  public:
173  void addExternalWidget(ContentFactory* factory);
174 
175  private:
176  MainWindow* mMainWindow;
177  int mExternalIndex;
178  QString mWindowTitle;
179 
180  QList<ContentWidget*> mContent;
181 
182  PythonConsoleWidget* mPythonConsoleWidget;
183  PythonEditor* mPythonWidget;
184  GraphTabWidget* mGraphTabWidget;
185  ModuleWidget* mModuleWidget;
186  ContextManagerWidget* mContextManagerWidget;
187  GroupingManagerWidget* mGroupingManagerWidget;
188  SelectionDetailsWidget* mSelectionDetailsWidget;
189  LoggerWidget* mLoggerWidget;
190  GraphContextSerializer *mContextSerializer;
191 
192  GraphContext* topModuleContextFactory();
193  static SettingsItemDropdown* sSettingSortMechanism;
194  static bool sSettingsInitialized;
195  static bool initializeSettings();
196 
197 #ifdef HAL_STUDY
198  SpecialLogContentManager* mSpecialLogContentManager;
199 #endif
200  };
201 }
QString name() const
virtual ExternalContentWidget * contentFactory() const =0
ContentFactory(const QString &nam=QString())
Manages all ContentWidgets.
GraphTabWidget * getGraphTabWidget()
Get hal's graph tab widget.
SelectionDetailsWidget * getSelectionDetailsWidget()
PythonEditor * getPythonEditorWidget()
ContentManager(MainWindow *parent)
void handleOpenDocument(const QString &fileName)
static SettingsItemKeybind * sSettingDeleteItem
GroupingManagerWidget * getGroupingManagerWidget()
static SettingsItemKeybind * sSettingSearch
ModuleWidget * getModuleWidget()
void setWindowTitle(const QString &filename)
void addExternalWidget(ContentFactory *factory)
ContextManagerWidget * getContextManagerWidget()
Abstract class for Widgets within HAL's ContentArea.
Provides the user with an interface to manage GraphContexts.
static ExternalContent * instance()
void removePlugin(const QString &pluginName)
QMap< QString, ExternalContentWidget * > openWidgets
ExternalContentWidget(const QString &pluginName, const QString &windowName, QWidget *parent=nullptr)
Logical container for modules, gates, and nets.
Definition: graph_context.h:55
A ContentWidget that holds all GraphWidget objects (GraphView) as tabs of a QTabWidget.
User interface for Groupings.
Displays the logs in the gui.
Definition: logger_widget.h:57
The top level widget.
Definition: main_window.h:65
Shows the modules of the netlist hierarchical in a tree view.
Definition: module_widget.h:59
Wraps the PythonConsole.
Main widget that combines all neccessary functionality to develop in python (for hal).
Definition: python_editor.h:99
Container for all specific details widgets.
A SettingsItem that represents a dropdown menu.
A SettingsItem to modify keybinds.
Logs the python editor and gui screenshots.
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const