Commit 2bd703f8 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

Disabled alarms view added

parent 97a61419
......@@ -73,9 +73,6 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
/* message label */
ui->msgLabel->setVisible(false);
connect(ui->treeWidgetAlarms, SIGNAL(message(QString)), ui->msgLabel, SLOT(setText(QString)));
connect(ui->treeWidgetAlarms, SIGNAL(mouseOverItem(bool)), ui->msgLabel, SLOT(setVisible(bool)));
ui->pBClearFilter->setDisabled(true);
ui->tWGroup->sortItems(0, Qt::AscendingOrder);
ui->tWGroup->header()->setHidden(true);
......@@ -136,8 +133,13 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
ui->liViewInfo->setVisible(false);
connect(ui->liViewInfo, SIGNAL(urlClicked(QString)), this, SLOT(openUrl(QString)));
connect(ui->pbInfo, SIGNAL(toggled(bool)), this, SLOT(onInfoListViewVisibilityChange(bool)));
connect(ui->treeWidgetAlarms, SIGNAL(itemSelectionChanged()), this, SLOT(onItemSelectionChange()));
connect(ui->treeWidgetAlarms, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onItemDoubleClicked(QModelIndex)));
foreach(QTreeWidget *tw, QList<QTreeWidget *>() << ui->treeWidgetAlarms << ui->twDisabledAlarms) {
connect(tw, SIGNAL(message(QString)), ui->msgLabel, SLOT(setText(QString)));
connect(tw, SIGNAL(mouseOverItem(bool)), ui->msgLabel, SLOT(setVisible(bool)));
connect(tw, SIGNAL(itemSelectionChanged()), this, SLOT(onItemSelectionChange()));
connect(tw, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onItemDoubleClicked(QModelIndex)));
}
/* connections for test section */
//connect(ui->pBTestSoundOn, SIGNAL(clicked()), this, SLOT(testSound()));
//connect(ui->pBTestSoundOff, SIGNAL(clicked()), this, SLOT(stopSound()));
......@@ -153,7 +155,10 @@ Alarm::~Alarm() {
}
void Alarm::refresh(const CuData &da) {
ui->treeWidgetAlarms->refresh(da);
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;
tw->refresh(da);
if(filtering && ui->cBDynamic->isChecked())
applyFilter();
}
......@@ -177,11 +182,13 @@ void Alarm::onGroupList(const CuData &da) {
}
void Alarm::m_connect_devs(const QStringList &devs) {
foreach(const QString dev, devs) {
QuWatcher *alrw = new QuWatcher(this, cu_pool, m_ctrl_factory_pool);
alrw->setObjectName(dev + "/alarm" + "+watcher");
connect(alrw, SIGNAL(newData(CuData)), this, SLOT(refresh(CuData)));
alrw->setSource(dev + "/alarm");
foreach(const QString& att, QStringList() << "alarm" << "alarmDisabled") {
foreach(const QString dev, devs) {
QuWatcher *alrw = new QuWatcher(this, cu_pool, m_ctrl_factory_pool);
alrw->setObjectName(dev + "/alarm" + "+watcher");
connect(alrw, SIGNAL(newData(CuData)), this, SLOT(refresh(CuData)));
alrw->setSource(dev + "/" + att);
}
}
}
......@@ -254,12 +261,14 @@ void Alarm::applyFilter()
filter.groups << groups[i]->text(0);
}
ui->treeWidgetAlarms->applyFilter(filter);
ui->twDisabledAlarms->applyFilter(filter);
filtering = true;
ui->pBClearFilter->setDisabled(false);
}
void Alarm::clearFilter() {
ui->treeWidgetAlarms->removeFilter();
ui->twDisabledAlarms->removeFilter();
ui->pBClearFilter->setDisabled(true);
ui->cBDynamic->setChecked(false);
filtering = false;
......@@ -268,15 +277,17 @@ void Alarm::clearFilter() {
void Alarm::onInfoListViewVisibilityChange(bool vis) {
if(!vis)
ui->liViewInfo->activate("", "");
else
ui->treeWidgetAlarms->selectedItems().size() == 1 ?
ui->liViewInfo->activate(ui->treeWidgetAlarms->selectedItems().first()->data(AlarmTreeWidgetItem::Device, Qt::UserRole).toString(),
ui->treeWidgetAlarms->selectedItems().first()->text(AlarmTreeWidgetItem::Alarm))
else {
AlarmTreeWidget *atw = ui->tabWidget->currentIndex() == 0 ? ui->treeWidgetAlarms : ui->twDisabledAlarms;
atw->selectedItems().size() == 1 ?
ui->liViewInfo->activate(atw->selectedItems().first()->data(AlarmTreeWidgetItem::Device, Qt::UserRole).toString(),
atw->selectedItems().first()->text(AlarmTreeWidgetItem::Alarm))
: ui->liViewInfo->activate("", "");
}
}
void Alarm::onItemSelectionChange() {
QList<QTreeWidgetItem *> sits = ui->treeWidgetAlarms->selectedItems();
QList<QTreeWidgetItem *> sits = qobject_cast<AlarmTreeWidget *>(sender())->selectedItems();
QTreeWidgetItem *it = nullptr;
if(sits.size() == 1)
it = sits.first();
......@@ -286,12 +297,12 @@ void Alarm::onItemSelectionChange() {
}
void Alarm::onItemDoubleClicked(const QModelIndex &mi) {
// if(mi.column() == AlarmTreeWidgetItem::Alarm)
ui->pbInfo->setChecked(true);
// if(mi.column() == AlarmTreeWidgetItem::Alarm)
ui->pbInfo->setChecked(true);
}
void Alarm::tabChanged(int t) {
if(t == 1) {
if(t > 1) {
ui->pBAckAll->setHidden(true);
ui->pBConfHistory->setHidden(false);
ui->pBConfHistory->setChecked(true);
......@@ -300,12 +311,13 @@ void Alarm::tabChanged(int t) {
ui->pBConfHistory->setHidden(true);
ui->pBStopSound->setHidden(true);
}
else if(t == 0) {
else if(t < 2) {
ui->pBStopSound->setHidden(false);
ui->pBAckAll->setHidden(false);
ui->pBConfHistory->setHidden(true);
ui->groupBoxFilter->setDisabled(false);
ui->pBFilter->setHidden(false);
onInfoListViewVisibilityChange(ui->liViewInfo->isVisible());
}
}
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>846</width>
<height>468</height>
<width>855</width>
<height>718</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -19,22 +19,22 @@
<property name="windowTitle">
<string>Alarm</string>
</property>
<layout class="QVBoxLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="tabAlarms">
<attribute name="title">
<string>Alarms</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabAlarms">
<attribute name="title">
<string>Alarms</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="AlarmTreeWidget" name="treeWidgetAlarms">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
......@@ -48,140 +48,162 @@
</property>
</column>
</widget>
<widget class="AlarmInfoW" name="liViewInfo"/>
</widget>
</item>
<item>
<widget class="QLabel" name="msgLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Alarm messages</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTest">
<attribute name="title">
<string>Test</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxTestSound">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Sound system</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QPushButton" name="pBTestSoundOn">
<property name="toolTip">
<string>Click to test if the sound is correctly configured in this workstation. Then click on Stop beep.</string>
</property>
<property name="text">
<string>Test Beep</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pBTestSoundOff">
<property name="toolTip">
<string>Click to stop the sound test.</string>
</property>
<property name="text">
<string>Stop Beep</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>441</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBoxTestCycle">
<property name="title">
<string>Alarm System</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QuButton" name="tPBTestAlarm">
<property name="toolTip">
<string>Click to test the Alarm System with a simulation. You must then click on Stop Test when happy.</string>
</property>
<property name="text">
<string>Start Test</string>
</property>
</widget>
</item>
<item>
<widget class="QuButton" name="tPBTestAlarmStop">
<property name="toolTip">
<string>Click this button to stop the test.</string>
</property>
<property name="text">
<string>Stop Test</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>441</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Disabled Alarms</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="AlarmTreeWidget" name="twDisabledAlarms">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<column>
<property name="text">
<string>Date/Time</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTest">
<attribute name="title">
<string>Test</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBoxTestSound">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Sound system</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QPushButton" name="pBTestSoundOn">
<property name="toolTip">
<string>Click to test if the sound is correctly configured in this workstation. Then click on Stop beep.</string>
</property>
<property name="text">
<string>Test Beep</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pBTestSoundOff">
<property name="toolTip">
<string>Click to stop the sound test.</string>
</property>
<property name="text">
<string>Stop Beep</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>441</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBoxTestCycle">
<property name="title">
<string>Alarm System</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QuButton" name="tPBTestAlarm">
<property name="toolTip">
<string>Click to test the Alarm System with a simulation. You must then click on Stop Test when happy.</string>
</property>
<property name="text">
<string>Start Test</string>
</property>
</widget>
</item>
<item>
<widget class="QuButton" name="tPBTestAlarmStop">
<property name="toolTip">
<string>Click this button to stop the test.</string>
</property>
<property name="text">
<string>Stop Test</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>441</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="AlarmInfoW" name="liViewInfo"/>
</widget>
</item>
<item>
<widget class="QLabel" name="msgLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Alarm messages</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
......
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