11 #include <QPushButton>
12 #include <QScrollArea>
15 #include <QVBoxLayout>
25 auto* vlayout =
new QVBoxLayout();
26 auto* hlayout =
new QHBoxLayout();
29 _availableMemoriesGroupBox =
new QGroupBox(
"Available memories");
30 auto vboxlayout =
new QVBoxLayout();
31 vboxlayout->setMargin(1);
32 vboxlayout->setSizeConstraint(QLayout::SizeConstraint::SetMinAndMaxSize);
33 vboxlayout->setAlignment(Qt::AlignTop);
34 _de_selectMemoryServers =
new QPushButton(selectText);
35 allMemoryServersSelected =
false;
36 vboxlayout->addWidget(_de_selectMemoryServers);
37 _availableMemoriesGroupBox->setLayout(vboxlayout);
38 hlayout->addWidget(_availableMemoriesGroupBox);
41 QFrame* vFrame =
new QFrame;
42 vFrame->setFrameShape(QFrame::VLine);
43 hlayout->addWidget(vFrame);
46 _additionalSettingsGroupBox =
new QGroupBox(
"Additional query settings");
47 auto vboxlayout =
new QVBoxLayout();
48 vboxlayout->setMargin(1);
49 vboxlayout->setSizeConstraint(QLayout::SizeConstraint::SetMinAndMaxSize);
50 vboxlayout->setAlignment(Qt::AlignTop);
51 _additionalSettingsGroupBox->setLayout(vboxlayout);
53 _dataCheckBox =
new QCheckBox(
"Get Data");
54 _dataCheckBox->setChecked(
true);
55 vboxlayout->addWidget(_dataCheckBox);
57 _dropRemovedCheckBox =
new QCheckBox(
"Drop disconnected memories");
58 _dropRemovedCheckBox->setChecked(
true);
59 vboxlayout->addWidget(_dropRemovedCheckBox);
61 _dropDisabledCheckBox =
new QCheckBox(
"Drop disabled memories");
62 _dropDisabledCheckBox->setChecked(
false);
63 vboxlayout->addWidget(_dropDisabledCheckBox);
65 auto* recDepthHLayout =
new QHBoxLayout();
66 _recursionDepthLabel =
new QLabel(
"Link resolution depth:");
67 recDepthHLayout->addWidget(_recursionDepthLabel);
68 _recursionDepthLabel->setFixedWidth(200);
70 _recursionDepthSpinner =
new QSpinBox();
72 _recursionDepthSpinner->setValue(0);
73 _recursionDepthSpinner->setEnabled(_dataCheckBox->isChecked());
74 _recursionDepthSpinner->setSpecialValueText(QString(
"Unlimited"));
75 recDepthHLayout->addWidget(_recursionDepthSpinner);
76 recDepthHLayout->addStretch();
77 vboxlayout->addLayout(recDepthHLayout);
109 auto ltmButtonsLayout =
new QVBoxLayout();
110 _storeInLTMButton =
new QPushButton(
"Query and store in LTM");
111 ltmButtonsLayout->addWidget(_storeInLTMButton);
113 auto* ltmRecHLayout =
new QHBoxLayout();
114 _startLTMRecordingButton =
new QPushButton(
"Start LTM Recording");
115 _stopLTMRecordingButton =
new QPushButton(
"Stop LTM Recording");
117 ltmRecHLayout->addWidget(_startLTMRecordingButton);
118 ltmRecHLayout->addWidget(_stopLTMRecordingButton);
119 ltmButtonsLayout->addLayout(ltmRecHLayout);
121 vboxlayout->addLayout(ltmButtonsLayout);
123 hlayout->addWidget(_additionalSettingsGroupBox);
125 vlayout->addLayout(hlayout);
142 _dataCheckBox, &QCheckBox::stateChanged,
this, &This::setRecursionDepthSpinnerEnabled);
144 connect(_de_selectMemoryServers, &QPushButton::pressed,
this, &This::deSelectMemoryServers);
152 std::scoped_lock l(enabledMemoriesMutex);
153 std::vector<std::string> alreadyPresentMemoryCheckboxes;
156 int maxIndex = _availableMemoriesGroupBox->layout()
158 for (
int i = 1; i < maxIndex; ++i)
160 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
161 QCheckBox* box =
static_cast<QCheckBox*
>(w);
162 std::string
memoryName = box->text().toStdString();
163 if (box->isEnabled() &&
164 std::find(activeMemoryNames.begin(), activeMemoryNames.end(),
memoryName) ==
165 activeMemoryNames.end())
168 box->setVisible(
false);
169 box->setChecked(
false);
170 box->setEnabled(
false);
172 if (not(box->isEnabled()) &&
173 std::find(activeMemoryNames.begin(), activeMemoryNames.end(),
memoryName) !=
174 activeMemoryNames.end())
177 box->setVisible(
true);
178 box->setChecked(
false);
179 box->setEnabled(
true);
181 alreadyPresentMemoryCheckboxes.push_back(
memoryName);
185 for (
const auto&
memoryName : activeMemoryNames)
187 if (std::find(alreadyPresentMemoryCheckboxes.begin(),
188 alreadyPresentMemoryCheckboxes.end(),
189 memoryName) == alreadyPresentMemoryCheckboxes.end())
192 auto box =
new QCheckBox(QString::fromStdString(
memoryName));
195 box->setVisible(
true);
196 box->setEnabled(
true);
197 _availableMemoriesGroupBox->layout()->addWidget(box);
212 return _dropRemovedCheckBox->isChecked();
218 return _dropDisabledCheckBox->isChecked();
221 std::map<std::string, QueryWidget::ActiveMemoryState>
224 std::scoped_lock l(enabledMemoriesMutex);
226 std::map<std::string, QueryWidget::ActiveMemoryState> states;
227 int maxIndex = _availableMemoriesGroupBox->layout()->count();
228 for (
int i = 1; i < maxIndex; ++i)
230 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
231 QCheckBox* box =
static_cast<QCheckBox*
>(w);
232 std::string
memoryName = box->text().toStdString();
233 if (box->isEnabled() && box->isChecked())
237 else if (box->isEnabled() && !box->isChecked())
249 std::vector<std::string>
252 std::scoped_lock l(enabledMemoriesMutex);
254 std::vector<std::string> enabledMemoryCheckboxes;
255 int maxIndex = _availableMemoriesGroupBox->layout()->count();
256 for (
int i = 1; i < maxIndex; ++i)
258 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
259 QCheckBox* box =
static_cast<QCheckBox*
>(w);
260 std::string
memoryName = box->text().toStdString();
261 if (box->isEnabled() && box->isChecked())
264 enabledMemoryCheckboxes.push_back(
memoryName);
267 return enabledMemoryCheckboxes;
273 return _recursionDepthSpinner->value();
277 QueryWidget::setRecursionDepthSpinnerEnabled(
int state)
282 _recursionDepthSpinner->setEnabled(
true);
286 _recursionDepthSpinner->setEnabled(
false);
292 QueryWidget::deSelectMemoryServers()
294 if (!allMemoryServersSelected)
298 std::scoped_lock l(enabledMemoriesMutex);
301 int maxIndex = _availableMemoriesGroupBox->layout()
303 for (
int i = 1; i < maxIndex; ++i)
305 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
306 QCheckBox* box =
static_cast<QCheckBox*
>(w);
307 std::string
memoryName = box->text().toStdString();
308 box->setChecked(
true);
311 allMemoryServersSelected =
true;
312 _de_selectMemoryServers->setText(deselectText);
318 std::scoped_lock l(enabledMemoriesMutex);
321 int maxIndex = _availableMemoriesGroupBox->layout()
323 for (
int i = 1; i < maxIndex; ++i)
325 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
326 QCheckBox* box =
static_cast<QCheckBox*
>(w);
327 box->setChecked(
false);
330 allMemoryServersSelected =
false;
331 _de_selectMemoryServers->setText(selectText);