26 #include <QHBoxLayout>
29 #include <QPushButton>
31 #include <QVBoxLayout>
39 memoryEntity(new QLineEdit()),
40 timestampInputSelector(new QComboBox()),
41 timestampLayout(new QHBoxLayout()),
42 instanceSpinner(new QSpinBox()),
43 predictionEngineSelector(new QComboBox()),
44 predictButton(new QPushButton(
"Predict")),
45 entityInfoRetriever(entityInfoRetriever)
47 auto* vlayout =
new QVBoxLayout();
48 auto* hlayout =
new QHBoxLayout();
49 hlayout->addWidget(
new QLabel(
"Entity ID"));
50 hlayout->addWidget(memoryEntity);
51 vlayout->addLayout(hlayout);
53 timestampInputSelector->addItems({
"Absolute",
"Relative to now"});
54 timestampLayout->addWidget(
new QLabel(
"Time"));
55 timestampLayout->addWidget(timestampInputSelector);
56 vlayout->addLayout(timestampLayout);
58 hlayout =
new QHBoxLayout();
59 predictionEngineSelector->setSizeAdjustPolicy(QComboBox::AdjustToContents);
60 hlayout->addWidget(
new QLabel(
"Engine"));
61 hlayout->addWidget(predictionEngineSelector);
62 hlayout->addStretch();
63 vlayout->addLayout(hlayout);
65 vlayout->addWidget(predictButton);
69 timestampLayout->addStretch();
73 showTimestampInputMethod(
"Absolute");
75 connect(timestampInputSelector,
76 &QComboBox::currentTextChanged,
78 &PredictionWidget::showTimestampInputMethod);
81 &QLineEdit::editingFinished,
83 &PredictionWidget::updateCurrentEntity);
85 connect(predictButton, &QPushButton::clicked,
this, &PredictionWidget::startPrediction);
91 timestampInputs.emplace(key,
input);
92 timestampLayout->addWidget(
input);
96 PredictionWidget::showTimestampInputMethod(
const QString& key)
98 for (
const auto& [inputKey,
input] : timestampInputs)
100 input->setVisible(key == inputKey);
105 PredictionWidget::updateCurrentEntity()
108 predictionEngineSelector->clear();
109 if (!entityID.hasGap() && entityID.hasEntityName())
111 auto info = entityInfoRetriever(entityID);
112 currentType = info.type;
113 currentEngines = info.engines;
114 for (
const auto& engine : info.engines)
116 predictionEngineSelector->addItem(QString::fromStdString(engine.engineID));
122 currentEngines.clear();
127 PredictionWidget::startPrediction()
131 for (
const auto& [inputKey,
input] : timestampInputs)
133 if (
input->isVisible())
135 timestamp =
input->retrieveTimeStamp();
138 std::string engineID = predictionEngineSelector->currentText().toStdString();