SkillGroupBox.cpp
Go to the documentation of this file.
1#include "SkillGroupBox.h"
2
3#include <QHBoxLayout>
4#include <QVBoxLayout>
5
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->getSkillsFiltered());
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
Brief description of class memory.
Definition memory.h:39
std::shared_ptr< SkillManagerWrapper > memory
void connectGui(std::string observerName)
static const constexpr char * GROUP_BOX_TITLE
void searchRequest(std::string search)
Output signal to controller.
void updateSkillDetails(skills::SkillID &skillId)
Notify the skill description widget of an updated selection.
void updateGui(SkillManagerWrapper::Snapshot update)
void acceptSearchRequest(std::string const &search)
Applies the search word to the update filter.
void updateSkillDetails(skills::SkillID &skillId)
Notify the skill description widget of an updated selection.