Commit ea6edd37 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

added alarm counter alongside tab text

parent 2bd703f8
...@@ -234,6 +234,20 @@ int AlarmTreeWidget::findPos(time_t ts, const QString &pri, const QString& statu ...@@ -234,6 +234,20 @@ int AlarmTreeWidget::findPos(time_t ts, const QString &pri, const QString& statu
return i; return i;
} }
int AlarmTreeWidget::countAll() const {
return topLevelItemCount();
}
int AlarmTreeWidget::countAlarmed() const {
int cnt = 0;
for(int i = 0; i < topLevelItemCount(); i++) {
const QString& s = topLevelItem(i)->text(AlarmTreeWidgetItem::Status);
if( (s == "ALARM" || s == "ERROR") && topLevelItem(i)->text(AlarmTreeWidgetItem::Ack) == "NACK")
cnt++;
}
return cnt;
}
void AlarmTreeWidget::contextMenuEvent(QContextMenuEvent *e) void AlarmTreeWidget::contextMenuEvent(QContextMenuEvent *e)
{ {
bool silenceAvail = true; bool silenceAvail = true;
......
...@@ -23,6 +23,8 @@ public: ...@@ -23,6 +23,8 @@ public:
void setType(Type t); void setType(Type t);
void removeFilter(); void removeFilter();
int findPos(time_t ts, const QString& pri, const QString &status); int findPos(time_t ts, const QString& pri, const QString &status);
int countAll() const;
int countAlarmed() const;
public slots: public slots:
void refresh(const CuData &v); void refresh(const CuData &v);
......
...@@ -156,11 +156,13 @@ Alarm::~Alarm() { ...@@ -156,11 +156,13 @@ Alarm::~Alarm() {
void Alarm::refresh(const CuData &da) { void Alarm::refresh(const CuData &da) {
const QString& att = QuString(da, "src").section('/', -1, -1); const QString& att = QuString(da, "src").section('/', -1, -1);
printf("Alarm::refresh: attribute is %s\n", qstoc(att));
AlarmTreeWidget *tw = att == "alarm" ? ui->treeWidgetAlarms : ui->twDisabledAlarms; AlarmTreeWidget *tw = att == "alarm" ? ui->treeWidgetAlarms : ui->twDisabledAlarms;
tw->refresh(da); tw->refresh(da);
if(filtering && ui->cBDynamic->isChecked()) if(filtering && ui->cBDynamic->isChecked())
applyFilter(); applyFilter();
QString tn = "Alarm [%1]";
if(att == "alarm") ui->tabWidget->setTabText(0, tn.arg(tw->countAlarmed()));
else ui->tabWidget->setTabText(1, tn.arg(tw->countAll()));
} }
void Alarm::onDevList(const CuData &da) { void Alarm::onDevList(const CuData &da) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment