[Kstars-devel] KDE/kdeedu/kstars/kstars

Akarsh Simha akarshsimha at gmail.com
Sat Dec 20 21:37:09 CET 2008


SVN commit 899458 by asimha:

Fix a whole bunch of (related) issues when using Localized Constellation Names:

+ Display localized constellation names in the find dialog

+ Display localized constellation names in the popup menu

+ Introduce an optional localized name for polyList, and ensure that
  polyListIndex includes that name in the hash as well, so that tools
  like the Observing List Wizard that use
  ConstellationBoundary::inConstellation() work correctly.

CCMAIL: kstars-devel at kde.org



 M  +5 -3      kstarsactions.cpp  
 M  +3 -2      skycomponents/constellationboundary.cpp  
 M  +1 -1      skycomponents/constellationboundarylines.cpp  
 M  +6 -5      skycomponents/constellationnamescomponent.cpp  
 M  +8 -0      skycomponents/constellationnamescomponent.h  
 M  +16 -2     skycomponents/polylist.h  
 M  +4 -0      skycomponents/polylistindex.cpp  
 M  +4 -0      skycomponents/skymapcomposite.cpp  
 M  +1 -0      skycomponents/skymapcomposite.h  


--- trunk/KDE/kdeedu/kstars/kstars/kstarsactions.cpp #899457:899458
@@ -409,9 +409,11 @@
     Options::self()->writeConfig();
 
     // If the focus object was a constellation and the sky culture has changed, remove the focus object
