SnapshotSelectorWidget.cpp
Go to the documentation of this file.
2 
3 #include <QCheckBox>
4 #include <QComboBox>
5 #include <QHBoxLayout>
6 #include <QPushButton>
7 #include <QVBoxLayout>
8 
10 
11 namespace armarx::armem::gui
12 {
13  client::query::SnapshotSelector
15  {
16  return _queryForms.at(_queryComboBox->currentText())->makeEntitySelector();
17  }
18 
20  {
21  _pageLayout = new QVBoxLayout();
22  setLayout(_pageLayout);
23 
24  {
25  QHBoxLayout* typeLayout = new QHBoxLayout();
26 
27  // snapshot select box
28  _queryComboBox = new QComboBox();
29  _queryComboBox->addItems({"All", "Single", "Time Range", "Index Range"});
30  _queryComboBox->setCurrentIndex(3);
31 
32  typeLayout->addWidget(_queryComboBox);
33 
34  connect(_queryComboBox,
35  &QComboBox::currentTextChanged,
36  this,
37  &This::showSelectedFormForQuery);
38  connect(_queryComboBox, &QComboBox::currentTextChanged, this, &This::queryChanged);
39 
40  // query type select box
41  auto queryTargetLayout = new QHBoxLayout();
42 
43  typeLayout->addLayout(queryTargetLayout);
44  _pageLayout->addLayout(typeLayout);
45  }
46 
47  // Build and add the forms.
48  _queryForms.clear();
49  addForm("All", new SnapshotFormAll());
50  addForm("Single", new SnapshotFormSingle());
51  addForm("Time Range", new SnapshotFormTimeRange());
52  addForm("Index Range", new SnapshotFormIndexRange());
53 
54  showSelectedFormForQuery(_queryComboBox->currentText());
55  }
56 
57  void
58  SnapshotSelectorWidget::showSelectedFormForQuery(QString selected)
59  {
60  for (auto& [name, form] : _queryForms)
61  {
62  form->setVisible(name == selected);
63  }
64  }
65 
66  void
67  SnapshotSelectorWidget::addForm(const QString& key, SnapshotForm* form)
68  {
69  auto r = _queryForms.emplace(key, form);
70  _pageLayout->addWidget(r.first->second);
71  //connect(r.first->second, &SnapshotForm::queryChanged, this, &This::updateSelector);
72  }
73 
74  void
75  SnapshotSelectorWidget::hideAllForms()
76  {
77  for (auto& [_, form] : _queryForms)
78  {
79  form->setVisible(false);
80  }
81  }
82 
83 
84 } // namespace armarx::armem::gui
SnapshotSelectorWidget.h
armarx::armem::gui::SnapshotFormSingle
Definition: SnapshotForm.h:42
armarx::armem::gui::SnapshotFormIndexRange
Definition: SnapshotForm.h:74
armarx::armem::gui::SnapshotSelectorWidget::SnapshotSelectorWidget
SnapshotSelectorWidget()
Definition: SnapshotSelectorWidget.cpp:19
armarx::armem::gui::SnapshotSelectorWidget::_queryComboBox
QComboBox * _queryComboBox
Definition: SnapshotSelectorWidget.h:62
armarx::armem::gui::SnapshotFormAll
Definition: SnapshotForm.h:33
ExpressionException.h
armarx::armem::gui::SnapshotSelectorWidget::selector
client::query::SnapshotSelector selector()
Definition: SnapshotSelectorWidget.cpp:14
armarx::armem::gui
Definition: ActionsMenuBuilder.cpp:5
armarx::armem::gui::SnapshotFormTimeRange
Definition: SnapshotForm.h:57
armarx::armem::gui::SnapshotSelectorWidget::queryChanged
void queryChanged()
armarx::armem::gui::SnapshotSelectorWidget::_pageLayout
QVBoxLayout * _pageLayout
Definition: SnapshotSelectorWidget.h:61
armarx::armem::gui::SnapshotSelectorWidget::_queryForms
std::map< QString, SnapshotForm * > _queryForms
The forms for the different query types. Hidden when not selected.
Definition: SnapshotSelectorWidget.h:64