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

Prakash Mohan prak902000 at gmail.com
Wed Jul 15 00:57:46 CEST 2009


SVN commit 996816 by prakash:

Adding support for reading the sessions part in the OAL XML logs

CCMAIL: kstars-devel at kde.org


 M  +51 -0     log.cpp  
 M  +2 -0      log.h  
 M  +1 -0      session.h  


--- branches/kstars/summer/kstars/kstars/comast/log.cpp #996815:996816
@@ -395,6 +395,8 @@
                 readObservers();
            else if( reader->name() == "sites" )
                 readSites();
+           else if( reader->name() == "sessions" )
+                readSessions();
            else if( reader->name() == "geodate" )
                 readGeoDate();
             else
@@ -451,6 +453,22 @@
     }
 }
 
+void Comast::Log::readSessions() {
+    while( ! reader->atEnd() ) {
+        reader->readNext();
+
+        if( reader->isEndElement() )
+            break;
+
+        if( reader->isStartElement() ) {
+            if( reader->name() == "session" )
+                readSession( reader->attributes().value( "id" ).toString(), reader->attributes().value( "lang" ).toString() );
+            else
+                readUnknownElement();
+        }
+    }
+}
+
 void Comast::Log::readTarget() {
     SkyObject *o = NULL;
     while( ! reader->atEnd() ) {
@@ -534,6 +552,39 @@
     m_siteList.append( o );
 }
 
+void Comast::Log::readSession( QString id, QString lang ) {
+    QString site, weather, equipment, comments, begin, end;
+    KStarsDateTime beginDT, endDT;
+    while( ! reader->atEnd() ) {
+        reader->readNext();
+
+        if( reader->isEndElement() )
+            break;
+
+        if( reader->isStartElement() ) {
+            if( reader->name() == "site" ) {
+                site = reader->readElementText();
+            } else if( reader->name() == "begin" ) {
+                begin = reader->readElementText() ;
+                beginDT.fromString( begin );
+            } else if( reader->name() == "end" ) {
+                end = reader->readElementText() ;
+                endDT.fromString( begin );
+            } else if( reader->name() == "weather" ) {
+                weather = reader->readElementText() ;
+            } else if( reader->name() == "equipment" ) {
+                equipment = reader->readElementText() ;
+            } else if( reader->name() == "comments" ) {
+                comments = reader->readElementText() ;
+            } else
+                readUnknownElement();
+        }
+    }
+    
+    Comast::Session *o= new Comast::Session( id, site, beginDT, endDT, weather, equipment, comments, lang );
+    m_sessionList.append( o );
+}
+
 void Comast::Log::readPosition() {
     while( ! reader->atEnd() ) {
         reader->readNext();
--- branches/kstars/summer/kstars/kstars/comast/log.h #996815:996816
@@ -69,9 +69,11 @@
         void readTargets();
         void readObservers();
         void readSites();
+        void readSessions();
         void readTarget();
         void readObserver();
         void readSite();
+        void readSession( QString id, QString lang );
         void readPosition();
         void readGeoDate();
     private:
--- branches/kstars/summer/kstars/kstars/comast/session.h #996815:996816
@@ -25,6 +25,7 @@
 
 class Comast::Session {
     public:
+       Session ( QString name, QString site, KStarsDateTime begin, KStarsDateTime end, QString weather, QString equipment, QString comment, QString lang ) { setSession( name, site, begin, end, weather, equipment, comment, lang ); }
        QString id() { return m_Id; }
        QString site() { return m_Site; }
        KStarsDateTime begin() { return m_Begin; }


More information about the Kstars-devel mailing list