[Kstars-devel] KDE/kdeedu/kstars/kstars
James Bowlin
bowlin at mindspring.com
Wed Aug 15 18:55:21 CEST 2007
SVN commit 700484 by jbowlin:
Converted SkyMap to a singleton.
This will allow us to simplify code but I'm only going to use it for
new code now and wait until after 4.0 to simplify the existing code.
CCMAIL: kstars-devel at kde.org
M +1 -1 kstarsinit.cpp
M +1 -1 main.cpp
M +14 -0 skymap.cpp
M +13 -3 skymap.h
--- trunk/KDE/kdeedu/kstars/kstars/kstarsinit.cpp #700483:700484
@@ -698,7 +698,7 @@
}
void KStars::buildGUI() {
//create the skymap
- skymap = new SkyMap( data(), this );
+ skymap = SkyMap::Create( data(), this );
setCentralWidget( skymap );
//Initialize menus, toolbars, and statusbars
--- trunk/KDE/kdeedu/kstars/kstars/main.cpp #700483:700484
@@ -138,7 +138,7 @@
KSNumbers num( dat->ut().djd() );
// dat->initGuides(&num);
- SkyMap *map = new SkyMap( dat );
+ SkyMap *map = SkyMap::Create( dat );
map->resize( w, h );
QPixmap sky( w, h );
--- trunk/KDE/kdeedu/kstars/kstars/skymap.cpp #700483:700484
@@ -59,6 +59,20 @@
#include "kscomet.h"
#include "starobject.h"
+SkyMap* SkyMap::pinstance = 0;
+
+SkyMap* SkyMap::Create( KStarsData *_data, KStars *_ks )
+{
+ if ( pinstance ) delete pinstance;
+ pinstance = new SkyMap( _data, _ks );
+ return pinstance;
+}
+
+SkyMap* SkyMap::Instance( )
+{
+ return pinstance;
+}
+
SkyMap::SkyMap( KStarsData *_data, KStars *_ks )
: QWidget(_ks), computeSkymap(true), angularDistanceMode(false),
ks(_ks), data(_data), pmenu(0), sky(0), sky2(0), IBoxes(0),
--- trunk/KDE/kdeedu/kstars/kstars/skymap.h #700483:700484
@@ -62,14 +62,21 @@
class SkyMap : public QWidget {
Q_OBJECT
-public:
-/**
+
+ protected:
+ /**
*Constructor. Read stored settings from KConfig object (focus position,
*zoom factor, sky color, etc.). Run initPopupMenus().
*/
explicit SkyMap( KStarsData *_data, KStars *_ks = 0 );
-/**
+public:
+
+ static SkyMap* Create( KStarsData *_data, KStars *_ks = 0 );
+
+ static SkyMap* Instance();
+
+ /**
*Destructor (empty)
*/
~SkyMap();
@@ -868,6 +875,9 @@
//QUATERNION
Quaternion m_rotAxis;
+
+ static SkyMap* pinstance;
+
};
#endif
More information about the Kstars-devel
mailing list