28 : QStandardItemModel()
39 ConditionRegistry::const_iterator iter = registry.begin();
41 while (iter != registry.end())
43 updateOrInsertCondition(iter->first, ConditionRootPtr::dynamicCast(iter->second));
58 setHorizontalHeaderItem(0,
new QStandardItem(
"id"));
59 setHorizontalHeaderItem(1,
new QStandardItem(
"component"));
60 setHorizontalHeaderItem(2,
new QStandardItem(
"state"));
61 setHorizontalHeaderItem(3,
new QStandardItem(
"event"));
62 setHorizontalHeaderItem(4,
new QStandardItem(
"fired"));
63 setHorizontalHeaderItem(5,
new QStandardItem(
"description"));
66 void ConditionItemModel::updateOrInsertCondition(
int id,
const ConditionRootPtr& condition)
72 for (
int r = 0 ; r < rowCount() ; r++)
74 QStandardItem* current = item(r, 0);
86 insertRow(rowCount());
87 updateRow = rowCount() - 1;
91 id_string.sprintf(
"%06d",
id);
93 QStandardItem*
index =
new QStandardItem(id_string);
96 setItem(updateRow, 0,
index);
97 setItem(updateRow, 1,
new QStandardItem(
"component"));
98 setItem(updateRow, 2,
new QStandardItem(
"state"));
99 setItem(updateRow, 3,
new QStandardItem(
"event"));
100 setItem(updateRow, 4,
new QStandardItem(
"false"));
101 setItem(updateRow, 5,
new QStandardItem(
"dsc"));
106 extractFields(condition->event->eventName, component, event);
109 item(updateRow, 1)->setData(QVariant(
component.c_str()), Qt::DisplayRole);
110 item(updateRow, 2)->setData(QVariant(condition->event->eventReceiverName.c_str()), Qt::DisplayRole);
111 item(updateRow, 3)->setData(QVariant(event.c_str()), Qt::DisplayRole);
113 if (condition->fired)
115 item(updateRow, 4)->setData(QVariant(
"true"), Qt::DisplayRole);
116 item(updateRow, 4)->setBackground(
Qt::green);
120 item(updateRow, 4)->setData(QVariant(
"false"), Qt::DisplayRole);
121 item(updateRow, 4)->setBackground(
Qt::red);
124 item(updateRow, 5)->setData(QVariant(condition->description.c_str()), Qt::DisplayRole);
127 void ConditionItemModel::markAllForDelete()
130 for (
int r = 0 ; r < rowCount() ; r++)
136 void ConditionItemModel::deleteUnusedItems()
139 std::vector<int> removeRows;
141 for (
int r = 0 ; r < rowCount() ; r++)
145 removeRows.push_back(r);
150 std::vector<int>::iterator iter = removeRows.begin();
152 while (iter != removeRows.end())
159 void ConditionItemModel::extractFields(std::string in, std::string& componentName, std::string& eventName)
161 std::size_t pos = in.find(
"_EventDistributor");
163 if (pos != std::string::npos)
165 componentName = in.substr(0, pos - 1);
168 std::size_t posEvent = in.find(
"__Event:");
169 std::size_t posRecv = in.find(
"__EventRecv:");
171 if ((posEvent == std::string::npos) || (posRecv == std::string::npos))
179 eventName = in.substr(posEvent, posRecv - posEvent - 13);