1 /***************************************************************************
2 kswizard.cpp - description
4 begin : Wed 28 Jan 2004
5 copyright : (C) 2004 by Jason Harris
6 email : kstars@30doradus.org
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
21 #include <klineedit.h>
23 #include <kpushbutton.h>
26 #include "kstarsdata.h"
28 #include "geolocation.h"
30 #include "telescopewizardprocess.h"
31 #include "kswizardui.h"
34 KSWizard::KSWizard( QWidget
*parent
, const char *name
)
35 : KSWizardUI( parent
, name
)
37 ksw
= (KStars
*)parent
;
40 //Removing telescope page for now...
41 removePage( page(2) );
43 //Remove Download page if KDE < 3.2.90
44 #if ( ! KDE_IS_VERSION( 3, 2, 90 ) )
45 removePage( page(3) );
48 //each page should have a finish button
49 for ( unsigned int i
=0; i
<((unsigned int) pageCount()); ++i
) {
50 setFinishEnabled( page(i
), true );
53 //Disable "Next" Button on last page
54 setNextEnabled( page( pageCount() - 1 ), false );
56 //Load images into banner frames.
58 QPixmap im
= QPixmap();
60 if ( KSUtils::openDataFile( imFile
, "wzstars.png" ) ) {
61 imFile
.close(); //Just need the filename...
62 im
.load( imFile
.name() );
64 Banner1
->setPixmap( im
);
66 if ( KSUtils::openDataFile( imFile
, "wzgeo.png" ) ) {
67 imFile
.close(); //Just need the filename...
68 im
.load( imFile
.name() );
70 Banner2
->setPixmap( im
);
72 //Uncomment if we ever need the telescope page...
73 // if ( KSUtils::openDataFile( imFile, "wzscope.png" ) ) {
74 // imFile.close(); //Just need the filename...
75 // im.load( imFile.name() );
77 // Banner3->setPixmap( im );
79 //Only load the download page banner if KDE >= 3.2.90
80 #if ( KDE_IS_VERSION( 3, 2, 90 ) )
81 if ( KSUtils::openDataFile( imFile
, "wzdownload.png" ) ) {
82 imFile
.close(); //Just need the filename...
83 im
.load( imFile
.name() );
85 Banner4
->setPixmap( im
);
88 //connect signals/slots
89 connect( CityListBox
, SIGNAL( selectionChanged() ), this, SLOT( slotChangeCity() ) );
90 connect( CityFilter
, SIGNAL( textChanged( const QString
& ) ), this, SLOT( slotFilterCities() ) );
91 connect( ProvinceFilter
, SIGNAL( textChanged( const QString
& ) ), this, SLOT( slotFilterCities() ) );
92 connect( CountryFilter
, SIGNAL( textChanged( const QString
& ) ), this, SLOT( slotFilterCities() ) );
93 //Uncomment if we ever need the telescope page...
94 // connect( TelescopeWizardButton, SIGNAL( clicked() ), this, SLOT( slotTelescopeSetup() ) );
95 #if ( KDE_IS_VERSION( 3, 2, 90 ) )
96 connect( DownloadButton
, SIGNAL( clicked() ), ksw
, SLOT( slotDownload() ) );
99 //Initialize Geographic Location page
100 filteredCityList
.setAutoDelete( false );
104 KSWizard::~KSWizard()
107 void KSWizard::initGeoPage() {
108 LongBox
->setReadOnly( true );
109 LatBox
->setReadOnly( true );
111 //Populate the CityListBox
112 //flag the ID of the current City
114 for (GeoLocation
*loc
= ksw
->data()->geoList
.first(); loc
; loc
= ksw
->data()->geoList
.next()) {
115 CityListBox
->insertItem( loc
->fullName() );
116 filteredCityList
.append( loc
);
118 if ( loc
->fullName() == ksw
->data()->geo()->fullName() )
119 index
= ksw
->data()->geoList
.at();
122 //Sort alphabetically
125 //preset to current city
126 CityListBox
->setCurrentItem( index
);
129 void KSWizard::slotChangeCity() {
132 if ( CityListBox
->currentItem() >= 0 ) {
133 for (GeoLocation
*loc
= filteredCityList
.first(); loc
; loc
= filteredCityList
.next()) {
134 if ( loc
->fullName() == CityListBox
->currentText() ) {
141 LongBox
->showInDegrees( Geo
->lng() );
142 LatBox
->showInDegrees( Geo
->lat() );
145 void KSWizard::slotFilterCities() {
146 CityListBox
->clear();
147 filteredCityList
.clear();
149 for (GeoLocation
*loc
= ksw
->data()->geoList
.first(); loc
; loc
= ksw
->data()->geoList
.next()) {
150 QString
sc( loc
->translatedName() );
151 QString
ss( loc
->translatedCountry() );
153 if ( !loc
->province().isEmpty() )
154 sp
= loc
->translatedProvince();
156 if ( sc
.lower().startsWith( CityFilter
->text().lower() ) &&
157 sp
.lower().startsWith( ProvinceFilter
->text().lower() ) &&
158 ss
.lower().startsWith( CountryFilter
->text().lower() ) ) {
159 CityListBox
->insertItem( loc
->fullName() );
160 filteredCityList
.append( loc
);
166 if ( CityListBox
->firstItem() ) // set first item in list as selected
167 CityListBox
->setCurrentItem( CityListBox
->firstItem() );
170 //Uncomment if we ever need the telescope page...
171 //void KSWizard::slotTelescopeSetup() {
172 // telescopeWizardProcess twiz(ksw);
176 #include "kswizard.moc"