[Kstars-devel] branches/kstars/summer/kstars/kstars

Prakash Mohan prak902000 at gmail.com
Fri Jul 10 17:20:16 CEST 2009


SVN commit 994445 by prakash:

Adding support for storing date and time in the session plans, and adding support for exporting the target lists in compliance to OAL 2.0 schema.

CCMAIL: kstars-devel at kde.org


 M  +47 -2     comast/log.cpp  
 M  +5 -1      comast/log.h  
 M  +18 -1     tools/observinglist.cpp  
 M  +12 -1     tools/observinglist.h  
 M  +7 -0      tools/observinglist.ui  


--- branches/kstars/summer/kstars/kstars/comast/log.cpp #994444:994445
@@ -20,6 +20,7 @@
 #include "skyobjects/skyobject.h"
 #include "skymap.h"
 #include "skycomponents/constellationboundary.h"
+#include "kstarsdatetime.h"
 
 void Comast::Log::writeBegin() {
     writer = new QXmlStreamWriter(&output);
@@ -33,9 +34,12 @@
 }
 
 QString Comast::Log::writeLog( bool _native ) {
+    ks = KStars::Instance();
     m_targetList = KStars::Instance()->observingList()->sessionList();
     native = _native;
     writeBegin();
+    if( native )
+        writeGeoDate();
     writeObservers();
     writeSites();
     writeSessions();
@@ -156,8 +160,25 @@
     writer->writeEndElement();
 }
 
+void Comast::Log::writeGeoDate() {
+    writer->writeStartElement( "geodate" );
+    writer->writeStartElement( "name" );
+    writer->writeCDATA( ks->observingList()->geoLocation()->name() );
+    writer->writeEndElement();
+    writer->writeStartElement( "province" );
+    writer->writeCDATA( ks->observingList()->geoLocation()->province() );
+    writer->writeEndElement();
+    writer->writeStartElement( "country" );
+    writer->writeCDATA( ks->observingList()->geoLocation()->country() );
+    writer->writeEndElement();
+    writer->writeStartElement( "date" );
+    writer->writeCDATA( ks->observingList()->dateTime().date().toString( "ddMMyyyy" ) );
+    writer->writeEndElement();
+    writer->writeEndElement();
+}
 void Comast::Log::readBegin( QString input ) {
     reader = new QXmlStreamReader( input );
+    ks = KStars::Instance();
     m_targetList.clear();
     while( ! reader->atEnd() ) {
         reader->readNext();
@@ -190,6 +211,8 @@
         if( reader->isStartElement() ) {
             if( reader->name() == "targets" )
                 readTargets();
+            if( reader->name() == "geodate" )
+                readGeoDate();
             else
                 readUnknownElement();
         }
@@ -228,8 +251,7 @@
                     if( ! o ) o = KStars::Instance()->data()->skyComposite()->findStarByGenetiveName( Name );
                     if( o ) KStars::Instance()->observingList()->slotAddObject( o, true );
                 }
-            }
-          else  if( reader->name() == "time" ) {
+            } else if( reader->name() == "time" ) {
                 if( o )
                     KStars::Instance()->observingList()->setTime( o, QTime::fromString( reader->readElementText(), "h:mm:ss AP" ) );
           }
@@ -262,3 +284,26 @@
         }
     }
 }
+void Comast::Log::readGeoDate() {
+    QString name, province, country, date;
+    while( ! reader->atEnd() ) {
+        reader->readNext();
+
+        if( reader->isEndElement() )
+            break;
+
+        if( reader->isStartElement() ) {
+            if( reader->name() == "name" )
+                name = reader->readElementText();
+            else if( reader->name() == "province" )
+                province = reader->readElementText();
+            else if( reader->name() == "country" )
+                country = reader->readElementText();
+            else if( reader->name() == "date" ){
+                date = reader->readElementText();
+            } else
+                readUnknownElement();
+        }
+    }
+    KStars::Instance()->observingList()->setGeoDate( name, province, country, date );
+}
--- branches/kstars/summer/kstars/kstars/comast/log.h #994444:994445
@@ -24,6 +24,7 @@
 #include <QXmlStreamReader>
 #include <QXmlStreamWriter>
 
+#include "kstars.h"
 #include "dms.h"
 #include "skyobjects/skyobject.h"
 
@@ -31,6 +32,7 @@
     public:
         QString writeLog( bool native = true );
         void writeBegin();
+        void writeGeoDate();
         void writeObservers();
         void writeSites();
         void writeSessions();
@@ -44,7 +46,7 @@
 //        void writeObserver();
 //        void writeSite();
 //        void writeSession();
-          void writeTarget( SkyObject *o );
+        void writeTarget( SkyObject *o );
 //        void writeScope();
 //        void writeEyePiece();
 //        void writeLense();
@@ -57,6 +59,7 @@
         void readTargets();
         void readTarget();
         void readPosition();
