HAL
gatelibrary_frame_init.cpp
Go to the documentation of this file.
4 
5 namespace hal
6 {
8  : GatelibraryComponentFrame("Init from Data Field", parent)
9  {
10  mCategoryLabel = new GateLibraryLabel(true, " - ", this);
11  mIdentifiersLabel = new GateLibraryLabel(true, " - ", this);
12 
13  mLayout->addRow(new GateLibraryLabel(false, "Category:", parent), mCategoryLabel);
14  mLayout->addRow(new GateLibraryLabel(false, "Identifiers:", parent), mIdentifiersLabel);
15 
17 
18  }
19 
21  {
23  {
24  auto init = gt->get_component_as<InitComponent>([](const GateTypeComponent* c) { return InitComponent::is_class_of(c); });
25 
26  if(init != nullptr)
27  {
28  mCategoryLabel->setText(QString::fromStdString(init->get_init_category()));
29  QString ids = "";
30 
31  bool first = true;
32  for (std::string i : init->get_init_identifiers()) {
33  if(first)
34  first = false;
35  else
36  ids.append("\n");
37 
39  }
40  mIdentifiersLabel->setText(ids);
41  show();
42  }
43  else hide();
44  }
45  else hide();
46  }
47 }
48 
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
GatelibraryFrameInit(QWidget *parent=nullptr)
static bool is_class_of(const GateTypeComponent *component)
void addRow(QWidget *label, QWidget *field)
void setFieldGrowthPolicy(QFormLayout::FieldGrowthPolicy policy)
void setText(const QString &)
QObject * parent() const const
QString & append(QChar ch)
QString fromStdString(const std::string &str)
void hide()
void show()
void update()