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

Prakash Mohan prak902000 at gmail.com
Thu May 28 08:19:40 CEST 2009


SVN commit 973898 by prakash:

Implementing the update of date and location for the Observing List.

CCMAIL: kstars-devel at kde.org


 M  +90 -56    observinglist.cpp  
 M  +10 -2     observinglist.h  
 M  +36 -14    observinglist.ui  


--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #973897:973898
@@ -47,6 +47,7 @@
 #include "obslistwizard.h"
 #include "kstars.h"
 #include "kstarsdata.h"
+#include "dialogs/locationdialog.h"
 #include "skyobjects/skyobject.h"
 #include "skyobjects/starobject.h"
 #include "skymap.h"
@@ -87,6 +88,8 @@
     setMainWidget( ui );
     setCaption( i18n( "Observing List" ) );
     setButtons( KDialog::Close );
+    dt = KStarsDateTime::currentDateTime();
+    geo = ks->geo();
 
     //Set up the Table Views
     m_Model = new QStandardItemModel( 0, 5, this );
@@ -111,20 +114,19 @@
     ui->SessionView->horizontalHeader()->setStretchLastSection( true );
     ui->SessionView->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
     ksal = KSAlmanac::Instance();
-    ksal->setLocation(ks->geo());
+    ksal->setLocation(geo);
     ui->View->setSunRiseSetTimes(ksal->getSunRise(),ksal->getSunSet());
     ui->View->setLimits( -12.0, 12.0, -90.0, 90.0 );
     ui->View->axis(KPlotWidget::BottomAxis)->setTickLabelFormat( 't' );
     ui->View->axis(KPlotWidget::BottomAxis)->setLabel( i18n( "Local Time" ) );
     ui->View->axis(KPlotWidget::TopAxis)->setTickLabelFormat( 't' );
     ui->View->axis(KPlotWidget::TopAxis)->setTickLabelsShown( true );
-
+    ui->DateEdit->setDate(dt.date());
+    ui->SetLocation->setText( geo -> fullName() );
     //Connections
     connect( this, SIGNAL( closeClicked() ), this, SLOT( slotClose() ) );
     connect( ui->TableView, SIGNAL( doubleClicked( const QModelIndex& ) ),
              this, SLOT( slotCenterObject() ) );
-    connect( ui->SessionView, SIGNAL( doubleClicked( const QModelIndex& ) ),
-             this, SLOT( slotCenterObject() ) );
     connect( ui->TableView->selectionModel(), 
             SIGNAL( selectionChanged(const QItemSelection&, const QItemSelection&) ),
             this, SLOT( slotNewSelection() ) );
@@ -160,6 +162,10 @@
              this, SLOT( slotWizard() ) );
     connect( ui->MiniButton, SIGNAL( clicked() ),
              this, SLOT( slotToggleSize() ) );
+    connect( ui->SetLocation, SIGNAL( clicked() ),
+             this, SLOT( slotLocation() ) );
+    connect( ui->Update, SIGNAL( clicked() ),
+             this, SLOT( slotUpdate() ) );
     connect( ui->tabWidget, SIGNAL( currentChanged(int) ),
              this, SLOT( slotChangeTab(int) ) );
     //Add icons to Push Buttons
@@ -177,9 +183,9 @@
     ui->NotesLabel->setEnabled( false );
     ui->NotesEdit->setEnabled( false );
     ui->AddToSession->setEnabled( false );
-    ui->SetDate->hide();
-    ui->SetLocation->hide();
-    ui->timeEdit->hide();
+//    ui->SetDate->hide();
+//    ui->SetLocation->hide();
+//    ui->timeEdit->hide();
 
     slotLoadWishList();
     //Hide the MiniButton until I can figure out how to resize the Dialog!
