26 #include "../ConditionViewerWidgetController.h"
27 #include "../ConditionTreeFactory.h"
38 : QWidget(0), timerId(0)
46 ui.graphicsView->setScene(scene);
52 ui.activeConditionsTableView->setModel(activeConditionsModel);
53 ui.pastConditionsTableView->setModel(pastConditionsModel);
56 QStringList checksHeader;
57 checksHeader <<
"datafield" <<
"checktype" <<
"parameters" <<
"state" <<
"current value";
58 ui.checksTableWidget->setColumnCount(5);
59 ui.checksTableWidget->setHorizontalHeaderLabels(checksHeader);
60 ui.checksTableWidget->update();
63 QItemSelectionModel* activeSelectionModel = ui.activeConditionsTableView->selectionModel();
64 QItemSelectionModel* pastSelectionModel = ui.pastConditionsTableView->selectionModel();
67 connect(activeSelectionModel, SIGNAL(selectionChanged(
const QItemSelection&,
const QItemSelection&)),
this, SLOT(
activeConditionItemSelected(
const QItemSelection&,
const QItemSelection&)));
68 connect(pastSelectionModel, SIGNAL(selectionChanged(
const QItemSelection&,
const QItemSelection&)),
this, SLOT(
pastConditionItemSelected(
const QItemSelection&,
const QItemSelection&)));
69 connect(scene, SIGNAL(graphicsSceneClicked()), ui.checksTableWidget, SLOT(clearSelection()));
85 ui.checksTableWidget->clearContents();
86 ui.checksTableWidget->setRowCount(0);
89 activeConditionsModel->
reset();
90 pastConditionsModel->
reset();
93 ui.activeConditionsTableView->resizeColumnsToContents();
94 ui.pastConditionsTableView->resizeColumnsToContents();
99 timerId = startTimer(500);
123 std::unique_lock lock(dataMutex);
125 if (selected.indexes().size() == 0)
130 QModelIndexList
list = selected.indexes();
131 QStandardItem* i = activeConditionsModel->itemFromIndex(
list.at(0));
144 std::unique_lock lock(dataMutex);
146 if (selected.indexes().size() == 0)
151 QModelIndexList
list = selected.indexes();
152 QStandardItem* i = pastConditionsModel->itemFromIndex(
list.at(0));
162 ConditionRootPtr ConditionViewerWidget::conditionFromItem(QStandardItem* selectedItem,
const ConditionRegistry& registry)
164 ConditionRegistry::const_iterator iter = registry.find(selectedItem->data(
CONDITION_ITEM_ID).toInt());
166 if (iter != registry.end())
168 ConditionRootPtr conditionRoot = ConditionRootPtr::dynamicCast(iter->second);
169 return conditionRoot;
175 void ConditionViewerWidget::updateCondition(
int conditionId,
ConditionRootPtr& condition)
177 std::unique_lock lock(dataMutex);
179 ui.checksTableWidget->clearContents();
180 ui.checksTableWidget->setRowCount(0);
190 void ConditionViewerWidget::updateLiterals()
196 std::vector<TreeNodePtr> tempChildNodes;
197 std::vector<TreeNodePtr> qtChildren;
198 int conditionId = -1;
200 std::unique_lock lock(dataMutex);
202 qtChildren.push_back(root);
203 tempChildNodes = root->getChildren();
204 conditionId = root->conditionId;
205 qtChildren.insert(qtChildren.end(), tempChildNodes.begin(), tempChildNodes.end());
206 auto result =
controller->handler->getCondition(conditionId);
212 TermImplSequence children;
213 children.push_back(newRoot);
214 auto temp2 = newRoot->getChilds();
215 children.insert(children.end(), temp2.begin(), temp2.end());
217 while (qtChildren.size() > 0)
220 TermImplPtr term = TermImplPtr::dynamicCast(*children.rbegin());
221 qtChildren.pop_back();
223 auto newQtChildren = node->getChildren();
224 qtChildren.insert(qtChildren.end(), newQtChildren.begin(), newQtChildren.end());
225 auto newChildren = term->getChilds();
226 children.insert(children.end(), newChildren.begin(), newChildren.end());
228 if (children.size() != qtChildren.size())
234 TermNodePtr termNode = std::dynamic_pointer_cast<TermNode>(node);
236 if (termNode && term)
238 emit termNode->newLiteralValue(term->getValue());
239 termNode->timerEventRun();
248 if (event->timerId() == timerId)
250 std::unique_lock lock(dataMutex);
252 activeConditions =
controller->getActiveConditions();
253 pastConditions =
controller->getPastConditions();
256 activeConditionsModel->
update(activeConditions);
257 pastConditionsModel->
update(pastConditions);
260 ui.activeConditionsTableView->resizeColumnsToContents();
261 ui.pastConditionsTableView->resizeColumnsToContents();