kstars
kswizard.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00041 removePage( page(2) );
00042
00043
00044 #if ( ! KDE_IS_VERSION( 3, 2, 90 ) )
00045 removePage( page(3) );
00046 #endif
00047
00048
00049 for ( unsigned int i=0; i<((unsigned int) pageCount()); ++i ) {
00050 setFinishEnabled( page(i), true );
00051 }
00052
00053
00054 setNextEnabled( page( pageCount() - 1 ), false );
00055
00056
00057 QFile imFile;
00058 QPixmap im = QPixmap();
00059
00060 if ( KSUtils::openDataFile( imFile, "wzstars.png" ) ) {
00061 imFile.close();
00062 im.load( imFile.name() );
00063 }
00064 Banner1->setPixmap( im );
00065
00066 if ( KSUtils::openDataFile( imFile, "wzgeo.png" ) ) {
00067 imFile.close();
00068 im.load( imFile.name() );
00069 }
00070 Banner2->setPixmap( im );
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 #if ( KDE_IS_VERSION( 3, 2, 90 ) )
00081 if ( KSUtils::openDataFile( imFile, "wzdownload.png" ) ) {
00082 imFile.close();
00083 im.load( imFile.name() );
00084 }
00085 Banner4->setPixmap( im );
00086 #endif
00087
00088
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
00094
00095 #if ( KDE_IS_VERSION( 3, 2, 90 ) )
00096 connect( DownloadButton, SIGNAL( clicked() ), ksw, SLOT( slotDownload() ) );
00097 #endif
00098
00099
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
00112
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
00125 CityListBox->sort();
00126
00127
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() )
00169 CityListBox->setCurrentItem( CityListBox->firstItem() );
00170 }
00171
00172
00173
00174
00175
00176
00177
00178 #include "kswizard.moc"