Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cs
gui
alarm-ng
Commits
22623709
Commit
22623709
authored
Apr 29, 2021
by
Giacomo Strangolino
Browse files
fixes. JSon interpretation in info.
parent
12442206
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/AlarmTreeWidget.cpp
View file @
22623709
...
...
@@ -151,7 +151,10 @@ void AlarmTreeWidget::refresh(const CuData &v) {
QString
src_fixed
;
QString
src
=
QuString
(
v
,
"src"
);
QString
dev
=
src
.
section
(
'/'
,
0
,
src
.
count
(
'/'
)
-
1
);
bool
err
=
v
[
"err"
].
toBool
();
bool
empty
=
QuString
(
v
,
"msg"
).
contains
(
QRegularExpression
(
"cannot
\\
s+extract"
));
bool
err
=
v
[
"err"
].
toBool
()
&&
!
empty
;
if
(
empty
)
printf
(
"\e[1;34mAlarmTreeWidget::refresh: attribute %s is empty <<<<<<<<<<<<<<<< \e[0m
\n
"
,
qstoc
(
src
));
QStringList
data
;
setToolTip
(
QuString
(
v
,
"msg"
));
/* remove the filter */
...
...
src/alarm.cpp
View file @
22623709
...
...
@@ -97,6 +97,14 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
connect
(
db_dlist_w
,
SIGNAL
(
newData
(
CuData
)),
this
,
SLOT
(
onDevList
(
CuData
)));
db_dlist_w
->
setSource
(
QString
(
"tango://#AlarmHandler#%1"
).
arg
(
devlist_prop
));
// groups
QuWatcher
*
grpW
=
new
QuWatcher
(
this
,
cu_pool
,
m_ctrl_factory_pool
);
grpW
->
setObjectName
(
"group_w"
);
grpW
->
setSingleShot
(
true
);
grpW
->
setAutoDestroy
(
true
);
connect
(
grpW
,
SIGNAL
(
newData
(
CuData
)),
this
,
SLOT
(
onGroupList
(
CuData
)));
grpW
->
setSource
(
QString
(
"tango://AlarmHandler(GroupNames)"
).
arg
(
devlist_prop
));
//---------------------------------------------------------------------------------------
if
(
args
.
contains
(
"--alarm-test-devname"
)
&&
args
.
size
()
>
args
.
indexOf
(
"--alarm-test-devname"
)
+
1
)
{
alarmSysTestServerName
=
args
.
at
(
args
.
indexOf
(
"--alarm-test-devname"
)
+
1
);
...
...
@@ -134,6 +142,7 @@ Alarm::Alarm(CumbiaPool *cu_p, QWidget *parent) : QWidget(parent)
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
)));
/* connections for test section */
//connect(ui->pBTestSoundOn, SIGNAL(clicked()), this, SLOT(testSound()));
//connect(ui->pBTestSoundOff, SIGNAL(clicked()), this, SLOT(stopSound()));
...
...
@@ -164,6 +173,14 @@ void Alarm::onDevList(const CuData &da) {
}
}
void
Alarm
::
onGroupList
(
const
CuData
&
da
)
{
if
(
!
da
[
"err"
].
toBool
()
&&
da
.
containsKey
(
"value"
))
{
foreach
(
QString
g
,
QuStringList
(
da
,
"value"
))
new
QTreeWidgetItem
(
ui
->
tWGroup
,
QStringList
()
<<
g
.
remove
(
"gr_"
));
}
else
perr
(
"Alarm.onGroupList: error fetching groups from %s: %s"
,
vtoc2
(
da
,
"src"
),
vtoc2
(
da
,
"msg"
));
}
void
Alarm
::
m_connect_devs
(
const
QStringList
&
devs
)
{
foreach
(
const
QString
dev
,
devs
)
{
QuWatcher
*
alrw
=
new
QuWatcher
(
this
,
cu_pool
,
m_ctrl_factory_pool
);
...
...
@@ -273,6 +290,11 @@ void Alarm::onItemSelectionChange() {
ui
->
liViewInfo
->
activate
(
it
->
data
(
AlarmTreeWidgetItem
::
Device
,
Qt
::
UserRole
).
toString
(),
it
->
text
(
AlarmTreeWidgetItem
::
Alarm
));
}
void
Alarm
::
onItemDoubleClicked
(
const
QModelIndex
&
mi
)
{
// if(mi.column() == AlarmTreeWidgetItem::Alarm)
ui
->
pbInfo
->
setChecked
(
true
);
}
void
Alarm
::
tabChanged
(
int
t
)
{
if
(
t
==
1
)
{
ui
->
pBAckAll
->
setHidden
(
true
);
...
...
src/alarm.h
View file @
22623709
...
...
@@ -56,6 +56,7 @@ public slots:
protected
slots
:
void
refresh
(
const
CuData
&
da
);
void
onDevList
(
const
CuData
&
da
);
void
onGroupList
(
const
CuData
&
da
);
void
m_connect_devs
(
const
QStringList
&
devs
);
void
ack
();
...
...
@@ -69,6 +70,7 @@ protected slots:
void
onInfoListViewVisibilityChange
(
bool
vis
);
void
onItemSelectionChange
();
void
onItemDoubleClicked
(
const
QModelIndex
&
mi
);
void
beep
();
...
...
src/alarm.ui
View file @
22623709
...
...
@@ -7,7 +7,7 @@
<x>
0
</x>
<y>
0
</y>
<width>
846
</width>
<height>
531
</height>
<height>
468
</height>
</rect>
</property>
<property
name=
"sizePolicy"
>
...
...
@@ -214,36 +214,11 @@
<property
name=
"spacing"
>
<number>
6
</number>
</property>
<item
row=
"1"
column=
"5"
>
<spacer>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
111
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"0"
column=
"4"
rowspan=
"3"
>
<widget
class=
"QTreeWidget"
name=
"tWGroup"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Maximum"
vsizetype=
"Expanding"
>
<horstretch>
1
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
70
</width>
<height>
16777215
</height>
</size>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::StyledPanel
</enum>
</property>
...
...
@@ -357,14 +332,14 @@
</property>
</widget>
</item>
<item
row=
"1"
column=
"
6
"
>
<item
row=
"1"
column=
"
5
"
>
<widget
class=
"QCheckBox"
name=
"cBDynamic"
>
<property
name=
"text"
>
<string>
Dynamic update
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"
6
"
>
<item
row=
"2"
column=
"
5
"
>
<widget
class=
"QPushButton"
name=
"pBApplyFilter"
>
<property
name=
"text"
>
<string>
Apply the Filter
</string>
...
...
@@ -391,7 +366,7 @@
</property>
</widget>
</item>
<item
row=
"0"
column=
"
6
"
>
<item
row=
"0"
column=
"
5
"
>
<widget
class=
"QPushButton"
name=
"pBClearFilter"
>
<property
name=
"text"
>
<string>
Clear the Filter
</string>
...
...
src/alarminfow.cpp
View file @
22623709
...
...
@@ -6,6 +6,10 @@
#include <qustring.h>
#include <QStandardItemModel>
#include <QStandardItem>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonValue>
#include <QJsonObject>
AlarmInfoW
::
AlarmInfoW
(
QWidget
*
parent
,
CumbiaPool
*
cu_pool
,
const
CuControlsFactoryPool
&
fpoo
)
:
QTreeView
(
parent
)
{
...
...
@@ -16,6 +20,7 @@ AlarmInfoW::AlarmInfoW(QWidget *parent, CumbiaPool *cu_pool, const CuControlsFac
setHeaderHidden
(
true
);
setModel
(
m
);
setMouseTracking
(
true
);
// for hand cursor over urls
setAlternatingRowColors
(
true
);
connect
(
this
,
SIGNAL
(
clicked
(
QModelIndex
)),
this
,
SLOT
(
onItemClicked
(
QModelIndex
)));
connect
(
this
,
SIGNAL
(
entered
(
QModelIndex
)),
this
,
SLOT
(
onItemEntered
(
QModelIndex
)));
}
...
...
@@ -76,11 +81,35 @@ void AlarmInfoW::onItemEntered(const QModelIndex &mi) {
QString
AlarmInfoW
::
m_line_break
(
const
QString
&
s
,
int
linelen
)
const
{
QString
s1
(
s
);
int
l
=
s
.
length
();
while
(
l
>
linelen
)
{
s1
.
insert
(
l
-
linelen
,
"↵
\n
"
);
l
-=
(
linelen
+
2
);
QString
s1
;
QJsonDocument
jd
=
QJsonDocument
::
fromJson
(
s
.
toLatin1
());
if
(
jd
.
isNull
())
{
s1
=
s
;
if
(
s
.
contains
(
"||"
)
||
s
.
contains
(
"&&"
))
{
s1
.
replace
(
"||"
,
"||
\n
"
).
replace
(
"&&"
,
"&&
\n
"
);
}
}
else
{
if
(
jd
.
isObject
())
{
QJsonObject
jo
=
jd
.
object
();
foreach
(
const
QString
&
k
,
jo
.
keys
())
{
QJsonValue
val
=
jo
[
k
];
if
(
val
.
isDouble
())
s1
+=
QString
(
"%1: %2
\n
"
).
arg
(
k
).
arg
(
val
.
toDouble
());
else
if
(
val
.
isBool
())
s1
+=
QString
(
"%1: %2
\n
"
).
arg
(
k
).
arg
(
val
.
toBool
()
?
"TRUE"
:
"FALSE"
);
else
if
(
val
.
isString
())
s1
+=
QString
(
"%1:
\"
%2
\"\n
"
).
arg
(
k
).
arg
(
val
.
toString
());
}
}
}
QString
out
;
foreach
(
QString
line
,
s1
.
split
(
"
\n
"
))
{
int
i
=
0
;
while
(
i
+
linelen
<
line
.
length
())
{
line
.
insert
(
i
+
linelen
,
"↵
\n
"
);
i
+=
linelen
+
2
;
}
out
+=
line
+
"
\n
"
;
}
return
s1
;
if
(
out
.
endsWith
(
"
\n
"
))
out
.
remove
(
out
.
length
()
-
1
,
1
);
// remove last \n
return
out
;
}
src/main.cpp
View file @
22623709
...
...
@@ -46,7 +46,7 @@ int main( int argc, char ** argv )
QuApplication
qu_app
(
argc
,
argv
);
qu_app
.
setOrganizationName
(
"Elettra"
);
qu_app
.
setApplicationName
(
"
Spbpm
"
);
qu_app
.
setApplicationName
(
"
alarm-ng
"
);
qu_app
.
setProperty
(
"author"
,
"Giacomo"
);
qu_app
.
setProperty
(
"mail"
,
"giacomo.strangolino@elettra.eu"
);
qu_app
.
setProperty
(
"phone"
,
"0403758073"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment