Diffstat (limited to 'noncore/todayplugins/weather/weatherpluginwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/todayplugins/weather/weatherpluginwidget.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.cpp b/noncore/todayplugins/weather/weatherpluginwidget.cpp index f4ea0f2..800fdcb 100644 --- a/noncore/todayplugins/weather/weatherpluginwidget.cpp +++ b/noncore/todayplugins/weather/weatherpluginwidget.cpp @@ -105,25 +105,26 @@ void WeatherPluginWidget::retreiveData() OProcess *proc = new OProcess; *proc << "wget" << "-q" << remoteFile << "-O" << localFile; connect( proc, SIGNAL( processExited( OProcess * ) ), this, SLOT( dataRetrieved( OProcess * ) ) ); proc->start(); } void WeatherPluginWidget::displayWeather() { weatherData = QString::null; QFile file( localFile ); - if ( file.open( IO_ReadOnly ) ) + + if ( file.size() > 0 && file.open( IO_ReadOnly ) ) { QTextStream data( &file ); while ( !data.eof() ) { weatherData.append( data.readLine() ); } file.close(); weatherData = weatherData.simplifyWhiteSpace(); QString tmpstr; tmpstr.append( tr( "Temp: " ) ); @@ -141,25 +142,25 @@ void WeatherPluginWidget::displayWeather() weatherLabel->setText( tmpstr ); tmpstr = "todayweatherplugin/"; getIcon( weatherData ); tmpstr.append( dataStr ); QImage logo1 = Resource::loadImage( tmpstr ); QPixmap pic; pic.convertFromImage( logo1 ); weatherIcon->setPixmap( pic ); } else { - weatherLabel->setText( tr( "Current weather data not available.\nTry looking out the window." ) ); + weatherLabel->setText( tr( "Current weather data not available." ) ); } } void WeatherPluginWidget::getTemp( const QString &data ) { int value; bool ok; int pos = data.find( QRegExp( "M?[0-9]+/M?[0-9]+" ), 20 ); if ( pos > -1 ) { if ( data.at( pos ) == 'M' ) @@ -310,15 +311,15 @@ void WeatherPluginWidget::getIcon(const QString &data ) dataStr = "sleet"; } } void WeatherPluginWidget::dataRetrieved( OProcess *process ) { if ( process->normalExit() ) { displayWeather(); } else { - weatherLabel->setText( tr( "Current weather data not available.\nTry looking out the window." ) ); + weatherLabel->setText( tr( "Current weather data not available." ) ); } } |