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
185
186
187
188
189
190
191
192
193
|
/*
KSysGuard, the KDE System Guard
Copyright (c) 1999, 2000 Chris Schlaeger <[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.
KSysGuard is currently maintained by Chris Schlaeger <[email protected]>. Please do
not commit any changes without consulting me first. Thanks!
*/
#ifndef KSG_SENSORBROWSER_H
#define KSG_SENSORBROWSER_H
#include <tqdict.h>
#include <tdelistview.h>
#include <ksgrd/SensorClient.h>
class TQMouseEvent;
namespace KSGRD {
class SensorManager;
class SensorAgent;
}
class SensorInfo;
class HostInfo;
/**
* The SensorBrowser is the graphical front-end of the SensorManager. It
* displays the currently available hosts and their sensors.
*/
class SensorBrowser : public TDEListView, public KSGRD::SensorClient
{
TQ_OBJECT
public:
SensorBrowser( TQWidget* parent, KSGRD::SensorManager* sm, const char* name = 0 );
~SensorBrowser();
TQStringList listHosts();
TQStringList listSensors( const TQString &hostName );
public slots:
void disconnect();
void hostReconfigured( const TQString &hostName );
void update();
void newItemSelected( TQListViewItem *item );
protected:
virtual void viewportMouseMoveEvent( TQMouseEvent* );
private:
void answerReceived( int id, const TQString& );
KSGRD::SensorManager* mSensorManager;
TQPtrList<HostInfo> mHostInfoList;
TQString mDragText;
};
/**
Helper classes
*/
class SensorInfo
{
public:
SensorInfo( TQListViewItem *lvi, const TQString &name, const TQString &desc,
const TQString &type );
~SensorInfo() {}
/**
Returns a pointer to the list view item of the sensor.
*/
TQListViewItem* listViewItem() const;
/**
Returns the name of the sensor.
*/
const TQString& name() const;
/**
Returns the description of the sensor.
*/
const TQString& description() const;
/**
Returns the type of the sensor.
*/
const TQString& type() const;
private:
TQListViewItem* mLvi;
TQString mName;
TQString mDesc;
TQString mType;
};
class HostInfo
{
public:
HostInfo( int id, const KSGRD::SensorAgent *agent, const TQString &name,
TQListViewItem *lvi );
~HostInfo() { }
/**
Returns the unique id of the host.
*/
int id() const;
/**
Returns a pointer to the sensor agent of the host.
*/
const KSGRD::SensorAgent* sensorAgent() const;
/**
Returns the name of the host.
*/
const TQString& hostName() const;
/**
Returns the a pointer to the list view item of the host.
*/
TQListViewItem* listViewItem() const;
/**
Returns the sensor name of a special list view item.
*/
const TQString& sensorName( const TQListViewItem *lvi ) const;
/**
Returns all sensor names of the host.
*/
TQStringList allSensorNames() const;
/**
Returns the type of a special list view item.
*/
const TQString& sensorType( const TQListViewItem *lvi ) const;
/**
Returns the description of a special list view item.
*/
const TQString& sensorDescription( const TQListViewItem *lvi ) const;
/**
Adds a new Sensor to the host.
@param lvi The list view item.
@param name The sensor name.
@param desc A description.
@param type The type of the sensor.
*/
void addSensor( TQListViewItem *lvi, const TQString& name,
const TQString& desc, const TQString& type );
/**
Returns whether the sensor with @ref name
is registered at the host.
*/
bool isRegistered( const TQString& name ) const;
/**
Returns whether the sensor with @ref lvi
is registered at the host.
*/
bool isRegistered( TQListViewItem *lvi ) const;
private:
int mId;
const KSGRD::SensorAgent* mSensorAgent;
const TQString mHostName;
TQListViewItem* mLvi;
TQPtrList<SensorInfo> mSensorList;
};
#endif
|