1 #include "ErrorHandler/Components/NodeInfo.h"
4 #include <QtGui/QPainter>
6 using namespace novadaq::errorhandler;
8 NodeInfo::NodeInfo ( node_type_t type
9 , std::string
const & key
10 , QListWidget * parent
13 : msgs_ptr (new msgs_t)
14 , highest_sev (SDEBUG)
21 QString cap = get_caption(key);
24 int icon_w = 0;
int icon_h = 0;
25 get_icon_geometry(icon_w, icon_h);
27 QPixmap pm(icon_w, icon_h);
31 item_ptr =
new QListWidgetItem(icon, cap, parent);
34 int node_w = 0;
int node_h = 0;
35 get_node_geometry(node_w, node_h);
36 QSize sz(node_w, node_h);
37 item_ptr->setSizeHint(sz);
40 QVariant v = qVariantFromValue( (
void*)
this );
41 item_ptr->setData(Qt::UserRole, v);
47 node_status NodeInfo::push_msg (
qt_mf_msg const & msg )
49 sev_code_t sev = msg.
sev();
51 node_status status = NORMAL;
53 if (sev >= highest_sev)
56 if (msgs_ptr->size() > MAX_QUEUE) msgs_ptr->pop_front();
57 msgs_ptr->push_back(msg);
60 if (sev > highest_sev)
62 if( sev==SWARNING && alarm_warning)
63 status = FIRST_WARNING;
64 else if( sev==SERROR && alarm_error)
77 void NodeInfo::reset()
80 update_icon(highest_sev);
83 QString NodeInfo::msgs_to_string()
const
87 msgs_t::const_iterator it = msgs_ptr->begin();
88 while (it!=msgs_ptr->end())
90 txt += (*it).text(
false);
97 void NodeInfo::update_icon ( sev_code_t sev )
99 int icon_w = 0;
int icon_h = 0;
100 get_icon_geometry(icon_w, icon_h);
102 QPixmap pm(icon_w, icon_h);
103 pm.fill(Qt::transparent);
110 background = QColor(255, 0, 0, 255);
break;
113 background = QColor(224,128, 0, 255);
break;
116 background = QColor( 0,128, 0, 255);
break;
119 background = QColor( 80, 80, 80, 255);
break;
122 background = QColor(200,200,200);
125 QPainter painter(&pm);
127 QRect rect(2, 2, icon_w-4, icon_h-4);
128 painter.setPen(Qt::NoPen);
129 painter.fillRect(rect, background);
134 QBrush brush(Qt::yellow);
138 int off = alarm_error ? 22 : 11;
139 QBrush brush(Qt::yellow);
140 painter.setBrush(brush);
141 painter.drawEllipse(icon_w-off, icon_h-11, 10, 10);
146 QBrush brush(Qt::red);
147 painter.setBrush(brush);
148 painter.drawEllipse(icon_w-11, icon_h-11, 10, 10);
153 item_ptr->setIcon(icon);
156 void NodeInfo::get_icon_geometry (
int & icon_w
157 ,
int & icon_h )
const
162 icon_w = BUFFERNODE_ICON_WIDTH;
163 icon_h = BUFFERNODE_ICON_HEIGHT;
166 icon_w = DCM_ICON_WIDTH;
167 icon_h = DCM_ICON_HEIGHT;
171 icon_w = MAINCOMPONENT_ICON_WIDTH;
172 icon_h = MAINCOMPONENT_ICON_HEIGHT;
176 void NodeInfo::get_node_geometry (
int & node_w
177 ,
int & node_h )
const
182 node_w = BUFFERNODE_NODE_WIDTH;
183 node_h = BUFFERNODE_NODE_HEIGHT;
186 node_w = DCM_NODE_WIDTH;
187 node_h = DCM_NODE_HEIGHT;
191 node_w = MAINCOMPONENT_NODE_WIDTH;
192 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