[Kstars-devel] [kstars] kstars: Moving ObservingList from KStars to KStarsData where it belongs. This will be the first of many structure that should be moved out of KStars and into KStarsData.

Jasem Mutlaq mutlaqja at ikarustech.com
Thu Feb 12 13:51:14 UTC 2015


Git commit 731ac815b9a283e06a3c13c82262a14f385e81d8 by Jasem Mutlaq.
Committed on 12/02/2015 at 13:48.
Pushed by mutlaqja into branch 'master'.

Moving ObservingList from KStars to KStarsData where it belongs. This will be the first of many structure that should be moved out of KStars and into KStarsData.
There were quite a few classes that are still being passed a pointer to KStars despite it being a singleton. This is probably due to old code that was not migrated.
I am going to migrate that slowly.

CCMAIL:kstars-devel at kde.org

M  +5    -6    kstars/dialogs/detaildialog.cpp
M  +23   -21   kstars/kspopupmenu.cpp
M  +1    -1    kstars/kstars.cpp
M  +2    -4    kstars/kstars.h
M  +2    -2    kstars/kstarsactions.cpp
M  +4    -0    kstars/kstarsdata.cpp
M  +3    -0    kstars/kstarsdata.h
M  +2    -2    kstars/kstarsdbus.cpp
M  +0    -3    kstars/kstarsinit.cpp
M  +18   -16   kstars/oal/execute.cpp
M  +0    -1    kstars/oal/execute.h
M  +14   -15   kstars/oal/log.cpp
M  +0    -1    kstars/oal/log.h
M  +2    -2    kstars/skycomponents/skymapcomposite.cpp
M  +3    -3    kstars/skymapevents.cpp
M  +23   -23   kstars/tools/observinglist.cpp
M  +1    -2    kstars/tools/observinglist.h
M  +14   -14   kstars/tools/obslistpopupmenu.cpp
M  +4    -4    kstars/tools/wutdialog.cpp

http://commits.kde.org/kstars/731ac815b9a283e06a3c13c82262a14f385e81d8

diff --git a/kstars/dialogs/detaildialog.cpp b/kstars/dialogs/detaildialog.cpp
index eb32746..1e07fe2 100644
--- a/kstars/dialogs/detaildialog.cpp
+++ b/kstars/dialogs/detaildialog.cpp
@@ -1072,18 +1072,17 @@ void DetailDialog::saveLogData() {
 }
 
 void DetailDialog::addToObservingList() {
-    KStars::Instance()->observingList()->slotAddObject( selectedObject );
+    KStarsData::Instance()->observingList()->slotAddObject( selectedObject );
 }
 
