HAL
gatelibrary_content_widget.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 "hal_core/defines.h"
29 
30 #include <QAction>
31 #include <QFrame>
32 #include <QTableView>
33 #include <QMessageBox>
34 #include <QFileDialog>
37 
38 namespace hal
39 {
41  class GatelibraryManager;
42  class Toolbar;
43  class Searchbar;
44 
46  {
47  Q_OBJECT
57 
58  friend class GateLibraryManager;
59 
60  QTableView* mTableView;
61  PinProxyModel* mPinProxyModel;
62  Searchbar* mSearchbar;
63  Toolbar* mToolbar;
64  QAction* mAddAction;
65  QAction* mEditAction;
66  QAction* mSearchAction;
67  QAction* mDeleteAction;
68 
69  QAction* mSaveAction;
70  QAction* mSaveAsAction;
71 
72  QString mDisabledIconStyle;
73  QString mEnabledIconStyle;
74  QString mAddTypeIconPath;
75  QString mEditTypeIconPath;
76  QString mSearchIconPath;
77  QString mSearchIconStyle;
78  QString mSearchActiveIconStyle;
79  QString mDeleteIconPath;
80  QString mDeleteIconStyle;
81 
82  bool mReadOnly = false;
83 
84  Q_SIGNALS:
89 
90  private Q_SLOTS:
91  void toggleSearchbar();
92  void handleEditAction();
93  void handleDeleteAction();
94  void handleCurrentSelectionChanged(QModelIndex prevIndex);
95  void handleDoubleClicked(QModelIndex index);
96  void handleUnsavedChanges();
97 
98  public Q_SLOTS:
99  void handleSaveAction();
100  void handleSaveAsAction();
101 
102  public:
104 
106 
107  void activate(bool readOnly = false);
108 
109  void toggleReadOnlyMode(bool readOnly);
110 
111  void toggleSelection(bool selected);
112 
113  void setGateLibrary(GateLibrary* gl);
114 
115  void setGateLibraryPath(std::filesystem::path p);
116 
117  QString disabledIconStyle() const;
118 
119  QString enabledIconStyle() const;
120 
121  QString addTypeIconPath() const;
122 
123  QString editTypeIconPath() const;
124 
125  QString searchIconPath() const;
126 
127  QString searchIconStyle() const;
128 
130 
131  QString deleteIconPath() const;
132 
133  QString deleteIconStyle() const;
134 
135  void setDisabledIconStyle(const QString& s);
136 
137  void setEnabledIconStyle(const QString& s);
138 
139  void setAddTypeIconPath(const QString& s);
140 
141  void setEditTypeIconPath(const QString& s);
142 
143  void setSearchIconPath(const QString& s);
144 
145  void setSearchIconStyle(const QString& s);
146 
147  void setSearchActiveIconStyle(const QString& s);
148 
149  void setDeleteIconPath(const QString& s);
150 
151  void setDeleteIconStyle(const QString& s);
152 
153  private:
154  GateLibrary* mGateLibrary;
155  std::filesystem::path mPath;
156  QString mTitle;
157  bool mCreationMode;
158  };
159 }
void setGateLibraryPath(std::filesystem::path p)
void triggerEditType(QModelIndex index)
void handleContextMenuRequested(const QPoint &pos)
void triggerCurrentSelectionChanged(QModelIndex index, QModelIndex prevIndex)
void triggerDoubleClicked(QModelIndex index)
GatelibraryContentWidget(GatelibraryTableModel *model, QWidget *parent=nullptr)
void triggerDeleteType(QModelIndex index)
A model to display loaded gatelibraries.
A proxy model to filter the ContextTableModel by a given string.
A QFrame with a QLineEdit that can be used to input a substring to search for.
Definition: searchbar.h:48
Toolbar for all ContentFrames and ContentWidgets.
Definition: toolbar.h:39
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const