@@ -226,12 +232,19 @@
     if(flag) {
         m_ObservingList.append( obj );
         m_CurrentObject = obj;
-        QList<QStandardItem*> itemList,i;
-        itemList << new QStandardItem( obj->translatedName() ) 
-                << new QStandardItem( obj->ra()->toHMSString() ) 
-                << new QStandardItem( obj->dec()->toDMSString() ) 
-                << new QStandardItem( smag )
-                << new QStandardItem( obj->typeName() );
+        QList<QStandardItem*> itemList;
+        if(obj->name() == "star" )
+            itemList << new QStandardItem( obj->translatedName() ) 
+                    << new QStandardItem( obj->ra0()->toHMSString() ) 
+                    << new QStandardItem( obj->dec0()->toDMSString() ) 
+                    << new QStandardItem( smag )
+                    << new QStandardItem( obj->typeName() );
+        else
+            itemList << new QStandardItem( obj->translatedName() ) 
+                    << new QStandardItem( obj->recomputeCoords(dt,geo).ra()->toHMSString() ) 
+                    << new QStandardItem( obj->recomputeCoords(dt,geo).dec()->toDMSString() ) 
+                    << new QStandardItem( smag )
+                    << new QStandardItem( obj->typeName() );
         m_Model->appendRow( itemList );
         //Note addition in statusbar
         ks->statusBar()->changeItem( i18n( "Added %1 to observing list.", obj->name() ), 0 );
@@ -242,20 +255,28 @@
     if( session )
     {
         m_SessionList.append(obj);
-        QList<QStandardItem*> itemList,i;
-        itemList << new QStandardItem( obj->translatedName() ) 
-                << new QStandardItem( obj->ra()->toHMSString() ) 
-                << new QStandardItem( obj->dec()->toDMSString() ) 
-                << new QStandardItem( smag )
-                << new QStandardItem( obj->typeName() );
+        QList<QStandardItem*> itemList;
+        if(obj->name() == "star" )
+            itemList << new QStandardItem( obj->translatedName() ) 
+                    << new QStandardItem( obj->ra0()->toHMSString() ) 
+                    << new QStandardItem( obj->dec0()->toDMSString() ) 
+                    << new QStandardItem( smag )
+                    << new QStandardItem( obj->typeName() );
+        else
+            itemList << new QStandardItem( obj->translatedName() ) 
+                    << new QStandardItem( obj->recomputeCoords(dt,geo).ra()->toHMSString() ) 
+                    << new QStandardItem( obj->recomputeCoords(dt,geo).dec()->toDMSString() ) 
+                    << new QStandardItem( smag )
+                    << new QStandardItem( obj->typeName() );
         m_Session->appendRow( itemList );
         if ( ! isModified ) isModified = true;
         ui->SessionView->resizeColumnsToContents();
+        ks->statusBar()->changeItem( i18n( "Added %1 to session list.", obj->name() ), 0 );
     }
 }
 
