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();
72  };
73 
75  {
76  Q_OBJECT
77  QString mPluginName;
78  public:
79  ExternalContentWidget(const QString& pluginName, const QString& windowName, QWidget* parent=nullptr);
80  virtual ~ExternalContentWidget();
81  QString pluginName() const { return mPluginName; }
82  };
83 
91  class ContentManager : public QObject
92  {
93  Q_OBJECT
94 
95  public:
102  explicit ContentManager(MainWindow* parent);
103  ~ContentManager();
104 
108  void deleteContent();
109 
116 
123 
130 
137 
144 
151 
157  void setWindowTitle(const QString& filename);
158 
159  public Q_SLOTS:
160 
167  void handleOpenDocument(const QString& fileName);
168 
169  public:
172  void addExternalWidget(ContentFactory* factory);
173 
174  private:
175  MainWindow* mMainWindow;
176  int mExternalIndex;
177  QString mWindowTitle;
178 
179  QList<ContentWidget*> mContent;
180 
181  PythonConsoleWidget* mPythonConsoleWidget;
182  PythonEditor* mPythonWidget;
183  GraphTabWidget* mGraphTabWidget;
184  ModuleWidget* mModuleWidget;
185  ContextManagerWidget* mContextManagerWidget;
186  GroupingManagerWidget* mGroupingManagerWidget;
187  SelectionDetailsWidget* mSelectionDetailsWidget;
188  LoggerWidget* mLoggerWidget;
189  GraphContextSerializer *mContextSerializer;
190 
191  GraphContext* topModuleContextFactory();
192  static SettingsItemDropdown* sSettingSortMechanism;
193  static bool sSettingsInitialized;
194  static bool initializeSettings();
195 
196 #ifdef HAL_STUDY
197  SpecialLogContentManager* mSpecialLogContentManager;
198 #endif
199  };
200 }
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()
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