HAL
expanding_list_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 <QScrollArea>
29 #include <QHash>
30 #include <QMap>
31 #include <QString>
32 #include <QList>
33 
34 class QFrame;
35 class QVBoxLayout;
36 
37 namespace hal
38 {
39  class ExpandingListButton;
40  class ExpandingListItem;
41 
46  class ExpandingListGroup : public QList<ExpandingListItem*>
47  {
48  public:
49  bool mCollapsed;
54 
60  void toggleCollapsed(ExpandingListButton* exceptSelected);
61  };
62 
74  {
75  Q_OBJECT
76 
77  public:
78 
85 
94  void appendItem(ExpandingListButton* button, const QString& groupName = QString());
95 
102  void selectButton(ExpandingListButton* button);
103 
107  void selectFirstItem();
108 
115  void selectItem(int index);
116 
120  void repolish();
121 
128  bool hasGroup(const QString& groupName) const;
129 
133  void clearSelected();
134 
135  Q_SIGNALS:
142 
143  public Q_SLOTS:
144 
148  void handleClicked();
149 
150  private:
151  QFrame* mContent;
152  QVBoxLayout* mContentLayout;
153  QFrame* mSpacer;
154 
156 
157  ExpandingListButton* mSelectedButton;
158 
159  int mItemWidth;
160  int mOffset;
162  };
163 }
One button of the ExpandingListWidget.
A helper class to group related list items (buttons).
void toggleCollapsed(ExpandingListButton *exceptSelected)
A selection menu with a hierarchic structure.
void selectItem(int index)
void selectButton(ExpandingListButton *button)
void appendItem(ExpandingListButton *button, const QString &groupName=QString())
void buttonSelected(ExpandingListButton *button)
bool hasGroup(const QString &groupName) const
ExpandingListWidget(QWidget *parent=nullptr)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const