HAL
init_wizardpage.cpp
Go to the documentation of this file.
4 
5 namespace hal
6 {
8  {
9  setTitle("Init from Data Field");
10  setSubTitle("Enter parameters for init component");
11  mLayout = new QGridLayout(this);
12 
13  mCategory = new QLineEdit(this);
14  mIdentifiers = new QTextEdit(this);
15 
16  mLabCategory = new QLabel("Category: ");
17  mLabIdentifiers = new QLabel("Identifiers: ");
18 
19  mLayout->addWidget(mLabCategory, 0, 0);
20  mLayout->addWidget(mCategory, 0, 1);
21  mLayout->addWidget(mLabIdentifiers, 1, 0);
22  mLayout->addWidget(mIdentifiers, 1, 1);
23 
24  setLayout(mLayout);
25 
26  connect(mCategory, &QLineEdit::textChanged, this, &InitWizardPage::handleTextChanged);
27  connect(mIdentifiers, &QTextEdit::textChanged, this, &InitWizardPage::handleTextEditChanged);
28  }
29 
31  {
32  mWizard = static_cast<GateLibraryWizard*>(wizard());
33  mWizard->mEditMode = true;
34  }
35 
38  {
39  auto init = gate->get_component_as<InitComponent>([](const GateTypeComponent* c) { return InitComponent::is_class_of(c); });
40 
41  if(init != nullptr)
42  {
43  mCategory->setText(QString::fromStdString(init->get_init_category()));
44  QString ids = "";
45 
46  bool first = true;
47  for (std::string i : init->get_init_identifiers()) {
48  if(first)
49  first = false;
50  else
51  ids.append("\n");
52 
54  }
55  mIdentifiers->setText(ids);
56  }
57  }
58  }
59 
60  void InitWizardPage::handleTextChanged(const QString& txt)
61  {
62  Q_UNUSED(txt);
63  mWizard = static_cast<GateLibraryWizard*>(wizard());
64 
65  //explicitly needed here because isComplete() is called
66  //before mWasEdited is changed in the wizard
67  if(mWizard->mEditMode) mWizard->mWasEdited = true;
68 
70  }
71 
72  void InitWizardPage::handleTextEditChanged()
73  {
74  mWizard = static_cast<GateLibraryWizard*>(wizard());
75 
76  //explicitly needed here because isComplete() is called
77  //before mWasEdited is changed in the wizard
78  if(mWizard->mEditMode) mWizard->mWasEdited = true;
79 
81  }
82 
84  {
85  if(isFinalPage() && !mWizard->mWasEdited) return false;
86  mWizard->mEditMode = false;
87  return true;
88  }
89 }
bool has_component_of_type(const GateTypeComponent::ComponentType type) const
Definition: gate_type.cpp:54
T * get_component_as(const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
Definition: gate_type.h:89
static bool is_class_of(const GateTypeComponent *component)
InitWizardPage(QWidget *parent=nullptr)
friend class GateLibraryWizard
void initializePage() override
void setData(GateType *gate)
bool isComplete() const override
void addWidget(QWidget *widget, int row, int column, Qt::Alignment alignment)
void setText(const QString &)
void textChanged(const QString &text)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString & append(QChar ch)
QString fromStdString(const std::string &str)
void setText(const QString &text)
void textChanged()
void setLayout(QLayout *layout)
void completeChanged()
bool isFinalPage() const const
void setSubTitle(const QString &subTitle)
void setTitle(const QString &title)
QWizard * wizard() const const