HAL
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 
47  class CommentWidget : public QWidget
48  {
49  Q_OBJECT
54 
55  public:
56  CommentWidget(QWidget* parent = nullptr);
58 
59  // property function
60  QString newCommentIconPath(){return mNewCommentIconPath;}
61  void setNewCommentIconPath(const QString& str){mNewCommentIconPath = str;}
62  QString newCommentIconStyle(){return mNewCommentIconStyle;}
63  void setNewCommentIconStyle(const QString& str){mNewCommentIconStyle = str;}
64 
65  QString searchIconPath(){return mSearchIconPath;}
66  void setSearchIconPath(const QString& str){mSearchIconPath = str;}
67  QString searchIconStyle(){return mSearchIconStyle;}
68  void setSearchIconStyle(const QString& str){mSearchIconStyle = str;}
69 
70  public Q_SLOTS:
71  void nodeChanged(const Node& nd);
72 
73  private:
74  QList<CommentItem*> mEntryItems;
75  QGridLayout* mTopLayout;
76  Node mCurrentNode;
77 
78  QString mNewCommentIconPath;
79  QString mNewCommentIconStyle;
80  QString mSearchIconPath;
81  QString mSearchIconStyle;
82 
83  // header part
84  QHBoxLayout* mHeaderLayout; //perhaps put in a container?
85  QToolBar* mToolbar; //put 2 actions and a widget in there? (or use simple qwidget(headerlayout) with buttons)
86  //Toolbar* mToolbar;
87  Searchbar* mSearchbar;
88  QToolButton* mSearchButton;
89  QToolButton* mNewCommentButton;
90 
91  // with toolbar:
92  //add action - add spacer (expanding, preferred) - add action - add searchbar
93  //when toggling the search action, hide spacer (and/or change properties) and show searchbar
94  //other idea: put the searchbar between header and comments, show/hide there (search action in header doesnt disappear)
95 
96  // comment part
97  QScrollArea* mScrollArea;
98 
99  QWidget* mCommentsContainer;
100  QVBoxLayout* mCommentsLayout;
101 
102  QWidget* createAndFillCommentContainerFactory(const Node& nd);
103 
104  void handleSearchbarTriggered();
105  void handleNewCommentTriggered();
106 
107  // possible other params: commententry, node
108  void handleCommentEntryDeleteRequest(CommentItem* item);
109  void handleCommentAboutToBeDeleted(CommentEntry* entry);
110  void handleEntryModified(CommentEntry* entry);
111  void handleCommentAdded(CommentEntry* entry);
112  void handleSearchbarTextEdited(const QString &text, SearchOptions opts);
113  };
114 }
The CommentEntry class encapsulated information related to a comment.
Definition: comment_entry.h:43
QString newCommentIconStyle
void setSearchIconPath(const QString &str)
void setSearchIconStyle(const QString &str)
QString newCommentIconPath()
CommentWidget(QWidget *parent=nullptr)
QString newCommentIconPath
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
Toolbar for all ContentFrames and ContentWidgets.
Definition: toolbar.h:39
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const