26 #include <QHBoxLayout>
29 #include <QPushButton>
31 #include <QVBoxLayout>
38 memoryEntity(new QLineEdit()),
39 timestampInputSelector(new QComboBox()),
40 timestampLayout(new QHBoxLayout()),
41 instanceSpinner(new QSpinBox()),
42 predictionEngineSelector(new QComboBox()),
43 predictButton(new QPushButton(
"Predict")),
44 entityInfoRetriever(entityInfoRetriever)
46 auto* vlayout =
new QVBoxLayout();
47 auto* hlayout =
new QHBoxLayout();
48 hlayout->addWidget(
new QLabel(
"Entity ID"));
49 hlayout->addWidget(memoryEntity);
50 vlayout->addLayout(hlayout);
52 timestampInputSelector->addItems({
"Absolute",
"Relative to now"});
53 timestampLayout->addWidget(
new QLabel(
"Time"));
54 timestampLayout->addWidget(timestampInputSelector);
55 vlayout->addLayout(timestampLayout);
57 hlayout =
new QHBoxLayout();
58 predictionEngineSelector->setSizeAdjustPolicy(QComboBox::AdjustToContents);
59 hlayout->addWidget(
new QLabel(
"Engine"));
60 hlayout->addWidget(predictionEngineSelector);
61 hlayout->addStretch();
62 vlayout->addLayout(hlayout);
64 vlayout->addWidget(predictButton);
68 timestampLayout->addStretch();
72 showTimestampInputMethod(
"Absolute");
74 connect(timestampInputSelector,
75 &QComboBox::currentTextChanged,
77 &PredictionWidget::showTimestampInputMethod);
80 &QLineEdit::editingFinished,
82 &PredictionWidget::updateCurrentEntity);
84 connect(predictButton, &QPushButton::clicked,
this, &PredictionWidget::startPrediction);
90 timestampInputs.emplace(key,
input);
91 timestampLayout->addWidget(
input);
95 PredictionWidget::showTimestampInputMethod(
const QString& key)
97 for (
const auto& [inputKey,
input] : timestampInputs)
99 input->setVisible(key == inputKey);
104 PredictionWidget::updateCurrentEntity()
107 predictionEngineSelector->clear();
108 if (!entityID.hasGap() && entityID.hasEntityName())
110 auto info = entityInfoRetriever(entityID);
111 currentType = info.type;
112 currentEngines = info.engines;
113 for (
const auto& engine : info.engines)
115 predictionEngineSelector->addItem(QString::fromStdString(engine.engineID));
121 currentEngines.clear();
126 PredictionWidget::startPrediction()
130 for (
const auto& [inputKey,
input] : timestampInputs)
132 if (
input->isVisible())
134 timestamp =
input->retrieveTimeStamp();
137 std::string engineID = predictionEngineSelector->currentText().toStdString();