1 #include "ErrorHandler/Components/NodeInfo.h"
4 #include <QtGui/QPainter>
6 using namespace novadaq::errorhandler;
8 NodeInfo::NodeInfo(node_type_t type, std::string
const& key, QListWidget* parent,
bool aow,
bool aoe)
17 QString cap = get_caption(key);
22 get_icon_geometry(icon_w, icon_h);
24 QPixmap pm(icon_w, icon_h);
28 item_ptr =
new QListWidgetItem(icon, cap, parent);
33 get_node_geometry(node_w, node_h);
34 QSize sz(node_w, node_h);
35 item_ptr->setSizeHint(sz);
38 QVariant v = qVariantFromValue((
void*)
this);
39 item_ptr->setData(Qt::UserRole, v);
45 node_status NodeInfo::push_msg(
qt_mf_msg const& msg)
47 sev_code_t sev = msg.
sev();
49 node_status status = NORMAL;
51 if (sev >= highest_sev)
54 if (msgs_ptr->size() > MAX_QUEUE) msgs_ptr->pop_front();
55 msgs_ptr->push_back(msg);
58 if (sev > highest_sev)
60 if (sev == SWARNING && alarm_warning)
61 status = FIRST_WARNING;
62 else if (sev == SERROR && alarm_error)
75 void NodeInfo::reset()
78 update_icon(highest_sev);
81 QString NodeInfo::msgs_to_string()
const
85 msgs_t::const_iterator it = msgs_ptr->begin();
86 while (it != msgs_ptr->end())
88 txt += (*it).text(
false);
95 void NodeInfo::update_icon(sev_code_t sev)
99 get_icon_geometry(icon_w, icon_h);
101 QPixmap pm(icon_w, icon_h);
102 pm.fill(Qt::transparent);
109 background = QColor(255, 0, 0, 255);
113 background = QColor(224, 128, 0, 255);
117 background = QColor(0, 128, 0, 255);
121 background = QColor(80, 80, 80, 255);
125 background = QColor(200, 200, 200);
128 QPainter painter(&pm);
130 QRect rect(2, 2, icon_w - 4, icon_h - 4);
131 painter.setPen(Qt::NoPen);
132 painter.fillRect(rect, background);
137 QBrush brush(Qt::yellow);
141 int off = alarm_error ? 22 : 11;
142 QBrush brush(Qt::yellow);
143 painter.setBrush(brush);
144 painter.drawEllipse(icon_w - off, icon_h - 11, 10, 10);
149 QBrush brush(Qt::red);
150 painter.setBrush(brush);
151 painter.drawEllipse(icon_w - 11, icon_h - 11, 10, 10);
156 item_ptr->setIcon(icon);
159 void NodeInfo::get_icon_geometry(
int& icon_w,
int& icon_h)
const
164 icon_w = BUFFERNODE_ICON_WIDTH;
165 icon_h = BUFFERNODE_ICON_HEIGHT;
168 icon_w = DCM_ICON_WIDTH;
169 icon_h = DCM_ICON_HEIGHT;
173 icon_w = MAINCOMPONENT_ICON_WIDTH;
174 icon_h = MAINCOMPONENT_ICON_HEIGHT;
178 void NodeInfo::get_node_geometry(
int& node_w,
int& node_h)
const
183 node_w = BUFFERNODE_NODE_WIDTH;
184 node_h = BUFFERNODE_NODE_HEIGHT;
187 node_w = DCM_NODE_WIDTH;
188 node_h = DCM_NODE_HEIGHT;
192 node_w = MAINCOMPONENT_NODE_WIDTH;
193 node_h = MAINCOMPONENT_NODE_HEIGHT;
197 QString NodeInfo::get_caption(std::string
const& key)
const
Qt wrapper around MessageFacility message
sev_code_t sev() const
Get the severity of the message