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 
36 #include "hal_config.h"
37 
38 namespace hal
39 {
40  class MainWindow;
41  class ContentWidget;
42  class PythonConsoleWidget;
43  class PythonEditor;
44  class GraphTabWidget;
45  class GraphContext;
46  class GroupingManagerWidget;
47  class ContextManagerWidget;
48  class SelectionDetailsWidget;
49  class ModuleWidget;
50  class LoggerWidget;
51  class SettingsItemDropdown;
52  class SettingsItemKeybind;
53  class GraphContextSerializer;
54 
55  class ExternalContentWidget;
56 
58  {
59  QString mPluginName;
60  public:
61  ContentFactory(const QString& nam=QString()) : mPluginName(nam) {;}
62  QString name() const {return mPluginName; }
63  virtual ExternalContentWidget* contentFactory() const = 0;
64  };
65 
68  int index;
70  bool visible;
71  };
72 
73  class ExternalContent : public QList<ContentFactory*>
74  {
75  static ExternalContent* inst;
76  ExternalContent() {;}
77  public:
78  static ExternalContent* instance();
79  void removePlugin(const QString& pluginName);
81  };
82 
84  {
85  Q_OBJECT
86  QString mPluginName;
87  public:
88  ExternalContentWidget(const QString& pluginName, const QString& windowName, QWidget* parent=nullptr);
89  virtual ~ExternalContentWidget();
90  QString pluginName() const { return mPluginName; }
91  };
92 
100  class ContentManager : public QObject
101  {
102  Q_OBJECT
103 
104  public:
111  explicit ContentManager(MainWindow* parent);
112  ~ContentManager();
113 
117  void deleteContent();
118 
125 
132 
139 
146 
153 
160 
166  void setWindowTitle(const QString& filename);
167 
168  public Q_SLOTS:
169 
176  void handleOpenDocument(const QString& fileName);
177 
178  public:
181  void addExternalWidget(ContentFactory* factory);
182 
183  private:
184  MainWindow* mMainWindow;
185  QString mWindowTitle;
186 
187  PythonConsoleWidget* mPythonConsoleWidget;
188  PythonEditor* mPythonWidget;
189  GraphTabWidget* mGraphTabWidget;
190  ModuleWidget* mModuleWidget;
191  ContextManagerWidget* mContextManagerWidget;
192  GroupingManagerWidget* mGroupingManagerWidget;
193  SelectionDetailsWidget* mSelectionDetailsWidget;
194  LoggerWidget* mLoggerWidget;
195  GraphContextSerializer *mContextSerializer;
196 
197  GraphContext* topModuleContextFactory();
198  static SettingsItemDropdown* sSettingSortMechanism;
199  static bool sSettingsInitialized;
200  static bool initializeSettings();
201 
202 #ifdef HAL_STUDY
203  SpecialLogContentManager* mSpecialLogContentManager;
204 #endif
205  };
206 }
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
ContentLayout::Position anchorPos