[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.2/kdeedu/marble/src/lib
From:       Torsten Rahn <tackat () kde ! org>
Date:       2009-01-25 14:37:51
Message-ID: 1232894271.571776.6616.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 916553 by rahn:

- Fix first part of Bug 181865



 M  +42 -0     MarbleModel.cpp  
 M  +1 -0      MarbleModel.h  
 M  +14 -5     MarbleWidgetPopupMenu.cpp  
 M  +1 -1      MarbleWidgetPopupMenu.h  


--- branches/KDE/4.2/kdeedu/marble/src/lib/MarbleModel.cpp #916552:916553
@@ -810,6 +810,8 @@
     QTimer::singleShot( 0, d->m_tileLoader, SLOT( update() ) );
 }
 
+// FIXME: We'd like to have a targetBody ("planet") class which stores all attributes we need.
+
 qreal MarbleModel::planetRadius()   const
 {
     if ( d->m_mapTheme ) {
@@ -853,6 +855,46 @@
     return 6378000.0;
 }
 
+QString MarbleModel::planetName()   const
+{
+    if ( d->m_mapTheme ) {
+        QString target = d->m_mapTheme->head()->target().toLower();
+
+        // planets
+               if ( target == "mercury" ) {
+            return  QString("Mercury");
+        } else if ( target == "venus" ) {
+            return  QString("Venus");
+        } else if ( target == "earth" ) {
+            return  QString("Earth");
+        } else if ( target == "mars" ) {
+            return  QString("Mars");
+        } else if ( target == "jupiter" ) {
+            return  QString("Jupiter");
+        } else if ( target == "saturn" ) {
+            return  QString("Saturn");
+        } else if ( target == "uranus" ) {
+            return  QString("Uranus");
+        } else if ( target == "neptune" ) {
+            return  QString("Neptune");
+
+        // dwarf planets ... (everybody likes pluto)
+        } else if ( target == "pluto" ) {
+            return  QString("Pluto");
+
+        // sun and moon
+        } else if ( target == "sun" ) {
+            return  QString("Sun");
+        } else if ( target == "moon" ) {
+            return  QString("Moon");
+        }
+    }
+
+    // Fallback to assuming that we deal with the earth
+    return QString("Earth");
+}
+
+
 ExtDateTime* MarbleModel::dateTime() const
 {
 //    qDebug() << "In dateTime, model:" << this;
--- branches/KDE/4.2/kdeedu/marble/src/lib/MarbleModel.h #916552:916553
@@ -249,6 +249,7 @@
     void stopPolling();
 
     qreal                 planetRadius()   const;
+    QString               planetName()     const;
 
     ExtDateTime*          dateTime()       const;
     SunLocator*           sunLocator()     const;
--- branches/KDE/4.2/kdeedu/marble/src/lib/MarbleWidgetPopupMenu.cpp #916552:916553
@@ -40,9 +40,9 @@
 void MarbleWidgetPopupMenu::createActions()
 {
     //	Property actions (Left mouse button)
-    //	m_earthaction = new QAction(QIcon("icon.png"), tr("&Earth"), this);
-    m_earthaction = new QAction( tr( "&Earth" ), this );
-    m_earthaction->setData( 0 );
+    //	m_planetAction = new QAction(QIcon("icon.png"), tr("&Earth"), this);
+    m_planetAction = new QAction( tr( "&Earth" ), this );
+    m_planetAction->setData( 0 );
     m_copyCoordinateAction = new QAction( tr( "0 N 0 W" ), this );
 
     //	Tool actions (Right mouse button)
@@ -94,11 +94,20 @@
     }
 
     // Not implemented yet ;-)
-    m_earthaction->setEnabled( false );
+    m_planetAction->setEnabled( false );
 
-    m_lmbMenu->addAction( m_earthaction );
+    m_lmbMenu->addAction( m_planetAction );
     m_lmbMenu->addSeparator();
 
+    // Setting the proper planet name
+    QString targetString = m_model->planetName();
+    qDebug() << "targetString" << targetString;
+    // FIXME: this should be removed later on ...
+    if ( targetString == "Earth" ) 
+        targetString = tr( "&Earth" );
+
+    m_planetAction->setText( targetString );
+
     qreal  lat;
     qreal  lon;
 
--- branches/KDE/4.2/kdeedu/marble/src/lib/MarbleWidgetPopupMenu.h #916552:916553
@@ -69,7 +69,7 @@
 
     QMenu    *m_lmbMenu;
     QMenu    *m_rmbMenu;
-    QAction  *m_earthaction;	
+    QAction  *m_planetAction;	
 
     QAction  *m_copyCoordinateAction;
     QAction  *m_setHomePointAction; 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic