1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/*
KSysGuard, the KDE System Guard
Copyright (c) 2001 Tobias Koenig <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General Public
License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _SensorLogger_h
#define _SensorLogger_h
#include <qdom.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qpopupmenu.h>
#include <qspinbox.h>
#include <qstring.h>
#include <SensorDisplay.h>
#include "SensorLoggerDlg.h"
#define NONE -1
class SensorLoggerSettings;
class SLListViewItem : public QListViewItem
{
public:
SLListViewItem(QListView *parent = 0);
void setTextColor(const QColor& color) { textColor = color; }
void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) {
QColorGroup cgroup(cg);
cgroup.setColor(QColorGroup::Text, textColor);
QListViewItem::paintCell(p, cgroup, column, width, alignment);
}
void paintFocus(QPainter *, const QColorGroup, const QRect) {}
private:
QColor textColor;
};
class LogSensor : public QObject, public KSGRD::SensorClient
{
Q_OBJECT
public:
LogSensor(QListView *parent);
~LogSensor(void);
void answerReceived(int id, const QString& answer);
void setHostName(const QString& name) { hostName = name; lvi->setText(3, name); }
void setSensorName(const QString& name) { sensorName = name; lvi->setText(2, name); }
void setFileName(const QString& name)
{
fileName = name;
lvi->setText(4, name);
}
void setUpperLimitActive(bool value) { upperLimitActive = value; }
void setLowerLimitActive(bool value) { lowerLimitActive = value; }
void setUpperLimit(double value) { upperLimit = value; }
void setLowerLimit(double value) { lowerLimit = value; }
void setTimerInterval(int interval) {
timerInterval = interval;
if (timerID != NONE)
{
timerOff();
timerOn();
}
lvi->setText(1, QString("%1").arg(interval));
}
QString getSensorName(void) { return sensorName; }
QString getHostName(void) { return hostName; }
QString getFileName(void) { return fileName; }
int getTimerInterval(void) { return timerInterval; }
bool getUpperLimitActive(void) { return upperLimitActive; }
bool getLowerLimitActive(void) { return lowerLimitActive; }
double getUpperLimit(void) { return upperLimit; }
double getLowerLimit(void) { return lowerLimit; }
QListViewItem* getListViewItem(void) { return lvi; }
public slots:
void timerOff()
{
killTimer(timerID);
timerID = NONE;
}
void timerOn()
{
timerID = startTimer(timerInterval * 1000);
}
bool isLogging() { return timerID != NONE; }
void startLogging(void);
void stopLogging(void);
protected:
virtual void timerEvent(QTimerEvent*);
private:
QListView* monitor;
SLListViewItem* lvi;
QPixmap pixmap_running;
QPixmap pixmap_waiting;
QString sensorName;
QString hostName;
QString fileName;
int timerInterval;
int timerID;
bool lowerLimitActive;
bool upperLimitActive;
double lowerLimit;
double upperLimit;
};
class SensorLogger : public KSGRD::SensorDisplay
{
Q_OBJECT
public:
SensorLogger(QWidget *parent = 0, const char *name = 0, const QString& title = 0);
~SensorLogger(void);
bool addSensor(const QString& hostName, const QString& sensorName, const QString& sensorType,
const QString& sensorDescr);
bool editSensor(LogSensor*);
void answerReceived(int id, const QString& answer);
void resizeEvent(QResizeEvent*);
bool restoreSettings(QDomElement& element);
bool saveSettings(QDomDocument& doc, QDomElement& element, bool save = true);
void configureSettings(void);
virtual bool hasSettingsDialog() const
{
return (true);
}
public slots:
void applySettings();
void applyStyle();
void RMBClicked(QListViewItem*, const QPoint&, int);
protected:
LogSensor* getLogSensor(QListViewItem*);
private:
QListView* monitor;
QPtrList<LogSensor> logSensors;
SensorLoggerDlg *sld;
SensorLoggerSettings *sls;
};
#endif // _SensorLogger_h
|