HAL
comment_item.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 <QFrame>
27 #include <QTextEdit>
28 
30 
31 
32 class QVBoxLayout;
33 class QHBoxLayout;
34 class QToolBar;
35 class QLabel;
36 class QAction;
37 class QToolButton;
38 
39 namespace hal
40 {
41  class CommentEntry;
42  class SearchableLabel;
43 
44  class CommentItem : public QFrame
45  {
46  Q_OBJECT
51  public:
52  CommentItem(QWidget* parent = nullptr);
53  CommentItem(CommentEntry* entry, QWidget* parent = nullptr);
54  ~CommentItem();
55 
56  void setComment(CommentEntry* entry);
57  void updateCurrentEntry();
58  bool search(const QString& string, SearchOptions searchOpts);
59 
61 
62  // properties
63  QString modifyCommentIconPath(){return mModifyCommentIconPath;}
64  void setModifyCommentIconPath(const QString& str){mModifyCommentIconPath = str;}
65  QString modifyCommentIconStyle(){return mModifyCommentIconStyle;}
66  void setModifyCommentIconStyle(const QString& str){mModifyCommentIconStyle = str;}
67 
68  QString deleteCommentIconPath(){return mDeleteCommentIconPath;}
69  void setDeleteCommentIconPath(const QString& str){mDeleteCommentIconPath = str;}
70  QString deleteCommentIconStyle(){return mDeleteCommentIconStyle;}
71  void setDeleteCommentIconStyle(const QString& str){mDeleteCommentIconStyle = str;}
72 
73  Q_SIGNALS:
74 
75  //perhaps the CommentEntry for which a delete is requested?
76  //Getter for CommentEntry needed
78 
79  private:
80  QVBoxLayout* mLayout;
81  CommentEntry* mEntry;
82 
83  QString mModifyCommentIconPath;
84  QString mModifyCommentIconStyle;
85  QString mDeleteCommentIconPath;
86  QString mDeleteCommentIconStyle;
87 
88  // header part (perhaps no toolbar but a layout with toolbuttons instead of actions?)
89  QToolBar* mTopToolbar;
90  SearchableLabel* mHeader;
91  QLabel* mCreationDate;
92  QAction* mModifyAction;
93  QAction* mDeleteAction;
94 
95  // header part v2
96  QWidget* mTopWidget;
97  QHBoxLayout* mTopLayout;
98  QToolButton* mModifyButton;
99  QToolButton* mDeleteButton;
100 
101  QTextEdit* mTextEdit;
102 
103  void init();
104 
105  void handleDeleteButtonTriggered();
106  void handleModifyButtonTriggered();
107  };
108 }
The CommentEntry class encapsulated information related to a comment.
Definition: comment_entry.h:43
QString deleteCommentIconStyle()
Definition: comment_item.h:70
void setComment(CommentEntry *entry)
void delete_requested(CommentItem *item)
bool search(const QString &string, SearchOptions searchOpts)
CommentItem(QWidget *parent=nullptr)
CommentEntry * getEntry()
void setDeleteCommentIconPath(const QString &str)
Definition: comment_item.h:69
QString deleteCommentIconPath()
Definition: comment_item.h:68
QString modifyCommentIconStyle()
Definition: comment_item.h:65
QString modifyCommentIconPath()
Definition: comment_item.h:63
QString modifyCommentIconPath
Definition: comment_item.h:47
QString deleteCommentIconPath
Definition: comment_item.h:49
QString deleteCommentIconStyle
Definition: comment_item.h:50
void setDeleteCommentIconStyle(const QString &str)
Definition: comment_item.h:71
void setModifyCommentIconStyle(const QString &str)
Definition: comment_item.h:66
void setModifyCommentIconPath(const QString &str)
Definition: comment_item.h:64
QString modifyCommentIconStyle
Definition: comment_item.h:48
void updateCurrentEntry()
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const