[Kstars-devel] branches/kstars/summer/kstars/kstars/comast
Prakash Mohan
prak902000 at gmail.com
Fri Aug 7 19:16:49 CEST 2009
SVN commit 1008508 by prakash:
Use an inbuilt id for a site, instead of the location's full name.
CCMAIL: kstars-devel at kde.org
M +12 -8 execute.cpp
M +1 -1 execute.h
M +11 -4 log.cpp
M +3 -2 log.h
M +4 -2 site.cpp
M +6 -5 site.h
--- branches/kstars/summer/kstars/kstars/comast/execute.cpp #1008507:1008508
@@ -50,6 +50,7 @@
currentSession = NULL;
nextSession = 0;
nextObservation = 0;
+ nextSite = 0;
//initialize the global logObject
logObject = ks->data()->logObject();
@@ -149,18 +150,21 @@
}
bool Execute::saveSession() {
+ Comast::Site *site = logObject->findSiteByName( geo->fullName() );
+ if( ! site ) {
+ while( logObject->findSiteById( i18n( "site_" ) + QString::number( nextSite ) ) )
+ nextSite++;
+ site = new Comast::Site( geo, i18n( "site_" ) + QString::number( nextSite++ ) );
+ logObject->siteList()->append( site );
+ }
if( currentSession ){
- currentSession->setSession( currentSession->id(), geo->fullName(), ui.Begin->dateTime(), ui.Begin->dateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
+ currentSession->setSession( currentSession->id(), site->id(), ui.Begin->dateTime(), ui.Begin->dateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
} else {
while( logObject->findSessionByName( i18n( "session_" ) + QString::number( nextSession ) ) )
nextSession++;
- currentSession = new Comast::Session( i18n( "session_" ) + QString::number( nextSession++ ) , geo->fullName(), ui.Begin->dateTime(), ui.Begin->dateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
+ currentSession = new Comast::Session( i18n( "session_" ) + QString::number( nextSession++ ) , site->id(), ui.Begin->dateTime(), ui.Begin->dateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
logObject->sessionList()->append( currentSession );
}
- if( ! logObject->findSiteByName( geo->fullName() ) ) {
- Comast::Site *newSite = new Comast::Site( geo );
- logObject->siteList()->append( newSite );
- }
ui.stackedWidget->setCurrentIndex( 1 ); //Move to the next page
return true;
}
@@ -247,14 +251,14 @@
QString observer = "";
if( currentObserver )
observer = currentObserver->id();
- Comast::Observation *o = new Comast::Observation( i18n( "observation_" ) + QString::number( nextObservation++ ) , observer, geo->fullName(), currentSession->id(), currentTarget->name(), dt, ui.FaintestStar->value(), ui.Seeing->value(), ui.Scope->currentText(), ui.Eyepiece->currentText(), ui.Lens->currentText(), ui.Filter->currentText(), ui.Description->toPlainText(), ui.Language->text() );
+ Comast::Observation *o = new Comast::Observation( i18n( "observation_" ) + QString::number( nextObservation++ ) , observer, currentSession->site(), currentSession->id(), currentTarget->name(), dt, ui.FaintestStar->value(), ui.Seeing->value(), ui.Scope->currentText(), ui.Eyepiece->currentText(), ui.Lens->currentText(), ui.Filter->currentText(), ui.Description->toPlainText(), ui.Language->text() );
logObject->observationList()->append( o );
ui.Description->clear();
return true;
}
void Execute::slotEndSession() {
if( currentSession ) {
- currentSession->setSession( currentSession->id(), geo->fullName(), ui.Begin->dateTime(), KStarsDateTime::currentDateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
+ currentSession->setSession( currentSession->id(), currentSession->site(), ui.Begin->dateTime(), KStarsDateTime::currentDateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
KUrl fileURL = KFileDialog::getSaveUrl( QDir::homePath(), "*.xml" );
if( fileURL.isValid() ) {
QFile f( fileURL.path() );
--- branches/kstars/summer/kstars/kstars/comast/execute.h #1008507:1008508
@@ -134,7 +134,7 @@
Comast::Filter *currentFilter;
GeoLocation *geo;
SkyObject *currentTarget;
- int nextSession, nextObservation;
+ int nextSession, nextObservation, nextSite;
};
#endif
--- branches/kstars/summer/kstars/kstars/comast/log.cpp #1008507:1008508
@@ -200,7 +200,7 @@
}
void Comast::Log::writeSite( Comast::Site *s ) {
writer->writeStartElement( "site" );
- writer->writeAttribute( "id", s->name() );
+ writer->writeAttribute( "id", s->id() );
writer->writeStartElement( "name" );
writer->writeCDATA( s->name() );
writer->writeEndElement();
@@ -466,7 +466,7 @@
if( reader->isStartElement() ) {
if( reader->name() == "site" )
- readSite();
+ readSite( reader->attributes().value( "id" ).toString() );
else
readUnknownElement();
}
@@ -614,7 +614,7 @@
m_observerList.append( o );
}
-void Comast::Log::readSite() {
+void Comast::Log::readSite( QString id ) {
QString name, latUnit, lonUnit, lat, lon;
while( ! reader->atEnd() ) {
reader->readNext();
@@ -635,7 +635,7 @@
readUnknownElement();
}
}
- Comast::Site *o= new Comast::Site( name, lat.toDouble(), latUnit, lon.toDouble(), lonUnit );
+ Comast::Site *o= new Comast::Site( id, name, lat.toDouble(), latUnit, lon.toDouble(), lonUnit );
m_siteList.append( o );
}
@@ -897,6 +897,13 @@
return NULL;
}
+Comast::Site* Comast::Log::findSiteById( QString id ) {
+ foreach( Comast::Site *s, *siteList() )
+ if( s->id() == id )
+ return s;
+ return NULL;
+}
+
Comast::Site* Comast::Log::findSiteByName( QString name ) {
foreach( Comast::Site *s, *siteList() )
if( s->name() == name )
--- branches/kstars/summer/kstars/kstars/comast/log.h #1008507:1008508
@@ -87,7 +87,7 @@
void readObservation( QString id );
void readTarget();
void readObserver( QString id );
- void readSite();
+ void readSite( QString id );
void readSession( QString id, QString lang );
void readScope( QString id );
void readEyepiece( QString id );
@@ -98,7 +98,8 @@
QString readResult();
Comast::Observer* findObserverByName( QString fullName );
Comast::Observer* findObserverById( QString id );
- Comast::Site* findSiteByName( QString id );
+ Comast::Site* findSiteByName( QString name );
+ Comast::Site* findSiteById( QString id );
Comast::Session* findSessionByName( QString id );
Comast::Scope* findScopeByName( QString id );
Comast::Eyepiece* findEyepieceByName( QString id );
--- branches/kstars/summer/kstars/kstars/comast/site.cpp #1008507:1008508
@@ -18,14 +18,16 @@
#include "comast/site.h"
-void Comast::Site::setSite( QString _name, double _lat, QString _latUnit, double _lon, QString _lonUnit ){
+void Comast::Site::setSite(QString _id, QString _name, double _lat, QString _latUnit, double _lon, QString _lonUnit ){
+ m_Id = _id;
m_Name = _name;
m_Lat = _lat;
m_Lon = _lon;
m_LatUnit = _latUnit;
m_LonUnit = _lonUnit;
}
-void Comast::Site::setSite( GeoLocation *geo ) {
+void Comast::Site::setSite( GeoLocation *geo, QString id ) {
+ m_Id = id;
m_Name = geo->name();
m_Lat = geo->lat()->radians();
m_Lon = geo->lng()->radians();
--- branches/kstars/summer/kstars/kstars/comast/site.h #1008507:1008508
@@ -26,17 +26,18 @@
class Comast::Site {
public:
- Site( QString name, double lat, QString latUnit, double lon, QString lonUnit ) { setSite( name, lat, latUnit, lon, lonUnit ); }
- Site( GeoLocation *geo ) { setSite( geo ); }
+ Site( QString id, QString name, double lat, QString latUnit, double lon, QString lonUnit ) { setSite( id, name, lat, latUnit, lon, lonUnit ); }
+ Site( GeoLocation *geo, QString id ) { setSite( geo, id ); }
+ QString id() { return m_Id; }
QString name() { return m_Name; }
double latitude() { return m_Lat; }
QString latUnit() { return m_LatUnit; }
double longitude() { return m_Lon; }
QString lonUnit() { return m_LonUnit; }
- void setSite( QString _name, double _lat, QString _latUnit, double _lon, QString _lonUnit);
- void setSite( GeoLocation *geo );
+ void setSite( QString _id, QString _name, double _lat, QString _latUnit, double _lon, QString _lonUnit);
+ void setSite( GeoLocation *geo, QString id );
private:
- QString m_Name, m_LatUnit, m_LonUnit;
+ QString m_Name, m_LatUnit, m_LonUnit, m_Id;
double m_Lat, m_Lon;
};
#endif
More information about the Kstars-devel
mailing list