[kde-doc-english] [kstars] kstars: Remove the notion of temp images in Obs. Planner. All images are saved.

Akarsh Simha akarsh at kde.org
Mon Jan 11 01:58:46 UTC 2016


Git commit c508d6ea4183a87eb5395747b89a3adf62c8ead6 by Akarsh Simha.
Committed on 11/01/2016 at 01:58.
Pushed by asimha into branch 'master'.

Remove the notion of temp images in Obs. Planner. All images are saved.

The concept of temporary images that are deleted upon exit seems both
counter-intuitive and superfluous. This commit gets rid of the concept
of temp images. Images that are downloaded in the observing list are
now saved on disk, and may be deleted either individually by clicking
the "Delete" button, or collectively by clicking the "Delete all
Images" button.

This change is NOT backwards-compatible. Any DSS images that were
saved as Temp_Image_<Obj. Name> are no longer visible / available in
KStars. In fact, they must be manually deleted from the disk by
opening the appropriate directory.

This backwards-incompatibility is partly intentional, since we
introduced the idea of DSS metadata. In any case, it would be wise to
re-download the DSS images with proper metadata so that features like
eyepiece view, and in future, DSS overlay work correctly without
trouble.

CCMAIL: kstars-devel at kde.org
GUI: GUI elements / config. options have been removed.

M  +0    -5    kstars/kstars.kcfg
M  +0    -4    kstars/kstarsactions.cpp
M  +0    -1    kstars/kstarsdbus.cpp
M  +0    -13   kstars/options/opsadvanced.ui
M  +14   -62   kstars/tools/observinglist.cpp
M  +3    -13   kstars/tools/observinglist.h
M  +0    -13   kstars/tools/observinglist.ui

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

diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index 5ea6298..6cdbca0 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -745,11 +745,6 @@
       <whatsthis>Objects in the observing list will be highlighted with a colored name label in the map.</whatsthis>
       <default>false</default>
     </entry>
-    <entry name="ObsListSaveImage" type="Bool">
-      <label>Save the DSS/SDSS images to disk</label>
-      <whatsthis>The images of objects in the observing list will be autosaved if you download them</whatsthis>
-      <default>false</default>
-    </entry>
     <entry name="ObsListPreferDSS" type="Bool">
       <label>Prefer Digitized Sky Survey imagery in the observing list</label>
       <whatsthis>The observing list will prefer DSS imagery while downloading imagery.</whatsthis>
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index a09dc31..f650daa 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -1388,10 +1388,6 @@ void KStars::slotAboutToQuit()
     //synch the config file with the Config object
     writeConfig();
 
-    if( !Options::obsListSaveImage() ) {
-        foreach ( const QString& file, m_KStarsData->observingList()->imageList() )
-            QFile::remove( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + file ) ;
-    }
 }
 
 void KStars::slotShowPositionBar(SkyPoint* p )
diff --git a/kstars/kstarsdbus.cpp b/kstars/kstarsdbus.cpp
index 8eb777d..64114c9 100644
--- a/kstars/kstarsdbus.cpp
+++ b/kstars/kstarsdbus.cpp
@@ -331,7 +331,6 @@ void KStars::changeViewOption( const QString &op, const QString &val ) {
     if ( op == "ShowPlanetNames"    && bOk ) Options::setShowPlanetNames(    bVal );
     if ( op == "ShowPlanetImages"   && bOk ) Options::setShowPlanetImages(   bVal );
     if ( op == "HideOnSlew"  && bOk ) Options::setHideOnSlew(  bVal );
-    if ( op == "ObsListSaveImage"  && bOk ) Options::setObsListSaveImage(  bVal );
     if ( op == "HideStars"   && bOk ) Options::setHideStars(   bVal );
     if ( op == "HidePlanets" && bOk ) Options::setHidePlanets( bVal );
     if ( op == "HideMessier" && bOk ) Options::setHideMessier( bVal );
diff --git a/kstars/options/opsadvanced.ui b/kstars/options/opsadvanced.ui
index a1c9689..bc1e488 100644
--- a/kstars/options/opsadvanced.ui
+++ b/kstars/options/opsadvanced.ui
@@ -731,19 +731,6 @@
         </widget>
        </item>
        <item>
-        <widget class="QCheckBox" name="kcfg_ObsListSaveImage">
-         <property name="toolTip">
-          <string>Save the downloaded DSS/SDSS images?</string>
-         </property>
-         <property name="whatsThis">
-          <string>Do you want the downloaded DSS/SDSS images to be saved when closing the observing list?</string>
-         </property>
-         <property name="text">
-          <string>Save downloaded images on exit</string>
-         </property>
-        </widget>
-       </item>
-       <item>
         <widget class="QGroupBox" name="ObsListImageryOptions">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index d66d770..17bd397 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -190,8 +190,6 @@ ObservingList::ObservingList()
              this, SLOT( slotLocation() ) );
     connect( ui->Update, SIGNAL( clicked() ),
              this, SLOT( slotUpdate() ) );
