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()->count();
157 for (
int i = 1; i < maxIndex; ++i)
159 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
160 QCheckBox* box =
static_cast<QCheckBox*
>(w);
161 std::string
memoryName = box->text().toStdString();
162 if (box->isEnabled() &&
163 std::find(activeMemoryNames.begin(), activeMemoryNames.end(),
memoryName) ==
164 activeMemoryNames.end())
167 box->setVisible(
false);
168 box->setChecked(
false);
169 box->setEnabled(
false);
171 if (not(box->isEnabled()) &&
172 std::find(activeMemoryNames.begin(), activeMemoryNames.end(),
memoryName) !=
173 activeMemoryNames.end())
176 box->setVisible(
true);
177 box->setChecked(
false);
178 box->setEnabled(
true);
180 alreadyPresentMemoryCheckboxes.push_back(
memoryName);
184 for (
const auto&
memoryName : activeMemoryNames)
186 if (std::find(alreadyPresentMemoryCheckboxes.begin(),
187 alreadyPresentMemoryCheckboxes.end(),
188 memoryName) == alreadyPresentMemoryCheckboxes.end())
191 auto box =
new QCheckBox(QString::fromStdString(
memoryName));
192 box->setChecked(
false);
193 box->setVisible(
true);
194 box->setEnabled(
true);
195 _availableMemoriesGroupBox->layout()->addWidget(box);
210 return _dropRemovedCheckBox->isChecked();
216 return _dropDisabledCheckBox->isChecked();
219 std::map<std::string, QueryWidget::ActiveMemoryState>
222 std::scoped_lock l(enabledMemoriesMutex);
224 std::map<std::string, QueryWidget::ActiveMemoryState> states;
225 int maxIndex = _availableMemoriesGroupBox->layout()->count();
226 for (
int i = 1; i < maxIndex; ++i)
228 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
229 QCheckBox* box =
static_cast<QCheckBox*
>(w);
230 std::string
memoryName = box->text().toStdString();
231 if (box->isEnabled() && box->isChecked())
235 else if (box->isEnabled() && !box->isChecked())
247 std::vector<std::string>
250 std::scoped_lock l(enabledMemoriesMutex);
252 std::vector<std::string> enabledMemoryCheckboxes;
253 int maxIndex = _availableMemoriesGroupBox->layout()->count();
254 for (
int i = 1; i < maxIndex; ++i)
256 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
257 QCheckBox* box =
static_cast<QCheckBox*
>(w);
258 std::string
memoryName = box->text().toStdString();
259 if (box->isEnabled() && box->isChecked())
262 enabledMemoryCheckboxes.push_back(
memoryName);
265 return enabledMemoryCheckboxes;
271 return _recursionDepthSpinner->value();
275 QueryWidget::setRecursionDepthSpinnerEnabled(
int state)
280 _recursionDepthSpinner->setEnabled(
true);
284 _recursionDepthSpinner->setEnabled(
false);
290 QueryWidget::deSelectMemoryServers()
292 if(!allMemoryServersSelected){
295 std::scoped_lock l(enabledMemoriesMutex);
298 int maxIndex = _availableMemoriesGroupBox->layout()->count();
299 for (
int i = 1; i < maxIndex; ++i)
301 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
302 QCheckBox* box =
static_cast<QCheckBox*
>(w);
303 std::string
memoryName = box->text().toStdString();
304 box->setChecked(
true);
307 allMemoryServersSelected =
true;
308 _de_selectMemoryServers->setText(deselectText);
313 std::scoped_lock l(enabledMemoriesMutex);
316 int maxIndex = _availableMemoriesGroupBox->layout()->count();
317 for (
int i = 1; i < maxIndex; ++i)
319 auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
320 QCheckBox* box =
static_cast<QCheckBox*
>(w);
321 box->setChecked(
false);
324 allMemoryServersSelected =
false;
325 _de_selectMemoryServers->setText(selectText);