summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-08-16 23:22:10 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-08-16 23:22:10 (GMT)
commit3aedf672b17e009c9c82ba0f51f884e0a1e7c45f (patch)
treef7f3ab263bdc25e129dff45f322ab54f8fdaf4a0
parent26d87871499f1e230803ca16aaec84423b972aeb (diff)
Prepare CatalogComponent to be sub-classed.
1. Make private members protected. 2. Make loadData() and selected() virtual 3. Add a parameter to the constructor that enables / disables the calling of loadData() at construct time. 4. Make loadData() a proxy for a protected method _loadData( bool ) that actually loads the data. 5. Make provisions for having "fake" catalogs, where the catalog name and ID are not official and should not be used as names.
-rw-r--r--kstars/skycomponents/catalogcomponent.cpp18
-rw-r--r--kstars/skycomponents/catalogcomponent.h15
2 files changed, 23 insertions, 10 deletions
diff --git a/kstars/skycomponents/catalogcomponent.cpp b/kstars/skycomponents/catalogcomponent.cpp
index 1248fd5..f7f6876 100644
--- a/kstars/skycomponents/catalogcomponent.cpp
+++ b/kstars/skycomponents/catalogcomponent.cpp
@@ -40,24 +40,29 @@ QStringList CatalogComponent::m_Columns
CatalogComponent::CatalogComponent(SkyComposite *parent,
const QString &catname,
- bool showerrs, int index)
+ bool showerrs, int index, bool callLoadData )
: ListComponent(parent), m_catName(catname),
m_Showerrs(showerrs), m_ccIndex(index) {
- loadData();
+ if( callLoadData )
+ loadData();
}
CatalogComponent::~CatalogComponent() {
}
-void CatalogComponent::loadData() {
- emitProgressText( i18n("Loading custom catalog: %1", m_catName ) );
+void CatalogComponent::_loadData( bool includeCatalogDesignation ) {
+ if( includeCatalogDesignation )
+ emitProgressText( i18n("Loading custom catalog: %1", m_catName ) );
+ else
+ emitProgressText( i18n("Loading internal catalog: %1", m_catName ) );
QList < QPair <int, QString> > names;
KStarsData::Instance()->catalogdb()->GetAllObjects(m_catName,
m_ObjectList,
names,
- this);
+ this,
+ includeCatalogDesignation);
for (int iter = 0; iter < names.size(); iter++) {
if (names.at(iter).first <= SkyObject::TYPE_UNKNOWN) {
//FIXME JM 2016-06-02: inefficient and costly check
@@ -124,6 +129,7 @@ void CatalogComponent::draw( SkyPainter *skyp ) {
update( 0 );
//Draw Custom Catalog objects
+ // FIXME: Improve using HTM!
foreach ( SkyObject *obj, m_ObjectList ) {
if ( obj->type()==0 ) {
StarObject *starobj = static_cast<StarObject*>(obj);
@@ -136,6 +142,8 @@ void CatalogComponent::draw( SkyPainter *skyp ) {
// PA for Deep-Sky objects is 90 + PA because major axis is
// horizontal at PA=0
// double pa = 90. + map->findPA( dso, o.x(), o.y() );
+ //
+ // ^ Not sure if above is still valid -- asimha 2016/08/16
DeepSkyObject *dso = static_cast<DeepSkyObject*>(obj);
skyp->drawDeepSkyObject(dso, true);
}
diff --git a/kstars/skycomponents/catalogcomponent.h b/kstars/skycomponents/catalogcomponent.h
index 4d0e679..da85944 100644
--- a/kstars/skycomponents/catalogcomponent.h
+++ b/kstars/skycomponents/catalogcomponent.h
@@ -44,7 +44,7 @@ public:
*@short Constructor
*@p parent Pointer to the parent SkyComposite object
*/
- CatalogComponent( SkyComposite*, const QString &fname, bool showerrs, int index );
+ CatalogComponent( SkyComposite*, const QString &fname, bool showerrs, int index, bool callLoadData = true );
/**
*@short Destructor. Delete list members
@@ -77,19 +77,24 @@ public:
*/
inline bool getVisibility() { return (Options::showCatalog()[m_ccIndex] > 0) ? true : false; }
-private:
+protected:
/** @short Load data into custom catalog */
- void loadData();
+ virtual void loadData() { _loadData( true ); }
+
+ /** @short Load data into custom catalog */
+ virtual void _loadData( bool includeCatalogDesignation );
+
+ // FIXME: There seems to be no way to remove catalogs from the program. -- asimha
- // FIXME: There is no way to remove catalogs from the program.
/**
* @brief Returns true if this catalog is to be drawn
* Overridden from SkyComponent::selected
* @return bool
**/
- bool selected();
+ virtual bool selected();
+
QString m_catName, m_catPrefix, m_catColor, m_catFluxFreq, m_catFluxUnit;
float m_catEpoch;