+        void readGeoDate();
     private:
         QList<SkyObject *> m_targetList;
 //        QList<Comast::Observer *> m_observerList;
@@ -70,6 +73,7 @@
         QString output;
         bool native;
         dms ra, dec;
+        KStars *ks;
         QXmlStreamWriter *writer;
         QXmlStreamReader *reader;
 };
--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #994444:994445
@@ -82,7 +82,13 @@
     setupUi( this );
 }
 
+void ObservingList::setGeoDate(QString name, QString province, QString country, QString date) {
+    geo = ks->data()->locationNamed( name, province, country );
+    dt.setDate( QDate::fromString( date, "ddMMyyyy" ) );
+    ui->DateEdit->setDate( dt.date() );
 
+}
+
 //
 // ObservingList
 // ---------------------------------
@@ -98,6 +104,7 @@
     dt = KStarsDateTime::currentDateTime();
     geo = ks->geo();
     sessionView = false;
+    nativeSave = true;
     FileName = "";
     pmenu = new ObsListPopupMenu( KStars::Instance() );
     //Set up the Table Views
@@ -183,6 +190,8 @@
              this, SLOT( slotSaveImages() ) );
     connect( ui->DeleteImages, SIGNAL( clicked() ),
              this, SLOT( slotDeleteImages() ) );
+    connect( ui->OALExport, SIGNAL( clicked() ),
+             this, SLOT( slotOALExport() ) );  
     //Add icons to Push Buttons
     ui->OpenButton->setIcon( KIcon("document-open") );
     ui->SaveButton->setIcon( KIcon("document-save") );
@@ -199,6 +208,7 @@
     ui->saveImages->setEnabled( false );
     ui->SaveImage->setEnabled( false );
     ui->DeleteImage->setEnabled( false );
+    ui->OALExport->setEnabled( false );
 
     slotLoadWishList(); //Load the wishlist from disk if present
     m_CurrentObject = 0;
@@ -947,7 +957,7 @@
     }
     QTextStream ostream( &f );
     Comast::Log log;
-    ostream<< log.writeLog( true );
+    ostream<< log.writeLog( nativeSave );
     f.close();
     isModified = false;//We've saved the session, so reset the modified flag.
 }
@@ -1067,6 +1077,7 @@
     }
     setSaveImages();
     ui->WizardButton->setEnabled( ! sessionView );//wizard adds only to the Wish List
+    ui->OALExport->setEnabled( sessionView );
     //Clear the selection in the Tables
     ui->TableView->clearSelection();
     ui->SessionView->clearSelection();
@@ -1349,4 +1360,10 @@
     }
 }
 
+void ObservingList::slotOALExport() {
+    nativeSave = false;
+    slotSaveSessionAs();
+    nativeSave = true;
+}
+
 #include "observinglist.moc"
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #994444:994445
@@ -25,6 +25,7 @@
 #include <kio/copyjob.h>
 
 #include "ui_observinglist.h"
+#include "kstars.h"
 #include "skyobjects/skyobject.h"
 #include "kstarsdatetime.h"
 #include "geolocation.h"
@@ -154,6 +155,12 @@
 
     void setTime( SkyObject *o, QTime t ) { TimeHash.insert( o->name(), t); }
 
+    void setGeoDate( QString name, QString province, QString country, QString date ); 
+
+    GeoLocation* geoLocation() { return geo; }
+
+    KStarsDateTime dateTime() { return dt; }
+
 public slots:
     /**@short add a new object to list
         *@p o pointer to the object to add to the list
@@ -300,6 +307,10 @@
         */
     void slotDSS() { slotGetImage( true ); }
 
+    /**@short Export a target list to the comast compliant format
+        */
+    void slotOALExport(); 
+
 protected slots:
     void slotClose();
     void downloadReady();
@@ -311,7 +322,7 @@
     QList<SkyObject*> m_ObservingList, m_SessionList;
     SkyObject *LogObject, *m_CurrentObject;
     uint noNameStars;
-    bool isModified, bIsLarge, sessionView, dss, singleSelection, showScope, noSelection;
+    bool isModified, bIsLarge, sessionView, dss, singleSelection, showScope, noSelection, nativeSave;
     QString FileName, CurrentImage, DSSUrl, SDSSUrl, ThumbImage, CurrentImagePath, CurrentTempPath;
     char decsgn;
     KStarsDateTime dt;
--- branches/kstars/summer/kstars/kstars/tools/observinglist.ui #994444:994445
@@ -162,6 +162,13 @@
       </widget>
      </item>
      <item>
+      <widget class="QPushButton" name="OALExport">
+       <property name="text">
+        <string>Export to OAL</string>
+       </property>
+      </widget>
+     </item>
+     <item>
       <spacer name="Spacer1">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>


More information about the Kstars-devel mailing list