Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

weatherconfig.cpp

Go to the documentation of this file.
00001 /*
00002                      This file is part of the OPIE Project
00003                =.
00004       .=l.            Copyright (c)  2002 Dan Williams <williamsdr@acm.org>
00005      .>+-=
00006 _;:,   .>  :=|.         This file is free software; you can
00007 .> <`_,  > .  <=          redistribute it and/or modify it under
00008 :`=1 )Y*s>-.--  :           the terms of the GNU General Public
00009 .="- .-=="i,   .._         License as published by the Free Software
00010 - .  .-<_>   .<>         Foundation; either version 2 of the License,
00011   ._= =}    :          or (at your option) any later version.
00012   .%`+i>    _;_.
00013   .i_,=:_.   -<s.       This file is distributed in the hope that
00014   + . -:.    =       it will be useful, but WITHOUT ANY WARRANTY;
00015   : ..  .:,   . . .    without even the implied warranty of
00016   =_    +   =;=|`    MERCHANTABILITY or FITNESS FOR A
00017  _.=:.    :  :=>`:     PARTICULAR PURPOSE. See the GNU General
00018 ..}^=.=    =    ;      Public License for more details.
00019 ++=  -.   .`   .:
00020 :   = ...= . :.=-        You should have received a copy of the GNU
00021 -.  .:....=;==+<;          General Public License along with this file;
00022  -_. . .  )=. =           see the file COPYING. If not, write to the
00023   --    :-=`           Free Software Foundation, Inc.,
00024                              59 Temple Place - Suite 330,
00025                              Boston, MA 02111-1307, USA.
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 Doesn't seem to like QPEApplication::clipboard()...
00119 
00120 void WeatherPluginConfig::slotCopyLink()
00121 {
00122         QPEApplication::clipboard()->setText( "http://www.nws.noaa.gov/tg/siteloc.shtml" );
00123 }
00124 */

Generated on Sat Nov 5 16:18:01 2005 for OPIE by  doxygen 1.4.2