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