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

kstars

kswizard.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           kswizard.cpp  -  description
00003                              -------------------
00004     begin                : Wed 28 Jan 2004
00005     copyright            : (C) 2004 by Jason Harris
00006     email                : kstars@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 <qfile.h>
00019 #include <qpixmap.h>
00020 #include <qlabel.h>
00021 #include <klineedit.h>
00022 #include <klistbox.h>
00023 #include <kpushbutton.h>
00024 
00025 #include "kstars.h"
00026 #include "kstarsdata.h"
00027 #include "ksutils.h"
00028 #include "geolocation.h"
00029 #include "dmsbox.h"
00030 #include "telescopewizardprocess.h"
00031 #include "kswizardui.h"
00032 #include "kswizard.h"
00033 
00034 KSWizard::KSWizard( QWidget *parent, const char *name )
00035  : KSWizardUI( parent, name )
00036 {
00037     ksw = (KStars *)parent;
00038     GeoID.resize(10000);
00039     
00040     //Removing telescope page for now...
00041     removePage( page(2) );
00042     
00043     //Remove Download page if KDE < 3.2.90
00044     #if ( ! KDE_IS_VERSION( 3, 2, 90 ) ) 
00045     removePage( page(3) );
00046     #endif
00047     
00048     //each page should have a finish button
00049     for ( unsigned int i=0; i<((unsigned int) pageCount()); ++i ) {
00050         setFinishEnabled( page(i), true );
00051     }
00052 
00053     //Disable "Next" Button on last page
00054     setNextEnabled( page( pageCount() - 1 ), false );
00055 
00056     //Load images into banner frames.
00057     QFile imFile;
00058     QPixmap im = QPixmap();
00059     
00060     if ( KSUtils::openDataFile( imFile, "wzstars.png" ) ) {
00061         imFile.close(); //Just need the filename...
00062         im.load( imFile.name() );
00063     }
00064     Banner1->setPixmap( im );
00065     
00066     if ( KSUtils::openDataFile( imFile, "wzgeo.png" ) ) {
00067         imFile.close(); //Just need the filename...
00068         im.load( imFile.name() );
00069     }
00070     Banner2->setPixmap( im );
00071     
00072 //Uncomment if we ever need the telescope page...
00073 //  if ( KSUtils::openDataFile( imFile, "wzscope.png" ) ) {
00074 //      imFile.close(); //Just need the filename...
00075 //      im.load( imFile.name() );
00076 //  }
00077 //  Banner3->setPixmap( im );
00078 
00079     //Only load the download page banner if KDE >= 3.2.90
00080     #if ( KDE_IS_VERSION( 3, 2, 90 ) )
00081     if ( KSUtils::openDataFile( imFile, "wzdownload.png" ) ) {
00082         imFile.close(); //Just need the filename...
00083         im.load( imFile.name() );
00084     }
00085     Banner4->setPixmap( im );
00086     #endif
00087 
00088     //connect signals/slots
00089     connect( CityListBox, SIGNAL( selectionChanged() ), this, SLOT( slotChangeCity() ) );
00090     connect( CityFilter, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotFilterCities() ) );
00091     connect( ProvinceFilter, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotFilterCities() ) );
00092     connect( CountryFilter, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotFilterCities() ) );
00093 //Uncomment if we ever need the telescope page...
00094 //  connect( TelescopeWizardButton, SIGNAL( clicked() ), this, SLOT( slotTelescopeSetup() ) );
00095     #if ( KDE_IS_VERSION( 3, 2, 90 ) )
00096     connect( DownloadButton, SIGNAL( clicked() ), ksw, SLOT( slotDownload() ) );
00097     #endif
00098     
00099     //Initialize Geographic Location page
00100     filteredCityList.setAutoDelete( false );
00101     initGeoPage();
00102 }
00103 
00104 KSWizard::~KSWizard() 
00105 {}
00106 
00107 void KSWizard::initGeoPage() {
00108     LongBox->setReadOnly( true );
00109     LatBox->setReadOnly( true );
00110 
00111     //Populate the CityListBox
00112     //flag the ID of the current City
00113     int index(0);
00114     for (GeoLocation *loc = ksw->data()->geoList.first(); loc; loc = ksw->data()->geoList.next()) {
00115         CityListBox->insertItem( loc->fullName() );
00116         filteredCityList.append( loc );
00117         
00118         if ( loc->fullName() == ksw->data()->geo()->fullName() ) {
00119             index = ksw->data()->geoList.at();
00120             Geo = loc;
00121         }
00122     }
00123     
00124     //Sort alphabetically
00125     CityListBox->sort();
00126     
00127     //preset to current city
00128     CityListBox->setCurrentItem( index + 1 );
00129 }
00130 
00131 void KSWizard::slotChangeCity() {
00132     Geo = 0L;
00133     
00134     if ( CityListBox->currentItem() >= 0 ) {
00135         for (GeoLocation *loc = filteredCityList.first(); loc; loc = filteredCityList.next()) {
00136             if ( loc->fullName() == CityListBox->currentText() ) {
00137                 Geo = loc;
00138                 break;
00139             }
00140         }
00141     }
00142 
00143     LongBox->showInDegrees( Geo->lng() );
00144     LatBox->showInDegrees( Geo->lat() );
00145 }
00146 
00147 void KSWizard::slotFilterCities() {
00148     CityListBox->clear();
00149     filteredCityList.clear();
00150 
00151     for (GeoLocation *loc = ksw->data()->geoList.first(); loc; loc = ksw->data()->geoList.next()) {
00152         QString sc( loc->translatedName() );
00153         QString ss( loc->translatedCountry() );
00154         QString sp = "";
00155         if ( !loc->province().isEmpty() )
00156             sp = loc->translatedProvince();
00157 
00158         if ( sc.lower().startsWith( CityFilter->text().lower() ) &&
00159                 sp.lower().startsWith( ProvinceFilter->text().lower() ) &&
00160                 ss.lower().startsWith( CountryFilter->text().lower() ) ) {
00161             CityListBox->insertItem( loc->fullName() );
00162             filteredCityList.append( loc );
00163         }
00164     }
00165     
00166     CityListBox->sort();
00167 
00168     if ( CityListBox->firstItem() )  // set first item in list as selected
00169         CityListBox->setCurrentItem( CityListBox->firstItem() );
00170 }
00171 
00172 //Uncomment if we ever need the telescope page...
00173 //void KSWizard::slotTelescopeSetup() {
00174 //  telescopeWizardProcess twiz(ksw);
00175 //  twiz.exec();
00176 //}
00177 
00178 #include "kswizard.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