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

List:       kde-commits
Subject:    branches/KDE/4.1/kdeedu/kstars/kstars
From:       Jason Harris <kstars () 30doradus ! org>
Date:       2008-08-23 14:15:53
Message-ID: 1219500953.642415.25473.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 851302 by harris:

When a custom object catalog is installed with the Get New Stuff tool, it will now 
be automatically added to the display.  Backported from trunk.



 M  +4 -4      addcatdialog.cpp  
 M  +14 -1     kstarsactions.cpp  
 M  +8 -5      opscatalog.cpp  
 M  +1 -1      skycomponents/customcatalogcomponent.cpp  
 M  +12 -1     skycomponents/customcatalogcomponent.h  
 M  +10 -7     skycomponents/skymapcomposite.cpp  
 M  +1 -1      skycomponents/skymapcomposite.h  


--- branches/KDE/4.1/kdeedu/kstars/kstars/addcatdialog.cpp #851301:851302
@@ -50,6 +50,9 @@
              this, SLOT( slotShowDataFile() ) );
     connect( acd->PreviewButton, SIGNAL( clicked() ), this, SLOT( \
                slotPreviewCatalog() ) );
     connect( this, SIGNAL( okClicked() ), this, SLOT( slotCreateCatalog() ) );
+//    connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
+    connect(this,SIGNAL(cancelClicked()),this,SLOT(slotCancel()));
+    connect(this,SIGNAL(helpClicked()),this,SLOT(slotHelp()));
 
     acd->FieldList->addItem( i18n( "ID Number" ) );
     acd->FieldList->addItem( i18n( "Right Ascension" ) );
@@ -62,9 +65,6 @@
     acd->FieldPool->addItem( i18n( "Minor Axis" ) );
     acd->FieldPool->addItem( i18n( "Position Angle" ) );
     acd->FieldPool->addItem( i18n( "Ignore" ) );