-void ObservingList::slotRemoveObject( SkyObject *o ) {
-    bool session = false;
+void ObservingList::slotRemoveObject( SkyObject *o, bool session, bool update ) {
+    
     if ( !o )
         o = ks->map()->clickedObject();
     else
@@ -302,7 +323,7 @@
        
         ui->View->removeAllPlotObjects();
         ui->TableView->resizeColumnsToContents();
-        slotSaveList();
+        if(!update) slotSaveList();
     } else {
         int k = SessionList().indexOf( o );
         if ( k < 0 ) return; //object not in observing list
@@ -679,7 +700,7 @@
 //Should have one window whose target object changes with selection
 void ObservingList::slotDetails() {
     if ( currentObject() ) {
-        QPointer<DetailDialog> dd = new DetailDialog( currentObject(), ks->data()->lt(), ks->geo(), ks );
+        QPointer<DetailDialog> dd = new DetailDialog( currentObject(), ks->data()->lt(), geo, ks );
         dd->exec();
 	delete dd;
     }
@@ -971,17 +992,17 @@
 void ObservingList::plot( SkyObject *o ) {
     if( !o ) return;
     float DayOffset = 0;
-    if (KStarsDateTime::currentDateTime().time().hour() > 12 )
+    if ( o->transitTime( dt, geo ).hour() > 12 )
         DayOffset = 1;
-    KStarsDateTime ut = KStarsDateTime::currentDateTime();
+    KStarsDateTime ut = dt;
     ut.setTime(QTime());
-    ut = ks->geo()->LTtoUT(ut);
+    ut = geo->LTtoUT(ut);
     ut = ut.addSecs( (0.5+DayOffset)*86400.0 );
-    double h1 = ks->geo()->GSTtoLST( ut.gst() ).Hours();
+    double h1 = geo->GSTtoLST( ut.gst() ).Hours();
     if ( h1 > 12.0 ) h1 -= 24.0;
     double h2 = h1 + 24.0;
     ui->View->setSecondaryLimits( h1, h2, -90.0, 90.0 );
-    ksal->setLocation(ks->geo());
+    ksal->setLocation(geo);
     ui->View->setSunRiseSetTimes(ksal->getSunRise(),ksal->getSunSet());
     ui->View->update();
     KPlotObject *po = new KPlotObject( Qt::white, KPlotObject::Lines, 2.0 );
@@ -992,12 +1013,12 @@
     ui->View->addPlotObject( po );
 }
 double ObservingList::findAltitude( SkyPoint *p, double hour ) {
-    KStarsDateTime ut = KStarsDateTime::currentDateTime();
+    KStarsDateTime ut = dt;
     ut.setTime(QTime());
-    ut = ks->geo()->LTtoUT(ut);
+    ut = geo->LTtoUT(ut);
     ut= ut.addSecs( hour*3600.0 );
-    dms LST = ks->geo()->GSTtoLST( ut.gst() );
-    p->EquatorialToHorizontal( &LST, ks->geo()->lat() );
+    dms LST = geo->GSTtoLST( ut.gst() );
+    p->EquatorialToHorizontal( &LST, geo->lat() );
     return p->alt()->Degrees();
 }
 
@@ -1076,31 +1097,44 @@
     }
 }
 
-void ObservingList::slotChangeTab(int index)
-{
-    if(index) {
-        ui->SetDate->show();
-        ui->SetLocation->show();
-        ui->timeEdit->show();
-    } else {
-        ui->SetDate->hide();
-        ui->SetLocation->hide();
-        ui->timeEdit->hide();
+void ObservingList::slotChangeTab(int index) {
+    ui->CenterButton->setEnabled( false );
+    ui->ScopeButton->setEnabled( false );
+    ui->DetailsButton->setEnabled( false );
+    ui->AVTButton->setEnabled( false );
+    ui->RemoveButton->setEnabled( false );
+    ui->NotesLabel->setText( i18n( "Select an object to record notes on it here:" ) );
+    ui->NotesLabel->setEnabled( false );
+    ui->NotesEdit->setEnabled( false );
+    ui->AddToSession->setEnabled( false );
+    m_CurrentObject = 0;
+
+    //Clear the user log text box.
+    saveCurrentUserLog();
+    ui->NotesEdit->setPlainText("");
+    ui->View->removeAllPlotObjects();
+}
+void ObservingList::slotLocation() {
+    LocationDialog ld( (KStars*) topLevelWidget()->parent() );
+
+    if ( ld.exec() == QDialog::Accepted ) {
+        geo = ld.selectedCity();
+        ui->SetLocation -> setText( geo -> fullName() );
     }
-        ui->CenterButton->setEnabled( false );
-        ui->ScopeButton->setEnabled( false );
-        ui->DetailsButton->setEnabled( false );
-        ui->AVTButton->setEnabled( false );
-        ui->RemoveButton->setEnabled( false );
-        ui->NotesLabel->setText( i18n( "Select an object to record notes on it here:" ) );
-        ui->NotesLabel->setEnabled( false );
-        ui->NotesEdit->setEnabled( false );
-        ui->AddToSession->setEnabled( false );
-        m_CurrentObject = 0;
+}
 
-        //Clear the user log text box.
-        saveCurrentUserLog();
-        ui->NotesEdit->setPlainText("");
-        ui->View->removeAllPlotObjects();
+void ObservingList::slotUpdate() {
+    dt.setDate( ui->DateEdit->date() );
+    ui->View->removeAllPlotObjects();
+    //Creating a copy of the lists, we can't use the original lists as they'll keep getting modified as the loop iterates
+    QList<SkyObject*> _obsList=m_ObservingList, _SessionList=m_SessionList;
+    foreach ( SkyObject *o, _obsList ) {
+        slotRemoveObject( o, false, true );
+        slotAddObject( o, false, true );
+    }
+    foreach ( SkyObject *obj, _SessionList ) {
+        slotRemoveObject( obj, true );
+        slotAddObject( obj, true, true );
+    }
 }
 #include "observinglist.moc"
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #973897:973898
@@ -24,11 +24,15 @@
 
 #include "skyobjects/skyobject.h"
 #include "ui_observinglist.h"
+#include "kstarsdatetime.h"
+#include "geolocation.h"
 #include "ksalmanac.h"
 class KSAlmanac;
 class QSortFilterProxyModel;
 class QStandardItemModel;
 class KStars;
+class KStarsDateTime;
+class GeoLocation;
 class ObservingListUI : public QFrame, public Ui::ObservingList {
     Q_OBJECT
 
@@ -124,7 +128,7 @@
         *@p o pointer to the SkyObject to be removed.
         *Use SkyMap::clickedObject() if o is NULL (default)
         */
-    void slotRemoveObject( SkyObject *o=NULL );
+    void slotRemoveObject( SkyObject *o=NULL, bool session=false, bool update=false );
 
     /**@short center the selected object in the display
         */
@@ -202,7 +206,10 @@
     double findAltitude( SkyPoint *p, double hour=0);
 
     void slotChangeTab(int index);
+    
+    void slotLocation();
 
+    void slotUpdate();
 protected slots:
     void slotClose();
 
@@ -216,7 +223,8 @@
     uint noNameStars;
     bool isModified, bIsLarge;
     QString ListName, FileName, SessionName;
-
+    KStarsDateTime dt;
+    GeoLocation *geo;
     QStandardItemModel *m_Model, *m_Session;
     QSortFilterProxyModel *m_SortModel, *m_SortModelSession;
 };
--- branches/kstars/summer/kstars/kstars/tools/observinglist.ui #973897:973898
@@ -378,13 +378,6 @@
       <number>0</number>
      </property>
      <item>
-      <widget class="QPushButton" name="SetDate">
-       <property name="text">
-        <string>Set Date</string>
-       </property>
-      </widget>
-     </item>
-     <item>
       <widget class="QPushButton" name="SetLocation">
        <property name="text">
         <string>Set Location</string>
@@ -392,12 +385,12 @@
       </widget>
      </item>
      <item>
-      <widget class="QTimeEdit" name="timeEdit">
-       <property name="maximumSize">
-        <size>
-         <width>100</width>
-         <height>30</height>
-        </size>
+      <widget class="QDateEdit" name="DateEdit"/>
+     </item>
+     <item>
+      <widget class="QPushButton" name="Update">
+       <property name="text">
+        <string>Update</string>
        </property>
       </widget>
      </item>
@@ -469,7 +462,7 @@
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>750</width>
+         <width>661</width>
          <height>170</height>
         </rect>
        </property>
@@ -498,6 +491,35 @@
         <bool>true</bool>
        </property>
       </widget>
+      <widget class="QTimeEdit" name="TimeEdit">
+       <property name="geometry">
+        <rect>
+         <x>660</x>
+         <y>70</y>
+         <width>100</width>
+         <height>27</height>
+        </rect>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>100</width>
+         <height>30</height>
+        </size>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label">
+       <property name="geometry">
+        <rect>
+         <x>673</x>
+         <y>50</y>
+         <width>71</width>
+         <height>20</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>Set Time:</string>
+       </property>
+      </widget>
      </widget>
     </widget>
    </item>


More information about the Kstars-devel mailing list