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

Prakash Mohan prak902000 at gmail.com
Wed Jul 8 18:26:29 CEST 2009


SVN commit 993400 by prakash:

Storing the Session plans in a semi-OAL compliant XML format.

CCMAIL: kstars-devel at kde.org


 M  +6 -1      CMakeLists.txt  
 A             comast (directory)  
 A             comast/comast.h   [License: GPL (v2+)]
 A             comast/log.cpp   [License: GPL (v2+)]
 A             comast/log.h   [License: GPL (v2+)]
 M  +13 -66    tools/observinglist.cpp  
 M  +5 -1      tools/observinglist.h  


--- branches/kstars/summer/kstars/kstars/CMakeLists.txt #993399:993400
@@ -5,6 +5,7 @@
 add_subdirectory( icons ) 
 add_subdirectory( satlib ) 
 add_subdirectory( htmesh ) 
+add_subdirectory( comast ) 
 
 Find_package(ZLIB REQUIRED)
 
@@ -309,9 +310,13 @@
 	thumbnailpicker.cpp thumbnaileditor.cpp quaternion.cpp binfilehelper.cpp
 )
 
+set(comast_SRCS
+    comast/log.cpp
+)
+
 set(kstars_SRCS ${indi_SRCS} ${fits_SRCS} 
 	${libkstarswidgets_SRCS} ${libkstarscomponents_SRCS} ${libkstarstools_SRCS} ${kstars_extra_SRCS} ${xplanet_SRCS}
-	${kstars_options_SRCS} ${kstars_skyobjects_SRCS} ${kstars_dialogs_SRCS}
+	${kstars_options_SRCS} ${kstars_skyobjects_SRCS} ${kstars_dialogs_SRCS} ${comast_SRCS}
 )
 
 qt4_add_dbus_adaptor(kstars_SRCS org.kde.kstars.xml kstars.h KStars)
--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #993399:993400
@@ -61,6 +61,8 @@
 #include "imageviewer.h"
 #include "thumbnailpicker.h"
 #include "obslistpopupmenu.h"
+#include "comast/log.h"
+#include "comast/comast.h"
 
 #include <config-kstars.h>
 
@@ -96,6 +98,7 @@
     dt = KStarsDateTime::currentDateTime();
     geo = ks->geo();
     sessionView = false;
+    FileName = "";
     pmenu = new ObsListPopupMenu( KStars::Instance() );
     //Set up the Table Views
     m_Model = new QStandardItemModel( 0, 5, this );
@@ -838,43 +841,10 @@
         //First line is the name of the list. The rest of the file is
         //object names, one per line. With the TimeHash value if present
         QTextStream istream( &f );
-        QString line;
-        SessionName = istream.readLine();
-        line = istream.readLine();
-        if( ! line.contains( '|' ) ) {
-            SessionName = "";
-            KMessageBox::sorry( 0, i18n( "Old formatted Observing Lists are not supported " ), i18n( "Invalid List" ) );
-            return;
-        }
-        QStringList fields = line.split( '|' ); 
-        geo = ks->data()->locationNamed( fields[0], fields[1], fields[2] );
-        ui->SetLocation -> setText( geo -> fullName() );
-        dt.setDate( QDate::fromString( fields[3], "ddMMyyyy" ) );
-        ui->DateEdit->setDate( dt.date() );
-        while ( ! istream.atEnd() ) {
-            line = istream.readLine();
-            QStringList parts = line.split( '|' ); 
-            //If the object is named "star", add it by coordinates
-            SkyObject *o;
-            if ( line.startsWith( QLatin1String( "star" ) ) ) {
-                QStringList fields = line.split( ' ', QString::SkipEmptyParts );
-                dms ra = dms::fromString( fields[1], false ); //false = hours
-                dms dc = dms::fromString( fields[2], true );  //true  = degrees
-                SkyPoint p( ra, dc );
-                double maxrad = 1000.0/Options::zoomFactor();
-                o = ks->data()->skyComposite()->starNearest( &p, maxrad );
-            } else {
-                o = ks->data()->objectNamed( parts[0] );
-            }
-            //If we still haven't identified the object, try interpreting the 
-            //name as a star's genetive name (with ascii letters)
-            if ( ! o ) o = ks->data()->skyComposite()->findStarByGenetiveName( parts[0] );
-            if ( o ) {
-                slotAddObject( o, true );
-                //If present, add the Time value into the Hash
-                if( ! parts[1].isEmpty() ) TimeHash.insert( o->name(), QTime::fromString( parts[1], "hms ap" ) );
-            }
-        }
+        QString input;
+        input = istream.readAll();
+        Comast::Log logObject;
+        logObject.readBegin( input );
         //Update the location and user set times from file
         slotUpdate();
         //Newly-opened list should not trigger isModified flag
