[Kstars-devel] branches/kstars/summer/kstars/kstars/comast
Prakash Mohan
prak902000 at gmail.com
Thu Aug 6 19:23:22 CEST 2009
SVN commit 1008013 by prakash:
Adding an id element to the observers and stop using the full name as the id.
CCMAIL: kstars-devel at kde.org
M +6 -3 execute.cpp
M +13 -6 log.cpp
M +3 -2 log.h
M +2 -1 observer.cpp
M +4 -3 observer.h
M +6 -3 observeradd.cpp
M +1 -0 observeradd.h
--- branches/kstars/summer/kstars/kstars/comast/execute.cpp #1008012:1008013
@@ -136,6 +136,7 @@
break;
}
case 2: {
+ addObservation();
ui.stackedWidget->setCurrentIndex( 1 );
ui.NextButton->setText( i18n( "Next Page >" ) );
QString prevTarget = currentTarget->name();
@@ -236,13 +237,16 @@
}
bool Execute::addObservation() {
+ slotSetCurrentObjects();
while( logObject->findObservationByName( i18n( "observation_" ) + QString::number( nextObservation ) ) )
nextObservation++;
KStarsDateTime dt = currentSession->begin();
dt.setTime( ui.Time->time() );
- Comast::Observation *o = new Comast::Observation( i18n( "observation_" ) + QString::number( nextObservation++ ) , ui.Observer->currentText(), 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() );
+ 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() );
logObject->observationList()->append( o );
- slotSetCurrentObjects();
ui.Description->clear();
return true;
}
@@ -341,7 +345,6 @@
SkyObject *o = fd->selectedObject();
if( o != 0 ) {
ks->observingList()->slotAddObject( o, true );
- kDebug() << "alpha";
init();
}
}
--- branches/kstars/summer/kstars/kstars/comast/log.cpp #1008012:1008013
@@ -186,7 +186,7 @@
void Comast::Log::writeObserver( Comast::Observer *o ) {
writer->writeStartElement( "observer" );
- writer->writeAttribute( "id", o->name() + o->surname() );
+ writer->writeAttribute( "id", o->id() );
writer->writeStartElement( "name" );
writer->writeCDATA( o->name() );
writer->writeEndElement();
@@ -450,7 +450,7 @@
if( reader->isStartElement() ) {
if( reader->name() == "observer" )
- readObserver();
+ readObserver( reader->attributes().value( "id" ).toString() );
else
readUnknownElement();
}
@@ -591,7 +591,7 @@
}
}
-void Comast::Log::readObserver() {
+void Comast::Log::readObserver( QString id ) {
QString name, surname, contact;
while( ! reader->atEnd() ) {
reader->readNext();
@@ -610,7 +610,7 @@
readUnknownElement();
}
}
- Comast::Observer *o= new Comast::Observer( name, surname, contact );
+ Comast::Observer *o= new Comast::Observer( id, name, surname, contact );
m_observerList.append( o );
}
@@ -876,13 +876,20 @@
dt.setDate( QDate::fromString( date, "ddMMyyyy" ) );
}
-Comast::Observer* Comast::Log::findObserverByName( QString id ) {
+Comast::Observer* Comast::Log::findObserverByName( QString name ) {
foreach( Comast::Observer *obs, *observerList() )
- if( obs->name() + obs->surname() == id )
+ if( obs->name() + " " + obs->surname() == name )
return obs;
return NULL;
}
+Comast::Observer* Comast::Log::findObserverById( QString id ) {
+ foreach( Comast::Observer *obs, *observerList() )
+ if( obs->id() == id )
+ return obs;
+ return NULL;
+}
+
Comast::Session* Comast::Log::findSessionByName( QString id ) {
foreach( Comast::Session *s, *sessionList() )
if( s->id() == id )
--- branches/kstars/summer/kstars/kstars/comast/log.h #1008012:1008013
@@ -86,7 +86,7 @@
void readFilters();
void readObservation( QString id );
void readTarget();
- void readObserver();
+ void readObserver( QString id );
void readSite();
void readSession( QString id, QString lang );
void readScope( QString id );
@@ -96,7 +96,8 @@
void readPosition();
void readGeoDate();
QString readResult();
- Comast::Observer* findObserverByName( QString id );
+ Comast::Observer* findObserverByName( QString fullName );
+ Comast::Observer* findObserverById( QString id );
Comast::Site* findSiteByName( QString id );
Comast::Session* findSessionByName( QString id );
Comast::Scope* findScopeByName( QString id );
--- branches/kstars/summer/kstars/kstars/comast/observer.cpp #1008012:1008013
@@ -18,7 +18,8 @@
#include "comast/observer.h"
-void Comast::Observer::setObserver( QString _name, QString _surname, QString _contact ){
+void Comast::Observer::setObserver( QString _id, QString _name, QString _surname, QString _contact ){
+ m_Id = _id;
m_Name = _name;
m_Surname = _surname;
m_Contact = _contact;
--- branches/kstars/summer/kstars/kstars/comast/observer.h #1008012:1008013
@@ -24,12 +24,13 @@
class Comast::Observer {
public:
+ QString id() { return m_Id; }
QString name() { return m_Name; }
QString surname() { return m_Surname; }
QString contact() { return m_Contact; }
- Observer( QString _name ="", QString _surname = "", QString _contact = "" ) { setObserver( _name, _surname, _contact ); }
- void setObserver( QString _name = "", QString _surname= "", QString _contact = "" );
+ Observer( QString _id, QString _name ="", QString _surname = "", QString _contact = "" ) { setObserver( _id, _name, _surname, _contact ); }
+ void setObserver( QString _id, QString _name = "", QString _surname= "", QString _contact = "" );
private:
- QString m_Name, m_Surname, m_Contact;
+ QString m_Name, m_Surname, m_Contact, m_Id;
};
#endif
--- branches/kstars/summer/kstars/kstars/comast/observeradd.cpp #1008012:1008013
@@ -34,6 +34,7 @@
setCaption( i18n( "Add Observer" ) );
setButtons( KDialog::Close );
ks = KStars::Instance();
+ nextObserver = 0;
// Load the observers list from the file
loadObservers();
@@ -47,14 +48,16 @@
KMessageBox::sorry( 0, i18n("The Name field cannot be empty"), i18n("Invalid Input") );
return;
}
- Comast::Observer *o = ks->data()->logObject()->findObserverByName( ui.Name->text() + ui.Surname->text() ); //The findObserverByName uses the fullName for searching
+ Comast::Observer *o = ks->data()->logObject()->findObserverByName( ui.Name->text() + " " + ui.Surname->text() ); //The findObserverByName uses the fullName for searching
if( o ) {
if( Comast::warningOverwrite( i18n( "Another Observer already exists with the given Name and Surname, Overwrite?" ) ) == KMessageBox::Yes ) {
- o->setObserver( o->name(), o->surname(), ui.Contact->text() );
+ o->setObserver( o->id(), o->name(), o->surname(), ui.Contact->text() );
} else
return; //Do nothing
} else { // No such observer exists, so create a new observer object and append to file
- o = new Comast::Observer( ui.Name->text(), ui.Surname->text(), ui.Contact->text() );
+ while( ks->data()->logObject()->findObserverById( i18n("observer_") + QString::number( nextObserver ) ) )
+ nextObserver++;
+ o = new Comast::Observer( i18n("observer_") + QString::number( nextObserver++ ), ui.Name->text(), ui.Surname->text(), ui.Contact->text() );
ks->data()->logObject()->observerList()->append( o );
}
--- branches/kstars/summer/kstars/kstars/comast/observeradd.h #1008012:1008013
@@ -51,5 +51,6 @@
private:
KStars *ks;
Ui::ObserverAdd ui;
+ int nextObserver;
};
#endif
More information about the Kstars-devel
mailing list