[Kstars-devel] [kstars] kstars: Fix flag manager and component handling of different epochs. Now the original epoch is stored in the database.

Jasem Mutlaq mutlaqja at ikarustech.com
Sat Feb 21 09:38:08 UTC 2015


Git commit e0f94fa84e34eae0b74b1ce0f3f438b9c2ce9b60 by Jasem Mutlaq.
Committed on 21/02/2015 at 09:35.
Pushed by mutlaqja into branch 'master'.

Fix flag manager and component handling of different epochs. Now the original epoch is stored in the database.
Also using QStandardPaths to display the location where of custom flag files instead of hardcoding it.
BUGS:344375
FIXED-IN:15.04
CCMAIL:kstars-devel at kde.org

M  +39   -2    kstars/skycomponents/flagcomponent.cpp
M  +17   -7    kstars/skycomponents/flagcomponent.h
M  +1    -1    kstars/skymap.cpp
M  +3    -0    kstars/tools/flagmanager.cpp
M  +2    -2    kstars/tools/flagmanager.ui

http://commits.kde.org/kstars/e0f94fa84e34eae0b74b1ce0f3f438b9c2ce9b60

diff --git a/kstars/skycomponents/flagcomponent.cpp b/kstars/skycomponents/flagcomponent.cpp
index e1e2bc8..028f05c 100644
--- a/kstars/skycomponents/flagcomponent.cpp
+++ b/kstars/skycomponents/flagcomponent.cpp
@@ -82,7 +82,14 @@ void FlagComponent::loadFromFile() {
         // Read coordinates
         dms r( flagEntry.at( 0 ) );
         dms d( flagEntry.at( 1 ) );
+
+        m_EpochCoords.append(qMakePair(r.Degrees(), d.Degrees()));
+
         SkyPoint* flagPoint = new SkyPoint( r, d );
+
+        // Convert to JNow
+        toJNow(flagPoint, flagEntry.at( 2 ));
+
         pointList().append( flagPoint );
 
         // Read epoch
@@ -128,8 +135,8 @@ void FlagComponent::saveToFile() {
     KStarsData::Instance()->userdb()->EraseAllFlags();
 
     for ( int i=0; i < size(); ++i ) {
-        KStarsData::Instance()->userdb()->AddFlag(QString::number( pointList().at( i )->ra0().Degrees() ),
-                                                  QString::number( pointList().at( i )->dec0().Degrees() ),
+        KStarsData::Instance()->userdb()->AddFlag(QString::number(epochCoords(i).first) ,
+                                                  QString::number(epochCoords(i).second),
                                                   epoch ( i ),
                                                   imageName( i ).replace( ' ', '_' ),
                                                   label( i ),
@@ -138,6 +145,12 @@ void FlagComponent::saveToFile() {
 }
 
 void FlagComponent::add( SkyPoint* flagPoint, QString epoch, QString image, QString label, QColor labelColor ) {
+
+    //JM 2015-02-21: Insert original coords in list and convert skypint to JNow
+    m_EpochCoords.append(qMakePair(flagPoint->ra().Degrees(), flagPoint->dec().Degrees()));
+
+    toJNow(flagPoint, epoch);
+
     pointList().append( flagPoint );
     m_Epoch.append( epoch );
 
@@ -157,6 +170,7 @@ void FlagComponent::remove( int index ) {
     }
 
     pointList().removeAt( index );
+    m_EpochCoords.removeAt(index);
     m_Epoch.removeAt( index );
     m_FlagImages.removeAt( index );
     m_Labels.removeAt( index );
@@ -171,6 +185,11 @@ void FlagComponent::updateFlag( int index, SkyPoint *flagPoint, QString epoch, Q
         return;
     }
     delete pointList().at( index );
+
+    m_EpochCoords.replace(index, qMakePair(flagPoint->ra().Degrees(), flagPoint->dec().Degrees()));
+
+    toJNow(flagPoint, epoch);
+
     pointList().replace( index, flagPoint);
 
     m_Epoch.replace( index, epoch );
@@ -302,3 +321,21 @@ QImage FlagComponent::imageList( int index ) {
 
     return m_Images.at( index );
 }
+
+void FlagComponent::toJNow(SkyPoint *p, QString epoch)
+{
+    KStarsDateTime dt;
+    dt.setFromEpoch(epoch);
+
+    p->apparentCoord(dt.djd(), KStarsData::Instance()->ut().djd());
+}
+
+QPair<double, double> FlagComponent::epochCoords(int index)
+{
+    if ( index > m_FlagImages.size() - 1 ) {
+         QPair<double, double> coord = qMakePair(0,0);
+         return coord;
+    }
+
+    return m_EpochCoords.at(index);
+}
diff --git a/kstars/skycomponents/flagcomponent.h b/kstars/skycomponents/flagcomponent.h
index ca59131..957cc1b 100644
--- a/kstars/skycomponents/flagcomponent.h
+++ b/kstars/skycomponents/flagcomponent.h
@@ -129,6 +129,13 @@ public:
      */
     QImage imageList( int index );
 
+    /**
+     * @brief epochCoords return coordinates recorded in original epoch
+     * @param index index of the flag
+     * @return pair of RA/DEC in original epoch
+     */
+    QPair<double, double> epochCoords(int index);
+
     /** @short Get list of flag indexes near specified SkyPoint with radius specified in pixels.
       *@param point central SkyPoint.
       *@param pixelRadius radius in pixels.
@@ -142,13 +149,16 @@ public:
     void saveToFile();
 
 private:
-    QStringList         m_Epoch;        /**< List of epochs                */
-    QList<int>          m_FlagImages;   /**< List of image index           */
-    QStringList         m_Labels;       /**< List of label                 */
-    QList<QColor>       m_LabelColors;  /**< List of label colors          */
-    QStringList         m_Names;        /**< List of image names           */
-    QList<QImage>       m_Images;       /**< List of flag images           */
-    KIO::ListJob*       m_Job;          /**< Used to list user's directory */
+    void toJNow(SkyPoint *p, QString epoch);
+
+    QStringList                     m_Epoch;        /**< List of epochs                  */
+    QList<QPair<double, double>>    m_EpochCoords;  /**< RA/DEC stored in original Epoch */
+    QList<int>                      m_FlagImages;   /**< List of image index             */
+    QStringList                     m_Labels;       /**< List of label                   */
+    QList<QColor>                   m_LabelColors;  /**< List of label colors            */
+    QStringList                     m_Names;        /**< List of image names             */
+    QList<QImage>                   m_Images;       /**< List of flag images             */
+    KIO::ListJob*                   m_Job;          /**< Used to list user's directory   */
 
 private slots:
     void slotLoadImages( KIO::Job* job, const KIO::UDSEntryList& list );
diff --git a/kstars/skymap.cpp b/kstars/skymap.cpp
index 0f6fe5c..343afda 100644
--- a/kstars/skymap.cpp
+++ b/kstars/skymap.cpp
@@ -600,7 +600,7 @@ void SkyMap::slotAddFlag() {
     // popup FlagManager window and update coordinates
     ks->slotFlagManager();
     ks->flagManager()->clearFields();
-    ks->flagManager()->setRaDec( clickedPoint()->ra(), clickedPoint()->dec() );
+    ks->flagManager()->setRaDec( clickedPoint()->ra0(), clickedPoint()->dec0() );
 }
 
 void SkyMap::slotEditFlag( int flagIdx ) {
diff --git a/kstars/tools/flagmanager.cpp b/kstars/tools/flagmanager.cpp
index e5830ec..6048c2d 100644
--- a/kstars/tools/flagmanager.cpp
+++ b/kstars/tools/flagmanager.cpp
@@ -66,6 +66,9 @@ FlagManager::FlagManager( QWidget *ks )
 
     m_Ks = KStars::Instance();
 
+    ui->hintLabel->setText(xi18n("To add custom icons, just add images in %1. File names must begin with flags"
+                                 "For example, the file <i>flagSmall_red_cross.gif</i> will be shown as <i>Small red cross</i> in the combo box.",
+                                 QStandardPaths::writableLocation(QStandardPaths::DataLocation)));
     //Set up the Table Views
     m_Model = new QStandardItemModel( 0, 5, this );
     m_Model->setHorizontalHeaderLabels( QStringList() << xi18nc( "Right Ascension", "RA" ) 
diff --git a/kstars/tools/flagmanager.ui b/kstars/tools/flagmanager.ui
index fc8d09e..fdb821b 100644
--- a/kstars/tools/flagmanager.ui
+++ b/kstars/tools/flagmanager.ui
@@ -162,9 +162,9 @@
     </layout>
    </item>
    <item>
-    <widget class="QLabel" name="label_3">
+    <widget class="QLabel" name="hintLabel">
      <property name="text">
-      <string>To add custom icons, just add images in $HOME/.kde/share/apps/kstars. File names must begin with "_flags". For example, the file "_flagSmall_red_cross.gif" will be shown as "Small red cross" in the combo box.</string>
+      <string/>
      </property>
      <property name="wordWrap">
       <bool>true</bool>


More information about the Kstars-devel mailing list