[Kstars-devel] KDE/kdeedu/kstars/kstars/tools
Jason Harris
kstars at 30doradus.org
Sun Jun 29 19:00:51 CEST 2008
SVN commit 825981 by harris:
kludgy-but-should-work fix for Bug #165170 (Cunjunctions not calculated for
Japanese locale.
Thank you for reporting this localization bug...please report any other problems
related to localization that you may run into! I did see your second report as
well, and I will get a fix ASAP.
The problem is that ComboBox->currentText() is translated, but the KSPlanet ctor
expects the untranslated name string as a parameter.
This solution uses currentIndex() instead, and a switch to determine which planet
should be used. The solution is a bit fragile, because the planets are now
assumed to appear in a particular order in the combobox.
I am planning to implement a better solution in the unfrozen branch, so please
don't port these changes to unfrozen or summer; wait for the unfrozen fix.
CCMAIL: kstars-devel at kde.org
BUG: 165170
M +43 -19 conjunctions.cpp
M +3 -7 conjunctions.h
--- trunk/KDE/kdeedu/kstars/kstars/tools/conjunctions.cpp #825980:825981
@@ -28,6 +28,7 @@
#include <kglobal.h>
#include <kmessagebox.h>
+#include "ksconjunct.h"
#include "geolocation.h"
#include "locationdialog.h"
#include "dms.h"
@@ -89,7 +90,6 @@
KStarsDateTime dtStart = startDate -> dateTime();
KStarsDateTime dtStop = stopDate -> dateTime();
- KStarsData *kd = KStarsData::Instance();
long double startJD = dtStart.djd();
long double stopJD = dtStop.djd();
dms maxSeparation(1.0); // TODO: Make maxSeparation user-specifiable
@@ -97,24 +97,9 @@
// dms LST( geoPlace->GSTtoLST( dt.gst() ) );
KSPlanetBase *Object1, *Object2;
- if(Obj1ComboBox -> currentIndex() <= 6)
- Object1 = (KSPlanetBase *)(new KSPlanet(kd, I18N_NOOP(Obj1ComboBox -> currentText())));
- else if(Obj1ComboBox -> currentIndex() == 7)
- Object1 = (KSPlanetBase *)(new KSPluto(kd));
- else if(Obj1ComboBox -> currentIndex() == 8)
- Object1 = (KSPlanetBase *)(new KSMoon(kd));
- else if(Obj1ComboBox -> currentIndex() == 9)
- Object1 = (KSPlanetBase *)(new KSSun(kd));
-
- if(Obj2ComboBox -> currentIndex() <= 6)
- Object2 = (KSPlanetBase *)(new KSPlanet(kd, I18N_NOOP(Obj2ComboBox -> currentText())));
- else if(Obj2ComboBox -> currentIndex() == 7)
- Object2 = (KSPlanetBase *)(new KSPluto(kd));
- else if(Obj2ComboBox -> currentIndex() == 8)
- Object2 = (KSPlanetBase *)(new KSMoon(kd));
- else if(Obj2ComboBox -> currentIndex() == 9)
- Object2 = (KSPlanetBase *)(new KSSun(kd));
-
+ Object1 = createPlanetFromIndex( Obj1ComboBox -> currentIndex() );
+ Object2 = createPlanetFromIndex( Obj2ComboBox -> currentIndex() );
+
KSConjunct ksc;
showConjunctions(ksc.findClosestApproach(*Object1, *Object2, startJD, stopJD, maxSeparation));
@@ -123,7 +108,46 @@
}
+KSPlanetBase* ConjunctionsTool::createPlanetFromIndex( int i ) {
+ KSPlanetBase *Object;
+ KStarsData *kd = KStarsData::Instance();
+ switch ( i ) {
+ case 0:
+ Object = (KSPlanetBase *)(new KSPlanet( kd, "Mercury" ));
+ break;
+ case 1:
+ Object = (KSPlanetBase *)(new KSPlanet( kd, "Venus" ));
+ break;
+ case 2:
+ Object = (KSPlanetBase *)(new KSPlanet( kd, "Mars" ));
+ break;
+ case 3:
+ Object = (KSPlanetBase *)(new KSPlanet( kd, "Jupiter" ));
+ break;
+ case 4:
+ Object = (KSPlanetBase *)(new KSPlanet( kd, "Saturn" ));
+ break;
+ case 5:
+ Object = (KSPlanetBase *)(new KSPlanet( kd, "Uranus" ));
+ break;
+ case 6:
+ Object = (KSPlanetBase *)(new KSPlanet( kd, "Neptune" ));
+ break;
+ case 7:
+ Object = (KSPlanetBase *)(new KSPluto( kd ));
+ break;
+ case 8:
+ Object = (KSPlanetBase *)(new KSSun( kd ));
+ break;
+ case 9:
+ Object = (KSPlanetBase *)(new KSMoon( kd ));
+ break;
+ }
+
+ return Object;
+}
+
void ConjunctionsTool::showConjunctions(QMap<long double, dms> conjunctionlist) {
KStarsDateTime dt;
--- trunk/KDE/kdeedu/kstars/kstars/tools/conjunctions.h #825980:825981
@@ -28,14 +28,10 @@
#include <QTextStream>
#include "ui_conjunctions.h"
-#include "ksconjunct.h"
class GeoLocation;
-class KSPlanet;
-class KSMoon;
-class KSSun;
-class KSPluto;
-class KSConjunct;
+class KSPlanetBase;
+class dms;
/**
*@short Predicts conjunctions using KSConjunct in the background
@@ -55,7 +51,7 @@
void slotCompute();
private:
-
+ KSPlanetBase* createPlanetFromIndex( int i );
void showConjunctions(QMap<long double, dms> conjunctionlist);
GeoLocation *geoPlace;
More information about the Kstars-devel
mailing list