HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
comment_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) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 
24 #pragma once
25 
26 #include <QWidget>
27 #include "gui/gui_def.h"
28 #include <QLabel>
29 //#include <QVBoxLayout>
30 //#include <QHBoxLayout>
31 #include <QGridLayout>
33 
34 class QVBoxLayout;
35 class QHBoxLayout;
36 class QScrollArea;
37 class QToolBar;
38 class QToolButton;
39 
40 namespace hal
41 {
42  class Toolbar;
43  class Searchbar;
44  class CommentItem;
45  class CommentEntry;
46 
50  class CommentWidget : public QWidget
51  {
52  Q_OBJECT
57 
58  public:
59  CommentWidget(QWidget* parent = nullptr);
61 
62  // property function
63  QString newCommentIconPath(){return mNewCommentIconPath;}
64  void setNewCommentIconPath(const QString& str){mNewCommentIconPath = str;}
65  QString newCommentIconStyle(){return mNewCommentIconStyle;}
66  void setNewCommentIconStyle(const QString& str){mNewCommentIconStyle = str;}
67 
68  QString searchIconPath(){return mSearchIconPath;}
69  void setSearchIconPath(const QString& str){mSearchIconPath = str;}
70  QString searchIconStyle(){return mSearchIconStyle;}
71  void setSearchIconStyle(const QString& str){mSearchIconStyle = str;}
72 
73  public Q_SLOTS:
74  void nodeChanged(const Node& nd);
75 
76  private:
77  QList<CommentItem*> mEntryItems;
78  QGridLayout* mTopLayout;
79  Node mCurrentNode;
80 
81  QString mNewCommentIconPath;
82  QString mNewCommentIconStyle;
83  QString mSearchIconPath;
84  QString mSearchIconStyle;
85 
86  // header part
87  QHBoxLayout* mHeaderLayout; //perhaps put in a container?
88  QToolBar* mToolbar; //put 2 actions and a widget in there? (or use simple qwidget(headerlayout) with buttons)
89  //Toolbar* mToolbar;
90  Searchbar* mSearchbar;
91  QToolButton* mSearchButton;
92  QToolButton* mNewCommentButton;
93 
94  // with toolbar:
95  //add action - add spacer (expanding, preferred) - add action - add searchbar
96  //when toggling the search action, hide spacer (and/or change properties) and show searchbar
97  //other idea: put the searchbar between header and comments, show/hide there (search action in header doesnt disappear)
98 
99  // comment part
100  QScrollArea* mScrollArea;
101 
102  QWidget* mCommentsContainer;
103  QVBoxLayout* mCommentsLayout;
104 
105  QWidget* createAndFillCommentContainerFactory(const Node& nd);
106 
107  void handleSearchbarTriggered();
108  void handleNewCommentTriggered();
109 
110  // possible other params: commententry, node
111  void handleCommentEntryDeleteRequest(CommentItem* item);
112  void handleCommentAboutToBeDeleted(CommentEntry* entry);
113  void handleEntryModified(CommentEntry* entry);
114  void handleCommentAdded(CommentEntry* entry);
115  void handleSearchbarTextEdited(const QString &text, SearchOptions opts);
116  };
117 }
The CommentEntry class encapsulated information related to a comment.
Definition: comment_entry.h:43
void setSearchIconPath(const QString &str)
void setSearchIconStyle(const QString &str)
QString newCommentIconPath()
CommentWidget(QWidget *parent=nullptr)
void setNewCommentIconPath(const QString &str)
QString newCommentIconStyle()
QString searchIconPath()
void nodeChanged(const Node &nd)
void setNewCommentIconStyle(const QString &str)
QString searchIconStyle()
The Node class object represents a module or a gate.
Definition: gui_def.h:61
A QFrame with a QLineEdit that can be used to input a substring to search for.
Definition: searchbar.h:48
Definition: defines.h:45
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const