summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/weather/weatherpluginwidget.cpp65
-rw-r--r--noncore/todayplugins/weather/weatherpluginwidget.h8
2 files changed, 39 insertions, 34 deletions
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.cpp b/noncore/todayplugins/weather/weatherpluginwidget.cpp
index 0fd8e57..6444ebf 100644
--- a/noncore/todayplugins/weather/weatherpluginwidget.cpp
+++ b/noncore/todayplugins/weather/weatherpluginwidget.cpp
@@ -1,321 +1,324 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#include <stdio.h>
29 28
30#include <qfile.h> 29#include <qfile.h>
31#include <qimage.h> 30#include <qimage.h>
32#include <qlabel.h> 31#include <qlabel.h>
33#include <qlayout.h> 32#include <qlayout.h>
34#include <qpixmap.h> 33#include <qpixmap.h>
35#include <qtextstream.h> 34#include <qtextstream.h>
36 35
36#include <opie/oprocess.h>
37
37#include <qpe/config.h> 38#include <qpe/config.h>
38#include <qpe/resource.h> 39#include <qpe/resource.h>
39 40
40#include "weatherpluginwidget.h" 41#include "weatherpluginwidget.h"
41 42
42WeatherPluginWidget::WeatherPluginWidget( QWidget *parent, const char* name ) 43WeatherPluginWidget::WeatherPluginWidget( QWidget *parent, const char* name )
43 : QWidget( parent, name ) 44 : QWidget( parent, name )
44{ 45{
45 Config config( "todayweatherplugin");
46 config.setGroup( "Config" );
47
48 location = config.readEntry( "Location", "" );
49 useMetric = config.readBoolEntry( "Metric", TRUE );
50 frequency = config.readNumEntry( "Frequency", 5 );
51
52 localFile = "/tmp/";
53 localFile.append( location );
54 localFile.append( ".TXT" );
55
56 remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/";
57 remoteFile.append( location );
58 remoteFile.append( ".TXT" );
59
60 QHBoxLayout *layout = new QHBoxLayout( this ); 46 QHBoxLayout *layout = new QHBoxLayout( this );
61 layout->setAutoAdd( TRUE ); 47 layout->setAutoAdd( TRUE );
62 layout->setSpacing( 2 ); 48 layout->setSpacing( 2 );
63 49
64 weatherIcon = new QLabel( this ); 50 weatherIcon = new QLabel( this );
65 weatherIcon->setMaximumWidth( 32 ); 51 weatherIcon->setMaximumWidth( 32 );
66 QImage logo1 = Resource::loadImage( "todayweatherplugin/wait" ); 52 QImage logo1 = Resource::loadImage( "todayweatherplugin/wait" );
67 QPixmap pic; 53 QPixmap pic;
68 pic.convertFromImage( logo1 ); 54 pic.convertFromImage( logo1 );
69 weatherIcon->setPixmap( pic ); 55 weatherIcon->setPixmap( pic );
70 56
71 weatherLabel = new QLabel( tr( "Retreiving current weather information." ), this ); 57 weatherLabel = new QLabel( tr( "Retreiving current weather information." ), this );
72 weatherLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ) ); 58 weatherLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ) );
73 59
74 startTimer(1000); 60 startTimer(1000);
75 //retreiveData();
76} 61}
77 62
78WeatherPluginWidget::~WeatherPluginWidget() 63WeatherPluginWidget::~WeatherPluginWidget()
79{ 64{
80 QFile file( localFile ); 65 QFile file( localFile );
81 if ( file.exists() ) 66 if ( file.exists() )
82 { 67 {
83 file.remove(); 68 file.remove();
84 } 69 }
85} 70}
86 71
87void WeatherPluginWidget::timerEvent( QTimerEvent *e ) 72void WeatherPluginWidget::timerEvent( QTimerEvent *e )
88{ 73{
89 killTimer( e->timerId() ); 74 killTimer( e->timerId() );
90 retreiveData(); 75 retreiveData();
91} 76}
92 77
93 78
94 79
95void WeatherPluginWidget::retreiveData() 80void WeatherPluginWidget::retreiveData()
96{ 81{
97 startTimer( frequency * 60000 ); 82 startTimer( frequency * 60000 );
98 83
84 Config config( "todayweatherplugin");
85 config.setGroup( "Config" );
86
87 location = config.readEntry( "Location", "" );
88 useMetric = config.readBoolEntry( "Metric", TRUE );
89 frequency = config.readNumEntry( "Frequency", 5 );
90
91 localFile = "/tmp/";
92 localFile.append( location );
93 localFile.append( ".TXT" );
94
95 remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/";
96 remoteFile.append( location );
97 remoteFile.append( ".TXT" );
98
99 QFile file( localFile ); 99 QFile file( localFile );
100 if ( file.exists() ) 100 if ( file.exists() )
101 { 101 {
102 file.remove(); 102 file.remove();
103 } 103 }
104 104
105 QString command = "wget -q "; 105 OProcess *proc = new OProcess;
106 command.append( remoteFile ); 106
107 command.append( " -O " ); 107 *proc << "wget" << "-q" << remoteFile << "-O" << localFile;
108 command.append( localFile ); 108 connect( proc, SIGNAL( processExited( OProcess * ) ), this, SLOT( dataRetrieved( OProcess * ) ) );
109 FILE *get = popen( command.latin1(), "r" ); 109 proc->start();
110 if ( get )
111 {
112 pclose( get );
113 displayWeather();
114 }
115 else
116 {
117 weatherLabel->setText( tr( "Current weather data not available.\nTry looking out the window." ) );
118 }
119} 110}
120 111
121void WeatherPluginWidget::displayWeather() 112void WeatherPluginWidget::displayWeather()
122{ 113{
123 weatherData = QString::null; 114 weatherData = QString::null;
124 115
125 QFile file( localFile ); 116 QFile file( localFile );
126 if ( file.open( IO_ReadOnly ) ) 117 if ( file.open( IO_ReadOnly ) )
127 { 118 {
128 QTextStream data( &file ); 119 QTextStream data( &file );
129 while ( !data.eof() ) 120 while ( !data.eof() )
130 { 121 {
131 weatherData.append( data.readLine() ); 122 weatherData.append( data.readLine() );
132 } 123 }
133 file.close(); 124 file.close();
134 weatherData = weatherData.simplifyWhiteSpace(); 125 weatherData = weatherData.simplifyWhiteSpace();
135 126
136 QString tmpstr; 127 QString tmpstr;
137 128
138 tmpstr.append( tr( "Temp: " ) ); 129 tmpstr.append( tr( "Temp: " ) );
139 getTemp( weatherData ); 130 getTemp( weatherData );
140 tmpstr.append( dataStr ); 131 tmpstr.append( dataStr );
141 132
142 tmpstr.append( tr( " Wind: " ) ); 133 tmpstr.append( tr( " Wind: " ) );
143 getWind( weatherData ); 134 getWind( weatherData );
144 tmpstr.append( dataStr ); 135 tmpstr.append( dataStr );
145 136
146 tmpstr.append( tr( "\nPres: " ) ); 137 tmpstr.append( tr( "\nPres: " ) );
147 getPressure( weatherData ); 138 getPressure( weatherData );
148 tmpstr.append( dataStr ); 139 tmpstr.append( dataStr );
149 140
150 weatherLabel->setText( tmpstr ); 141 weatherLabel->setText( tmpstr );
151 142
152 tmpstr = "todayweatherplugin/"; 143 tmpstr = "todayweatherplugin/";
153 getIcon( weatherData ); 144 getIcon( weatherData );
154 tmpstr.append( dataStr ); 145 tmpstr.append( dataStr );
155 QImage logo1 = Resource::loadImage( tmpstr ); 146 QImage logo1 = Resource::loadImage( tmpstr );
156 QPixmap pic; 147 QPixmap pic;
157 pic.convertFromImage( logo1 ); 148 pic.convertFromImage( logo1 );
158 weatherIcon->setPixmap( pic ); 149 weatherIcon->setPixmap( pic );
159 } 150 }
160 else 151 else
161 { 152 {
162 weatherLabel->setText( tr( "Current weather data not available.\nTry looking out the window." ) ); 153 weatherLabel->setText( tr( "Current weather data not available.\nTry looking out the window." ) );
163 } 154 }
164} 155}
165 156
166void WeatherPluginWidget::getTemp( const QString &data ) 157void WeatherPluginWidget::getTemp( const QString &data )
167{ 158{
168 int value; 159 int value;
169 bool ok; 160 bool ok;
170 161
171 int pos = data.find( QRegExp( "M?[0-9]+/M?[0-9]+" ), 20 ); 162 int pos = data.find( QRegExp( "M?[0-9]+/M?[0-9]+" ), 20 );
172 if ( pos > -1 ) 163 if ( pos > -1 )
173 { 164 {
174 if ( data.at( pos ) == 'M' ) 165 if ( data.at( pos ) == 'M' )
175 { 166 {
176 value = -1 * data.mid( pos + 1, 2 ).toInt( &ok ); 167 value = -1 * data.mid( pos + 1, 2 ).toInt( &ok );
177 } 168 }
178 else 169 else
179 { 170 {
180 value = data.mid( pos, 2 ).toInt( &ok ); 171 value = data.mid( pos, 2 ).toInt( &ok );
181 } 172 }
182 if ( useMetric ) 173 if ( useMetric )
183 { 174 {
184 dataStr = QString::number( value ); 175 dataStr = QString::number( value );
185 dataStr.append( 'C' ); 176 dataStr.append( 'C' );
186 } 177 }
187 else 178 else
188 { 179 {
189 dataStr = QString::number( ( value * 9 / 5 ) + 32 ); 180 dataStr = QString::number( ( value * 9 / 5 ) + 32 );
190 dataStr.append( 'F' ); 181 dataStr.append( 'F' );
191 } 182 }
192 } 183 }
193 else 184 else
194 { 185 {
195 dataStr = tr( "n/a" ); 186 dataStr = tr( "n/a" );
196 } 187 }
197} 188}
198 189
199void WeatherPluginWidget::getWind( const QString &data ) 190void WeatherPluginWidget::getWind( const QString &data )
200{ 191{
201 int value; 192 int value;
202 bool ok; 193 bool ok;
203 194
204 int pos = data.find( QRegExp( "[0-9]*G*[0-9]*KT" ), 20 ); 195 int pos = data.find( QRegExp( "[0-9]*G*[0-9]*KT" ), 20 );
205 if ( pos > -1 ) 196 if ( pos > -1 )
206 { 197 {
207 if ( data.mid( pos, 3 ) != "VRB" ) 198 if ( data.mid( pos, 3 ) != "VRB" )
208 { 199 {
209 value = data.mid( pos, 3 ).toInt( &ok ); 200 value = data.mid( pos, 3 ).toInt( &ok );
210 if ( ( value >= 0 && value < 23 ) || ( value >= 239 && value <= 360 ) ) 201 if ( ( value >= 0 && value < 23 ) || ( value >= 239 && value <= 360 ) )
211 dataStr = tr("E " ); 202 dataStr = tr("E " );
212 else if ( value >= 23 && value < 69 ) 203 else if ( value >= 23 && value < 69 )
213 dataStr = tr( "NE " ); 204 dataStr = tr( "NE " );
214 else if ( value >= 69 && value < 113 ) 205 else if ( value >= 69 && value < 113 )
215 dataStr = tr( "N " ); 206 dataStr = tr( "N " );
216 else if ( value >= 113 && value < 157 ) 207 else if ( value >= 113 && value < 157 )
217 dataStr = tr( "NW " ); 208 dataStr = tr( "NW " );
218 else if ( value >= 157 && value < 203 ) 209 else if ( value >= 157 && value < 203 )
219 dataStr = tr( "W " ); 210 dataStr = tr( "W " );
220 else if ( value >= 203 && value < 248 ) 211 else if ( value >= 203 && value < 248 )
221 dataStr = tr( "SW " ); 212 dataStr = tr( "SW " );
222 else if ( value >= 248 && value < 294 ) 213 else if ( value >= 248 && value < 294 )
223 dataStr = tr( "S " ); 214 dataStr = tr( "S " );
224 else if ( value >= 294 && value < 238 ) 215 else if ( value >= 294 && value < 238 )
225 dataStr = tr( "SE " ); 216 dataStr = tr( "SE " );
226 } 217 }
227 if ( data.mid( pos + 5, 1) == "G" || 218 if ( data.mid( pos + 5, 1) == "G" ||
228 data.mid( pos + 5, 1) == "K" ) 219 data.mid( pos + 5, 1) == "K" )
229 { 220 {
230 value = data.mid( pos + 3, 2 ).toInt( &ok ); 221 value = data.mid( pos + 3, 2 ).toInt( &ok );
231 } 222 }
232 else 223 else
233 { 224 {
234 value = data.mid( pos + 3, 3 ).toInt( &ok ); 225 value = data.mid( pos + 3, 3 ).toInt( &ok );
235 } 226 }
236 if ( useMetric ) 227 if ( useMetric )
237 { 228 {
238 value = value * 3.6 / 1.94; 229 value = value * 3.6 / 1.94;
239 dataStr.append( QString::number( value ) ); 230 dataStr.append( QString::number( value ) );
240 dataStr.append( tr( " KPH" ) ); 231 dataStr.append( tr( " KPH" ) );
241 } 232 }
242 else 233 else
243 { 234 {
244 value = value * 2.24 / 1.94; 235 value = value * 2.24 / 1.94;
245 dataStr.append( QString::number( value ) ); 236 dataStr.append( QString::number( value ) );
246 dataStr.append( tr( " MPH" ) ); 237 dataStr.append( tr( " MPH" ) );
247 } 238 }
248 } 239 }
249 else 240 else
250 { 241 {
251 dataStr = tr( "n/a" ); 242 dataStr = tr( "n/a" );
252 } 243 }
253} 244}
254 245
255void WeatherPluginWidget::getPressure( const QString &data ) 246void WeatherPluginWidget::getPressure( const QString &data )
256{ 247{
257 float value; 248 float value;
258 bool ok; 249 bool ok;
259 250
260 int pos = data.find( QRegExp( "[AQ][0-9]+" ), 20 ); 251 int pos = data.find( QRegExp( "[AQ][0-9]+" ), 20 );
261 if ( pos > -1 ) 252 if ( pos > -1 )
262 { 253 {
263 value = data.mid( pos + 1, 4 ).toFloat( &ok ); 254 value = data.mid( pos + 1, 4 ).toFloat( &ok );
264 if ( useMetric ) 255 if ( useMetric )
265 { 256 {
266 if ( data.mid( pos, 1 ) == "A" ) 257 if ( data.mid( pos, 1 ) == "A" )
267 value *= 33.8639 / 100; 258 value *= 33.8639 / 100;
268 dataStr = QString::number( value, 'f', 2 ); 259 dataStr = QString::number( value, 'f', 2 );
269 dataStr.append( tr( " hPa" ) ); 260 dataStr.append( tr( " hPa" ) );
270 } 261 }
271 else 262 else
272 { 263 {
273 if ( data.mid( pos, 1 ) == "Q" ) 264 if ( data.mid( pos, 1 ) == "Q" )
274 value /= 33.8639; 265 value /= 33.8639;
275 else 266 else
276 value /= 100; 267 value /= 100;
277 dataStr = QString::number( value, 'f', 2 ); 268 dataStr = QString::number( value, 'f', 2 );
278 dataStr.append( tr( " Hg" ) ); 269 dataStr.append( tr( " Hg" ) );
279 } 270 }
280 } 271 }
281 else 272 else
282 { 273 {
283 dataStr = tr( "n/a" ); 274 dataStr = tr( "n/a" );
284 } 275 }
285} 276}
286 277
287void WeatherPluginWidget::getIcon(const QString &data ) 278void WeatherPluginWidget::getIcon(const QString &data )
288{ 279{
289 dataStr = "psunny"; 280 dataStr = "psunny";
290 if ( data.find( "CLR ", 20 ) > -1 || 281 if ( data.find( "CLR ", 20 ) > -1 ||
291 data.find( "SKC ", 20 ) > -1 || 282 data.find( "SKC ", 20 ) > -1 ||
292 data.find( "CAVOK ", 20 ) > -1 ) 283 data.find( "CAVOK ", 20 ) > -1 )
293 { 284 {
294 dataStr = "sunny"; 285 dataStr = "sunny";
295 } 286 }
296 else if ( data.find( "SH ", 20 ) > -1 || 287 else if ( data.find( "SH ", 20 ) > -1 ||
297 data.find( "DZ ", 20 ) > -1 || 288 data.find( "DZ ", 20 ) > -1 ||
298 data.find( "RA ", 20 ) > -1 || 289 data.find( "RA ", 20 ) > -1 ||
299 data.find( "UP ", 20 ) > -1 || 290 data.find( "UP ", 20 ) > -1 ||
300 data.find( "BR ", 20 ) > -1 ) 291 data.find( "BR ", 20 ) > -1 )
301 { 292 {
302 dataStr = "shower"; 293 dataStr = "shower";
303 } 294 }
304 else if ( data.find( "TS ", 20 ) > -1 ) 295 else if ( data.find( "TS ", 20 ) > -1 )
305 { 296 {
306 dataStr = "tstorm"; 297 dataStr = "tstorm";
307 } 298 }
308 else if ( data.find( "SN ", 20 ) > -1 || 299 else if ( data.find( "SN ", 20 ) > -1 ||
309 data.find( "SG ", 20 ) > -1 ) 300 data.find( "SG ", 20 ) > -1 )
310 { 301 {
311 dataStr = "snow"; 302 dataStr = "snow";
312 } 303 }
313 else if ( data.find( "FZ ", 20 ) > -1 || 304 else if ( data.find( "FZ ", 20 ) > -1 ||
314 data.find( "GR ", 20 ) > -1 || 305 data.find( "GR ", 20 ) > -1 ||
315 data.find( "GS ", 20 ) > -1 || 306 data.find( "GS ", 20 ) > -1 ||
316 data.find( "PE ", 20 ) > -1 || 307 data.find( "PE ", 20 ) > -1 ||
317 data.find( "IC ", 20 ) > -1 ) 308 data.find( "IC ", 20 ) > -1 )
318 { 309 {
319 dataStr = "sleet"; 310 dataStr = "sleet";
320 } 311 }
321} 312}
313
314void WeatherPluginWidget::dataRetrieved( OProcess *process )
315{
316 if ( process->normalExit() )
317 {
318 displayWeather();
319 }
320 else
321 {
322 weatherLabel->setText( tr( "Current weather data not available.\nTry looking out the window." ) );
323 }
324}
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.h b/noncore/todayplugins/weather/weatherpluginwidget.h
index 2c0238d..d2bbd8b 100644
--- a/noncore/todayplugins/weather/weatherpluginwidget.h
+++ b/noncore/todayplugins/weather/weatherpluginwidget.h
@@ -1,69 +1,71 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 4             .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef WEATHER_PLUGIN_WIDGET_H 29#ifndef WEATHER_PLUGIN_WIDGET_H
30#define WEATHER_PLUGIN_WIDGET_H 30#define WEATHER_PLUGIN_WIDGET_H
31 31
32#include <qstring.h> 32#include <qstring.h>
33#include <qwidget.h> 33#include <qwidget.h>
34 34
35#include <unistd.h> 35class OProcess;
36
37class QLabel; 36class QLabel;
38class QTimer; 37class QTimer;
39 38
40class WeatherPluginWidget : public QWidget { 39class WeatherPluginWidget : public QWidget {
41 40
42 Q_OBJECT 41 Q_OBJECT
43 42
44 public: 43 public:
45 WeatherPluginWidget( QWidget *parent, const char *name ); 44 WeatherPluginWidget( QWidget *parent, const char *name );
46 ~WeatherPluginWidget(); 45 ~WeatherPluginWidget();
47 46
48 private: 47 private:
49 QString location; 48 QString location;
50 QString remoteFile; 49 QString remoteFile;
51 QString localFile; 50 QString localFile;
52 QString weatherData; 51 QString weatherData;
53 QString dataStr; 52 QString dataStr;
54 bool useMetric; 53 bool useMetric;
55 int frequency; 54 int frequency;
56 55
57 QLabel *weatherLabel; 56 QLabel *weatherLabel;
58 QLabel *weatherIcon; 57 QLabel *weatherIcon;
59 58
60 void timerEvent( QTimerEvent * ); 59 void timerEvent( QTimerEvent * );
61 void retreiveData(); 60 void retreiveData();
62 void displayWeather(); 61 void displayWeather();
63 void getTemp( const QString & ); 62 void getTemp( const QString & );
64 void getWind( const QString & ); 63 void getWind( const QString & );
65 void getPressure( const QString & ); 64 void getPressure( const QString & );
66 void getIcon( const QString & ); 65 void getIcon( const QString & );
66
67 private slots:
68 void dataRetrieved( OProcess * );
67}; 69};
68 70
69#endif 71#endif