HAL
generalinfo_wizardpage.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 
30 
31 #include <QWizardPage>
32 #include <QGridLayout>
33 #include <QLabel>
34 #include <QLineEdit>
35 #include <QListView>
36 #include <QComboBox>
37 #include <QPushButton>
38 #include <QIcon>
39 #include <QAbstractTableModel>
40 #include <QSortFilterProxyModel>
41 
42 namespace hal {
44  {
45  Q_OBJECT
46  public:
48  {
50  bool isSelected;
51  };
52  private:
54  public:
55  ListPropertyModel(QObject* parent = nullptr);
56  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
57  int columnCount(const QModelIndex& index = QModelIndex()) const override { return 1; }
58  int rowCount(const QModelIndex& index = QModelIndex()) const override { return mList.size(); }
59  bool isSelected(int irow) const { return mList.at(irow).isSelected; }
60  GateTypeProperty property(int irow) const { return mList.at(irow).property; }
61  void setSelected(GateTypeProperty gtp, bool select);
62  };
63 
65  {
66  Q_OBJECT
67  bool mShowSelected;
68  public:
69  ListPropertyProxy(bool showSel, QObject* parent = nullptr);
70  bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent = QModelIndex()) const override;
71  };
72 
73  class GateLibraryWizard;
75  Q_OBJECT
76 
81  public:
82  GeneralInfoWizardPage(const GateLibrary* gt, QWidget* parent = nullptr);
83  void setData(QString name, const std::vector<GateTypeProperty>& properties);
84  QString getName();
86  bool isComplete() const override;
87  void initializePage() override;
88 
89  QString disabledIconStyle() const { return mDisabledIconStyle; }
90  QString enabledIconStyle() const { return mEnabledIconStyle; }
91  QString leftArrowIconPath() const { return mLeftArrowIconPath; }
92  QString rightArrowIconPath() const { return mRightArrowIconPath; }
93 
94  void setDisabledIconStyle (const QString& s) { mDisabledIconStyle = s; }
95  void setEnabledIconStyle (const QString& s) { mEnabledIconStyle = s; }
96  void setLeftArrowIconPath (const QString& p) { mLeftArrowIconPath = p; }
97  void setRightArrowIconPath(const QString& p) { mRightArrowIconPath = p; }
98 
99  private Q_SLOTS:
100  void addProperty();
101  void deleteProperty();
102  void handleNameChanged(const QString& txt);
103 
104  private:
105  GateLibraryWizard* mWizard;
106  QGridLayout* mLayout;
107  QLabel* mLabelName;
108 
109  QLineEdit* mName;
110  QListView* mPropertiesSelected;
111  QListView* mPropertiesAvailable;
112  ListPropertyModel* mPropertyModel;
113 
114  QPushButton* mDelBtn;
115  QPushButton* mAddBtn;
116 
117  QIcon mLeftArrowIcon;
118  QIcon mRightArrowIcon;
119 
120  const GateLibrary* mGateLibrary;
121  QString mNameInit;
122  QValidator* mValidator;
123 
124  QString mDisabledIconStyle;
125  QString mEnabledIconStyle;
126  QString mLeftArrowIconPath;
127  QString mRightArrowIconPath;
128  };
129 }
void setLeftArrowIconPath(const QString &p)
QList< GateTypeProperty > getProperties() const
void setDisabledIconStyle(const QString &s)
void setRightArrowIconPath(const QString &p)
GeneralInfoWizardPage(const GateLibrary *gt, QWidget *parent=nullptr)
void setEnabledIconStyle(const QString &s)
void setData(QString name, const std::vector< GateTypeProperty > &properties)
int rowCount(const QModelIndex &index=QModelIndex()) const override
bool isSelected(int irow) const
void setSelected(GateTypeProperty gtp, bool select)
int columnCount(const QModelIndex &index=QModelIndex()) const override
ListPropertyModel(QObject *parent=nullptr)
GateTypeProperty property(int irow) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
ListPropertyProxy(bool showSel, QObject *parent=nullptr)
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent=QModelIndex()) const override
std::string name
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
const T & at(int i) const const
int size() const const
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
DisplayRole
GateTypeProperty property
bool isSelected