-    connect(this,SIGNAL(okClicked()),this,SLOT(slotOk()));
-    connect(this,SIGNAL(cancelClicked()),this,SLOT(slotCancel()));
-    connect(this,SIGNAL(helpClicked()),this,SLOT(slotHelp()));
 }
 
 AddCatDialog::~AddCatDialog(){
@@ -132,7 +132,7 @@
         QTextStream ostream( &tmpFile );
         ostream << CatalogContents;
         ostream.flush();
-        CustomCatalogComponent newCat( 0, tmpFile.fileName(), true, \
Options::showOther ); +        CustomCatalogComponent newCat( 0, tmpFile.fileName(), \
true, 0 );  newCat.init( ks->data() );
 
         int nObjects = newCat.objectList().size();
--- branches/KDE/4.1/kdeedu/kstars/kstars/kstarsactions.cpp #851301:851302
@@ -85,6 +85,7 @@
 #include "indifitsconf.h"
 #include "telescopewizardprocess.h"
 #include "telescopeprop.h"
+#include "skycomponents/customcatalogcomponent.h"
 
 #include <config-kstars.h>
 
@@ -206,8 +207,20 @@
 
 void KStars::slotDownload() {
     KNS::Entry::List entries = KNS::Engine::download();
+
+    foreach ( KNS::Entry *e, entries ) {
+        foreach ( QString fname, e->installedFiles() ) {
+            if ( fname.endsWith( ".cat" ) ) {
+                //To start displaying the custom catalog, add it to SkyMapComposite
+                Options::setCatalogFile( Options::catalogFile() << fname );
+                Options::setShowCatalog( Options::showCatalog() << 1 );
+                data()->skyComposite()->addCustomCatalog( fname, data(),  \
Options::catalogFile().size()-1 ); +            }
+        }
+    }
+
     // we need to delete the entry* items in the returned list
-	qDeleteAll(entries);
+    qDeleteAll(entries);
 }
 
 void KStars::slotLCGenerator() {
--- branches/KDE/4.1/kdeedu/kstars/kstars/opscatalog.cpp #851301:851302
@@ -126,6 +126,9 @@
 void OpsCatalog::selectCatalog() {
     //If selected item is a custom catalog, enable the remove button (otherwise, \
disable it)  RemoveCatalog->setEnabled( false );
+
+    if ( ! CatalogList->currentItem() ) return;
+    
     foreach ( SkyComponent *sc, ksw->data()->skyComposite()->customCatalogs() ) {
         CustomCatalogComponent *cc = (CustomCatalogComponent*)sc;
         if ( CatalogList->currentItem()->text() == cc->name() ) {
@@ -146,7 +149,7 @@
     QString filename = KFileDialog::getOpenFileName( QDir::homePath(), "*");
     if ( ! filename.isEmpty() ) {
         //test integrity of file before trying to add it
-      CustomCatalogComponent newCat( ksw->data()->skyComposite(), filename, true, \
Options::showOther ); +        CustomCatalogComponent newCat( \
ksw->data()->skyComposite(), filename, true, 0 );  newCat.init( ksw->data() );
         if ( newCat.objectList().size() )
             insertCatalog( filename );
@@ -174,8 +177,8 @@
         QString name = cc->name();
 
         if ( CatalogList->currentItem()->text() == name ) {
-            m_CustomCatalogFile.removeAll( m_CustomCatalogFile[i] );
-            m_ShowCustomCatalog.removeAll( m_ShowCustomCatalog[i] );
+            m_CustomCatalogFile.removeAt( i );
+            m_ShowCustomCatalog.removeAt( i );
             break;
         }
     }
@@ -226,17 +229,17 @@
     }
 
     //Add custom catalogs as needed
+    Options::setShowCatalog( m_ShowCustomCatalog );
     for ( int i=0; i < m_CustomCatalogFile.size(); ++i ) {
         QString filename = m_CustomCatalogFile[i];
 
         if ( ! Options::catalogFile().contains( filename ) ) {
             //Add this catalog
-            ksw->data()->skyComposite()->addCustomCatalog( filename, ksw->data(),  \
Options::showOther ); +            ksw->data()->skyComposite()->addCustomCatalog( \
filename, ksw->data(),  i );  }
     }
 
     Options::setCatalogFile( m_CustomCatalogFile );
-    Options::setShowCatalog( m_ShowCustomCatalog );
 
     // update time for all objects because they might be not initialized
     // it's needed when using horizontal coordinates
--- branches/KDE/4.1/kdeedu/kstars/kstars/skycomponents/customcatalogcomponent.cpp \
#851301:851302 @@ -34,7 +34,7 @@
 
 QStringList CustomCatalogComponent::m_Columns = QString( "ID RA Dc Tp Nm Mg Mj Mn PA \
Ig" ).split( " ", QString::SkipEmptyParts );  
-CustomCatalogComponent::CustomCatalogComponent(SkyComponent *parent, const QString \
&fname, bool showerrs, bool (*visibleMethod)()) : ListComponent(parent, \
visibleMethod), m_Filename( fname ), m_Showerrs( showerrs ) \
+CustomCatalogComponent::CustomCatalogComponent(SkyComponent *parent, const QString \
&fname, bool showerrs, int index) : ListComponent(parent), m_Filename( fname ), \
m_Showerrs( showerrs ), m_ccIndex(index)  {
 }
 
--- branches/KDE/4.1/kdeedu/kstars/kstars/skycomponents/customcatalogcomponent.h \
#851301:851302 @@ -20,6 +20,7 @@
 
 
 #include "listcomponent.h"
+#include "Options.h"
 
 class KStarsData;
 class CustomCatalog;
@@ -41,7 +42,7 @@
     	*@short Constructor
     	*@p parent Pointer to the parent SkyComponent object
     	*/
-    CustomCatalogComponent( SkyComponent*, const QString &fname, bool showerrs, bool \
(*visibleMethod)() ); +    CustomCatalogComponent( SkyComponent*, const QString \
&fname, bool showerrs, int index );  /**
     	*@short Destructor.  Delete list members
     	*/
@@ -66,6 +67,15 @@
     	*/
     QString name() const { return m_catName; }
 
+    /**
+     *@return true if visibility Option is set for this catalog
+     *@note this is complicated for custom catalogs, because 
+     *Option::showCatalog() returns a QList<int>, not a bool.
+     *This function extracts the correct visibility value and 
+     *returns the appropriate bool value
+     */
+    inline bool getVisibility() { return (Options::showCatalog()[m_ccIndex] > 0) ? \
true : false; } +    
 private:
 
     /**
@@ -120,6 +130,7 @@
     QString m_catName, m_catPrefix, m_catColor;
     float m_catEpoch;
     bool m_Showerrs;
+    int m_ccIndex;
 
     static QStringList m_Columns;
 };
--- branches/KDE/4.1/kdeedu/kstars/kstars/skycomponents/skymapcomposite.cpp \
#851301:851302 @@ -97,11 +97,9 @@
     m_DeepSky = new DeepSkyComponent( this );
     addComponent( m_DeepSky );
 
-    //FIXME: can't use Options::showCatalog as visibility fcn,
-    //because it returns QList, not bool
     m_CustomCatalogs = new SkyComposite( this );
-    foreach ( const QString &fname, Options::catalogFile() ) {
-        CustomCatalogComponent *cc = new CustomCatalogComponent( this, fname, false, \
&Options::showOther ); +    for ( int i=0; i<Options::catalogFile().size(); ++ i ) {
+        CustomCatalogComponent *cc = new CustomCatalogComponent( this, \
Options::catalogFile()[i], false, i );  cc->init( data );
         m_CustomCatalogs->addComponent( cc );
     }
@@ -416,10 +414,15 @@
 }
 **/
 
-void SkyMapComposite::addCustomCatalog( const QString &filename, KStarsData *data, \
                bool (*visibleMethod)() ) {
-    CustomCatalogComponent *cc = new CustomCatalogComponent( this, filename, false, \
visibleMethod ); +void SkyMapComposite::addCustomCatalog( const QString &filename, \
KStarsData *data, int index ) { +    CustomCatalogComponent *cc = new \
CustomCatalogComponent( this, filename, false, index );  cc->init( data );
-    m_CustomCatalogs->addComponent( cc );
+    
+    if ( cc->objectList().size() ) {
+        m_CustomCatalogs->addComponent( cc );
+    } else {
+        delete cc;
+    }
 }
 
 void SkyMapComposite::removeCustomCatalog( const QString &name ) {
--- branches/KDE/4.1/kdeedu/kstars/kstars/skycomponents/skymapcomposite.h \
#851301:851302 @@ -155,7 +155,7 @@
     virtual bool removeTrail( SkyObject *o );
     virtual void clearTrailsExcept( SkyObject *o );
 
-    void addCustomCatalog( const QString &filename, KStarsData *data, bool \
(*visibleMethod)() ); +    void addCustomCatalog( const QString &filename, KStarsData \
*data, int index );  void removeCustomCatalog( const QString &name );
 
     bool addNameLabel( SkyObject *o );


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

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