[Kstars-devel] KDE/kdeedu/kstars/kstars
James Bowlin
bowlin at mindspring.com
Wed Aug 15 22:34:39 CEST 2007
SVN commit 700553 by jbowlin:
Converted KStarsData to a singleton. This should open the door for
cleaning up a lot of code but I will try to restrain myself and just
use it for new code for now.
Also made the SkyMap copy-constructor protected even though we never
use it.
CCMAIL: kstars-devel at kde.org
M +1 -1 kstars.cpp
M +15 -0 kstarsdata.cpp
M +12 -2 kstarsdata.h
M +1 -1 main.cpp
M +2 -0 skymap.h
--- trunk/KDE/kdeedu/kstars/kstars/kstars.cpp #700552:700553
@@ -67,7 +67,7 @@
connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( slotAboutToQuit() ) );
- kstarsData = new KStarsData( this );
+ kstarsData = KStarsData::Create( this );
connect( kstarsData, SIGNAL( initFinished(bool) ), this, SLOT( datainitFinished(bool) ) );
//Set Geographic Location from Options
--- trunk/KDE/kdeedu/kstars/kstars/kstarsdata.cpp #700552:700553
@@ -52,6 +52,21 @@
int KStarsData::objects = 0;
+KStarsData* KStarsData::pinstance = 0;
+
+KStarsData* KStarsData::Create( KStars* kstars )
+{
+ if ( pinstance ) delete pinstance;
+ pinstance = new KStarsData( kstars );
+ return pinstance;
+}
+
+KStarsData* KStarsData::Instance( )
+{
+ return pinstance;
+}
+
+
KStarsData::KStarsData(KStars* kstars) : locale(0),
LST(0), HourAngle(0), initTimer(0), m_kstars(kstars),
m_preUpdateID(0), m_preUpdateNumID(0),
--- trunk/KDE/kdeedu/kstars/kstars/kstarsdata.h #700552:700553
@@ -76,6 +76,13 @@
class KStarsData : public QObject
{
Q_OBJECT
+
+protected:
+ /**Constructor. */
+ KStarsData( KStars* kstars=0 );
+
+ KStarsData( KStarsData& ksd );
+
public:
//Friend classes can see the private data.
//FIXME: can we avoid having so many friend classes?
@@ -100,9 +107,10 @@
friend class telescopeWizardProcess;
friend class ObsListWizard;
- /**Constructor. */
- KStarsData( KStars* kstars=0 );
+ static KStarsData* Create( KStars* kstars=0 );
+ static KStarsData* Instance();
+
/**Destructor. Delete data objects. */
virtual ~KStarsData();
@@ -490,6 +498,8 @@
quint32 m_preUpdateID, m_updateID;
quint32 m_preUpdateNumID, m_updateNumID;
KSNumbers m_preUpdateNum, m_updateNum;
+
+ static KStarsData* pinstance;
};
--- trunk/KDE/kdeedu/kstars/kstars/main.cpp #700552:700553
@@ -93,7 +93,7 @@
return 1;
}
- KStarsData *dat = new KStarsData();
+ KStarsData *dat = KStarsData::Create();
QObject::connect( dat, SIGNAL( progressText(QString) ), dat, SLOT( slotConsoleMessage(QString) ) );
dat->initialize();
while (!dat->startupComplete) { qApp->processEvents(); }
--- trunk/KDE/kdeedu/kstars/kstars/skymap.h #700552:700553
@@ -70,6 +70,8 @@
*/
explicit SkyMap( KStarsData *_data, KStars *_ks = 0 );
+ SkyMap( SkyMap& skyMap );
+
public:
static SkyMap* Create( KStarsData *_data, KStars *_ks = 0 );
More information about the Kstars-devel
mailing list