[Kstars-devel] branches/kstars/summer/kstars/kstars/comast
Prakash Mohan
prak902000 at gmail.com
Thu Aug 6 08:45:43 CEST 2009
SVN commit 1007701 by prakash:
Make the equipment list editable, display a List of items already stored.
CCMAIL: kstars-devel at kde.org
M +211 -4 equipmentwriter.cpp
M +14 -0 equipmentwriter.h
M +53 -8 equipmentwriter.ui
--- branches/kstars/summer/kstars/kstars/comast/equipmentwriter.cpp #1007700:1007701
@@ -37,13 +37,29 @@
setButtons( KDialog::Close );
ks = KStars::Instance();
loadEquipment();
+ newScope = true;
+ newEyepiece = true;
+ newLens = true;
+ newFilter = true;
//make connections
connect( this, SIGNAL( closeClicked() ), this, SLOT( slotClose() ) );
- connect( ui.AddScope, SIGNAL( clicked() ), this, SLOT( slotAddScope() ) );
- connect( ui.AddEyepiece, SIGNAL( clicked() ), this, SLOT( slotAddEyepiece() ) );
- connect( ui.AddLens, SIGNAL( clicked() ), this, SLOT( slotAddLens() ) );
- connect( ui.AddFilter, SIGNAL( clicked() ), this, SLOT( slotAddFilter() ) );
+ connect( ui.NewScope, SIGNAL( clicked() ), this, SLOT( slotNewScope() ) );
+ connect( ui.NewEyepiece, SIGNAL( clicked() ), this, SLOT( slotNewEyepiece() ) );
+ connect( ui.NewLens, SIGNAL( clicked() ), this, SLOT( slotNewLens() ) );
+ connect( ui.NewFilter, SIGNAL( clicked() ), this, SLOT( slotNewFilter() ) );
+ connect( ui.AddScope, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
+ connect( ui.AddEyepiece, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
+ connect( ui.AddLens, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
+ connect( ui.AddFilter, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
+ connect( ui.ScopeList, SIGNAL( currentTextChanged(const QString) ),
+ this, SLOT( slotSetScope(QString) ) );
+ connect( ui.EyepieceList, SIGNAL( currentTextChanged(const QString) ),
+ this, SLOT( slotSetEyepiece(QString) ) );
+ connect( ui.LensList, SIGNAL( currentTextChanged(const QString) ),
+ this, SLOT( slotSetLens(QString) ) );
+ connect( ui.FilterList, SIGNAL( currentTextChanged(const QString) ),
+ this, SLOT( slotSetFilter(QString) ) );
}
void EquipmentWriter::slotAddScope() {
@@ -69,7 +85,39 @@
ui.Type->clear();
ui.FocalLength->setValue(0);
}
+void EquipmentWriter::slotSaveScope() {
+ if( ui.Id->text().isEmpty() ) {
+ KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
+ return;
+ }
+ Comast::Scope *s = ks->data()->logObject()->findScopeByName( ui.Id->text() );
+ if( s ) {
+ s->setScope( ui.Id->text(), ui.Model->text(), ui.Vendor->text(), ui.Type->text(), ui.FocalLength->value(), ui.Aperture->value() );
+ }
+ saveEquipment(); //Save the new list.
+}
+void EquipmentWriter::slotSetScope( QString id) {
+ Comast::Scope *s = ks->data()->logObject()->findScopeByName( id );
+ if ( s ) {
+ ui.Id->setText( s->id() ) ;
+ ui.Model->setText( s->model() );
+ ui.Vendor->setText( s->vendor() );
+ ui.Type->setText( s->type() );
+ ui.FocalLength->setValue( s->focalLength() );
+ newScope = false;
+ }
+}
+void EquipmentWriter::slotNewScope() {
+ ui.Id->clear();
+ ui.Model->clear();
+ ui.Vendor->clear();
+ ui.Type->clear();
+ ui.FocalLength->setValue(0);
+ ui.ScopeList->selectionModel()->clear();
+ newScope = true;
+}
+
void EquipmentWriter::slotAddEyepiece() {
if( ui.e_Id->text().isEmpty() ) {
KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
@@ -93,6 +141,41 @@
ui.e_focalLength->setValue(0);
}
+void EquipmentWriter::slotSaveEyepiece() {
+ if( ui.e_Id->text().isEmpty() ) {
+ KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
+ return;
+ }
+ Comast::Eyepiece *e = ks->data()->logObject()->findEyepieceByName( ui.e_Id->text() );
+ if( e ){
+ e->setEyepiece( ui.e_Id->text(), ui.e_Model->text(), ui.e_Vendor->text(), ui.Fov->value(), ui.FovUnit->currentText(), ui.e_focalLength->value() );
+ }
+ saveEquipment(); //Save the new list.
+}
+
+void EquipmentWriter::slotSetEyepiece( QString id ) {
+ Comast::Eyepiece *e;
+ e = ks->data()->logObject()->findEyepieceByName( id );
+ if( e ) {
+ ui.e_Id->setText( e->id() );
+ ui.e_Model->setText( e->model() );
+ ui.e_Vendor->setText( e->vendor() );
+ ui.Fov->setValue( e->appFov() );
+ ui.e_focalLength->setValue( e->focalLength() );
+ newEyepiece = false;
+ }
+}
+
+void EquipmentWriter::slotNewEyepiece() {
+ ui.e_Id->clear();
+ ui.e_Model->clear();
+ ui.e_Vendor->clear();
+ ui.Fov->setValue(0);
+ ui.e_focalLength->setValue(0);
+ ui.EyepieceList->selectionModel()->clear();
+ newEyepiece = true;
+}
+
void EquipmentWriter::slotAddLens() {
if( ui.l_Id->text().isEmpty() ) {
KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
@@ -115,6 +198,39 @@
ui.l_Factor->setValue(0);
}
+void EquipmentWriter::slotSaveLens() {
+ if( ui.l_Id->text().isEmpty() ) {
+ KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
+ return;
+ }
+ Comast::Lens *l = ks->data()->logObject()->findLensByName( ui.l_Id->text() );
+ if( l ){
+ l->setLens( ui.l_Id->text(), ui.l_Model->text(), ui.l_Vendor->text(), ui.l_Factor->value() );
+ }
+ saveEquipment(); //Save the new list.
+}
+
+void EquipmentWriter::slotSetLens( QString id ) {
+ Comast::Lens *l;
+ l = ks->data()->logObject()->findLensByName( id );
+ if( l ) {
+ ui.l_Id->setText( l->id() );
+ ui.l_Model->setText( l->model() );
+ ui.l_Vendor->setText( l->vendor() );
+ ui.l_Factor->setValue( l->factor() );
+ newLens = false;
+ }
+}
+
+void EquipmentWriter::slotNewLens() {
+ ui.l_Id->clear();
+ ui.l_Model->clear();
+ ui.l_Vendor->clear();
+ ui.l_Factor->setValue(0);
+ ui.LensList->selectionModel()->clear();
+ newLens = true;
+}
+
void EquipmentWriter::slotAddFilter() {
if( ui.f_Id->text().isEmpty() ) {
KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
@@ -138,6 +254,41 @@
ui.f_Color->clear();
}
+void EquipmentWriter::slotSaveFilter() {
+ if( ui.f_Id->text().isEmpty() ) {
+ KMessageBox::sorry( 0, i18n("The Id field cannot be empty"), i18n("Invalid Id") );
+ return;
+ }
+ Comast::Filter *f = ks->data()->logObject()->findFilterByName( ui.f_Id->text() );
+ if( f ){
+ f->setFilter( ui.f_Id->text(), ui.f_Model->text(), ui.f_Vendor->text(), ui.f_Type->text(), ui.f_Color->text() );
+ }
+ saveEquipment(); //Save the new list.
+}
+
+void EquipmentWriter::slotSetFilter( QString id ) {
+ Comast::Filter *f;
+ f = ks->data()->logObject()->findFilterByName( id );
+ if( f ) {
+ ui.f_Id->setText( f->id() );
+ ui.f_Model->setText( f->model() );
+ ui.f_Vendor->setText( f->vendor() );
+ ui.f_Type->setText( f->type() );
+ ui.f_Color->setText( f->color() );
+ newFilter = false;
+ }
+}
+
+void EquipmentWriter::slotNewFilter() {
+ ui.f_Id->clear();
+ ui.f_Model->clear();
+ ui.f_Vendor->clear();
+ ui.f_Type->clear();
+ ui.f_Color->clear();
+ ui.FilterList->selectionModel()->clear();
+ newFilter = true;
+}
+
void EquipmentWriter::saveEquipment() {
QFile f;
f.setFileName( KStandardDirs::locateLocal( "appdata", "equipmentlist.xml" ) );
@@ -164,6 +315,62 @@
QTextStream istream( &f );
ks->data()->logObject()->readBegin( istream.readAll() );
f.close();
+ ui.ScopeList->clear();
+ ui.EyepieceList->clear();
+ ui.LensList->clear();
+ ui.FilterList->clear();
+ foreach( Comast::Scope *s, *( ks->data()->logObject()->scopeList() ) )
+ ui.ScopeList->addItem( s->id() );
+ foreach( Comast::Eyepiece *e, *( ks->data()->logObject()->eyepieceList() ) )
+ ui.EyepieceList->addItem( e->id() );
+ foreach( Comast::Lens *l, *( ks->data()->logObject()->lensList() ) )
+ ui.LensList->addItem( l->id() );
+ foreach( Comast::Filter *f, *( ks->data()->logObject()->filterList() ) )
+ ui.FilterList->addItem( f->id() );
}
+void EquipmentWriter::slotSave() {
+ switch( ui.tabWidget->currentIndex() ) {
+ case 0: {
+ if( newScope )
+ slotAddScope();
+ else
+ slotSaveScope();
+ ui.ScopeList->clear();
+ foreach( Comast::Scope *s, *( ks->data()->logObject()->scopeList() ) )
+ ui.ScopeList->addItem( s->id() );
+ break;
+ }
+ case 1: {
+ if( newEyepiece )
+ slotAddEyepiece();
+ else
+ slotSaveEyepiece();
+ ui.EyepieceList->clear();
+ foreach( Comast::Eyepiece *e, *( ks->data()->logObject()->eyepieceList() ) )
+ ui.EyepieceList->addItem( e->id() );
+ break;
+ }
+ case 2: {
+ if( newLens )
+ slotAddLens();
+ else
+ slotSaveLens();
+ ui.LensList->clear();
+ foreach( Comast::Lens *l, *( ks->data()->logObject()->lensList() ) )
+ ui.LensList->addItem( l->id() );
+ break;
+ }
+ case 3: {
+ if( newFilter )
+ slotAddFilter();
+ else
+ slotSaveFilter();
+ ui.FilterList->clear();
+ foreach( Comast::Filter *f, *( ks->data()->logObject()->filterList() ) )
+ ui.FilterList->addItem( f->id() );
+ break;
+ }
+ }
+}
#include "equipmentwriter.moc"
--- branches/kstars/summer/kstars/kstars/comast/equipmentwriter.h #1007700:1007701
@@ -40,11 +40,25 @@
void slotAddEyepiece();
void slotAddLens();
void slotAddFilter();
+ void slotSaveScope();
+ void slotSaveEyepiece();
+ void slotSaveLens();
+ void slotSaveFilter();
+ void slotSetScope( QString );
+ void slotSetEyepiece( QString );
+ void slotSetLens( QString );
+ void slotSetFilter( QString );
+ void slotNewScope();
+ void slotNewEyepiece();
+ void slotNewLens();
+ void slotNewFilter();
void slotClose() { hide(); }
+ void slotSave();
private:
KStars *ks;
Ui::EquipmentWriter ui;
+ bool newScope, newEyepiece, newLens, newFilter;
};
--- branches/kstars/summer/kstars/kstars/comast/equipmentwriter.ui #1007700:1007701
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>340</width>
+ <width>411</width>
<height>275</height>
</rect>
</property>
@@ -29,8 +29,11 @@
<attribute name="title">
<string>Scope</string>
</attribute>
- <layout class="QVBoxLayout" name="_3">
+ <layout class="QHBoxLayout" name="_3">
<item>
+ <widget class="KListWidget" name="ScopeList"/>
+ </item>
+ <item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
@@ -115,9 +118,16 @@
</spacer>
</item>
<item>
+ <widget class="QPushButton" name="NewScope">
+ <property name="text">
+ <string>Add New..</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="AddScope">
<property name="text">
- <string>Add Scope</string>
+ <string>Save Scope</string>
</property>
</widget>
</item>
@@ -133,6 +143,9 @@
</attribute>
<layout class="QHBoxLayout">
<item>
+ <widget class="KListWidget" name="EyepieceList"/>
+ </item>
+ <item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QFormLayout" name="formLayout_2">
@@ -245,9 +258,16 @@
</spacer>
</item>
<item>
+ <widget class="QPushButton" name="NewEyepiece">
+ <property name="text">
+ <string>Add New</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="AddEyepiece">
<property name="text">
- <string>Add Eyepiece</string>
+ <string>Save Eyepiece</string>
</property>
</widget>
</item>
@@ -261,8 +281,11 @@
<attribute name="title">
<string>Lens</string>
</attribute>
- <layout class="QVBoxLayout" name="_4">
+ <layout class="QHBoxLayout" name="_4">
<item>
+ <widget class="KListWidget" name="LensList"/>
+ </item>
+ <item>
<layout class="QVBoxLayout" name="verticalLayout3">
<item>
<layout class="QFormLayout" name="formLayout3">
@@ -327,9 +350,16 @@
</spacer>
</item>
<item>
+ <widget class="QPushButton" name="NewLens">
+ <property name="text">
+ <string>Add New..</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="AddLens">
<property name="text">
- <string>Add Lens</string>
+ <string>Save Lens</string>
</property>
</widget>
</item>
@@ -343,8 +373,11 @@
<attribute name="title">
<string>Filter</string>
</attribute>
- <layout class="QVBoxLayout" name="_5">
+ <layout class="QHBoxLayout" name="_5">
<item>
+ <widget class="KListWidget" name="FilterList"/>
+ </item>
+ <item>
<layout class="QVBoxLayout" name="verticalLayout4">
<item>
<layout class="QFormLayout" name="formLayout4">
@@ -419,9 +452,16 @@
</spacer>
</item>
<item>
+ <widget class="QPushButton" name="NewFilter">
+ <property name="text">
+ <string>Add New..</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="AddFilter">
<property name="text">
- <string>Add Filter</string>
+ <string>Save Filter</string>
</property>
</widget>
</item>
@@ -437,6 +477,11 @@
</widget>
<customwidgets>
<customwidget>
+ <class>KListWidget</class>
+ <extends>QListWidget</extends>
+ <header>klistwidget.h</header>
+ </customwidget>
+ <customwidget>
<class>KDoubleNumInput</class>
<extends>QWidget</extends>
<header>knuminput.h</header>
More information about the Kstars-devel
mailing list