-    if( map()->focusObject() && map()->focusObject()->type() == SkyObject::CONSTELLATION && kstarsData->skyComposite()->currentCulture() != kstarsData->skyComposite()->getCultureName( (int)Options::skyCulture() ) ) {
-        map()->setClickedObject( NULL );
-        map()->setFocusObject( NULL );
+    if( map()->focusObject() && map()->focusObject()->type() == SkyObject::CONSTELLATION ) {
+        if( kstarsData->skyComposite()->currentCulture() != kstarsData->skyComposite()->getCultureName( (int)Options::skyCulture() ) || kstarsData->skyComposite()->isLocalCNames() != Options::useLocalConstellNames() ) {
+            map()->setClickedObject( NULL );
+            map()->setFocusObject( NULL );
+        }
     }
 
     applyConfig();
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/constellationboundary.cpp #899457:899458
@@ -62,8 +62,9 @@
 QString ConstellationBoundary::constellationName( SkyPoint *p )
 {
     PolyList *polyList = ContainingPoly( p );
-    if ( polyList ) return polyList->name();
-
+    if ( polyList ) {
+        return ( Options::useLocalConstellNames() ? i18nc( "Constellation name (optional)", polyList->name().toUpper().toLocal8Bit().data() ) : polyList->name() );
+    }
     return i18n("Unknown");
 }
 
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/constellationboundarylines.cpp #899457:899458
@@ -103,7 +103,7 @@
 
             if ( polyList ) boundaryPoly->appendPoly( polyList, idxFile, verbose );
             QString cName = line.mid(1);
-            polyList = new PolyList( cName );
+            polyList = new PolyList( cName , i18nc( "Constellation name (optional)", cName.toUpper().toLocal8Bit().data() ) );
             if ( verbose == -1 ) printf(":\n");
             lastRa = lastDec = -1000.0;
             continue;
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/constellationnamescomponent.cpp #899457:899458
@@ -52,6 +52,8 @@
     if ( ! fileReader.open( "cnames.dat" ) ) return;
 
     emitProgressText( i18n("Loading constellation names" ) );
+    
+    localCNames = ( Options::useLocalConstellNames() ? true : false );
 
     while ( fileReader.hasMoreLines() ) {
         QString line, name, abbrev;
@@ -86,6 +88,9 @@
             abbrev = line.mid( 13, 3 );
             name  = line.mid( 17 ).trimmed();
 
+            if( Options::useLocalConstellNames() )
+                name = i18nc( "Constellation name (optional)", name.toLocal8Bit().data() );
+
             dms r; r.setH( rah, ram, ras );
             dms d( dd, dm,  ds );
 
@@ -131,13 +136,9 @@
         QPointF o = map->toScreen( p );
         if ( ! map->onScreen( o ) ) continue;
 
-        if ( Options::useLatinConstellNames() ) {
+        if ( Options::useLatinConstellNames() || Options::useLocalConstellNames() ) {
             name = p->name();
         }
-        else if ( Options::useLocalConstellNames() ) {
-            name = i18nc( "Constellation name (optional)",
-                          p->name().toLocal8Bit().data() );
-        }
         else {
             name = p->name2();
         }
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/constellationnamescomponent.h #899457:899458
@@ -73,8 +73,16 @@
      */
     void update( KStarsData *data, KSNumbers *num );
 
+    /**
+     *@short Return true if we are using localized constellation names
+     */
+    inline bool isLocalCNames() { return localCNames; }
+
     bool selected();
 
+ private:
+    bool localCNames;
+
 };
 
 #endif
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/polylist.h #899457:899458
@@ -31,12 +31,17 @@
  */
 class PolyList
 {
-public:
+ public:
     /* @short trivial constructor that also sets the name.   It was
      * convenient to specify the name at construction time.
      */
     PolyList( QString name) : m_wrapRA(false) { m_name = name; };
 
+    /* @short trivial constructor that also sets the name and
+     * localized name. 
+     */
+    PolyList( QString name, QString lname ) : m_wrapRA(false) { m_name = name; m_lname = lname; };
+
     /* @short returns the QPolygonF that holds the points.
      */
     const QPolygonF* poly() { return &m_poly; }
@@ -51,16 +56,25 @@
      */
     void setName( QString name ) { m_name = name; }
 
+    /* @short set the localized name
+     */
+    void setLocalizedName( QString lname ) { m_lname = lname; }
+
     /* @short returns the name.
      */
     const QString &name() { return m_name; }
 
+    /* @short returns the localized name.
+     */
+    const QString &localizedName() { return m_lname; }
+
     bool wrapRA() { return m_wrapRA; }
     void wrapRA( bool wrap ) { m_wrapRA = wrap; }
 
-private:
+ private:
     QPolygonF m_poly;
     QString   m_name;
+    QString   m_lname; // Localized name
     bool      m_wrapRA;
 
 };
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/polylistindex.cpp #899457:899458
@@ -49,6 +49,8 @@
         return appendPoly( polyList, debug );
 
     m_nameHash.insert( polyList->name(), polyList );
+    if( !polyList->localizedName().isEmpty() )
+        m_nameHash.insert( polyList->localizedName(), polyList );
 
     while ( file->hasMoreLines() ) {
         QString line = file->readLine();
@@ -61,6 +63,8 @@
 void PolyListIndex::appendPoly( PolyList* polyList, int debug)
 {
     m_nameHash.insert( polyList->name(), polyList );
+    if( !polyList->localizedName().isEmpty() )
+        m_nameHash.insert( polyList->localizedName(), polyList );
 
     if ( debug >= 0 && debug < skyMesh()->debug() ) debug = skyMesh()->debug();
 
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/skymapcomposite.cpp #899457:899458
@@ -506,6 +506,10 @@
     m_CNames->init( data );
 }
 
+bool SkyMapComposite::isLocalCNames() {
+    return m_CNames->isLocalCNames();
+}
+
 void SkyMapComposite::emitProgressText( const QString &message ) {
     emit progressText( message );
     qApp->processEvents();         // -jbb: this seemed to make it work.
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/skymapcomposite.h #899457:899458
@@ -201,6 +201,7 @@
     QString getCultureName( int index );
     QString currentCulture();
     void setCurrentCulture( QString culture );
+    bool isLocalCNames();
 
     QList<SkyComponent*> customCatalogs();
 


More information about the Kstars-devel mailing list