-    connect( ui->SaveImage, SIGNAL( clicked() ),
-             this, SLOT( slotSaveImage() ) );
     connect( ui->DeleteImage, SIGNAL( clicked() ),
              this, SLOT( slotDeleteCurrentImage() ) );
     connect( ui->SearchImage, SIGNAL( clicked() ),
@@ -220,7 +218,6 @@ ObservingList::ObservingList()
     ui->TimeEdit->setEnabled( false );
     ui->SearchImage->setEnabled( false );
     ui->saveImages->setEnabled( false );
-    ui->SaveImage->setEnabled( false );
     ui->DeleteImage->setEnabled( false );
     ui->OALExport->setEnabled( false );
 
@@ -451,7 +448,6 @@ void ObservingList::slotNewSelection() {
     QModelIndexList selectedItems;
     QString newName;
     SkyObject *o;
-    ui->SaveImage->setEnabled( false );
     ui->DeleteImage->setEnabled( false );
 
     selectedItems = getActiveSortModel()->mapSelectionToSource( getActiveView()->selectionModel()->selection() ).indexes();
@@ -517,8 +513,6 @@ void ObservingList::slotNewSelection() {
             if( QFile( ImagePath = BasePath + CurrentImage ).exists() )  {
                 ;
             }
-            else if( QFile( ImagePath = BasePath + "Temp_" + CurrentImage ).exists() ) 
-                ;
             else
                 ImagePath = QString();
             if( !ImagePath.isEmpty() ) {//If the image is present, show it!
@@ -532,7 +526,6 @@ void ObservingList::slotNewSelection() {
                 else
                     ui->dssMetadataLabel->setText( i18n( "No image info available." ) );
                 ui->ImagePreview->show();
-                ui->SaveImage->setEnabled( false );
                 ui->DeleteImage->setEnabled( true );
             }
             else
@@ -677,8 +670,6 @@ void ObservingList::slotEyepieceView() {
         m_epf = new EyepieceField( this );
     if( QFile::exists( CurrentImagePath ) )
         imagePath = CurrentImagePath;
-    else if( QFile::exists( CurrentTempPath ) )
-        imagePath = CurrentTempPath;
 
     KStarsData *data = KStarsData::Instance();
     bool ok = true;
@@ -1060,7 +1051,6 @@ void ObservingList::slotChangeTab(int index) {
     ui->TimeEdit->setEnabled( false );
     ui->SetTime->setEnabled( false );
     ui->SearchImage->setEnabled( false );
-    ui->SaveImage->setEnabled( false );
     ui->DeleteImage->setEnabled( false );
     m_CurrentObject = 0;
     sessionView     = index != 0;
@@ -1133,31 +1123,20 @@ void ObservingList::slotCustomDSS() {
 
 }
 
-void ObservingList::slotGetImage( bool _dss, const SkyObject *o, bool temp ) {
+void ObservingList::slotGetImage( bool _dss, const SkyObject *o ) {
     dss = _dss;
     if( !o )
         o = currentObject();
     ui->SearchImage->setEnabled( false );
     ui->ImagePreview->clearPreview();
     if( ! QFile::exists( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + CurrentImage ) )  // FIXME: Might have issues on Windows with using '/'
-        setCurrentImage( o, temp );
+        setCurrentImage( o );
     QFile::remove( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + CurrentImage ) ;
     QUrl url;
     dss = true;
     qDebug() << "FIXME: Removed support for SDSS. Until reintroduction, we will supply a DSS image";
-    /*
-    if( dss ) {
-        url.setUrl( DSSUrl );
-    } else {
-        url.setUrl( SDSSUrl );
-    }
-    */
     KSDssDownloader *dler = new KSDssDownloader( o, QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + CurrentImage );
     connect( dler, SIGNAL( downloadComplete( bool ) ), SLOT( downloadReady( bool ) ) );
-    /*
-    downloadJob = KIO::copy ( url, fileURL ) ;
-    connect ( downloadJob, SIGNAL ( result (KJob *) ), SLOT ( downloadReady() ) );
-    */
 }
 
 void ObservingList::downloadReady( bool success ) {
@@ -1180,10 +1159,6 @@ void ObservingList::downloadReady( bool success ) {
         saveThumbImage();
         ui->ImagePreview->show();
         ui->ImagePreview->setCursor( Qt::PointingHandCursor );
-        if( CurrentImage.contains( "Temp" ) ) {
-            ImageList.append( CurrentImage );
-            ui->SaveImage->setEnabled( true );
-        }
         ui->DeleteImage->setEnabled( true );
     }
     /*
@@ -1193,42 +1168,34 @@ void ObservingList::downloadReady( bool success ) {
     */
 }
 
-void ObservingList::setCurrentImage( const SkyObject *o, bool temp  ) {
+void ObservingList::setCurrentImage( const SkyObject *o  ) {
     // TODO: Remove code duplication -- we have the same stuff
     // implemented in SkyMap::slotDSS in skymap.cpp; must try to
     // de-duplicate as much as possible.
 
-    if( temp )
-        CurrentImage = "Temp_Image_" +  o->name().remove(' ');
-    else
-        CurrentImage = "Image_" +  o->name().remove(' ');
+    CurrentImage = "Image_" +  o->name().remove(' ');
     ThumbImage = "thumb-" + o->name().toLower().remove(' ') + ".png";
     if( o->name() == "star" ) {
         QString RAString( o->ra0().toHMSString() );
         QString DecString( o->dec0().toDMSString() );
-        if( temp )
-            CurrentImage = "Temp_Image" + RAString.remove(' ') + DecString.remove(' ');
-        else
-            CurrentImage = "Image" + RAString.remove(' ') + DecString.remove(' ');
+        CurrentImage = "Image" + RAString.remove(' ') + DecString.remove(' ');
         QChar decsgn = ( (o->dec0().Degrees() < 0.0 ) ? '-' : '+' );
         CurrentImage = CurrentImage.remove('+').remove('-') + decsgn;
     }
     CurrentImagePath = QStandardPaths::locate( QStandardPaths::DataLocation , CurrentImage );
-    CurrentTempPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "Temp_" + CurrentImage ; // FIXME: Eh? -- asimha
     DSSUrl = KSDssDownloader::getDSSURL( o );
-    QString UrlPrefix("http://casjobs.sdss.org/ImgCutoutDR6/getjpeg.aspx?"); // FIXME: Upgrade to use SDSS Data Release 9 / 10. DR6 is well outdated.
-    QString UrlSuffix("&scale=1.0&width=600&height=600&opt=GST&query=SR(10,20)");
+    // QString UrlPrefix("http://casjobs.sdss.org/ImgCutoutDR6/getjpeg.aspx?"); // FIXME: Upgrade to use SDSS Data Release 9 / 10. DR6 is well outdated.
+    // QString UrlSuffix("&scale=1.0&width=600&height=600&opt=GST&query=SR(10,20)");
 
-    QString RA, Dec;
-    RA = RA.sprintf( "ra=%f", o->ra0().Degrees() );
-    Dec = Dec.sprintf( "&dec=%f", o->dec0().Degrees() );
+    // QString RA, Dec;
+    // RA = RA.sprintf( "ra=%f", o->ra0().Degrees() );
+    // Dec = Dec.sprintf( "&dec=%f", o->dec0().Degrees() );
 
-    SDSSUrl = UrlPrefix + RA + Dec + UrlSuffix;
+    // SDSSUrl = UrlPrefix + RA + Dec + UrlSuffix;
 }
 
 void ObservingList::slotSaveAllImages() {
     ui->SearchImage->setEnabled( false );
-    ui->SaveImage->setEnabled( false );
     ui->DeleteImage->setEnabled( false );
     m_CurrentObject = 0;
     //Clear the selection in the Tables
@@ -1252,31 +1219,18 @@ void ObservingList::saveImage( QUrl url, QString filename, const SkyObject *o )
     if( !o )
         o = currentObject();
     Q_ASSERT( o );
-    if( ! QFile::exists( CurrentImagePath  ) && ! QFile::exists( CurrentTempPath ) )
+    if( ! QFile::exists( CurrentImagePath  ) )
     {
         // Call the DSS downloader
-        slotGetImage( true, o, true );
-    } else if( QFile::exists( CurrentTempPath ) )
-    {
-        QFile f( CurrentTempPath );
-        f.rename( CurrentImagePath );
+        slotGetImage( true, o );
     }
 
 }
 
-void ObservingList::slotSaveImage() {
-    setCurrentImage( currentObject() );
-    QFile f( CurrentTempPath);
-    f.rename( CurrentImagePath );
-    ui->SaveImage->setEnabled( false );
-}
-
 void ObservingList::slotImageViewer() {
     ImageViewer *iv = 0;
     if( QFile::exists( CurrentImagePath ) )
         iv = new ImageViewer( CurrentImagePath, this );
-    else if( QFile::exists( CurrentTempPath ) )
-        iv = new ImageViewer( CurrentTempPath, this );
 
     if( iv )
         iv->show();
@@ -1287,7 +1241,6 @@ void ObservingList::slotDeleteAllImages() {
         return;
     ui->ImagePreview->setCursor( Qt::ArrowCursor );
     ui->SearchImage->setEnabled( false );
-    ui->SaveImage->setEnabled( false );
     ui->DeleteImage->setEnabled( false );
     m_CurrentObject = 0;
     //Clear the selection in the Tables
@@ -1318,7 +1271,7 @@ bool ObservingList::eventFilter( QObject *obj, QEvent *event ) {
     if( obj == ui->ImagePreview ) {
         if( event->type() == QEvent::MouseButtonRelease ) {
             if( currentObject() ) {
-                if( ( ( QFile( CurrentImagePath ).size() < 13000 ) && (  QFile( CurrentTempPath ).size() < 13000 ) ) ) { // FIXME: This size estimate is unreliable.
+                if( !QFile::exists( CurrentImagePath ) ) {
                     if( ! currentObject()->isSolarSystem() )
                         slotGetImage( Options::obsListPreferDSS() );
                     else
@@ -1382,7 +1335,6 @@ void ObservingList::slotSearchImage() {
 
 void ObservingList::slotDeleteCurrentImage() {
     QFile::remove( CurrentImagePath );
-    QFile::remove( CurrentTempPath );
     slotNewSelection();
 }
 
diff --git a/kstars/tools/observinglist.h b/kstars/tools/observinglist.h
index c924309..d61f333 100644
--- a/kstars/tools/observinglist.h
+++ b/kstars/tools/observinglist.h
@@ -128,15 +128,10 @@ public:
         */
     double findAltitude( SkyPoint *p, double hour=0);
 
-    /** @short Return the list of downloaded images
-        */
-    QList<QString> imageList() { return ImageList; }
-
     /** @short Sets the image parameters for the current object
         *@p o The passed object for setting the parameters
-        *@p temp A flag to edit the name for temporary images
         */
-    void setCurrentImage( const SkyObject *o, bool temp = false );
+    void setCurrentImage( const SkyObject *o );
 
     /** @short Save the user log text to a file.
         *@note the log is attached to the current object in obsList.
@@ -299,7 +294,7 @@ public slots:
     /** @short Downloads the corresponding DSS or SDSS image from the web and
         *displays it
         */
-    void slotGetImage( bool _dss = false, const SkyObject *o = 0, bool temp=true );
+    void slotGetImage( bool _dss = false, const SkyObject *o = 0 );
 
     void slotSearchImage();
 
@@ -316,10 +311,6 @@ public slots:
         */
     void saveImage( QUrl url , QString filename, const SkyObject *o = 0 );
 
-    /** @short saves the temporary image permanently
-        */
-    void slotSaveImage();
-
     /** @short Shows the image in a ImageViewer window.
         */
     void slotImageViewer();
@@ -394,14 +385,13 @@ private:
     QList<SkyObject*> m_WishList, m_SessionList;
     SkyObject *LogObject, *m_CurrentObject;
     bool isModified, bIsLarge, sessionView, dss, singleSelection, showScope, noSelection;
-    QString FileName, CurrentImage, DSSUrl, SDSSUrl, ThumbImage, CurrentImagePath, CurrentTempPath;
+    QString FileName, CurrentImage, DSSUrl, SDSSUrl, ThumbImage, CurrentImagePath;
     KStarsDateTime dt;
     GeoLocation *geo;
     QStandardItemModel *m_WishListModel, *m_SessionModel;
     QSortFilterProxyModel *m_WishListSortModel, *m_SessionSortModel;
     KIO::Job *downloadJob;  // download job of image -> 0 == no job is running
     QHash<QString, QTime> TimeHash;
-    QList<QString> ImageList;
     ObsListPopupMenu *pmenu;
     EyepieceField *m_epf;
     KSDssDownloader *m_dl;
diff --git a/kstars/tools/observinglist.ui b/kstars/tools/observinglist.ui
index 1dfb1c1..169e1cd 100644
--- a/kstars/tools/observinglist.ui
+++ b/kstars/tools/observinglist.ui
@@ -624,19 +624,6 @@
         <number>12</number>
        </property>
        <item>
-        <widget class="QPushButton" name="SaveImage">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="text">
-          <string>Save</string>
-         </property>
-        </widget>
-       </item>
-       <item>
         <widget class="QPushButton" name="SearchImage">
          <property name="text">
           <string>Find Image</string>



More information about the kde-doc-english mailing list