SkillGroupBox.cpp
Go to the documentation of this file.
1 #include "SkillGroupBox.h"
2 
3 #include <QHBoxLayout>
4 #include <QVBoxLayout>
5 
6 namespace armarx::skills::gui
7 {
8  void
9  SkillGroupBox::handleSearch()
10  {
11  std::string search = this->searchBar->text().toStdString();
12  emit searchRequest(search);
13  }
14 
15  void
16  SkillGroupBox::filterAndFetch()
17  {
18  memory->updateFromMemory();
19  handleSearch();
20  }
21 
22  void
23  SkillGroupBox::connectGui(std::string observerName)
24  {
25  setTitle(QString::fromStdString(observerName));
26  }
27 
28  void
30  {
31  skillTreeWidget->updateGui(update.skills);
32  }
33 
34  void
36  {
37  this->skillTreeWidget->updateGui(memory->getSkills());
38  }
39 
40  void
41  SkillGroupBox::setupUi()
42  {
43  this->setTitle(QString::fromStdString(GROUP_BOX_TITLE));
44 
45  this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
46 
47 
48  // construct widgets
49  this->searchBar = new QLineEdit();
50  this->acceptSearchButton = new QPushButton();
51  this->skillTreeWidget = new SkillTreeWidget(memory, this);
52 
53  // layouting
54  QHBoxLayout* searchLayout = new QHBoxLayout();
55  QVBoxLayout* layout = new QVBoxLayout();
56  this->setLayout(layout);
57  layout->addLayout(searchLayout);
58  layout->addWidget(this->skillTreeWidget);
59 
60  searchLayout->addWidget(this->searchBar);
61  searchLayout->addWidget(this->acceptSearchButton);
62 
63  // text
64  this->searchBar->setPlaceholderText(QString::fromStdString("Search ..."));
65  this->acceptSearchButton->setText(QString::fromStdString("Update and Search"));
66 
67  // some further information to explain the search bar
68  this->searchBar->setToolTip(
69  QString::fromStdString("Accepting the search (with Enter) searches all currently known "
70  "skills. This is not the same as 'Update & Search'!"));
71 
72  connectSignals();
73  }
74 
75  void
76  SkillGroupBox::connectSignals()
77  {
78  connect(
79  this->acceptSearchButton, &QPushButton::clicked, this, &SkillGroupBox::filterAndFetch);
80  connect(this->searchBar, &QLineEdit::editingFinished, this, &SkillGroupBox::handleSearch);
81  connect(this->searchBar, &QLineEdit::textChanged, this, &SkillGroupBox::handleSearch);
82  connect(this,
84  this->memory.get(),
86  connect(memory.get(),
88  this,
90 
91  connect(skillTreeWidget,
93  this,
95 
96  // disconnect
97  connect(
99  }
100 } // namespace armarx::skills::gui
armarx::skills::gui::SkillGroupBox::connectGui
void connectGui(std::string observerName)
Definition: SkillGroupBox.cpp:23
armarx::skills::gui::SkillGroupBox::updateSkillDetails
void updateSkillDetails(skills::SkillID &skillId)
Notify the skill description widget of an updated selection.
armarx::skills::gui::SkillGroupBox::disconnectGui
void disconnectGui()
armarx::skills::gui::MemoryCommunicatorBase::memory
std::shared_ptr< SkillManagerWrapper > memory
Definition: MemoryCommunicatorBase.h:23
armarx::skills::gui::SkillGroupBox::searchCallback
void searchCallback()
Definition: SkillGroupBox.cpp:35
armarx::skills::gui::SkillManagerWrapper::searchAccepted
void searchAccepted()
armarx::memory
Brief description of class memory.
Definition: memory.h:39
armarx::skills::gui::SkillTreeWidget::updateSkillDetails
void updateSkillDetails(skills::SkillID &skillId)
Notify the skill description widget of an updated selection.
armarx::skills::gui::SkillManagerWrapper::Snapshot
Definition: SkillManagerWrapper.h:70
armarx::skills::gui::SkillTreeWidget
Definition: SkillTreeWidget.h:15
armarx::skills::gui::SkillGroupBox::searchRequest
void searchRequest(std::string search)
Output signal to controller.
armarx::skills::gui
Definition: PeriodicUpdateWidget.cpp:11
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:67
armarx::skills::gui::SkillTreeWidget::disconnectGui
void disconnectGui()
Definition: SkillTreeWidget.cpp:137
SkillGroupBox.h
armarx::skills::gui::SkillGroupBox::GROUP_BOX_TITLE
static const constexpr char * GROUP_BOX_TITLE
Definition: SkillGroupBox.h:17
armarx::skills::gui::SkillTreeWidget::updateGui
void updateGui(SkillMap update)
Definition: SkillTreeWidget.cpp:28
armarx::skills::gui::SkillGroupBox::updateGui
void updateGui(SkillManagerWrapper::Snapshot update)
Definition: SkillGroupBox.cpp:29
armarx::skills::gui::SkillManagerWrapper::acceptSearchRequest
void acceptSearchRequest(std::string const &search)
Applies the search word to the update filter.
Definition: SkillManagerWrapper.cpp:189