-void DetailDialog::centerMap() {
-    SkyMap* map = KStars::Instance()->map();
-    map->setClickedObject( selectedObject );
-    map->slotCenter();
+void DetailDialog::centerMap()
+{
+    SkyMap::Instance()->setClickedObject( selectedObject );
+    SkyMap::Instance()->slotCenter();
 }
 
 void DetailDialog::centerTelescope()
 {
-
 #ifdef HAVE_INDI
 
     if (INDIListener::Instance()->size() == 0)
diff --git a/kstars/kspopupmenu.cpp b/kstars/kspopupmenu.cpp
index 4a5d9e0..a3ed275 100644
--- a/kstars/kspopupmenu.cpp
+++ b/kstars/kspopupmenu.cpp
@@ -265,7 +265,8 @@ void KSPopupMenu::createSupernovaMenu(Supernova* supernova)
 void KSPopupMenu::initPopupMenu( SkyObject *obj, QString name, QString type, QString info,
                                  bool showDetails, bool showObsList, bool showFlags )
 {
-    KStars* ks = KStars::Instance();
+    KStarsData* data = KStarsData::Instance();
+    SkyMap * map = SkyMap::Instance();
 
     clear();
     bool showLabel = name != xi18n("star") && !name.isEmpty();
@@ -287,50 +288,51 @@ void KSPopupMenu::initPopupMenu( SkyObject *obj, QString name, QString type, QSt
     delete o;
 
     // Show 'Select this object' item when in object pointing mode and when obj is not empty sky
-    if(KStars::Instance()->map()->isInObjectPointingMode() && obj->type() != 21) {
-        addAction( xi18n( "Select this object"), KStars::Instance()->map(), SLOT(slotObjectSelected()));
+    if(map->isInObjectPointingMode() && obj->type() != 21)
+    {
+        addAction( xi18n( "Select this object"), map, SLOT(slotObjectSelected()));
     }
 
     //Insert item for centering on object
-    addAction( xi18n( "Center && Track" ), ks->map(), SLOT( slotCenter() ) );
+    addAction( xi18n( "Center && Track" ), map, SLOT( slotCenter() ) );
 
-    if ( showFlags ) {
+    if ( showFlags )
+    {
         //Insert actions for flag operations
         initFlagActions( obj );
     }
 
     //Insert item for measuring distances
     //FIXME: add key shortcut to menu items properly!
-    addAction( xi18n( "Angular Distance To...            [" ), ks->map(),
-               SLOT(slotBeginAngularDistance()) );
-    addAction( xi18n( "Starhop from here to...            " ), ks->map(),
-               SLOT(slotBeginStarHop()) );
+    addAction( xi18n( "Angular Distance To...            [" ), map, SLOT(slotBeginAngularDistance()) );
+    addAction( xi18n( "Starhop from here to...            " ), map, SLOT(slotBeginStarHop()) );
 
     //Insert item for Showing details dialog
     if ( showDetails )
-        addAction( xi18nc( "Show Detailed Information Dialog", "Details" ), ks->map(), SLOT( slotDetail() ) );
+        addAction( xi18nc( "Show Detailed Information Dialog", "Details" ), map, SLOT( slotDetail() ) );
     //Insert "Add/Remove Label" item
-    if ( showLabel ) {
-        if ( ks->map()->isObjectLabeled( obj ) ) {
-            addAction( xi18n( "Remove Label" ), ks->map(), SLOT( slotRemoveObjectLabel() ) );
+    if ( showLabel )
+    {
+        if ( map->isObjectLabeled( obj ) ) {
+            addAction( xi18n( "Remove Label" ), map, SLOT( slotRemoveObjectLabel() ) );
         } else {
-            addAction( xi18n( "Attach Label" ), ks->map(), SLOT( slotAddObjectLabel() ) );
+            addAction( xi18n( "Attach Label" ), map, SLOT( slotAddObjectLabel() ) );
         }
     }
     // Should show observing list
     if( showObsList ) {
-        if ( ks->observingList()->contains( obj ) )
-            addAction( xi18n("Remove From Observing WishList"), ks->observingList(), SLOT( slotRemoveObject() ) );
+        if ( data->observingList()->contains( obj ) )
+            addAction( xi18n("Remove From Observing WishList"), data->observingList(), SLOT( slotRemoveObject() ) );
         else
-            addAction( xi18n("Add to Observing WishList"), ks->observingList(), SLOT( slotAddObject() ) );
+            addAction( xi18n("Add to Observing WishList"), data->observingList(), SLOT( slotAddObject() ) );
     }
     // Should we show trail actions
     TrailObject* t = dynamic_cast<TrailObject*>( obj );
     if( t ) {
         if( t->hasTrail() )
-            addAction( xi18n( "Remove Trail" ), ks->map(), SLOT( slotRemovePlanetTrail() ) );
+            addAction( xi18n( "Remove Trail" ), map, SLOT( slotRemovePlanetTrail() ) );
         else
-            addAction( xi18n( "Add Trail" ), ks->map(), SLOT( slotAddPlanetTrail() ) );
+            addAction( xi18n( "Add Trail" ), map, SLOT( slotAddPlanetTrail() ) );
     }
 
     addSeparator();
@@ -338,8 +340,8 @@ void KSPopupMenu::initPopupMenu( SkyObject *obj, QString name, QString type, QSt
     if ( obj->isSolarSystem() && obj->type() != SkyObject::COMET ) { // FIXME: We now have asteroids -- so should this not be isMajorPlanet() || Pluto?
         QMenu *xplanetSubmenu = new QMenu();
         xplanetSubmenu->setTitle( xi18n( "Print Xplanet view" ) );
-        xplanetSubmenu->addAction( xi18n( "To screen" ), ks->map(), SLOT( slotXplanetToScreen() ) );
-        xplanetSubmenu->addAction( xi18n( "To file..." ), ks->map(), SLOT( slotXplanetToFile() ) );
+        xplanetSubmenu->addAction( xi18n( "To screen" ), map, SLOT( slotXplanetToScreen() ) );
+        xplanetSubmenu->addAction( xi18n( "To file..." ), map, SLOT( slotXplanetToFile() ) );
         addMenu( xplanetSubmenu );
     }
 #endif
diff --git a/kstars/kstars.cpp b/kstars/kstars.cpp
index 171ffe4..ce3ef27 100644
--- a/kstars/kstars.cpp
+++ b/kstars/kstars.cpp
@@ -54,7 +54,7 @@ KStars *KStars::pinstance = 0;
 KStars::KStars( bool doSplash, bool clockrun, const QString &startdate )
     : KXmlGuiWindow(), kstarsData(0), skymap(0), TimeStep(0),
       colorActionMenu(0), fovActionMenu(0), findDialog(0),
-      imgExportDialog(0), imageExporter(0), m_observingList(0), m_execute(0),
+      imgExportDialog(0), imageExporter(0), m_execute(0),
       m_altVsTime(0), m_WUTDialog(0), m_WIView(0), m_ObsConditions(0), m_wiDock(0), m_skyCalender(0),
       m_scriptBuilder(0), m_planetViewer(0), m_JMoonTool(0), m_moonPhaseTool(0), m_flagManager(0), astrocalc(0), m_printingWizard(0),
       m_ekosManager(0), DialogIsObsolete(false), StartClockRunning( clockrun ),
diff --git a/kstars/kstars.h b/kstars/kstars.h
index ce7e6fb..9d73821 100644
--- a/kstars/kstars.h
+++ b/kstars/kstars.h
@@ -122,9 +122,7 @@ public:
     inline KStarsData* data() const { return kstarsData; }
 
     /** @return pointer to SkyMap object which is the sky display widget. */
-    inline SkyMap* map() const { return skymap; }
-
-    inline ObservingList* observingList() const { return m_observingList; }
+    inline SkyMap* map() const { return skymap; }    
 
     inline EkosManager *ekosManager() const { return m_ekosManager; }
 
@@ -616,7 +614,7 @@ private:
     ImageExporter *imageExporter;
 
     //FIXME: move to KStarsData
-    ObservingList *m_observingList;
+
     EquipmentWriter *m_equipmentWriter;
     ObserverAdd *m_observerAdd;
     Execute *m_execute;
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index a33b199..3fbfef8 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -1166,7 +1166,7 @@ void KStars::slotFOVEdit() {
 }
 
 void KStars::slotObsList() {
-    m_observingList->show();
+    kstarsData->observingList()->show();
 }
 
 void KStars::slotEquipmentWriter() {
@@ -1275,7 +1275,7 @@ void KStars::slotAboutToQuit()
     writeConfig();
 
     if( !Options::obsListSaveImage() ) {
-        foreach ( const QString& file, m_observingList->imageList() )
+        foreach ( const QString& file, kstarsData->observingList()->imageList() )
             QFile::remove( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + file ) ;
     }
 }
diff --git a/kstars/kstarsdata.cpp b/kstars/kstarsdata.cpp
index 2d2f7e3..16ebc3d 100644
--- a/kstars/kstarsdata.cpp
+++ b/kstars/kstarsdata.cpp
@@ -99,6 +99,7 @@ KStarsData::KStarsData() :
     m_Geo(dms(0), dms(0)),
     m_ksuserdb(),
     m_catalogdb(),
+    m_observingList(0),
     temporaryTrail( false ),
     //locale( new KLocale( "kstars" ) ),
     m_preUpdateID(0),        m_updateID(0),
@@ -167,6 +168,9 @@ bool KStarsData::initialize() {
         skyComposite()->supernovaeComponent()->slotTriggerDataFileUpdate();
     }
 
+    //Initialize Observing List
+    m_observingList = new ObservingList();
+
     readUserLog();
 
     readADVTreeData();
diff --git a/kstars/kstarsdata.h b/kstars/kstarsdata.h
index 8794442..3e3b833 100644
--- a/kstars/kstarsdata.h
+++ b/kstars/kstarsdata.h
@@ -214,6 +214,8 @@ public:
     /** Return ADV Tree */
     QList<ADVTreeData*> avdTree() { return ADVtreeList; }
 
+    inline ObservingList* observingList() const { return m_observingList; }
+
     /*@short Increments the updateID, forcing a recomputation of star positions as well */
     unsigned int incUpdateID();
 
@@ -333,6 +335,7 @@ private:
     CatalogDB m_catalogdb;
     ColorScheme CScheme;
     OAL::Log *m_logObject;
+    ObservingList *m_observingList;
 
     bool TimeRunsForward, temporaryTrail;
     // FIXME: Used in SkyMap only. Check!
diff --git a/kstars/kstarsdbus.cpp b/kstars/kstarsdbus.cpp
index bd1c0f4..38adf3e 100644
--- a/kstars/kstarsdbus.cpp
+++ b/kstars/kstarsdbus.cpp
@@ -492,7 +492,7 @@ QString KStars::getObjectDataXML( const QString &objectName ) {
 
 QString KStars::getObservingWishListObjectNames() {
     QString output;
-    foreach( const SkyObject *object,  observingList()->obsList() ) {
+    foreach( const SkyObject *object,  KStarsData::Instance()->observingList()->obsList() ) {
         output.append( object->name() + '\n' );
     }
     return output;
@@ -500,7 +500,7 @@ QString KStars::getObservingWishListObjectNames() {
 
 QString KStars::getObservingSessionPlanObjectNames() {
     QString output;
-    foreach( const SkyObject *object,  observingList()->sessionList() ) {
+    foreach( const SkyObject *object,  KStarsData::Instance()->observingList()->sessionList() ) {
         output.append( object->name() + '\n' );
     }
     return output;
diff --git a/kstars/kstarsinit.cpp b/kstars/kstarsinit.cpp
index a0b4779..bcfd84c 100644
--- a/kstars/kstarsinit.cpp
+++ b/kstars/kstarsinit.cpp
@@ -584,9 +584,6 @@ void KStars::datainitFinished() {
     connect( TimeStep, SIGNAL( scaleChanged(float) ), data()->clock(), SLOT( setClockScale( float )) );
     connect( TimeStep, SIGNAL( scaleChanged(float) ), map(),  SLOT( setFocus() ) );
 
-
-    //Initialize Observing List
-    m_observingList = new ObservingList( this );
     m_equipmentWriter = new EquipmentWriter();
     m_observerAdd = new ObserverAdd;
     #ifdef HAVE_INDI
diff --git a/kstars/oal/execute.cpp b/kstars/oal/execute.cpp
index 36879cb..fbd6e21 100644
--- a/kstars/oal/execute.cpp
+++ b/kstars/oal/execute.cpp
@@ -54,7 +54,6 @@ Execute::Execute() {
 
     setWindowTitle( xi18n( "Execute Session" ) );
 
-    ks = KStars::Instance();
     currentTarget = NULL;
     currentObserver = NULL;
     currentScope = NULL;
@@ -67,7 +66,7 @@ Execute::Execute() {
     nextSite = 0;
 
     //initialize the global logObject
-    logObject = ks->data()->logObject();
+    logObject = KStarsData::Instance()->logObject();
 
     //initialize the lists and parameters
     init();
@@ -99,7 +98,7 @@ Execute::Execute() {
 
 void Execute::init() {
     //initialize geo to current location of the ObservingList
-    geo = ks->observingList()->geoLocation();
+    geo = KStarsData::Instance()->geo();
     ui.Location->setText( geo->fullName() );
 
 
@@ -212,7 +211,7 @@ void Execute::slotLocation() {
 void Execute::loadTargets() {
     ui.Target->clear();
     sortTargetList();
-    foreach( SkyObject *o, ks->observingList()->sessionList() ) {
+    foreach( SkyObject *o, KStarsData::Instance()->observingList()->sessionList() ) {
         ui.Target->addItem( getObjectName(o, false) );
     }
 }
@@ -239,11 +238,14 @@ void Execute::loadObservers() {
 }
 
 void Execute::sortTargetList() {
-    qSort( ks->observingList()->sessionList().begin(), ks->observingList()->sessionList().end(), Execute::timeLessThan );
+    qSort( KStarsData::Instance()->observingList()->sessionList().begin(), KStarsData::Instance()->observingList()->sessionList().end(), Execute::timeLessThan );
 }
 
- bool Execute::timeLessThan ( SkyObject *o1, SkyObject *o2 ) {
-    QTime t1 = KStars::Instance()->observingList()->scheduledTime( o1 ), t2 = KStars::Instance()->observingList()->scheduledTime( o2 );
+bool Execute::timeLessThan ( SkyObject *o1, SkyObject *o2 )
+{
+    QTime t1 = KStarsData::Instance()->observingList()->scheduledTime( o1 );
+    QTime t2 = KStarsData::Instance()->observingList()->scheduledTime( o2 );
+
     if( t1 < QTime(12,0,0) )
         t1.setHMS( t1.hour()+12, t1.minute(), t1.second() );
     else
@@ -258,7 +260,7 @@ void Execute::sortTargetList() {
 void Execute::addTargetNotes() {
     if( ! ui.Target->count() )
         return;
-    SkyObject *o = KStars::Instance()->observingList()->findObjectByName( ui.Target->currentItem()->text() );
+    SkyObject *o = KStarsData::Instance()->observingList()->findObjectByName( ui.Target->currentItem()->text() );
     if( o ) {
         currentTarget = o;
         o->setNotes( ui.Notes->toPlainText() );
@@ -322,7 +324,7 @@ void Execute::slotEndSession() {
 }
 
 void Execute::slotSetTarget( QString name ) {
-    currentTarget = ks->observingList()->findObjectByName( name );
+    currentTarget = KStarsData::Instance()->observingList()->findObjectByName( name );
     if( ! currentTarget ) {
         ui.NextButton->setEnabled( false );
         ui.Slew->setEnabled( false );
@@ -330,13 +332,13 @@ void Execute::slotSetTarget( QString name ) {
     } else {
         ui.NextButton->setEnabled( true );
         ui.Slew->setEnabled( true );
-        ks->observingList()->selectObject( currentTarget );
-        ks->observingList()->slotCenterObject();
+        KStarsData::Instance()->observingList()->selectObject( currentTarget );
+        KStarsData::Instance()->observingList()->slotCenterObject();
         QString smag = "--";
         if (  - 30.0 < currentTarget->mag() && currentTarget->mag() < 90.0 ) smag = QString::number( currentTarget->mag(), 'g', 2 ); // The lower limit to avoid display of unrealistic comet magnitudes
         ui.Mag->setText( smag );
         ui.Type->setText( currentTarget->typeName() );
-        ui.SchTime->setText( ks->observingList()->scheduledTime(currentTarget).toString( "h:mm:ss AP" ) ) ;
+        ui.SchTime->setText( KStarsData::Instance()->observingList()->scheduledTime(currentTarget).toString( "h:mm:ss AP" ) ) ;
         SkyPoint p = currentTarget->recomputeCoords( KStarsDateTime::currentDateTime() , geo );
         dms lst(geo->GSTtoLST( KStarsDateTime::currentDateTime().gst() ));
         p.EquatorialToHorizontal( &lst, geo->lat() );
@@ -349,7 +351,7 @@ void Execute::slotSetTarget( QString name ) {
 }
 
 void Execute::slotSlew() {
-    ks->observingList()->slotSlewToObject();
+    KStarsData::Instance()->observingList()->slotSlewToObject();
 }
 
 void Execute::selectNextTarget() {
@@ -388,11 +390,11 @@ void Execute::slotShowTargets() {
 }
 
 void Execute::slotAddObject() {
-   QPointer<FindDialog> fd = new FindDialog( ks );
+   QPointer<FindDialog> fd = new FindDialog( KStars::Instance() );
    if ( fd->exec() == QDialog::Accepted ) {
        SkyObject *o = fd->selectedObject();
        if( o != 0 ) {
-           ks->observingList()->slotAddObject( o, true );
+           KStarsData::Instance()->observingList()->slotAddObject( o, true );
            init();
        }
    }
@@ -411,7 +413,7 @@ void Execute::slotRemoveObject()
 
 	if( obj!=0 )
 	{
-		ks->observingList()->slotRemoveObject( obj, true );
+        KStarsData::Instance()->observingList()->slotRemoveObject( obj, true );
 		loadTargets();
 	}
 }
diff --git a/kstars/oal/execute.h b/kstars/oal/execute.h
index f9d4014..fed501d 100644
--- a/kstars/oal/execute.h
+++ b/kstars/oal/execute.h
@@ -135,7 +135,6 @@ Q_OBJECT
         void slotRemoveObject();
 
     private:
-        KStars *ks;
         Ui::Execute ui;
         OAL::Session *currentSession;
         OAL::Log *logObject;
diff --git a/kstars/oal/log.cpp b/kstars/oal/log.cpp
index 194548d..59fbc99 100644
--- a/kstars/oal/log.cpp
+++ b/kstars/oal/log.cpp
@@ -25,10 +25,10 @@
 #include "skycomponents/skymapcomposite.h"
 #include "kstarsdatetime.h"
 
-void OAL::Log::writeBegin() {
-    ks = KStars::Instance();
+void OAL::Log::writeBegin()
+{
     output = "";
-    m_targetList = ks->observingList()->sessionList();
+    m_targetList = KStarsData::Instance()->observingList()->sessionList();
     writer = new QXmlStreamWriter(&output);
     writer->setAutoFormatting( true );
     writer->writeStartDocument();
@@ -179,9 +179,9 @@ void OAL::Log::writeTarget( SkyObject *o ) {
     writer->writeCharacters( QString::number( o->dec().radians() ) );
     writer->writeEndElement();
     writer->writeEndElement();
-    if( native && ! ks->observingList()->getTime( o ).isEmpty() ) {
+    if( native && ! KStarsData::Instance()->observingList()->getTime( o ).isEmpty() ) {
         writer->writeStartElement("time");
-        writer->writeCDATA( ks->observingList()->getTime( o ) );
+        writer->writeCDATA( KStarsData::Instance()->observingList()->getTime( o ) );
         writer->writeEndElement();
     }
     writer->writeStartElement( "constellation" );
@@ -372,22 +372,21 @@ void OAL::Log::writeObservation( OAL::Observation *o ) {
 void OAL::Log::writeGeoDate() {
     writer->writeStartElement( "geodate" );
     writer->writeStartElement( "name" );
-    writer->writeCDATA( ks->observingList()->geoLocation()->name() );
+    writer->writeCDATA( KStarsData::Instance()->observingList()->geoLocation()->name() );
     writer->writeEndElement();
     writer->writeStartElement( "province" );
-    writer->writeCDATA( ks->observingList()->geoLocation()->province() );
+    writer->writeCDATA( KStarsData::Instance()->observingList()->geoLocation()->province() );
     writer->writeEndElement();
     writer->writeStartElement( "country" );
-    writer->writeCDATA( ks->observingList()->geoLocation()->country() );
+    writer->writeCDATA( KStarsData::Instance()->observingList()->geoLocation()->country() );
     writer->writeEndElement();
     writer->writeStartElement( "date" );
-    writer->writeCDATA( ks->observingList()->dateTime().date().toString( "ddMMyyyy" ) );
+    writer->writeCDATA( KStarsData::Instance()->observingList()->dateTime().date().toString( "ddMMyyyy" ) );
     writer->writeEndElement();
     writer->writeEndElement();
 }
 void OAL::Log::readBegin( QString input ) {
     reader = new QXmlStreamReader( input );
-    ks = KStars::Instance();
     while( ! reader->atEnd() ) {
         reader->readNext();
         if( reader->isStartElement() ) {
@@ -517,8 +516,8 @@ void OAL::Log::readTarget() {
                 name = reader->readElementText();
                 if( name != "star" )
                 {
-                    o = ks->data()->objectNamed( name );
-                    if( ! o ) o = ks->data()->skyComposite()->findStarByGenetiveName( name );
+                    o = KStarsData::Instance()->objectNamed( name );
+                    if( ! o ) o = KStarsData::Instance()->skyComposite()->findStarByGenetiveName( name );
                     if( o ) targetList()->append( o );
                 }
             }
@@ -530,7 +529,7 @@ void OAL::Log::readTarget() {
                    double maxrd=0.5;
                    while (!o && maxrd <= 2.0)
                    {
-                        o = ks->data()->skyComposite()->starNearest(&pos, maxrd);
+                        o = KStarsData::Instance()->skyComposite()->starNearest(&pos, maxrd);
                         if (!o)
                             maxrd += 0.5;
                    }
@@ -739,11 +738,11 @@ void OAL::Log::readGeoDate() {
                 readUnknownElement();
         }
     }
-    geo = ks->data()->locationNamed( name, province, country );
+    geo = KStarsData::Instance()->locationNamed( name, province, country );
     if (geo == NULL)
     {
         qDebug() << "Warning! Location " << name << ", " << province << ", " << country << " not found in KStars. Using current location." << endl;
-        geo = ks->data()->geo();
+        geo = KStarsData::Instance()->geo();
     }
     dt.setDate( QDate::fromString( date, "ddMMyyyy" ) );
 }
diff --git a/kstars/oal/log.h b/kstars/oal/log.h
index a176807..49da8ca 100644
--- a/kstars/oal/log.h
+++ b/kstars/oal/log.h
@@ -129,7 +129,6 @@ class OAL::Log {
         QString output;
         bool native;
         dms ra, dec;
-        KStars *ks;
         QXmlStreamWriter *writer;
         QXmlStreamReader *reader;
         QHash<QString, QTime> TimeHash;
diff --git a/kstars/skycomponents/skymapcomposite.cpp b/kstars/skycomponents/skymapcomposite.cpp
index 97766d9..a720961 100644
--- a/kstars/skycomponents/skymapcomposite.cpp
+++ b/kstars/skycomponents/skymapcomposite.cpp
@@ -214,7 +214,7 @@ void SkyMapComposite::draw( SkyPainter *skyp )
     // map->infoBoxes()->reserveBoxes( psky );
 
     if( KStars::Instance() ) {
-        const QList<SkyObject*> obsList = KStars::Instance()->observingList()->sessionList();
+        const QList<SkyObject*> obsList = KStarsData::Instance()->observingList()->sessionList();
         if( Options::obsListText() )
             foreach( SkyObject* obj, obsList ) {
                 SkyLabeler::AddLabel( obj, SkyLabeler::RUDE_LABEL );
@@ -258,7 +258,7 @@ void SkyMapComposite::draw( SkyPainter *skyp )
 
     m_ObservingList->pen = QPen( QColor(data->colorScheme()->colorNamed( "ObsListColor" )), 1. );
     if( KStars::Instance() && !m_ObservingList->list )
-        m_ObservingList->list = &KStars::Instance()->observingList()->sessionList();
+        m_ObservingList->list = &KStarsData::Instance()->observingList()->sessionList();
     if( m_ObservingList )
         m_ObservingList->draw( skyp );
 
diff --git a/kstars/skymapevents.cpp b/kstars/skymapevents.cpp
index ed3e5e3..4061d2b 100644
--- a/kstars/skymapevents.cpp
+++ b/kstars/skymapevents.cpp
@@ -67,8 +67,8 @@ void SkyMap::resizeEvent( QResizeEvent * )
     m_iboxes->resize( size() );
 }
 
-void SkyMap::keyPressEvent( QKeyEvent *e ) {
-    KStars* kstars = KStars::Instance();
+void SkyMap::keyPressEvent( QKeyEvent *e )
+{
     QString s;
     bool arrowKeyPressed( false );
     bool shiftPressed( false );
@@ -271,7 +271,7 @@ void SkyMap::keyPressEvent( QKeyEvent *e ) {
         }
 
         if ( clickedObject() ) {
-            kstars->observingList()->slotAddObject();
+            data->observingList()->slotAddObject();
         }
 
         if ( orig ) {
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index 537fb21..e70d7d1 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -83,9 +83,9 @@ ObservingListUI::ObservingListUI( QWidget *p ) : QFrame( p ) {
 //
 // ObservingList
 // ---------------------------------
-ObservingList::ObservingList( KStars *_ks )
-        : QDialog( (QWidget*)_ks ),
-        ks( _ks ), LogObject(0), m_CurrentObject(0),
+ObservingList::ObservingList()
+        : QDialog( (QWidget*) KStars::Instance() ),
+        LogObject(0), m_CurrentObject(0),
           isModified(false), bIsLarge(true), m_epf( 0 )
 {
     ui = new ObservingListUI( this );
@@ -99,7 +99,7 @@ ObservingList::ObservingList( KStars *_ks )
 
     dt = KStarsDateTime::currentDateTime();
     setFocusPolicy(Qt::StrongFocus);
-    geo = ks->data()->geo();
+    geo = KStarsData::Instance()->geo();
     sessionView = false;
     FileName = "";
     pmenu = new ObsListPopupMenu();
@@ -228,7 +228,7 @@ ObservingList::~ObservingList()
 void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
     bool addToWishList=true;
     if( ! obj )
-        obj = ks->map()->clickedObject();
+        obj = SkyMap::Instance()->clickedObject();
 
     if ( !obj ) {
         qWarning() << "Trying to add null object to observing list!";
@@ -246,13 +246,13 @@ void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
     if ( obsList().contains( obj ) ) {
         addToWishList = false;
         if( ! session ) {
-            ks->statusBar()->showMessage( xi18n( "%1 is already in your wishlist.", finalObjectName ), 0 );
+            KStars::Instance()->statusBar()->showMessage( xi18n( "%1 is already in your wishlist.", finalObjectName ), 0 );
             return;
         }
     }
 
     if ( session && sessionList().contains( obj ) ) {
-        ks->statusBar()->showMessage( xi18n( "%1 is already in the session plan.", finalObjectName ), 0 );
+        KStars::Instance()->statusBar()->showMessage( xi18n( "%1 is already in the session plan.", finalObjectName ), 0 );
         return;
     }
 
@@ -291,7 +291,7 @@ void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
 
         m_WishListModel->appendRow( itemList );
         //Note addition in statusbar
-        ks->statusBar()->showMessage( xi18n( "Added %1 to observing list.", finalObjectName ), 0 );
+        KStars::Instance()->statusBar()->showMessage( xi18n( "Added %1 to observing list.", finalObjectName ), 0 );
         ui->TableView->resizeColumnsToContents();
         if( ! update ) slotSaveList();
     }
@@ -334,7 +334,7 @@ void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
         isModified = true;
         ui->SessionView->resizeColumnsToContents();
         //Note addition in statusbar
-        ks->statusBar()->showMessage( xi18n( "Added %1 to session list.", finalObjectName ), 0 );
+        KStars::Instance()->statusBar()->showMessage( xi18n( "Added %1 to session list.", finalObjectName ), 0 );
     }
     setSaveImagesButton();
 }
@@ -342,7 +342,7 @@ void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
 void ObservingList::slotRemoveObject( SkyObject *o, bool session, bool update ) {
     if( ! update ) {
         if ( ! o )
-            o = ks->map()->clickedObject();
+            o = SkyMap::Instance()->clickedObject();
         else if( sessionView ) //else if is needed as clickedObject should not be removed from the session list.
             session = true;
     }
@@ -417,7 +417,7 @@ void ObservingList::slotRemoveSelectedObjects() {
         //we've removed all selected objects, so clear the selection
         ui->SessionView->selectionModel()->clear();
         //Update the lists in the Execute window as well
-        ks->getExecute()->init();
+        KStars::Instance()->getExecute()->init();
     }
 
     setSaveImagesButton();
@@ -544,9 +544,9 @@ void ObservingList::slotNewSelection() {
 
 void ObservingList::slotCenterObject() {
     if ( getSelectedItems().size() == 1 ) {
-        ks->map()->setClickedObject( currentObject() );
-        ks->map()->setClickedPoint( currentObject() );
-        ks->map()->slotCenter();
+        SkyMap::Instance()->setClickedObject( currentObject() );
+        SkyMap::Instance()->setClickedPoint( currentObject() );
+        SkyMap::Instance()->slotCenter();
     }
 }
 
@@ -595,7 +595,7 @@ void ObservingList::slotSlewToObject()
 //Should have one window whose target object changes with selection
 void ObservingList::slotDetails() {
     if ( currentObject() ) {
-        QPointer<DetailDialog> dd = new DetailDialog( currentObject(), ks->data()->lt(), geo, ks );
+        QPointer<DetailDialog> dd = new DetailDialog( currentObject(), KStarsData::Instance()->lt(), geo, KStars::Instance() );
         dd->exec();
         delete dd;
     }
@@ -604,7 +604,7 @@ void ObservingList::slotDetails() {
 void ObservingList::slotWUT() {
     KStarsDateTime lt = dt;
     lt.setTime( QTime(8,0,0) );
-    QPointer<WUTDialog> w = new WUTDialog( ks, sessionView, geo, lt );
+    QPointer<WUTDialog> w = new WUTDialog( KStars::Instance(), sessionView, geo, lt );
     w->exec();
     delete w;
 }
@@ -622,7 +622,7 @@ void ObservingList::slotAddToSession() {
 }
 
 void ObservingList::slotFind() {
-   QPointer<FindDialog> fd = new FindDialog( ks );
+   QPointer<FindDialog> fd = new FindDialog( KStars::Instance() );
    if ( fd->exec() == QDialog::Accepted ) {
        SkyObject *o = fd->selectedObject();
        if( o != 0 ) {
@@ -642,7 +642,7 @@ void ObservingList::slotAVT() {
     QModelIndexList selectedItems;
     // TODO: Think and see if there's a more effecient way to do this. I can't seem to think of any, but this code looks like it could be improved. - Akarsh
     if( sessionView ) {
-        QPointer<AltVsTime> avt = new AltVsTime( ks );//FIXME KStars class is singleton, so why pass it?
+        QPointer<AltVsTime> avt = new AltVsTime( KStars::Instance() );
         for ( int irow = m_SessionModel->rowCount()-1; irow >= 0; --irow ) {
             if ( ui->SessionView->selectionModel()->isRowSelected( irow, QModelIndex() ) ) {
                 QModelIndex mSortIndex = m_SessionSortModel->index( irow, 0 );
@@ -660,7 +660,7 @@ void ObservingList::slotAVT() {
     } else {
         selectedItems = m_WishListSortModel->mapSelectionToSource( ui->TableView->selectionModel()->selection() ).indexes();
         if ( selectedItems.size() ) {
-            QPointer<AltVsTime> avt = new AltVsTime( ks );//FIXME KStars class is singleton, so why pass it?
+            QPointer<AltVsTime> avt = new AltVsTime( KStars::Instance() );
             foreach ( const QModelIndex &i, selectedItems ) { // FIXME: This code is repeated too many times. We should find a better way to do it.
                 foreach ( SkyObject *o, obsList() )
                     if ( getObjectName(o) == i.data().toString() )
@@ -826,11 +826,11 @@ void ObservingList::slotLoadWishList() {
             o = ks->data()->skyComposite()->starNearest( &p, maxrad );
         }
         else {*/
-        o = ks->data()->objectNamed( line );
+        o = KStarsData::Instance()->objectNamed( line );
         //}
         //If we haven't identified the object, try interpreting the
         //name as a star's genetive name (with ascii letters)
-        if ( ! o ) o = ks->data()->skyComposite()->findStarByGenetiveName( line );
+        if ( ! o ) o = KStarsData::Instance()->skyComposite()->findStarByGenetiveName( line );
         if ( o ) slotAddObject( o, false, true );
     }
     f.close();
@@ -858,7 +858,7 @@ void ObservingList::slotSaveSession(bool nativeSave) {
 }
 
 void ObservingList::slotWizard() {
-    QPointer<ObsListWizard> wizard = new ObsListWizard( ks );
+    QPointer<ObsListWizard> wizard = new ObsListWizard( KStars::Instance() );
     if ( wizard->exec() == QDialog::Accepted ) {
         foreach ( SkyObject *o, wizard->obsList() ) {
             slotAddObject( o );
@@ -1266,7 +1266,7 @@ void ObservingList::slotOALExport() {
 void ObservingList::slotAddVisibleObj() {
     KStarsDateTime lt = dt;
     lt.setTime( QTime(8,0,0) );
-    QPointer<WUTDialog> w = new WUTDialog( ks, sessionView, geo, lt );
+    QPointer<WUTDialog> w = new WUTDialog( KStars::Instance(), sessionView, geo, lt );
     w->init();
     QModelIndexList selectedItems;
     selectedItems = m_WishListSortModel->mapSelectionToSource( ui->TableView->selectionModel()->selection() ).indexes();
diff --git a/kstars/tools/observinglist.h b/kstars/tools/observinglist.h
index 98f8592..c7df035 100644
--- a/kstars/tools/observinglist.h
+++ b/kstars/tools/observinglist.h
@@ -84,7 +84,7 @@ class ObservingList : public QDialog
 public:
     /** @short Constructor
         */
-    ObservingList( KStars *_ks );
+    ObservingList();
     /** @short Destuctor (empty)
         */
     ~ObservingList();
@@ -378,7 +378,6 @@ private:
      */
     inline QModelIndexList getSelectedItems() const { return getActiveView()->selectionModel()->selectedRows(); }
 
-    KStars *ks;
     KSAlmanac *ksal;
     ObservingListUI *ui;
     QList<SkyObject*> m_WishList, m_SessionList;
diff --git a/kstars/tools/obslistpopupmenu.cpp b/kstars/tools/obslistpopupmenu.cpp
index dbcaa6f..3307963 100644
--- a/kstars/tools/obslistpopupmenu.cpp
+++ b/kstars/tools/obslistpopupmenu.cpp
@@ -33,51 +33,51 @@ ObsListPopupMenu::~ObsListPopupMenu() { }
 
 void ObsListPopupMenu::initPopupMenu( bool sessionView, bool multiSelection, bool showScope )
 {
-    KStars* ks = KStars::Instance();
+    KStarsData* ksdata = KStarsData::Instance();
 
     clear();
 
     //Insert item for adding the object to the session view
     if( !sessionView ) {
-        addAction( xi18n( "Add to session plan" ), ks->observingList(), SLOT( slotAddToSession() ) );
-        addAction( xi18n( "Add objects visible tonight to session plan" ), ks->observingList(), SLOT( slotAddVisibleObj() ) );
+        addAction( xi18n( "Add to session plan" ), ksdata->observingList(), SLOT( slotAddToSession() ) );
+        addAction( xi18n( "Add objects visible tonight to session plan" ), ksdata->observingList(), SLOT( slotAddVisibleObj() ) );
     }
 
     addSeparator();
 
     if( !multiSelection )
-        addAction( xi18n( "Center" ), ks->observingList(), SLOT( slotCenterObject() ) ); //Insert item for centering on object
+        addAction( xi18n( "Center" ), ksdata->observingList(), SLOT( slotCenterObject() ) ); //Insert item for centering on object
 
     if( !multiSelection && showScope ) // Insert item for slewing telescope
-        addAction( xi18nc( "Show the selected object in the telescope", "Scope" ), ks->observingList(), SLOT( slotSlewToObject() ) );
+        addAction( xi18nc( "Show the selected object in the telescope", "Scope" ), ksdata->observingList(), SLOT( slotSlewToObject() ) );
 
     addSeparator();
 
 
     if( !multiSelection ) {
-        addAction( xi18nc( "Show Detailed Information Dialog", "Details" ), ks->observingList(), SLOT( slotDetails() ) ); // Insert item for showing details dialog
-        addAction( xi18n( "Eyepiece view (Beta)" ), ks->observingList(), SLOT( slotEyepieceView() ) ); // Insert item for showing eyepiece view
+        addAction( xi18nc( "Show Detailed Information Dialog", "Details" ), ksdata->observingList(), SLOT( slotDetails() ) ); // Insert item for showing details dialog
+        addAction( xi18n( "Eyepiece view (Beta)" ), ksdata->observingList(), SLOT( slotEyepieceView() ) ); // Insert item for showing eyepiece view
     }
 
     //Insert item for opening the Altitude vs time dialog
-    addAction( xi18n( "Altitude vs. Time" ), ks->observingList(), SLOT( slotAVT() ) );
+    addAction( xi18n( "Altitude vs. Time" ), ksdata->observingList(), SLOT( slotAVT() ) );
 
     addSeparator();
 
     //Insert item for dowloading different images
     if( !multiSelection ) {
-        if( ks->observingList()->currentObject() != NULL && ! ks->observingList()->currentObject()->isSolarSystem() )
+        if( ksdata->observingList()->currentObject() != NULL && ! ksdata->observingList()->currentObject()->isSolarSystem() )
         {
-            addAction( xi18n( "Show SDSS image" ), ks->observingList(), SLOT( slotGetImage() ) );
-            addAction( xi18n( "Show DSS image" ), ks->observingList(), SLOT( slotDSS() ) );
+            addAction( xi18n( "Show SDSS image" ), ksdata->observingList(), SLOT( slotGetImage() ) );
+            addAction( xi18n( "Show DSS image" ), ksdata->observingList(), SLOT( slotDSS() ) );
         }
-        addAction( xi18n( "Show images from web " ), ks->observingList(), SLOT( slotSearchImage() ) );
+        addAction( xi18n( "Show images from web " ), ksdata->observingList(), SLOT( slotSearchImage() ) );
         addSeparator();
     }
 
     //Insert item for Removing the object(s)
     if( !sessionView )
-        addAction( xi18n("Remove from WishList"), ks->observingList(), SLOT( slotRemoveSelectedObjects() ) );
+        addAction( xi18n("Remove from WishList"), ksdata->observingList(), SLOT( slotRemoveSelectedObjects() ) );
     else
-        addAction( xi18n("Remove from Session Plan"), ks->observingList(), SLOT( slotRemoveSelectedObjects() ) );
+        addAction( xi18n("Remove from Session Plan"), ksdata->observingList(), SLOT( slotRemoveSelectedObjects() ) );
 }
diff --git a/kstars/tools/wutdialog.cpp b/kstars/tools/wutdialog.cpp
index 97b72d9..5a653a8 100644
--- a/kstars/tools/wutdialog.cpp
+++ b/kstars/tools/wutdialog.cpp
@@ -469,15 +469,15 @@ void WUTDialog::slotDetails() {
 	delete detail;
     }
 }
-void WUTDialog::slotObslist() {
-    KStars* kstars = KStars::Instance();
+void WUTDialog::slotObslist()
+{
     SkyObject *o = 0;
     // get selected item
     if (WUT->ObjectListWidget->currentItem() != 0) {
-        o = kstars->data()->objectNamed( WUT->ObjectListWidget->currentItem()->text() );
+        o = KStarsData::Instance()->objectNamed( WUT->ObjectListWidget->currentItem()->text() );
     }
     if(o != 0) {
-        kstars->observingList()->slotAddObject( o, session ) ;
+        KStarsData::Instance()->observingList()->slotAddObject( o, session ) ;
     }
 }
 


More information about the Kstars-devel mailing list