@@ -899,13 +869,9 @@
 }
 
 void ObservingList::slotSaveSessionAs() {
-    bool ok(false);
-    SessionName = KInputDialog::getText( i18n( "Enter Session Name" ),
-                                      i18n( "Session name:" ), QString(), &ok );
-    if ( ok ) {
-        KUrl fileURL = KFileDialog::getSaveUrl( QDir::homePath(), "*.obslist|KStars Observing List (*.obslist)" );
-        if ( fileURL.isValid() )
-            FileName = fileURL.path();
+    KUrl fileURL = KFileDialog::getSaveUrl( QDir::homePath(), "*.obslist|KStars Observing List (*.obslist)" );
+    if ( fileURL.isValid() ) {
+        FileName = fileURL.path();
         slotSaveSession();
     }
 }
@@ -966,7 +932,7 @@
 }
 
 void ObservingList::slotSaveSession() {
-    if ( FileName.isEmpty() || SessionName.isEmpty()  ) {
+    if ( FileName.isEmpty() ) {
         slotSaveSessionAs();
         return;
     }
@@ -980,27 +946,8 @@
     return;
     }
     QTextStream ostream( &f );
-    ostream << SessionName << endl;
-    ostream << geo->name() << "|" <<geo->province() << "|" << geo->country() << "|" << dt.date().toString("ddMMyyyy") << endl;
-    foreach ( SkyObject* o, sessionList() ) {
-        if ( o->name() == "star" ) {
-            ostream << o->name() << "  " << o->ra0()->Hours() << "  " << o->dec0()->Degrees() << endl;
-        } else {
-            if ( o->type() == SkyObject::STAR ) {
-                StarObject *s = (StarObject*)o;
-
-                if ( s->name() == s->gname() ) {
-                    ostream << s->name2() << "|";
-                } else { 
-                    ostream << s->name() << "|";
-                }
-            } else {
-                ostream << o->name() << "|";
-            }
-            if( TimeHash.value( o->name(), QTime(30,0,0) ).isValid() ) ostream << TimeHash.value( o->name() ).toString( "hms ap" );
-            ostream<<endl;
-        }
-    }
+    Comast::Log log;
+    ostream<< log.writeLog( true );
     f.close();
     isModified = false;//We've saved the session, so reset the modified flag.
 }
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #993399:993400
@@ -150,6 +150,10 @@
 
     void saveThumbImage();
 
+    QString getTime( SkyObject *o ) { return TimeHash.value( o->name(), QTime( 30,0,0 ) ).toString( "h:mm:ss AP" ); }
+
+    void setTime( SkyObject *o, QTime t ) { TimeHash.insert( o->name(), t); }
+
 public slots:
     /**@short add a new object to list
         *@p o pointer to the object to add to the list
@@ -308,7 +312,7 @@
     SkyObject *LogObject, *m_CurrentObject;
     uint noNameStars;
     bool isModified, bIsLarge, sessionView, dss, singleSelection, showScope, noSelection;
-    QString FileName, SessionName, CurrentImage, DSSUrl, SDSSUrl, ThumbImage, CurrentImagePath, CurrentTempPath;
+    QString FileName, CurrentImage, DSSUrl, SDSSUrl, ThumbImage, CurrentImagePath, CurrentTempPath;
     char decsgn;
     KStarsDateTime dt;
     GeoLocation *geo;


More information about the Kstars-devel mailing list