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 
29 #include <QAction>
30 #include <QFrame>
31 #include <QTableView>
32 #include <QMessageBox>
33 #include <QFileDialog>
36 
37 namespace hal
38 {
40  class GatelibraryManager;
41  class Toolbar;
42  class Searchbar;
43 
45  {
46  Q_OBJECT
56 
57  friend class GateLibraryManager;
58 
59  QTableView* mTableView;
60  PinProxyModel* mPinProxyModel;
61  Searchbar* mSearchbar;
62  Toolbar* mToolbar;
63  QAction* mAddAction;
64  QAction* mEditAction;
65  QAction* mSearchAction;
66  QAction* mDeleteAction;
67 
68  QAction* mSaveAction;
69  QAction* mSaveAsAction;
70 
71  QString mDisabledIconStyle;
72  QString mEnabledIconStyle;
73  QString mAddTypeIconPath;
74  QString mEditTypeIconPath;
75  QString mSearchIconPath;
76  QString mSearchIconStyle;
77  QString mSearchActiveIconStyle;
78  QString mDeleteIconPath;
79  QString mDeleteIconStyle;
80 
81  bool mReadOnly = false;
82 
83  Q_SIGNALS:
88 
89  private Q_SLOTS:
90  void toggleSearchbar();
91  void handleEditAction();
92  void handleDeleteAction();
93  void handleCurrentSelectionChanged(QModelIndex prevIndex);
94  void handleDoubleClicked(QModelIndex index);
95  void handleUnsavedChanges();
96 
97  public Q_SLOTS:
98  void handleSaveAction();
99  void handleSaveAsAction();
100 
101  public:
103 
105 
106  void activate(bool readOnly = false);
107 
108  void toggleReadOnlyMode(bool readOnly);
109 
110  void toggleSelection(bool selected);
111 
112  void setGateLibrary(GateLibrary* gl);
113 
114  void setGateLibraryPath(std::filesystem::path p);
115 
116  QString disabledIconStyle() const;
117 
118  QString enabledIconStyle() const;
119 
120  QString addTypeIconPath() const;
121 
122  QString editTypeIconPath() const;
123 
124  QString searchIconPath() const;
125 
126  QString searchIconStyle() const;
127 
129 
130  QString deleteIconPath() const;
131 
132  QString deleteIconStyle() const;
133 
134  void setDisabledIconStyle(const QString& s);
135 
136  void setEnabledIconStyle(const QString& s);
137 
138  void setAddTypeIconPath(const QString& s);
139 
140  void setEditTypeIconPath(const QString& s);
141 
142  void setSearchIconPath(const QString& s);
143 
144  void setSearchIconStyle(const QString& s);
145 
146  void setSearchActiveIconStyle(const QString& s);
147 
148  void setDeleteIconPath(const QString& s);
149 
150  void setDeleteIconStyle(const QString& s);
151 
152  private:
153  GateLibrary* mGateLibrary;
154  std::filesystem::path mPath;
155  QString mTitle;
156  bool mCreationMode;
157 
158  bool initialize(GateLibrary* gateLibrary, bool readOnly); // only callable from friend
159  };
160 }
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
void initialize()
Definition: event_log.cpp:302
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const