[Kstars-devel] branches/kstars/summer/kstars/kstars/comast
Prakash Mohan
prak902000 at gmail.com
Thu Aug 6 16:46:12 CEST 2009
SVN commit 1007937 by prakash:
Auto generating the ids for the sessions and observations.
CCMAIL: kstars-devel at kde.org
M +11 -27 execute.cpp
M +1 -0 execute.h
M +29 -53 execute.ui
--- branches/kstars/summer/kstars/kstars/comast/execute.cpp #1007936:1007937
@@ -48,6 +48,8 @@
currentLens = NULL;
currentFilter = NULL;
currentSession = NULL;
+ nextSession = 0;
+ nextObservation = 0;
//initialize the global logObject
logObject = ks->data()->logObject();
@@ -134,8 +136,8 @@
break;
}
case 2: {
- if ( addObservation() )
ui.stackedWidget->setCurrentIndex( 1 );
+ ui.NextButton->setText( i18n( "Next Page >" ) );
QString prevTarget = currentTarget->name();
loadTargets();
ui.Target->setCurrentRow( findIndexOfTarget( prevTarget ), QItemSelectionModel::SelectCurrent );
@@ -146,18 +148,12 @@
}
bool Execute::saveSession() {
- if( ui.Id->text().isEmpty() ) {
- KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
- return false;
- }
- currentSession = logObject->findSessionByName( ui.Id->text() );
if( currentSession ){
-// if( Comast::warningOverwrite( i18n("Another session already exists with the given Id, Overwrite?") ) == KMessageBox::Yes ) {
- currentSession->setSession( ui.Id->text(), geo->fullName(), ui.Begin->dateTime(), ui.Begin->dateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
-// } else
-// return false;
+ currentSession->setSession( currentSession->id(), geo->fullName(), ui.Begin->dateTime(), ui.Begin->dateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
} else {
- currentSession = new Comast::Session( ui.Id->text(), geo->fullName(), ui.Begin->dateTime(), ui.Begin->dateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
+ 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() );
logObject->sessionList()->append( currentSession );
}
if( ! logObject->findSiteByName( geo->fullName() ) ) {
@@ -240,30 +236,19 @@
}
bool Execute::addObservation() {
- if( ui.Id->text().isEmpty() ) {
- KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
- return false;
- }
- Comast::Observation *o = logObject->findObservationByName( ui.o_Id->text() );
+ while( logObject->findObservationByName( i18n( "observation_" ) + QString::number( nextObservation ) ) )
+ nextObservation++;
KStarsDateTime dt = currentSession->begin();
dt.setTime( ui.Time->time() );
- if( o ){
- if( Comast::warningOverwrite( i18n("Another observation already exists with the given Id, Overwrite?") ) == KMessageBox::Yes ) {
- o->setObservation( ui.o_Id->text(), 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() );
- } else
- return false;
- } else {
- o = new Comast::Observation( ui.o_Id->text(), 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() );
+ 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() );
logObject->observationList()->append( o );
- }
slotSetCurrentObjects();
- ui.o_Id->clear();
ui.Description->clear();
return true;
}
void Execute::slotEndSession() {
if( currentSession ) {
- currentSession->setSession( ui.Id->text(), geo->fullName(), ui.Begin->dateTime(), KStarsDateTime::currentDateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
+ currentSession->setSession( currentSession->id(), geo->fullName(), 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() );
@@ -277,7 +262,6 @@
f.close();
}
}
- ui.Id->clear();
hide();
ui.stackedWidget->setCurrentIndex(0);
logObject->observationList()->clear();
--- branches/kstars/summer/kstars/kstars/comast/execute.h #1007936:1007937
@@ -134,6 +134,7 @@
Comast::Filter *currentFilter;
GeoLocation *geo;
SkyObject *currentTarget;
+ int nextSession, nextObservation;
};
#endif
--- branches/kstars/summer/kstars/kstars/comast/execute.ui #1007936:1007937
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>611</width>
+ <width>623</width>
<height>482</height>
</rect>
</property>
@@ -90,77 +90,67 @@
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Id:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="Id"/>
- </item>
- <item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Location:</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="0" column="1">
<widget class="QPushButton" name="Location">
<property name="text">
<string>set location</string>
</property>
</widget>
</item>
- <item row="2" column="0">
+ <item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Begin:</string>
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="1" column="1">
<widget class="KDateTimeWidget" name="Begin"/>
</item>
- <item row="3" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Weather:</string>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="2" column="1">
<widget class="KTextEdit" name="Weather"/>
</item>
- <item row="4" column="0">
+ <item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Equipment:</string>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="3" column="1">
<widget class="KTextEdit" name="Equipment"/>
</item>
- <item row="5" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Comment:</string>
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="4" column="1">
<widget class="KTextEdit" name="Comment"/>
</item>
- <item row="6" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Language:</string>
</property>
</widget>
</item>
- <item row="6" column="1">
+ <item row="5" column="1">
<widget class="KLineEdit" name="Language"/>
</item>
</layout>
@@ -375,107 +365,93 @@
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>Id:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KLineEdit" name="o_Id">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Observer</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="0" column="1">
<widget class="KComboBox" name="Observer"/>
</item>
- <item row="2" column="0">
+ <item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Scope:</string>
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="1" column="1">
<widget class="KComboBox" name="Scope"/>
</item>
- <item row="3" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Eyepiece:</string>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="2" column="1">
<widget class="KComboBox" name="Eyepiece"/>
</item>
- <item row="4" column="0">
+ <item row="3" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Lens:</string>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="3" column="1">
<widget class="KComboBox" name="Lens"/>
</item>
- <item row="5" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Filter:</string>
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="4" column="1">
<widget class="KComboBox" name="Filter"/>
</item>
- <item row="6" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Seeing:</string>
</property>
</widget>
</item>
- <item row="6" column="1">
+ <item row="5" column="1">
<widget class="KDoubleNumInput" name="Seeing"/>
</item>
- <item row="7" column="0">
+ <item row="6" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>FaintestStar:</string>
</property>
</widget>
</item>
- <item row="7" column="1">
+ <item row="6" column="1">
<widget class="KDoubleNumInput" name="FaintestStar"/>
</item>
- <item row="8" column="0">
+ <item row="7" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Time:</string>
</property>
</widget>
</item>
- <item row="8" column="1">
+ <item row="7" column="1">
<widget class="QTimeEdit" name="Time"/>
</item>
- <item row="9" column="0">
+ <item row="8" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
- <item row="9" column="1">
+ <item row="8" column="1">
<widget class="KTextEdit" name="Description"/>
</item>
</layout>
More information about the Kstars-devel
mailing list