00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "weatherconfig.h"
00030
00031 #include <qpe/config.h>
00032 #include <qpe/qpeapplication.h>
00033
00034 #include <qcheckbox.h>
00035 #include <qclipboard.h>
00036 #include <qfontmetrics.h>
00037 #include <qlabel.h>
00038 #include <qlayout.h>
00039 #include <qlineedit.h>
00040 #include <qlayout.h>
00041 #include <qpushbutton.h>
00042 #include <qspinbox.h>
00043 #include <qwhatsthis.h>
00044
00045 #include <stdlib.h>
00046
00047 WeatherPluginConfig::WeatherPluginConfig( QWidget *parent, const char* name)
00048 : TodayConfigWidget(parent, name )
00049 {
00050 Config config( "todayweatherplugin");
00051 config.setGroup( "Config" );
00052
00053 QFontMetrics fm = fontMetrics();
00054 int fh = fm.height();
00055
00056 QGridLayout *layout = new QGridLayout( this );
00057 layout->setSpacing( 4 );
00058 layout->setMargin( 4 );
00059
00060 QLabel *label = new QLabel( tr( "Enter ICAO location identifier:" ), this );
00061 label->setMaximumHeight( fh + 3 );
00062 layout->addMultiCellWidget( label, 0, 0, 0, 1 );
00063 QWhatsThis::add( label, tr( "Enter the 4 letter code for the desired location here. See http://www.nws.noaa.gov/tg/siteloc.shtml to find a location near you." ) );
00064
00065 locationEdit = new QLineEdit( config.readEntry( "Location", "" ), this );
00066 locationEdit->setMaximumHeight( fh + 5 );
00067 locationEdit->setFocus();
00068 layout->addMultiCellWidget( locationEdit, 1, 1, 0, 1 );
00069 QWhatsThis::add( locationEdit, tr( "Enter the 4 letter code for the desired location here. See http://www.nws.noaa.gov/tg/siteloc.shtml to find a location near you." ) );
00070
00071 label = new QLabel( tr( "Visit http://www.nws.noaa.gov/tg/siteloc.shtml to find the nearest location." ), this );
00072 label->setAlignment( AlignHCenter | WordBreak );
00073 label->setMaximumHeight( label->height() );
00074 layout->addMultiCellWidget( label, 2, 2, 0, 1 );
00075
00076 metricCB = new QCheckBox( tr( "Use metric units" ), this );
00077 metricCB->setMaximumHeight( fh + 5 );
00078 metricCB->setChecked( config.readBoolEntry( "Metric", TRUE ) );
00079 layout->addMultiCellWidget( metricCB, 3, 3, 0, 1 );
00080 QWhatsThis::add( metricCB, tr( "Click here to select type of units displayed." ) );
00081
00082 label = new QLabel( tr( "Update frequency (in minutes):" ), this );
00083 label->setMaximumHeight( fh + 3 );
00084 layout->addWidget( label, 4, 0 );
00085 QWhatsThis::add( label, tr( "Select how often (in minutes) you want the weather to be updated." ) );
00086
00087 timerDelaySB = new QSpinBox( 1, 60, 1, this );
00088 timerDelaySB->setMaximumHeight( fh + 5 );
00089 timerDelaySB->setValue( config.readNumEntry( "Frequency", 5 ) );
00090 layout->addWidget( timerDelaySB, 4, 1 );
00091 QWhatsThis::add( timerDelaySB, tr( "Select how often (in minutes) you want the weather to be updated." ) );
00092 }
00093
00094
00095 void WeatherPluginConfig::writeConfig()
00096 {
00097 Config config( "todayweatherplugin");
00098 config.setGroup( "Config" );
00099
00100 config.writeEntry( "Location", locationEdit->text().upper().stripWhiteSpace() );
00101 config.writeEntry( "Metric", metricCB->isChecked() );
00102 config.writeEntry( "Frequency", timerDelaySB->value() );
00103
00104 config.write();
00105 }
00106
00107 WeatherPluginConfig::~WeatherPluginConfig()
00108 {
00109 }
00110
00111 void WeatherPluginConfig::doLookup()
00112 {
00113 system( "weather" );
00114 }
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124