[PATCH]Fix KStars startup wizard

Jason Harris kstars at 30doradus.org
Tue Mar 1 07:37:09 GMT 2005


Hello,

There's a bug in the KStars startup wizard that selects a different city 
from the one the user highlighted.  See: 
http://bugs.kde.org/show_bug.cgi?id=100371

I would like to get this into 3.4.0; may I commit to KDE_3_4_BRANCH ?
(Patch tested in HEAD)

Here is the patch:

Index: kswizard.h
===================================================================
RCS file: /home/kde/kdeedu/kstars/kstars/kswizard.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -p -r1.4 -r1.5
--- kswizard.h  12 Jun 2004 19:05:07 -0000      1.4
+++ kswizard.h  28 Feb 2005 14:47:42 -0000      1.5
@@ -21,6 +21,8 @@
 #include <qmemarray.h>
 #include "kswizardui.h"

+class GeoLocation;
+
 /**@class Setup Wizard for KStars
        *The Setup Wizard will be automatically opened when KStars runs
        *for the first time.  It allows the user to set up some basic 
parameters:
@@ -53,6 +55,7 @@ private:
        KStars *ksw;
        QMemArray<int> GeoID;
        GeoLocation *Geo;
+       QPtrList<GeoLocation> filteredCityList;
 };

 #endif


Index: kswizard.cpp
===================================================================
RCS file: /home/kde/kdeedu/kstars/kstars/kswizard.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -p -r1.7 -r1.8
--- kswizard.cpp        7 Jan 2005 04:10:50 -0000       1.7
+++ kswizard.cpp        28 Feb 2005 14:47:42 -0000      1.8
@@ -97,6 +97,7 @@ KSWizard::KSWizard( QWidget *parent, con
        #endif

        //Initialize Geographic Location page
+       filteredCityList.setAutoDelete( false );
        initGeoPage();
 }

@@ -111,17 +112,10 @@ void KSWizard::initGeoPage() {
        //flag the ID of the current City
        int index(0);
        for (GeoLocation *loc = ksw->data()->geoList.first(); loc; loc = 
ksw->data()->geoList.next()) {
-               QString s;
-               if ( loc->province().isEmpty() ) {
-                       s = loc->translatedName() + ", " + 
loc->translatedCountry();
-               } else {
-                       s = loc->translatedName() + ", " + 
loc->translatedProvince() +
-                                       ", " + loc->translatedCountry();
-               }
-               CityListBox->insertItem( s );
-               GeoID[CityListBox->count() - 1] = 
ksw->data()->geoList.at();
+               CityListBox->insertItem( loc->fullName() );
+               filteredCityList.append( loc );

-               if ( loc->name() == ksw->data()->geo()->name() && 
loc->country() == ksw->data()->geo()->country() )
+               if ( loc->fullName() == ksw->data()->geo()->fullName() )
                        index = ksw->data()->geoList.at();
        }

@@ -130,17 +124,28 @@ void KSWizard::initGeoPage() {

        //preset to current city
        CityListBox->setCurrentItem( index );
-       Geo = ksw->data()->geoList.at( GeoID[ index ] );
 }

 void KSWizard::slotChangeCity() {
-       Geo = 
ksw->data()->geoList.at(GeoID[CityListBox->currentItem()]);
+       Geo = 0L;
+
+       if ( CityListBox->currentItem() >= 0 ) {
+               for (GeoLocation *loc = filteredCityList.first(); loc; 
loc = filteredCityList.next()) {
+                       if ( loc->fullName() == 
CityListBox->currentText() ) {
+                               Geo = loc;
+                               break;
+                       }
+               }
+       }
+
        LongBox->showInDegrees( Geo->lng() );
        LatBox->showInDegrees( Geo->lat() );
 }

 void KSWizard::slotFilterCities() {
        CityListBox->clear();
+       filteredCityList.clear();
+
        for (GeoLocation *loc = ksw->data()->geoList.first(); loc; loc = 
ksw->data()->geoList.next()) {
                QString sc( loc->translatedName() );
                QString ss( loc->translatedCountry() );
@@ -151,22 +156,15 @@ void KSWizard::slotFilterCities() {
                if ( sc.lower().startsWith( CityFilter->text().lower() ) 
&&
                                
sp.lower().startsWith( ProvinceFilter->text().lower() ) &&
                                
ss.lower().startsWith( CountryFilter->text().lower() ) ) {
-                       sc.append( ", " );
-                       if ( !sp.isEmpty() ) {
-                               sc.append( sp );
-                               sc.append( ", " );
-                       }
-                       sc.append( ss );
-
-                       CityListBox->insertItem( sc );
-                       GeoID[CityListBox->count() - 1] = 
ksw->data()->geoList.at();
+                       CityListBox->insertItem( loc->fullName() );
+                       filteredCityList.append( loc );
                }
        }
+
+       CityListBox->sort();

-       if ( CityListBox->firstItem() ) {  // set first item in list as 
selected
+       if ( CityListBox->firstItem() )  // set first item in list as 
selected
                CityListBox->setCurrentItem( CityListBox->firstItem() );
-               Geo = 
ksw->data()->geoList.at( GeoID[ CityListBox->currentItem() ] );
-       }
 }

 //Uncomment if we ever need the telescope page...

-- 
KStars: Desktop Planetarium for KDE
http://edu.kde.org/kstars




More information about the kde-core-devel mailing list