2
KSysGuard, the KDE System Guard
4
Copyright (c) 1999 - 2001 Chris Schlaeger <cs@kde.org>
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of version 2 of the GNU General Public
8
License as published by the Free Software Foundation.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
KSysGuard is currently maintained by Chris Schlaeger <cs@kde.org>.
20
Please do not commit any changes without consulting me first. Thanks!
24
#ifndef KSG_SENSORDISPLAY_H
25
#define KSG_SENSORDISPLAY_H
27
#include <qgroupbox.h>
29
#include <qvaluelist.h>
32
#include <knotifyclient.h>
34
#include <ksgrd/SensorClient.h>
43
class SensorProperties;
46
This class is the base class for all displays for sensors. A
47
display is any kind of widget that can display the value of one or
48
more sensors in any form. It must be inherited by all displays that
49
should be inserted into the work sheet.
51
class SensorDisplay : public QWidget, public SensorClient
59
SensorDisplay( QWidget *parent = 0, const char *name = 0,
60
const QString& title = 0, bool nf = false, bool isApplet = false );
65
virtual ~SensorDisplay();
68
Sets the title of the display.
70
void setTitle( const QString &title );
73
Returns the title of the display.
75
QString title() const;
78
Sets the unit of the display.
80
void setUnit( const QString &unit );
83
Returns the unit of the display.
88
Sets whether the unit string should be displayed at the top
91
void setShowUnit( bool value );
94
Returns whether the unit string should be displayed at the top
95
of the display frame. @see setShowUnit()
97
bool showUnit() const;
100
Sets whether the update interval of the work sheet should be
101
used instead of the one, set by @ref setUpdateInterval().
103
void setUseGlobalUpdateInterval( bool value );
106
Returns whether the update interval of the work sheet should be
107
used instead of the one, set by @ref setUpdateInterval().
108
see @ref setUseGlobalUpdateInterval()
110
bool useGlobalUpdateInterval() const;
113
Sets the update interval of the timer, which triggers the timer
114
events. The state of the timer can be set with @ref setTimerOn().
116
void setUpdateInterval( uint interval );
119
Returns the update interval.
121
uint updateInterval() const;
124
This method appends all hosts of the display to @ref list.
126
void hosts( QStringList& list );
129
Sets the widget on which the error icon can be drawn.
131
void setPlotterWidget( QWidget *plotter );
134
Returns the widget on which the error icon can be drawn.
136
QWidget *plotterWidget() const;
139
Add a sensor to the display.
141
@param hostName The name of the host, the sensor belongs to.
142
@param name The sensor name.
143
@param type The type of the sensor.
144
@param description A short description of the sensor.
146
virtual bool addSensor( const QString &hostName, const QString &name,
147
const QString &type, const QString &description );
150
Removes the sensor from the display, that is at the position
151
@ref pos of the intern sensor list.
153
virtual bool removeSensor( uint pos );
156
This function is a wrapper function to SensorManager::sendRequest.
157
It should be used by all SensorDisplay functions that need to send
158
a request to a sensor since it performs an appropriate error
159
handling by removing the display of necessary.
161
void sendRequest( const QString &hostName, const QString &cmd, int id );
164
Raises the configure dialog to setup the update interval.
166
void configureUpdateInterval();
169
Returns whether the display provides a settings dialog.
170
This method should be reimplemented in the derived class.
172
virtual bool hasSettingsDialog() const;
175
This method is called to raise the settings dialog of the
176
display. It should be reimplemented in the derived class.
178
virtual void configureSettings();
181
Reimplement this method to setup the display from config data.
183
virtual bool restoreSettings( QDomElement& );
186
Reimplement this method to save the displays config data.
188
virtual bool saveSettings( QDomDocument&, QDomElement&, bool = true );
191
Reimplement this method to catch error messages from the SensorManager.
193
@param sensorId The unique id of the sensor.
194
@param mode The mode: true = error, false = everthing ok
196
virtual void sensorError( int sensorId, bool mode );
199
Normaly you shouldn't reimplement this methode
201
virtual void sensorLost( int reqId );
205
If @ref value is true, this method starts the timer that triggers
206
timer events. If @ref value is false, the timer is stopped.
208
void setTimerOn( bool value );
211
Calling this method emits the @ref showPopupMenu() with this
217
Sets whether the display is modified of not.
219
void setModified( bool modified );
222
This method can be used to apply the new settings. Just connect
223
the applyClicked() signal of your configuration dialog with this
224
slot and reimplement it.
226
virtual void applySettings();
229
This methid is called whenever the global style is changed.
230
Reimplement it to apply the new style settings to the display.
232
virtual void applyStyle();
236
void showPopupMenu( KSGRD::SensorDisplay *display );
237
void modified( bool modified );
240
virtual bool eventFilter( QObject*, QEvent* );
241
virtual void resizeEvent( QResizeEvent* );
242
virtual void timerEvent( QTimerEvent* );
244
void registerSensor( SensorProperties *sp );
245
void unregisterSensor( uint pos );
247
QColor restoreColor( QDomElement &element, const QString &attr,
248
const QColor& fallback );
249
void saveColor( QDomElement &element, const QString &attr,
250
const QColor &color );
252
virtual QString additionalWhatsThis();
254
void setSensorOk( bool ok );
256
bool modified() const;
257
bool timerOn() const;
261
// void setNoFrame( bool value );
262
bool noFrame() const;
264
void reorderSensors(const QValueList<int> &orderOfSensors);
265
QPtrList<SensorProperties> &sensors();
268
void updateWhatsThis();
271
bool mUseGlobalUpdateInterval;
279
// The frame around the other widgets.
282
QPtrList<SensorProperties> mSensors;
287
QWidget* mErrorIndicator;
288
QWidget* mPlotterWdg;
291
class SensorProperties
295
SensorProperties( const QString &hostName, const QString &name,
296
const QString &type, const QString &description );
299
void setHostName( const QString &hostName );
300
QString hostName() const;
302
void setName( const QString &name );
303
QString name() const;
305
void setType( const QString &type );
306
QString type() const;
308
void setDescription( const QString &description );
309
QString description() const;
311
void setUnit( const QString &unit );
312
QString unit() const;
314
void setIsOk( bool value );
321
QString mDescription;
324
/* This flag indicates whether the communication to the sensor is