• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

locationdialog.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           locationdialog.cpp  -  K Desktop Planetarium
00003                              -------------------
00004     begin                : Sun Feb 11 2001
00005     copyright            : (C) 2001 by Jason Harris
00006     email                : jharris@30doradus.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include <stdlib.h>
00019 #include <stdio.h>
00020 
00021 #include <kmessagebox.h>
00022 #include <kstandarddirs.h>
00023 #include <klineedit.h>
00024 
00025 #include <qlayout.h>
00026 #include <qpushbutton.h>
00027 #include <qgroupbox.h>
00028 #include <qlabel.h>
00029 #include <qlistbox.h>
00030 #include <qcombobox.h>
00031 #include <qfile.h>
00032 
00033 #include "locationdialog.h"
00034 #include "kstars.h"
00035 #include "kstarsdata.h"
00036 #include "mapcanvas.h"
00037 #include "dmsbox.h"
00038 
00039 LocationDialog::LocationDialog( QWidget* parent )
00040     : KDialogBase( KDialogBase::Plain, i18n( "Set Geographic Location" ), Ok|Cancel, Ok, parent ) {
00041 
00042     KStars *p = (KStars *)parent;
00043 
00044     QFrame *page = plainPage();
00045     CityBox = new QGroupBox( page, "CityBox" );
00046     CoordBox = new QGroupBox( page, "CoordBox" );
00047     CityBox->setTitle( i18n( "Choose City" ) );
00048     CoordBox->setTitle( i18n( "Choose/Modify Coordinates" ) );
00049 
00050 //Create Layout managers
00051     RootLay = new QVBoxLayout( page, 4, 4 ); //root mgr for dialog
00052     CityLay = new QVBoxLayout( CityBox, 6, 4 ); //root mgr for CityBox
00053     CityLay->setSpacing( 6 );
00054     CityLay->setMargin( 6 );
00055     hlay = new QHBoxLayout( 2 ); //this layout will be added to CityLay
00056     vlay = new QVBoxLayout( 2 ); //this layout will be added to hlay
00057     glay = new QGridLayout( 3, 2, 6 ); //this layout will be added to vlay
00058 
00059     CoordLay = new QVBoxLayout( CoordBox, 6, 4 ); //root mgr for coordbox
00060     CoordLay->setSpacing( 6 );
00061     CoordLay->setMargin( 6 );
00062     glay2 = new QGridLayout( 3, 4, 4 ); //this layout will be added to CoordLay
00063     hlayCoord   = new QHBoxLayout( 2 ); //this layout will be added to glay2
00064     hlayTZ      = new QHBoxLayout( 2 ); //this layout will be added to glay2
00065     hlayButtons = new QHBoxLayout( 2 ); //this layout will be added to glay2
00066     hlay3       = new QHBoxLayout( 2 ); //this layout will be added to CoordLay
00067 
00068 //Create widgets
00069   CityFiltLabel = new QLabel( CityBox );
00070   CityFiltLabel->setText( i18n( "City filter:"  ) );
00071   ProvinceFiltLabel = new QLabel( CityBox );
00072   ProvinceFiltLabel->setText( i18n( "Province filter:"  ) );
00073   CountryFiltLabel = new QLabel( CityBox );
00074   CountryFiltLabel->setText( i18n( "Country filter:"  ) );
00075 
00076   CountLabel = new QLabel( CityBox );
00077 
00078   CityFilter = new KLineEdit( CityBox );
00079   CityFilter->setFocus();  // set focus to city inputline
00080   ProvinceFilter = new KLineEdit( CityBox );
00081   CountryFilter = new KLineEdit( CityBox );
00082 
00083   GeoBox = new QListBox( CityBox );
00084   GeoBox->setVScrollBarMode( QListBox::AlwaysOn );
00085   GeoBox->setHScrollBarMode( QListBox::AlwaysOff );
00086 
00087     MapView = new MapCanvas( CityBox );
00088     MapView->setFixedSize( 360, 180 ); //each pixel 1 deg x 2 deg
00089 
00090     NewCityLabel = new QLabel( i18n( "City:" ), CoordBox );
00091     NewProvinceLabel = new QLabel( i18n( "State/Province:" ), CoordBox );
00092     NewCountryLabel = new QLabel( i18n( "Country:" ), CoordBox );
00093     LongLabel = new QLabel( i18n( "Longitude:" ), CoordBox );
00094     LatLabel = new QLabel( i18n( "Latitude:" ), CoordBox );
00095     TZLabel = new QLabel( i18n( "timezone offset from universal time", "UT offset:" ), CoordBox );
00096     TZRuleLabel = new QLabel( i18n( "daylight savings time rule", "DST rule:" ), CoordBox );
00097 
00098     NewCityName = new KLineEdit( CoordBox );
00099     NewProvinceName = new KLineEdit( CoordBox );
00100     NewCountryName = new KLineEdit( CoordBox );
00101     NewLong = new dmsBox( CoordBox );
00102     NewLat = new dmsBox( CoordBox );
00103 
00104     TZBox = new QComboBox( CoordBox );
00105     TZRuleBox = new QComboBox( CoordBox );
00106     TZBox->setMinimumWidth( 16 );
00107     TZRuleBox->setMinimumWidth( 16 );
00108     TZBox->setEditable( true );
00109     TZBox->setDuplicatesEnabled( false );
00110 
00111     for ( int i=0; i<25; ++i )
00112         TZBox->insertItem( KGlobal::locale()->formatNumber( (double)(i-12) ) );
00113 
00114     QMap<QString, TimeZoneRule>::Iterator it = p->data()->Rulebook.begin();
00115     QMap<QString, TimeZoneRule>::Iterator itEnd = p->data()->Rulebook.end();
00116     for ( ; it != itEnd; ++it )
00117         if ( it.key().length() )
00118             TZRuleBox->insertItem( it.key() );
00119 
00120     ClearFields = new QPushButton( i18n( "Clear Fields" ), CoordBox, "ClearFields" );
00121     ShowTZRules = new QPushButton( i18n( "Explain DST Rules" ), CoordBox, "ShowDSTRules" );
00122 
00123     AddCityButton = new QPushButton( i18n ( "Add to List" ), CoordBox, "AddCityButton" );
00124 
00125 //Pack the widgets into the layouts
00126     RootLay->addWidget( CityBox, 0, 0 );
00127     RootLay->addWidget( CoordBox, 0, 0 );
00128 
00129     CityLay->addSpacing( 14 );
00130     CityLay->addLayout( hlay, 0 );
00131 
00132     hlay->addLayout( vlay, 0 );
00133     hlay->addSpacing( 12 );
00134     hlay->addWidget( GeoBox, 0, 0 );
00135 
00136     vlay->addWidget( MapView, 0, 0 );
00137     vlay->addLayout( glay, 0 );
00138     vlay->addWidget( CountLabel, 0, 0 );
00139 
00140     glay->addWidget( CityFiltLabel, 0, 0 );
00141     glay->addWidget( ProvinceFiltLabel, 1, 0 );
00142     glay->addWidget( CountryFiltLabel, 2, 0 );
00143     glay->addWidget( CityFilter, 0, 1 );
00144     glay->addWidget( ProvinceFilter, 1, 1 );
00145     glay->addWidget( CountryFilter, 2, 1 );
00146 
00147     hlay->activate();
00148 
00149     CoordLay->addSpacing( 14 );
00150     CoordLay->addLayout( glay2, 0 );
00151     CoordLay->addLayout( hlay3, 0 );
00152 
00153     glay2->addWidget( NewCityLabel, 0, 0 );
00154     glay2->addWidget( NewProvinceLabel, 1, 0 );
00155     glay2->addWidget( NewCountryLabel, 2, 0 );
00156     glay2->addWidget( NewCityName, 0, 1 );
00157     glay2->addWidget( NewProvinceName, 1, 1 );
00158     glay2->addWidget( NewCountryName, 2, 1 );
00159     glay2->addLayout( hlayCoord, 0, 3 );
00160     glay2->addLayout( hlayTZ, 1, 3 );
00161     glay2->addLayout( hlayButtons, 2, 3 );
00162 
00163     hlayCoord->addWidget( LongLabel );
00164     hlayCoord->addWidget( NewLong );
00165     hlayCoord->addWidget( LatLabel );
00166     hlayCoord->addWidget( NewLat );
00167 
00168     hlayTZ->addWidget( TZLabel );
00169     hlayTZ->addWidget( TZBox );
00170     hlayTZ->addWidget( TZRuleLabel );
00171     hlayTZ->addWidget( TZRuleBox );
00172 
00173     hlayButtons->addStretch();
00174     hlayButtons->addWidget( ClearFields );
00175     hlayButtons->addWidget( ShowTZRules );
00176 
00177     hlay3->addStretch();
00178     hlay3->addWidget( AddCityButton, 0 );
00179 
00180     CoordLay->activate();
00181     RootLay->activate();
00182 
00183     connect( this, SIGNAL( cancelClicked() ), this, SLOT( reject() ) );
00184     connect( CityFilter, SIGNAL( textChanged( const QString & ) ), this, SLOT( filterCity() ) );
00185     connect( ProvinceFilter, SIGNAL( textChanged( const QString & ) ), this, SLOT( filterCity() ) );
00186     connect( CountryFilter, SIGNAL( textChanged( const QString & ) ), this, SLOT( filterCity() ) );
00187     connect( NewCityName, SIGNAL( textChanged( const QString & ) ), this, SLOT( nameChanged() ) );
00188     connect( NewProvinceName, SIGNAL( textChanged( const QString & ) ), this, SLOT( nameChanged() ) );
00189     connect( NewCountryName, SIGNAL( textChanged( const QString & ) ), this, SLOT( nameChanged() ) );
00190     connect( NewLong, SIGNAL( textChanged( const QString & ) ), this, SLOT( dataChanged() ) );
00191     connect( NewLat, SIGNAL( textChanged( const QString & ) ), this, SLOT( dataChanged() ) );
00192     connect( TZBox, SIGNAL( activated(int) ), this, SLOT( dataChanged() ) );
00193     connect( TZRuleBox, SIGNAL( activated(int) ), this, SLOT( dataChanged() ) );
00194     connect( GeoBox, SIGNAL( selectionChanged() ), this, SLOT( changeCity() ) );
00195     connect( AddCityButton, SIGNAL( clicked() ), this, SLOT( addCity() ) );
00196     connect( ClearFields, SIGNAL( clicked() ), this, SLOT( clearFields() ) );
00197     connect( ShowTZRules, SIGNAL( clicked() ), this, SLOT( showTZRules() ) );
00198 
00199     dataModified = false;
00200     nameModified = false;
00201     AddCityButton->setEnabled( false );
00202 
00203     NewCityName->setTrapReturnKey(true);
00204     NewProvinceName->setTrapReturnKey(true);
00205     NewCountryName->setTrapReturnKey(true);
00206     CityFilter->setTrapReturnKey(true);
00207     ProvinceFilter->setTrapReturnKey(true);
00208     CountryFilter->setTrapReturnKey(true);
00209 
00210     filteredCityList.setAutoDelete( false );
00211     
00212     initCityList();
00213     resize (640, 480);
00214 }
00215 
00216 LocationDialog::~LocationDialog(){
00217 }
00218 
00219 void LocationDialog::initCityList( void ) {
00220     KStars *p = (KStars *)parent();
00221     for (GeoLocation *loc = p->data()->geoList.first(); loc; loc = p->data()->geoList.next())
00222     {
00223         GeoBox->insertItem( loc->fullName() );
00224         filteredCityList.append( loc );
00225 
00226         //If TZ is not even integer value, add it to listbox
00227         if ( loc->TZ0() - int( loc->TZ0() ) && ! TZBox->listBox()->findItem( KGlobal::locale()->formatNumber( loc->TZ0() ) ) ) {
00228             for ( unsigned int i=0; i<((unsigned int) TZBox->count()); ++i ) {
00229                 if ( TZBox->text( i ).toDouble() > loc->TZ0() ) {
00230                     TZBox->insertItem( KGlobal::locale()->formatNumber( loc->TZ0() ), i-1 );
00231                     break;
00232                 }
00233             }
00234         }
00235     }
00236 
00237     //Sort the list of Cities alphabetically...note that filteredCityList may now have a different ordering!
00238     GeoBox->sort();
00239     
00240     CountLabel->setText( i18n("One city matches search criteria","%n cities match search criteria",GeoBox->count()) );
00241 
00242     // attempt to highlight the current kstars location in the GeoBox
00243     GeoBox->setCurrentItem( 0 );
00244     if ( GeoBox->count() ) {
00245         for ( uint i=0; i<GeoBox->count(); i++ ) {
00246             if ( GeoBox->item(i)->text() == p->geo()->fullName() ) {
00247                 GeoBox->setCurrentItem( i );
00248                 break;
00249             }
00250         }
00251     }
00252 }
00253 
00254 void LocationDialog::filterCity( void ) {
00255     KStars *p = (KStars *)parent();
00256     GeoBox->clear();
00257     filteredCityList.clear();
00258     
00259     nameModified = false;
00260     dataModified = false;
00261     AddCityButton->setEnabled( false );
00262 
00263     for (GeoLocation *loc = p->data()->geoList.first(); loc; loc = p->data()->geoList.next()) {
00264         QString sc( loc->translatedName() );
00265         QString ss( loc->translatedCountry() );
00266         QString sp = "";
00267         if ( !loc->province().isEmpty() )
00268             sp = loc->translatedProvince();
00269 
00270         if ( sc.lower().startsWith( CityFilter->text().lower() ) &&
00271                 sp.lower().startsWith( ProvinceFilter->text().lower() ) &&
00272                 ss.lower().startsWith( CountryFilter->text().lower() ) ) {
00273 
00274             GeoBox->insertItem( loc->fullName() );
00275             filteredCityList.append( loc );
00276         }
00277     }
00278 
00279     GeoBox->sort();
00280     
00281     CountLabel->setText( i18n("One city matches search criteria","%n cities match search criteria", GeoBox->count()) );
00282 
00283     if ( GeoBox->firstItem() )      // set first item in list as selected
00284         GeoBox->setCurrentItem( GeoBox->firstItem() );
00285 
00286     MapView->repaint();
00287 }
00288 
00289 void LocationDialog::changeCity( void ) {
00290     //when the selected city changes, set newCity, and redraw map
00291     SelectedCity = 0L;
00292     if ( GeoBox->currentItem() >= 0 ) {
00293         for (GeoLocation *loc = filteredCityList.first(); loc; loc = filteredCityList.next()) {
00294             if ( loc->fullName() == GeoBox->currentText() ) {
00295                 SelectedCity = loc;
00296                 break;
00297             }
00298         }
00299     }
00300     
00301     MapView->repaint();
00302 
00303     //Fill the fields at the bottom of the window with the selected city's data.
00304     if ( SelectedCity ) {
00305         KStars *p = (KStars *)parent();
00306         NewCityName->setText( SelectedCity->translatedName() );
00307         NewProvinceName->setText( SelectedCity->translatedProvince() );
00308         NewCountryName->setText( SelectedCity->translatedCountry() );
00309         NewLong->showInDegrees( SelectedCity->lng() );
00310         NewLat->showInDegrees( SelectedCity->lat() );
00311         TZBox->setCurrentText( KGlobal::locale()->formatNumber( SelectedCity->TZ0() ) );
00312         
00313         //Pick the City's rule from the rulebook
00314         for ( int i=0; i<TZRuleBox->count(); ++i ) {
00315             if ( p->data()->Rulebook[ TZRuleBox->text(i) ].equals( SelectedCity->tzrule() ) ) {
00316                 TZRuleBox->setCurrentItem( i );
00317         //DEBUG
00318         kdDebug() << "tzrule: " << TZRuleBox->text(i) <<":"<<i << endl;
00319 
00320                 break;
00321             }
00322         }
00323     }
00324     
00325     nameModified = false;
00326     dataModified = false;
00327     AddCityButton->setEnabled( false );
00328 }
00329 
00330 void LocationDialog::addCity( void ) {
00331     KStars *p = (KStars *)parent();
00332     bCityAdded = false;
00333 
00334     if ( !nameModified && !dataModified ) {
00335         QString message = i18n( "This City already exists in the database." );
00336         KMessageBox::sorry( 0, message, i18n( "Error: Duplicate Entry" ) );
00337         return;
00338     }
00339 
00340     bool latOk(false), lngOk(false), tzOk(false);
00341     dms lat = NewLat->createDms( true, &latOk );
00342     dms lng = NewLong->createDms( true, &lngOk );
00343     double TZ = TZBox->lineEdit()->text().toDouble( &tzOk );
00344 
00345     if ( NewCityName->text().isEmpty() || NewCountryName->text().isEmpty() ) {
00346         QString message = i18n( "All fields (except province) must be filled to add this location." );
00347         KMessageBox::sorry( 0, message, i18n( "Fields are Empty" ) );
00348         return;
00349 
00350     //FIXME after strings freeze lifts, separate TZ check from lat/long check
00351     } else if ( ! latOk || ! lngOk || ! tzOk ) {
00352         QString message = i18n( "Could not parse coordinates." );
00353         KMessageBox::sorry( 0, message, i18n( "Bad Coordinates" ) );
00354         return;
00355     } else {
00356         if ( !nameModified ) {
00357             QString message = i18n( "Really override original data for this city?" );
00358             if ( KMessageBox::questionYesNo( 0, message, i18n( "Override Existing Data?" ), i18n("Override Data"), i18n("Do Not Override")) == KMessageBox::No )
00359                 return; //user answered No.
00360         }
00361 
00362         QString entry;
00363         QFile file;
00364 
00365         //Strip off white space
00366         QString name = NewCityName->text().stripWhiteSpace();
00367         QString province = NewProvinceName->text().stripWhiteSpace();
00368         QString country = NewCountryName->text().stripWhiteSpace();
00369 
00370         //check for user's city database.  If it doesn't exist, create it.
00371         file.setName( locateLocal( "appdata", "mycities.dat" ) ); //determine filename in local user KDE directory tree.
00372 
00373         if ( !file.open( IO_ReadWrite | IO_Append ) ) {
00374             QString message = i18n( "Local cities database could not be opened.\nLocation will not be recorded." );
00375             KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
00376             return;
00377         } else {
00378             char ltsgn = 'N'; if ( lat.degree()<0 ) ltsgn = 'S';
00379             char lgsgn = 'E'; if ( lng.degree()<0 ) lgsgn = 'W';
00380             QString TZrule = TZRuleBox->currentText();
00381 
00382             entry = entry.sprintf( "%-32s : %-21s : %-21s : %2d : %2d : %2d : %c : %3d : %2d : %2d : %c : %5.1f : %2s\n",
00383                         name.local8Bit().data(), province.local8Bit().data(), country.local8Bit().data(),
00384                         abs(lat.degree()), lat.arcmin(), lat.arcsec(), ltsgn,
00385                         abs(lng.degree()), lng.arcmin(), lat.arcsec(), lgsgn,
00386                         TZ, TZrule.local8Bit().data() );
00387 
00388             QTextStream stream( &file );
00389             stream << entry;
00390             file.close();
00391 
00392             //Add city to geoList...don't need to insert it alphabetically, since we always sort GeoList
00393             GeoLocation *g = new GeoLocation( lng.Degrees(), lat.Degrees(),
00394                                                         NewCityName->text(), NewProvinceName->text(), NewCountryName->text(),
00395                                                         TZ, &p->data()->Rulebook[ TZrule ] );
00396             p->data()->geoList.append( g );
00397             
00398             //(possibly) insert new city into GeoBox by running filterCity()
00399             filterCity();
00400             
00401             //Attempt to highlight new city in list
00402             GeoBox->setCurrentItem( 0 );
00403             if ( GeoBox->count() ) {
00404                 for ( uint i=0; i<GeoBox->count(); i++ ) {
00405                     if ( GeoBox->item(i)->text() == g->fullName() ) {
00406                         GeoBox->setCurrentItem( i );
00407                         break;
00408                     }
00409                 }
00410             }
00411         
00412         }
00413     }
00414 
00415     bCityAdded = true;
00416     return;
00417 }
00418 
00419 void LocationDialog::findCitiesNear( int lng, int lat ) {
00420     KStars *ks = (KStars *)parent();
00421 
00422     //find all cities within 3 degrees of (lng, lat); list them in GeoBox
00423     GeoBox->clear();
00424     filteredCityList.clear();
00425     for (GeoLocation *loc = ks->data()->geoList.first(); loc; loc = ks->data()->geoList.next()) {
00426         if ( ( abs( lng - int( loc->lng()->Degrees() ) ) < 3 ) &&
00427                  ( abs( lat - int( loc->lat()->Degrees() ) ) < 3 ) ) {
00428             
00429             GeoBox->insertItem( loc->fullName() );
00430             filteredCityList.append( loc );
00431         }
00432     }
00433 
00434     GeoBox->sort();
00435     CountLabel->setText( i18n("One city matches search criteria","%n cities match search criteria",GeoBox->count()) );
00436 
00437     if ( GeoBox->firstItem() )      // set first item in list as selected
00438         GeoBox->setCurrentItem( GeoBox->firstItem() );
00439 
00440     repaint();
00441 }
00442 
00443 bool LocationDialog::checkLongLat( void ) {
00444     if ( NewLong->text().isEmpty() || NewLat->text().isEmpty() ) return false;
00445 
00446     bool ok(false);
00447     double lng = NewLong->createDms(true, &ok).Degrees();
00448     if ( ! ok ) return false;
00449     double lat = NewLat->createDms(true, &ok).Degrees();
00450     if ( ! ok ) return false;
00451 
00452     if ( lng < -180.0 || lng > 180.0 ) return false;
00453     if ( lat <  -90.0 || lat >  90.0 ) return false;
00454 
00455     return true;
00456 }
00457 
00458 void LocationDialog::clearFields( void ) {
00459     CityFilter->clear();
00460     ProvinceFilter->clear();
00461     CountryFilter->clear();
00462     NewCityName->clear();
00463     NewProvinceName->clear();
00464     NewCountryName->clear();
00465     NewLong->clearFields();
00466     NewLat->clearFields();
00467     TZBox->lineEdit()->setText( KGlobal::locale()->formatNumber( 0.0 ) );
00468     TZRuleBox->setCurrentItem( 0 );
00469     nameModified = true;
00470     dataModified = false;
00471     AddCityButton->setEnabled( false );
00472     NewCityName->setFocus();
00473 }
00474 
00475 void LocationDialog::showTZRules( void ) {
00476     QStringList lines;
00477     lines.append( i18n( " Start Date (Start Time)  /  Revert Date (Revert Time)" ) );
00478     lines.append( " " );
00479     lines.append( i18n( "--: No DST correction" ) );
00480     lines.append( i18n( "AU: last Sun in Oct. (02:00) / last Sun in Mar. (02:00)" ) );
00481     lines.append( i18n( "BZ:  2nd Sun in Oct. (00:00) /  3rd Sun in Feb. (00:00)" ) );
00482     lines.append( i18n( "CH:  2nd Sun in Apr. (00:00) /  2nd Sun in Sep. (00:00)" ) );
00483     lines.append( i18n( "CL:  2nd Sun in Oct. (04:00) /  2nd Sun in Mar. (04:00)" ) );
00484     lines.append( i18n( "CZ:  1st Sun in Oct. (02:45) /  3rd Sun in Mar. (02:45)" ) );
00485     lines.append( i18n( "EE: Last Sun in Mar. (00:00) / Last Sun in Oct. (02:00)" ) );
00486     lines.append( i18n( "EG: Last Fri in Apr. (00:00) / Last Thu in Sep. (00:00)" ) );
00487     lines.append( i18n( "EU: Last Sun in Mar. (01:00) / Last Sun in Oct. (01:00)" ) );
00488     lines.append( i18n( "FK:  1st Sun in Sep. (02:00) /  3rd Sun in Apr. (02:00)" ) );
00489     lines.append( i18n( "HK:  2nd Sun in May  (03:30) /  3rd Sun in Oct. (03:30)" ) );
00490     lines.append( i18n( "IQ: Apr 1 (03:00) / Oct. 1 (00:00)" ) );
00491     lines.append( i18n( "IR: Mar 21 (00:00) / Sep. 22 (00:00)" ) );
00492     lines.append( i18n( "JD: Last Thu in Mar. (00:00) / Last Thu in Sep. (00:00)" ) );
00493     lines.append( i18n( "LB: Last Sun in Mar. (00:00) / Last Sun in Oct. (00:00)" ) );
00494     lines.append( i18n( "MX:  1st Sun in May  (02:00) / Last Sun in Sep. (02:00)" ) );
00495     lines.append( i18n( "NB:  1st Sun in Sep. (02:00) /  1st Sun in Apr. (02:00)" ) );
00496     lines.append( i18n( "NZ:  1st Sun in Oct. (02:00) /  3rd Sun in Mar. (02:00)" ) );
00497     lines.append( i18n( "PY:  1st Sun in Oct. (00:00) /  1st Sun in Mar. (00:00)" ) );
00498     lines.append( i18n( "RU: Last Sun in Mar. (02:00) / Last Sun in Oct. (02:00)" ) );
00499     lines.append( i18n( "SK:  2nd Sun in May  (00:00) /  2nd Sun in Oct. (00:00)" ) );
00500     lines.append( i18n( "SY: Apr. 1 (00:00) / Oct. 1 (00:00)" ) );
00501     lines.append( i18n( "TG:  1st Sun in Nov. (02:00) / Last Sun in Jan. (02:00)" ) );
00502     lines.append( i18n( "TS:  1st Sun in Oct. (02:00) / Last Sun in Mar. (02:00)" ) );
00503     lines.append( i18n( "US:  1st Sun in Apr. (02:00) / Last Sun in Oct. (02:00)" ) );
00504     lines.append( i18n( "ZN: Apr. 1 (01:00) / Oct. 1 (00:00)" ) );
00505 
00506     QString message = i18n( "Daylight Saving Time Rules" );
00507     KMessageBox::informationList( 0, message, lines, message );
00508 }
00509 
00510 void LocationDialog::nameChanged( void ) {
00511     nameModified = true;
00512     dataChanged();
00513 }
00514 
00515 //do not enable Add button until all data are present and valid.
00516 void LocationDialog::dataChanged( void ) {
00517     dataModified = true;
00518     if ( ! NewCityName->text().isEmpty() && ! NewCountryName->text().isEmpty() && checkLongLat() )
00519         AddCityButton->setEnabled( true );
00520     else
00521         AddCityButton->setEnabled( false );
00522 }
00523 
00524 void LocationDialog::slotOk( void ) {
00525     bool bOkToClose = false;
00526     if ( addCityEnabled() ) { //user closed the location dialog without adding their new city;
00527         addCity();                   //call addCity() for them!
00528         bOkToClose = bCityAdded;
00529     } else {
00530         bOkToClose = true;
00531     }
00532 
00533     if ( bOkToClose ) accept();
00534 }
00535 
00536 bool LocationDialog::addCityEnabled() { return AddCityButton->isEnabled(); }
00537 
00538 #include "locationdialog.moc"

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal