[Kstars-devel] [kstars] /: Minimizing KStars dependency on KDE's KIO framework. This should help facilitate migration of KStars to other platforms especially for embedded devices where KIO is not available. KIO is still used in several places that are quite unlikely to remain in the desktop

Jasem Mutlaq mutlaqja at ikarustech.com
Sun May 15 16:00:22 UTC 2016


Git commit 2a5cd68a7ce1e9e1462229107853bff30c6d7093 by Jasem Mutlaq.
Committed on 15/05/2016 at 15:57.
Pushed by mutlaqja into branch 'master'.

Minimizing KStars dependency on KDE's KIO framework. This should help facilitate migration of KStars to other platforms especially for embedded devices where KIO is not available. KIO is still used in several places that are quite unlikely to remain in the desktop
version of KStars such as the calculator.

Please test this huge change as it introduce regressions especially on the observation manager and any task that requires any download of any sort.

CCMAIL:kstars-devel at kde.org

M  +1    -1    CMakeLists.txt
M  +1    -0    kstars/CMakeLists.txt
A  +69   -0    kstars/auxiliary/filedownloader.cpp     [License: GPL (v2+)]
A  +49   -0    kstars/auxiliary/filedownloader.h     [License: GPL (v2+)]
M  +42   -24   kstars/auxiliary/imageviewer.cpp
M  +10   -3    kstars/auxiliary/imageviewer.h
M  +63   -40   kstars/auxiliary/ksdssdownloader.cpp
M  +4    -4    kstars/auxiliary/ksdssdownloader.h
M  +1    -1    kstars/fitsviewer/fitshistogram.cpp
M  +1    -1    kstars/fitsviewer/fitsviewer.cpp
M  +1    -1    kstars/indi/opsindi.cpp
M  +16   -3    kstars/kstarsactions.cpp
M  +51   -40   kstars/skycomponents/asteroidscomponent.cpp
M  +13   -3    kstars/skycomponents/asteroidscomponent.h
M  +43   -36   kstars/skycomponents/cometscomponent.cpp
M  +11   -1    kstars/skycomponents/cometscomponent.h
M  +16   -36   kstars/skycomponents/flagcomponent.cpp
M  +1    -6    kstars/skycomponents/flagcomponent.h
M  +35   -10   kstars/skycomponents/satellitescomponent.cpp
M  +3    -1    kstars/skycomponents/satellitescomponent.h
M  +1    -1    kstars/skycomponents/supernovaecomponent.h
M  +1    -1    kstars/tools/modcalcdaylength.cpp
M  +1    -0    kstars/tools/modcalcsidtime.cpp
M  +1    -0    kstars/tools/modcalcvizequinox.cpp
M  +53   -25   kstars/tools/observinglist.cpp
M  +3    -2    kstars/tools/observinglist.h
M  +23   -36   kstars/tools/observinglist.ui
M  +2    -1    kstars/widgets/dmsbox.h

http://commits.kde.org/kstars/2a5cd68a7ce1e9e1462229107853bff30c6d7093

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48065ad..ef7c72f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,7 +16,7 @@ find_package(ECM 1.7.0 REQUIRED NO_MODULE)
 set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
 
-find_package(Qt5 5.4 REQUIRED COMPONENTS Gui Qml Quick Xml Sql Svg PrintSupport)
+find_package(Qt5 5.4 REQUIRED COMPONENTS Gui Qml Quick Xml Sql Svg Network PrintSupport)
 
 include(KDEInstallDirs)
 include(KDECompilerSettings NO_POLICY_SCOPE)
diff --git a/kstars/CMakeLists.txt b/kstars/CMakeLists.txt
index c3611c8..1845fc2 100644
--- a/kstars/CMakeLists.txt
+++ b/kstars/CMakeLists.txt
@@ -438,6 +438,7 @@ set(kstars_extra_SRCS
         auxiliary/kswizard.cpp
         auxiliary/qcustomplot.cpp
         auxiliary/profileinfo.cpp
+        auxiliary/filedownloader.cpp
         time/simclock.cpp
         time/kstarsdatetime.cpp
         time/timezonerule.cpp
diff --git a/kstars/auxiliary/filedownloader.cpp b/kstars/auxiliary/filedownloader.cpp
new file mode 100644
index 0000000..01deb73
--- /dev/null
+++ b/kstars/auxiliary/filedownloader.cpp
@@ -0,0 +1,69 @@
+/*  KStars File Downloader
+ *
+    Copyright (C) 2016 Jasem Mutlaq <mutlaqja at ikarustech.com>
+
+    Adapted from https://wiki.qt.io/Download_Data_from_URL
+
+    This application is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+ */
+
+#include <QFile>
+
+#include "filedownloader.h"
+
+FileDownloader::FileDownloader(QObject *parent) :  QObject(parent)
+{
+    connect(&m_WebCtrl, SIGNAL (finished(QNetworkReply*)), this, SLOT (fileDownloaded(QNetworkReply*)));
+}
+
+FileDownloader::~FileDownloader()
+{    
+}
+
+void FileDownloader::get(const QUrl & fileUrl)
+{
+    QNetworkRequest request(fileUrl);
+    QNetworkReply *reply = m_WebCtrl.get(request);
+
+    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError()));
+}
+
+void FileDownloader::post(const QUrl &fileUrl, QByteArray & data)
+{
+    QNetworkRequest request(fileUrl);
+    QNetworkReply *reply = m_WebCtrl.post(request, data);
+
+    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError()));
+}
+
+void FileDownloader::post(const QUrl & fileUrl, QHttpMultiPart *parts)
+{
+    QNetworkRequest request(fileUrl);
+    QNetworkReply *reply = m_WebCtrl.post(request, parts);
+
+    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError()));
+}
+
+
+void FileDownloader::fileDownloaded(QNetworkReply* pReply)
+{
+    m_DownloadedData = pReply->readAll();
+    pReply->deleteLater();
+    //emit a signal    
+    emit downloaded();
+}
+
+void FileDownloader::slotError()
+{
+    QNetworkReply *pReply = static_cast<QNetworkReply *>(sender());
+    pReply->deleteLater();
+    emit error(pReply->errorString());
+}
+
+QByteArray FileDownloader::downloadedData() const
+{
+    return m_DownloadedData;
+}
diff --git a/kstars/auxiliary/filedownloader.h b/kstars/auxiliary/filedownloader.h
new file mode 100644
index 0000000..0f30cf9
--- /dev/null
+++ b/kstars/auxiliary/filedownloader.h
@@ -0,0 +1,49 @@
+/*  KStars File Downloader
+ *
+    Copyright (C) 2016 Jasem Mutlaq <mutlaqja at ikarustech.com>
+
+    Adapted from https://wiki.qt.io/Download_Data_from_URL
+
+    This application is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef FILEDOWNLOADER_H
+#define FILEDOWNLOADER_H
+
+#include <QObject>
+#include <QByteArray>
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+
+class FileDownloader : public QObject
+{
+    Q_OBJECT
+public:
+    explicit FileDownloader(QObject *parent = 0);
+    virtual ~FileDownloader();
+
+    void get(const QUrl & fileUrl);
+    void post(const QUrl & fileUrl, QByteArray & data);
+    void post(const QUrl & fileUrl, QHttpMultiPart *parts);
+
+    QByteArray downloadedData() const;
+
+signals:
+    void downloaded();
+    void error(const QString &errorString);
+
+
+private slots:
+    void fileDownloaded(QNetworkReply* pReply);
+    void slotError();
+
+private:
+    QNetworkAccessManager m_WebCtrl;
+    QByteArray m_DownloadedData;
+};
+
+#endif // FILEDOWNLOADER_H
diff --git a/kstars/auxiliary/imageviewer.cpp b/kstars/auxiliary/imageviewer.cpp
index 65b6165..ed942a1 100644
--- a/kstars/auxiliary/imageviewer.cpp
+++ b/kstars/auxiliary/imageviewer.cpp
@@ -33,7 +33,7 @@
 #include <QStatusBar>
 
 #include <KJobUiDelegate>
-#include <KIO/CopyJob>
+//#include <KIO/CopyJob>
 #include <KLocalizedString>
 #include <KMessageBox>
 
@@ -92,8 +92,7 @@ ImageViewer::ImageViewer (const QString &caption, QWidget *parent):
 ImageViewer::ImageViewer (const QUrl &url, const QString &capText, QWidget *parent) :
     QDialog( parent ),
     m_ImageUrl(url),
-    fileIsImage(false),
-    downloadJob(0)
+    fileIsImage(false)
 {
     init(url.fileName(), capText);        
 
@@ -172,11 +171,13 @@ void ImageViewer::init(QString caption, QString capText)
 }
 
 ImageViewer::~ImageViewer() {
-    if ( downloadJob ) {
+    /*if ( downloadJob ) {
         // close job quietly, without emitting a result
         downloadJob->kill( KJob::Quietly );
         delete downloadJob;
-    }
+    }*/
+
+    QApplication::restoreOverrideCursor();
 }
 
 void ImageViewer::loadImageFromURL()
@@ -186,28 +187,42 @@ void ImageViewer::loadImageFromURL()
     if (!saveURL.isValid())
         qDebug()<<"tempfile-URL is malformed\n";
 
-    downloadJob = KIO::copy (m_ImageUrl, saveURL);	// starts the download asynchron
-    connect (downloadJob, SIGNAL (result (KJob *)), SLOT (downloadReady (KJob *)));
+    //downloadJob = KIO::copy (m_ImageUrl, saveURL);	// starts the download asynchron
+    //connect (downloadJob, SIGNAL (result (KJob *)), SLOT (downloadReady (KJob *)));
+
+    QApplication::setOverrideCursor(Qt::WaitCursor);
+
+    connect(&downloadJob, SIGNAL(downloaded()), this, SLOT(downloadReady()));
+    connect(&downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));
+
+    downloadJob.get(m_ImageUrl);
 }
 
-void ImageViewer::downloadReady (KJob *job)
+void ImageViewer::downloadReady ()
 {
-    // set downloadJob to 0, but don't delete it - the job will be deleted automatically !!!
-    downloadJob = 0;
+    QApplication::restoreOverrideCursor();
 
-    if ( job->error() ) {
-        job->uiDelegate()->showErrorMessage();
-        close();        
-        return;
-    }
+    if (file.open(QFile::WriteOnly))
+    {
+        file.write(downloadJob.downloadedData());
+        file.close(); // to get the newest information from the file and not any information from opening of the file
 
-    file.close(); // to get the newest information from the file and not any information from opening of the file
+        if ( file.exists() )
+        {
+            showImage();
+            return;
+        }
 
-    if ( file.exists() ) {
-        showImage();
-        return;
+        close();
     }
-    close();
+    else
+        KMessageBox::error(0, file.errorString(), i18n("Image Viewer"));
+}
+
+void ImageViewer::downloadError(const QString &errorString)
+{
+    QApplication::restoreOverrideCursor();
+    KMessageBox::error(this, errorString);
 }
 
 bool ImageViewer::loadImage(const QString &filename)
@@ -291,13 +306,16 @@ void ImageViewer::saveFileToDisc()
     }
 }
 
-void ImageViewer::saveFile (QUrl &url) {
+void ImageViewer::saveFile (QUrl &url)
+{
     // synchronous access to prevent segfaults
 
     //if (!KIO::NetAccess::file_copy (QUrl (file.fileName()), url, (QWidget*) 0))
-    QUrl tmpURL((file.fileName()));
-    tmpURL.setScheme("file");
-    if (KIO::file_copy(tmpURL, url)->exec() == false)
+    //QUrl tmpURL((file.fileName()));
+    //tmpURL.setScheme("file");
+
+    if (file.copy(url.path()) == false)
+    //if (KIO::file_copy(tmpURL, url)->exec() == false)
     {
         QString text = i18n ("Saving of the image %1 failed.", url.toString());
         KMessageBox::error (this, text);
diff --git a/kstars/auxiliary/imageviewer.h b/kstars/auxiliary/imageviewer.h
index 409b89a..4c647bd 100644
--- a/kstars/auxiliary/imageviewer.h
+++ b/kstars/auxiliary/imageviewer.h
@@ -23,9 +23,11 @@
 #include <QImage>
 #include <QPixmap>
 
-#include <kio/job.h>
+//#include <kio/job.h>
 #include <QDialog>
 
+#include "auxiliary/filedownloader.h"
+
 class QUrl;
 class QLabel;
 
@@ -103,7 +105,9 @@ private:
     bool fileIsImage;
     QString filename;
 
-    KIO::Job *downloadJob;  // download job of image -> 0 == no job is running
+    //KIO::Job *downloadJob;  // download job of image -> 0 == no job is running
+
+    FileDownloader downloadJob;
 
     ImageLabel *m_View;
     QLabel     *m_Caption;
@@ -112,7 +116,10 @@ private slots:
     /** Initialize (common part of onstructors) */
     void init(QString caption, QString capText);
     /** Make sure download has finished, then make sure file exists, then display the image */
-    void downloadReady (KJob *);
+    //void downloadReady (KJob *);
+
+    void downloadReady();
+    void downloadError(const QString &errorString);
 
     /** Saves file to disc. */
     void saveFileToDisc();
diff --git a/kstars/auxiliary/ksdssdownloader.cpp b/kstars/auxiliary/ksdssdownloader.cpp
index 1a05ddb..c26bf67 100644
--- a/kstars/auxiliary/ksdssdownloader.cpp
+++ b/kstars/auxiliary/ksdssdownloader.cpp
@@ -15,20 +15,6 @@
  *                                                                         *
  ***************************************************************************/
 
-
-/* Project Includes */
-#include "ksdssdownloader.h"
-#include "ksdssimage.h"
-#include "skypoint.h"
-#include "skyobject.h"
-#include "deepskyobject.h"
-#include "dms.h"
-#include "Options.h"
-
-/* KDE Includes */
-#include <KIO/Job>
-#include <KIO/CopyJob>
-
 /* Qt Includes */
 #include <QString>
 #include <QImage>
@@ -38,6 +24,15 @@
 #include <QMimeType>
 #include <QTemporaryFile>
 
+/* Project Includes */
+#include "ksdssdownloader.h"
+#include "ksdssimage.h"
+#include "skypoint.h"
+#include "skyobject.h"
+#include "deepskyobject.h"
+#include "dms.h"
+#include "Options.h"
+#include "auxiliary/filedownloader.h"
 
 KSDssDownloader::KSDssDownloader( QObject *parent ) : QObject( parent ) {
     m_VersionPreference << "poss2ukstu_blue" << "poss2ukstu_red" << "poss1_blue" << "poss1_red" << "quickv" << "poss2ukstu_ir";
@@ -187,11 +182,19 @@ void KSDssDownloader::initiateSingleDownloadAttempt( QUrl srcUrl ) {
     qDebug() << "Temp file is at " << m_TempFile.fileName();
     QUrl fileUrl = QUrl::fromLocalFile( m_TempFile.fileName() );
     qDebug() << "Attempt #" << m_attempt << "downloading DSS Image. URL: " << srcUrl << " to " << fileUrl;
-    m_DownloadJob = KIO::copy( srcUrl, fileUrl, KIO::Overwrite ) ; // FIXME: Can be done with pure Qt
-    connect ( m_DownloadJob, SIGNAL ( result (KJob *) ), SLOT ( downloadAttemptFinished() ) );
+    //m_DownloadJob = KIO::copy( srcUrl, fileUrl, KIO::Overwrite ) ; // FIXME: Can be done with pure Qt
+    //connect ( m_DownloadJob, SIGNAL ( result (KJob *) ), SLOT ( downloadAttemptFinished() ) );
+
+    downloadJob = new FileDownloader();
+
+    connect(downloadJob, SIGNAL(downloaded()), this, SLOT(downloadAttemptFinished()));
+    connect(downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));
+
+    downloadJob->get(srcUrl);
 }
 
-void KSDssDownloader::startDownload( const SkyPoint * const p, const QString &destFileName ) {
+void KSDssDownloader::startDownload( const SkyPoint * const p, const QString &destFileName )
+{
     QUrl srcUrl;
     m_FileName = destFileName;
     m_attempt = 0;
@@ -203,22 +206,39 @@ void KSDssDownloader::startSingleDownload( const QUrl srcUrl, const QString &des
     m_FileName = destFileName;
     QUrl fileUrl = QUrl::fromLocalFile( m_TempFile.fileName() );
     qDebug() << "Downloading DSS Image from URL: " << srcUrl << " to " << fileUrl;
-    m_DownloadJob = KIO::copy( srcUrl, fileUrl, KIO::Overwrite ) ; // FIXME: Can be done with pure Qt
-    connect ( m_DownloadJob, SIGNAL ( result (KJob *) ), SLOT ( singleDownloadFinished() ) );
+    //m_DownloadJob = KIO::copy( srcUrl, fileUrl, KIO::Overwrite ) ; // FIXME: Can be done with pure Qt
+    //connect ( m_DownloadJob, SIGNAL ( result (KJob *) ), SLOT ( singleDownloadFinished() ) );
+
+    downloadJob = new FileDownloader();
+
+    connect(downloadJob, SIGNAL(downloaded()), this, SLOT(singleDownloadFinished));
+    connect(downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));
+
     m_AttemptData = md;
+
+    downloadJob->get(srcUrl);
 }
 
-void KSDssDownloader::singleDownloadFinished() {
-    // Check if there was an error downloading itself
-    if( m_DownloadJob->error() != 0 ) {
-        qDebug() << "Error " << m_DownloadJob->error() << " downloading DSS images!";
-        emit downloadComplete( false );
-        return;
-    }
+void KSDssDownloader::downloadError(const QString &errorString)
+{
+    qDebug() << "Error " << errorString << " downloading DSS images!" ;
+    emit downloadComplete( false );
+    downloadJob->deleteLater();
+    return;
+}
+
+void KSDssDownloader::singleDownloadFinished()
+{
+    m_TempFile.open();
+    m_TempFile.write(downloadJob->downloadedData());
+    m_TempFile.close();
+    delete (downloadJob);
+
     // Check if we have a proper DSS image or the DSS server failed
     QMimeDatabase mdb;
     QMimeType mt = mdb.mimeTypeForFile( m_TempFile.fileName(), QMimeDatabase::MatchContent );
-    if( mt.name().contains( "image", Qt::CaseInsensitive ) ) {
+    if( mt.name().contains( "image", Qt::CaseInsensitive ) )
+    {
         qDebug() << "DSS download was successful";
         emit downloadComplete( writeImageWithMetadata( m_TempFile.fileName(), m_FileName, m_AttemptData ) );
         return;
@@ -229,26 +249,28 @@ void KSDssDownloader::singleDownloadFinished() {
 
 
 
-void KSDssDownloader::downloadAttemptFinished() {
-    // Check if there was an error downloading itself
-    if( m_DownloadJob->error() != 0 ) {
-        qDebug() << "Error " << m_DownloadJob->error() << " downloading DSS images!";
-        emit downloadComplete( false );
-        deleteLater();
-        return;
-    }
-
-    if( m_AttemptData.src == KSDssImage::Metadata::SDSS ) {
+void KSDssDownloader::downloadAttemptFinished()
+{
+    if( m_AttemptData.src == KSDssImage::Metadata::SDSS )
+    {
         // FIXME: do SDSS-y things
         emit downloadComplete( false );
         deleteLater();
+        delete (downloadJob);
         return;
     }
-    else {
+    else
+    {
+        m_TempFile.open();
+        m_TempFile.write(downloadJob->downloadedData());
+        m_TempFile.close();
+        delete (downloadJob);
+
         // Check if we have a proper DSS image or the DSS server failed
         QMimeDatabase mdb;
         QMimeType mt = mdb.mimeTypeForFile( m_TempFile.fileName(), QMimeDatabase::MatchContent );
-        if( mt.name().contains( "image", Qt::CaseInsensitive ) ) {
+        if( mt.name().contains( "image", Qt::CaseInsensitive ) )
+        {
             qDebug() << "DSS download was successful";
             emit downloadComplete( writeImageFile() );
             deleteLater();
@@ -258,7 +280,8 @@ void KSDssDownloader::downloadAttemptFinished() {
         // We must have failed, try the next attempt
         QUrl srcUrl;
         m_attempt++;
-        if( m_attempt == m_VersionPreference.count() ) {
+        if( m_attempt == m_VersionPreference.count() )
+        {
             // Nothing downloaded... very strange. Fail.
             qDebug() << "Error downloading DSS images: All alternatives failed!";
             emit downloadComplete( false );
diff --git a/kstars/auxiliary/ksdssdownloader.h b/kstars/auxiliary/ksdssdownloader.h
index b8ae468..6045ace 100644
--- a/kstars/auxiliary/ksdssdownloader.h
+++ b/kstars/auxiliary/ksdssdownloader.h
@@ -22,13 +22,12 @@
 
 #include "ksdssimage.h"
 
-#include <KIO/Job>
-
 #include <QObject>
 #include <QString>
 #include <QStringList>
 #include <QTemporaryFile>
 
+class FileDownloader;
 class SkyPoint;
 class dms;
 
@@ -45,7 +44,7 @@ class dms;
 
 class KSDssDownloader : public QObject {
 
-    Q_OBJECT;
+    Q_OBJECT
 
  public:
 
@@ -118,6 +117,7 @@ class KSDssDownloader : public QObject {
  private slots:
      void downloadAttemptFinished();
      void singleDownloadFinished();
+     void downloadError(const QString &errorString);
 
  private:
      void startDownload( const SkyPoint * const p, const QString &destFileName );
@@ -129,7 +129,7 @@ class KSDssDownloader : public QObject {
      struct KSDssImage::Metadata m_AttemptData;
      QString m_FileName;
      QTemporaryFile m_TempFile;
-     KIO::Job *m_DownloadJob;
+     FileDownloader *downloadJob;
 
 };
 
diff --git a/kstars/fitsviewer/fitshistogram.cpp b/kstars/fitsviewer/fitshistogram.cpp
index 6b9fbe3..4204de1 100644
--- a/kstars/fitsviewer/fitshistogram.cpp
+++ b/kstars/fitsviewer/fitshistogram.cpp
@@ -30,7 +30,7 @@
 
 #include <QUndoStack>
 #include <QDebug>
-#include <klineedit.h>
+//#include <klineedit.h>
 #include <KLocalizedString>
 #include <KMessageBox>
 
diff --git a/kstars/fitsviewer/fitsviewer.cpp b/kstars/fitsviewer/fitsviewer.cpp
index e5775ed..62d1b84 100644
--- a/kstars/fitsviewer/fitsviewer.cpp
+++ b/kstars/fitsviewer/fitsviewer.cpp
@@ -48,7 +48,7 @@
 #include <KStandardAction>
 #include <KToolBar>
 #include <KLocalizedString>
-#include <klineedit.h>
+//#include <klineedit.h>
 
 #include <cmath>
 #ifndef __MINGW32__
diff --git a/kstars/indi/opsindi.cpp b/kstars/indi/opsindi.cpp
index 6e46b32..d7a94f6 100644
--- a/kstars/indi/opsindi.cpp
+++ b/kstars/indi/opsindi.cpp
@@ -12,7 +12,7 @@
 
 #include <QPushButton>
 #include <QFileDialog>
-#include <KLineEdit>
+//#include <KLineEdit>
 #include <KConfigDialog>
 
 #include <QCheckBox>
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index 088871e..d47d20e 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -845,9 +845,18 @@ void KStars::slotRunScript() {
 
     QUrl fileURL = QFileDialog::getOpenFileUrl(KStars::Instance(), QString(), QUrl(QDir::homePath()), "*.kstars|" + i18nc("Filter by file type: KStars Scripts.", "KStars Scripts (*.kstars)") );
     QFile f;
-    QString fname;
+    //QString fname;
 
-    if ( fileURL.isValid() ) {
+    if ( fileURL.isValid() )
+    {
+
+        if (fileURL.isLocalFile() == false)
+        {
+            KMessageBox::sorry(0, i18n("Executing remote scripts is not supported."));
+            return;
+        }
+
+        /*
         if ( ! fileURL.isLocalFile() )
         {
             //Warn the user about executing remote code.
@@ -908,11 +917,13 @@ void KStars::slotRunScript() {
                 return;
             }
         }
+        */
 
         //Damn the torpedos and full speed ahead, we're executing the script!
         QTemporaryFile tmpfile;
         tmpfile.open();
 
+        /*
         if ( ! fileURL.isLocalFile() )
         {
             fname = tmpfile.fileName();
@@ -926,7 +937,9 @@ void KStars::slotRunScript() {
             }
         } else {
             f.setFileName( fileURL.toLocalFile() );
-        }
+        }*/
+
+        f.setFileName( fileURL.toLocalFile() );
 
         if ( !f.open( QIODevice::ReadOnly) )
         {
diff --git a/kstars/skycomponents/asteroidscomponent.cpp b/kstars/skycomponents/asteroidscomponent.cpp
index 2c77d1e..25f19f5 100644
--- a/kstars/skycomponents/asteroidscomponent.cpp
+++ b/kstars/skycomponents/asteroidscomponent.cpp
@@ -15,8 +15,17 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <cmath>
+#include <QDebug>
+#include <QStandardPaths>
+#include <QHttpMultiPart>
+#include <QPen>
+
+#include <KLocalizedString>
+
 #include "asteroidscomponent.h"
 
+#include "auxiliary/filedownloader.h"
 #include "projections/projector.h"
 #include "solarsystemcomposite.h"
 #include "skycomponent.h"
@@ -28,16 +37,8 @@
 #include "kstarsdata.h"
 #include "ksfilereader.h"
 
-#include <cmath>
-#include <QDebug>
-#include <QStandardPaths>
-#include <QPen>
-
-#include <KIOCore/KIO/Job>
-#include <KJobUiDelegate>
-
-AsteroidsComponent::AsteroidsComponent(SolarSystemComposite *parent)
-    : SolarSystemListComponent(parent) {
+AsteroidsComponent::AsteroidsComponent(SolarSystemComposite *parent) : SolarSystemListComponent(parent)
+{
     loadData();
 }
 
@@ -77,13 +78,14 @@ bool AsteroidsComponent::selected() {
  * @li 22 earth minimum orbit intersection distance [double]
  * @li 23 orbit classification [string]
  */
-void AsteroidsComponent::loadData() {
+void AsteroidsComponent::loadData()
+{
     QString name, full_name, orbit_id, orbit_class, dimensions;
     int mJD;
     double q, a, e, dble_i, dble_w, dble_N, dble_M, H, G, earth_moid;
     long double JD;
     float diameter, albedo, rot_period, period;
-    bool neo;
+    bool neo;    
 
     emitProgressText( i18n("Loading asteroids") );
 
@@ -242,7 +244,13 @@ SkyObject* AsteroidsComponent::objectNearest( SkyPoint *p, double &maxrad ) {
     return oBest;
 }
 
-void AsteroidsComponent::updateDataFile() {
+void AsteroidsComponent::updateDataFile()
+{
+    downloadJob = new FileDownloader();
+
+    QObject::connect(downloadJob, SIGNAL(downloaded()), this, SLOT(downloadReady()));
+    QObject::connect(downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));
+
     QUrl url = QUrl( "http://ssd.jpl.nasa.gov/sbdb_query.cgi" );
     QByteArray post_data = QByteArray( "obj_group=all&obj_kind=ast&obj_numbere"
     "d=num&OBJ_field=0&ORB_field=0&c1_group=OBJ&c1_item=Ai&c1_op=%3C&c1_value="
@@ -251,31 +259,34 @@ void AsteroidsComponent::updateDataFile() {
     "t_option&.cgifields=field_list&.cgifields=obj_kind&.cgifields=obj_group&."
     "cgifields=obj_numbered&.cgifields=combine_mode&.cgifields=ast_orbit_class"
     "&.cgifields=table_format&.cgifields=ORB_field_set&.cgifields=OBJ_field_se"
-    "t&.cgifields=preset_field_set&.cgifields=com_orbit_class" );
-    QString content_type = "Content-Type: application/x-www-form-urlencoded";
-
-    // Download file
-    KIO::StoredTransferJob* get_job = KIO::storedHttpPost(post_data,  url);
-    get_job->addMetaData("content-type", content_type );
-
-    if( get_job->exec() )
-    {
-        // Comment the first line
-        QByteArray data = get_job->data();
-        data.insert( 0, '#' );
-
-        // Write data to asteroids.dat
-        QFile file( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "asteroids.dat" ) ;
-        file.open( QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text );
-        file.write( data );
-        file.close();
-
-        // Reload asteroids
-        loadData();
-
-        KStars::Instance()->data()->setFullTimeUpdate();
-    } else
-    {
-        get_job->uiDelegate()->showErrorMessage();
-    }
+    "t&.cgifields=preset_field_set&.cgifields=com_orbit_class" );    
+
+    downloadJob->post(url, post_data);
+}
+
+void AsteroidsComponent::downloadReady()
+{
+    // Comment the first line
+    QByteArray data = downloadJob->downloadedData();
+    data.insert( 0, '#' );
+
+    // Write data to asteroids.dat
+    QFile file( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "asteroids.dat" ) ;
+    file.open( QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text );
+    file.write( data );
+    file.close();
+
+    // Reload asteroids
+    loadData();
+
+    KStars::Instance()->data()->setFullTimeUpdate();
+
+    downloadJob->deleteLater();
+}
+
+void AsteroidsComponent::downloadError(const QString &errorString)
+{
+    KMessageBox::error(0, i18n("Error downloading asteroids data: %1", errorString));
+
+    downloadJob->deleteLater();
 }
diff --git a/kstars/skycomponents/asteroidscomponent.h b/kstars/skycomponents/asteroidscomponent.h
index 6b22794..40e31b5 100644
--- a/kstars/skycomponents/asteroidscomponent.h
+++ b/kstars/skycomponents/asteroidscomponent.h
@@ -18,12 +18,14 @@
 #ifndef ASTEROIDSCOMPONENT_H
 #define ASTEROIDSCOMPONENT_H
 
+#include <QList>
+#include <QPointer>
+
 #include "solarsystemlistcomponent.h"
 #include "ksparser.h"
-#include <QList>
 #include "typedef.h"
 
-class KJob;
+class FileDownloader;
 
 /** @class AsteroidsComponent
  * Represents the asteroids on the sky map.
@@ -31,8 +33,10 @@ class KJob;
  * @author Thomas Kabelmann
  * @version 0.1
  */
-class AsteroidsComponent: public SolarSystemListComponent
+class AsteroidsComponent: public QObject, public SolarSystemListComponent
 {
+    Q_OBJECT
+
 public:
     /** @short Default constructor.
      * @p parent pointer to the parent SolarSystemComposite
@@ -45,8 +49,14 @@ public:
     virtual SkyObject* objectNearest( SkyPoint *p, double &maxrad );
     void updateDataFile();
     QString ans();
+
+protected slots:
+    void downloadReady();
+    void downloadError(const QString &errorString);
+
 private:
     void loadData();
+    FileDownloader* downloadJob;
 };
 
 #endif
diff --git a/kstars/skycomponents/cometscomponent.cpp b/kstars/skycomponents/cometscomponent.cpp
index a244f78..a696368 100644
--- a/kstars/skycomponents/cometscomponent.cpp
+++ b/kstars/skycomponents/cometscomponent.cpp
@@ -15,6 +15,13 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <cmath>
+#include <QStandardPaths>
+#include <QDebug>
+#include <QFile>
+#include <QPen>
+#include <QHttpMultiPart>
+
 #include "cometscomponent.h"
 #include "solarsystemcomposite.h"
 
@@ -27,15 +34,7 @@
 #include "skylabeler.h"
 #include "skypainter.h"
 #include "projections/projector.h"
-
-#include <cmath>
-#include <QStandardPaths>
-#include <QDebug>
-#include <QFile>
-#include <QPen>
-
-#include <KJobUiDelegate>
-#include <KIOCore/KIO/StoredTransferJob>
+#include "auxiliary/filedownloader.h"
 
 CometsComponent::CometsComponent( SolarSystemComposite *parent )
         : SolarSystemListComponent( parent ) {
@@ -202,6 +201,10 @@ void CometsComponent::draw( SkyPainter *skyp )
 
 void CometsComponent::updateDataFile()
 {
+    downloadJob = new FileDownloader();
+
+    connect(downloadJob, SIGNAL(downloaded()), this, SLOT(downloadReady()));
+    connect(downloadJob, SIGNAL(error(QString)), this, SLOT(downloadError(QString)));
 
     QUrl url = QUrl( "http://ssd.jpl.nasa.gov/sbdb_query.cgi" );
     QByteArray post_data = QByteArray( "obj_group=all&obj_kind=com&obj_numbere"
@@ -213,31 +216,35 @@ void CometsComponent::updateDataFile()
     "j_kind&.cgifields=obj_group&.cgifields=obj_numbered&.cgifields=combine_mo"
     "de&.cgifields=ast_orbit_class&.cgifields=table_format&.cgifields=ORB_fiel"
     "d_set&.cgifields=OBJ_field_set&.cgifields=preset_field_set&.cgifields=com"
-    "_orbit_class" );
-    QString content_type = "Content-Type: application/x-www-form-urlencoded";
-
-    // Download file
-    KIO::StoredTransferJob* get_job = KIO::storedHttpPost(post_data,  url);
-    get_job->addMetaData("content-type", content_type );
-
-    if( get_job->exec() )
-    {
-        // Comment the first line
-        QByteArray data = get_job->data();
-        data.insert( 0, '#' );
-
-        // Write data to comets.dat
-        QFile file( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "comets.dat" ) ;
-        file.open( QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text );
-        file.write( data );
-        file.close();
-
-        // Reload comets
-        loadData();
-
-        KStars::Instance()->data()->setFullTimeUpdate();
-    } else
-    {
-        get_job->uiDelegate()->showErrorMessage();
-    }
+    "_orbit_class" );    
+
+    downloadJob->post(url, post_data);
+
+}
+
+void CometsComponent::downloadReady()
+{
+    // Comment the first line
+    QByteArray data = downloadJob->downloadedData();
+    data.insert( 0, '#' );
+
+    // Write data to asteroids.dat
+    QFile file( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "comets.dat" ) ;
+    file.open( QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text );
+    file.write( data );
+    file.close();
+
+    // Reload asteroids
+    loadData();
+
+    KStars::Instance()->data()->setFullTimeUpdate();
+
+    downloadJob->deleteLater();
+}
+
+void CometsComponent::downloadError(const QString &errorString)
+{
+    KMessageBox::error(0, i18n("Error downloading comets data: %1", errorString));
+
+    downloadJob->deleteLater();
 }
diff --git a/kstars/skycomponents/cometscomponent.h b/kstars/skycomponents/cometscomponent.h
index 204ad7b..59897a6 100644
--- a/kstars/skycomponents/cometscomponent.h
+++ b/kstars/skycomponents/cometscomponent.h
@@ -24,14 +24,18 @@ class SkyLabeler;
 #include "ksparser.h"
 #include <QList>
 
+class FileDownloader;
+
 /** @class CometsComponent
  * This class encapsulates the Comets
  *
  * @author Jason Harris
  * @version 0.1
  */
-class CometsComponent : public SolarSystemListComponent
+class CometsComponent : public QObject, public SolarSystemListComponent
 {
+    Q_OBJECT
+
 public:
     /** @short Default constructor.
      * @p parent pointer to the parent SolarSystemComposite
@@ -42,8 +46,14 @@ public:
     virtual bool selected();
     virtual void draw( SkyPainter *skyp );
     void updateDataFile();
+
+protected slots:
+    void downloadReady();
+    void downloadError(const QString &errorString);
+
 private:
     void loadData();
+    FileDownloader* downloadJob;
 };
 
 #endif
diff --git a/kstars/skycomponents/flagcomponent.cpp b/kstars/skycomponents/flagcomponent.cpp
index 4a94fe6..b87d623 100644
--- a/kstars/skycomponents/flagcomponent.cpp
+++ b/kstars/skycomponents/flagcomponent.cpp
@@ -19,10 +19,9 @@
 #include "flagcomponent.h"
 
 #include <QtMath>
+#include <QDir>
 #include <QStandardPaths>
 
-#include <KJob>
-#include <KFileItem>
 #include <KLocalizedString>
 
 #include "Options.h"
@@ -41,14 +40,21 @@ FlagComponent::FlagComponent( SkyComposite *parent )
     m_Images.append( QImage() );
     m_Names.append( i18n( "Default" ) );
     m_Images.append( QImage( QStandardPaths::locate(QStandardPaths::DataLocation, "defaultflag.gif" ) ));
-    QUrl dir = QUrl( QStandardPaths::writableLocation(QStandardPaths::DataLocation)) ;
-    dir.setScheme("file");
-    // List user's directory
-    m_Job = KIO::listDir( dir, KIO::HideProgressInfo, false) ;
-    connect( m_Job,SIGNAL( entries(KIO::Job*, const KIO::UDSEntryList& ) ),
-            SLOT( slotLoadImages( KIO::Job*, const KIO::UDSEntryList& ) ) );
-    connect( m_Job, SIGNAL( result( KJob * ) ), this, SLOT( slotInit( KJob * ) ) );
-    m_Job->start();
+
+    QDir appDir( QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+    appDir.setNameFilters(QStringList() << "flag*");
+    // Add all other images found in user appdata directory
+    foreach( QString item, appDir.entryList())
+    {
+      QString fileName = item.replace(QRegExp("\\.[^.]*$"), QString()).replace(QRegExp("^flag"),   QString()).replace('_',' ');
+      m_Names.append( fileName );
+
+      // FIXME need to append path??!
+      m_Images.append( QImage( item ));
+      //m_Images.append( QImage( item.localPath() ));
+    }
+
+    loadFromFile();
 }
 
 
@@ -203,32 +209,6 @@ void FlagComponent::updateFlag( int index, SkyPoint *flagPoint, QString epoch, Q
     m_LabelColors.replace( index, labelColor );
 }
 
-void FlagComponent::slotLoadImages( KIO::Job*, const KIO::UDSEntryList& list ) {
-    // Add all other images found in user appdata directory
-    foreach( KIO::UDSEntry entry, list) {
-        KFileItem item(entry, m_Job->url(), false, true);
-        if( item.name().startsWith( "flag" ) ) {
-            QString fileName = item.name()
-                .replace(QRegExp("\\.[^.]*$"), QString())
-                .replace(QRegExp("^flag"),   QString())
-                .replace('_',' ');
-            m_Names.append( fileName );
-            m_Images.append( QImage( item.localPath() ));
-        }
-    }
-}
-
-void FlagComponent::slotInit( KJob *job ) {
-    Q_UNUSED (job)
-
-    loadFromFile();
-
-    // Redraw Skymap
-    //FIXME JM: SkyMap is not initialized yet, this is causing SIGSEGV.
-    //SkyMap::Instance()->forceUpdate(false);
-}
-
-
 QStringList FlagComponent::getNames() {
     return m_Names;
 }
diff --git a/kstars/skycomponents/flagcomponent.h b/kstars/skycomponents/flagcomponent.h
index 957cc1b..bacffaf 100644
--- a/kstars/skycomponents/flagcomponent.h
+++ b/kstars/skycomponents/flagcomponent.h
@@ -19,7 +19,7 @@
 #define FLAGCOMPONENT_H
 
 
-#include <kio/jobclasses.h>
+//#include <kio/jobclasses.h>
 
 #include "pointlistcomponent.h"
 #include "typedef.h"
@@ -158,11 +158,6 @@ private:
     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 );
-    void slotInit( KJob *job );
 };
 
 #endif
diff --git a/kstars/skycomponents/satellitescomponent.cpp b/kstars/skycomponents/satellitescomponent.cpp
index bb34409..6842933 100644
--- a/kstars/skycomponents/satellitescomponent.cpp
+++ b/kstars/skycomponents/satellitescomponent.cpp
@@ -20,6 +20,8 @@
 #include <QStringList>
 #include <QObject>
 #include <QProgressDialog>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
 
 #include <KJobUiDelegate>
 #include <KLocalizedString>
@@ -121,12 +123,12 @@ void SatellitesComponent::drawTrails( SkyPainter *skyp ) {
 void SatellitesComponent::updateTLEs()
 {
     int i = 0;
-    
     QProgressDialog progressDlg( i18n( "Update TLEs..." ), i18n( "Abort" ), 0, m_groups.count() );
     progressDlg.setWindowModality( Qt::WindowModal );
     progressDlg.setValue( 0 );
         
-    foreach ( SatelliteGroup *group, m_groups ) {
+    foreach ( SatelliteGroup *group, m_groups )
+    {
         if ( progressDlg.wasCanceled() )
             return;
 
@@ -134,16 +136,39 @@ void SatellitesComponent::updateTLEs()
             continue;
         
         progressDlg.setLabelText( i18n( "Update %1 satellites", group->name() ) );
-        KIO::Job* getJob = KIO::file_copy(group->tleUrl(), group->tleFilename(), -1, KIO::Overwrite | KIO::HideProgressInfo );
-        if( getJob->exec() )
+        progressDlg.setWindowTitle(i18n("Satellite Orbital Elements Update"));
+
+        QNetworkAccessManager manager;
+        QNetworkReply *response = manager.get(QNetworkRequest(group->tleUrl()));
+
+        // Wait synchronously
+        QEventLoop event;
+        QObject::connect(response,SIGNAL(finished()),&event,SLOT(quit()));
+        event.exec();
+
+        if (response->error() == QNetworkReply::NoError)
         {
-            group->readTLE();
-            group->updateSatellitesPos();
-            progressDlg.setValue( ++i );
-        } else
+            QFile file(group->tleFilename().path());
+            if (file.open(QFile::WriteOnly))
+            {
+                file.write(response->readAll());
+                file.close();
+                group->readTLE();
+                group->updateSatellitesPos();
+                progressDlg.setValue( ++i );
+            }
+            else
+            {
+                KMessageBox::error(0, file.errorString());
+                return;
+            }
+
+        }
+        else
         {
-            getJob->uiDelegate()->showErrorMessage();
-        }   
+            KMessageBox::error(0, response->errorString());
+            return;
+        }
     }
 }
 
diff --git a/kstars/skycomponents/satellitescomponent.h b/kstars/skycomponents/satellitescomponent.h
index fecb850..508d251 100644
--- a/kstars/skycomponents/satellitescomponent.h
+++ b/kstars/skycomponents/satellitescomponent.h
@@ -20,12 +20,13 @@
 
 #include <QList>
 
-#include <kio/job.h>
+//#include <kio/job.h>
 
 #include "skycomponent.h"
 #include "satellitegroup.h"
 
 class Satellite;
+class FileDownloader;
 
 /**
 	*@class SatellitesComponent
@@ -105,6 +106,7 @@ public:
 protected:
     virtual void drawTrails( SkyPainter* skyp );
 
+
 private:
     QList<SatelliteGroup*> m_groups;    // List of all groups
     QHash<QString, Satellite*> nameHash;
diff --git a/kstars/skycomponents/supernovaecomponent.h b/kstars/skycomponents/supernovaecomponent.h
index 750d320..b78758f 100644
--- a/kstars/skycomponents/supernovaecomponent.h
+++ b/kstars/skycomponents/supernovaecomponent.h
@@ -38,7 +38,7 @@ class Supernova;
 
 class SupernovaeComponent : public QObject, public ListComponent
 {
-    Q_OBJECT;
+    Q_OBJECT
 
 public:
     explicit SupernovaeComponent(SkyComposite* parent);
diff --git a/kstars/tools/modcalcdaylength.cpp b/kstars/tools/modcalcdaylength.cpp
index 880ef1d..4b48858 100644
--- a/kstars/tools/modcalcdaylength.cpp
+++ b/kstars/tools/modcalcdaylength.cpp
@@ -17,7 +17,7 @@
 
 #include "modcalcdaylength.h"
 
-#include <QLineEdit>
+#include <KLineEdit>
 
 #include <KLocalizedString>
 #include <KMessageBox>
diff --git a/kstars/tools/modcalcsidtime.cpp b/kstars/tools/modcalcsidtime.cpp
index 55e5218..6dc23e0 100644
--- a/kstars/tools/modcalcsidtime.cpp
+++ b/kstars/tools/modcalcsidtime.cpp
@@ -22,6 +22,7 @@
 
 #include <KLocalizedString>
 #include <KMessageBox>
+#include <KLineEdit>
 
 #include "kstarsdata.h"
 #include "kstarsdatetime.h"
diff --git a/kstars/tools/modcalcvizequinox.cpp b/kstars/tools/modcalcvizequinox.cpp
index d8bb017..56a53f4 100644
--- a/kstars/tools/modcalcvizequinox.cpp
+++ b/kstars/tools/modcalcvizequinox.cpp
@@ -25,6 +25,7 @@
 #include <KPlotPoint>
 #include <KLocalizedString>
 #include <KMessageBox>
+#include <KLineEdit>
 
 #include "dms.h"
 #include "kstarsdata.h"
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index 0a9ce5c..787a01c 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -221,6 +221,13 @@ ObservingList::ObservingList()
     ui->DeleteImage->setEnabled( false );
     ui->OALExport->setEnabled( false );
 
+    QFile file;
+    if ( KSUtils::openDataFile( file, "noimage.png" ) )
+    {
+        file.close();
+        m_NoImagePixmap = QPixmap(file.fileName()).scaledToHeight(ui->ImagePreview->width());
+    }
+
     slotLoadWishList(); //Load the wishlist from disk if present
     m_CurrentObject = 0;
     setSaveImagesButton();
@@ -363,6 +370,9 @@ void ObservingList::slotRemoveObject( SkyObject *o, bool session, bool update )
             session = true;
     }
 
+    // Remove from hash
+    ImagePreviewHash.remove(o);
+
     QStandardItemModel *currentModel;
 
     int k;
@@ -443,7 +453,8 @@ void ObservingList::slotNewSelection() {
     singleSelection = false;
     noSelection = false;
     showScope = false;
-    ui->ImagePreview->clearPreview();
+    //ui->ImagePreview->clearPreview();
+    //ui->ImagePreview->setPixmap(QPixmap());
     ui->ImagePreview->setCursor( Qt::ArrowCursor );
     QModelIndexList selectedItems;
     QString newName;
@@ -471,11 +482,11 @@ void ObservingList::slotNewSelection() {
         ui->ImagePreview->setCursor( Qt::PointingHandCursor );
         #ifdef HAVE_INDI
             showScope = true;
-        #endif
-        setDefaultImage();
-        if ( found ) {
+        #endif        
+        if ( found )
+        {
             m_CurrentObject = o;
-            QPoint pos(0,0);
+            //QPoint pos(0,0);
             plot( o );
             //Change the CurrentImage, DSS/SDSS Url to correspond to the new object
             setCurrentImage( o );
@@ -515,10 +526,17 @@ void ObservingList::slotNewSelection() {
             }
             else
                 ImagePath = QString();
-            if( !ImagePath.isEmpty() ) {//If the image is present, show it!
+            if( !ImagePath.isEmpty() )
+            {
+                //If the image is present, show it!
                 KSDssImage ksdi( ImagePath );
                 KSDssImage::Metadata md = ksdi.getMetadata();
-                ui->ImagePreview->showPreview( QUrl::fromLocalFile( ksdi.getFileName() ) );
+                //ui->ImagePreview->showPreview( QUrl::fromLocalFile( ksdi.getFileName() ) );
+                if (ImagePreviewHash.contains(o) == false)
+                    ImagePreviewHash[o] = QPixmap(ksdi.getFileName()).scaledToHeight(ui->ImagePreview->width());
+
+                //ui->ImagePreview->setPixmap(QPixmap(ksdi.getFileName()).scaledToHeight(ui->ImagePreview->width()));
+                ui->ImagePreview->setPixmap(ImagePreviewHash[o]);
                 if( md.width != 0 ) {// FIXME: Need better test for meta data presence
                     ui->dssMetadataLabel->setText( i18n( "DSS Image metadata: \n Size: %1\' x %2\' \n Photometric band: %3 \n Version: %4",
                                                          QString::number( md.width ), QString::number( md.height ), QString() + md.band, md.version ) );
@@ -529,8 +547,14 @@ void ObservingList::slotNewSelection() {
                 ui->DeleteImage->setEnabled( true );
             }
             else
+            {
+                setDefaultImage();
                 ui->dssMetadataLabel->setText( i18n( "No image available. Click on the placeholder image to download one." ) );
-        } else {
+            }
+        }
+        else
+        {
+            setDefaultImage();
             qDebug() << "Object " << newName << " not found in list.";
         }
     } else {
@@ -708,7 +732,7 @@ void ObservingList::slotClose() {
     saveCurrentUserLog();
     ui->avt->removeAllPlotObjects();
     slotNewSelection();
-    saveCurrentList();
+    saveCurrentList();    
     hide();
 }
 
@@ -966,7 +990,7 @@ void ObservingList::slotToggleSize() {
         //Hide Observing notes
         ui->NotesLabel->hide();
         ui->NotesEdit->hide();
-        ui->kseparator->hide();
+        //ui->kseparator->hide();
         ui->avt->hide();
         ui->dssMetadataLabel->hide();
         ui->setMinimumSize(320, 600);
@@ -1011,7 +1035,7 @@ void ObservingList::slotToggleSize() {
         //Show Observing notes
         ui->NotesLabel->show();
         ui->NotesEdit->show();
-        ui->kseparator->show();
+        //ui->kseparator->show();
         ui->setMinimumSize(837, 650);
         ui->avt->show();
         ui->dssMetadataLabel->show();
@@ -1082,7 +1106,8 @@ void ObservingList::slotSetTime() {
 
 void ObservingList::slotCustomDSS() {
     ui->SearchImage->setEnabled( false );
-    ui->ImagePreview->clearPreview();
+    //ui->ImagePreview->clearPreview();
+    ui->ImagePreview->setPixmap(QPixmap());
 
     KSDssImage::Metadata md;
     bool ok = true;
@@ -1107,11 +1132,12 @@ void ObservingList::slotGetImage( bool _dss, const SkyObject *o ) {
     if( !o )
         o = currentObject();
     ui->SearchImage->setEnabled( false );
-    ui->ImagePreview->clearPreview();
+    //ui->ImagePreview->clearPreview();
+    ui->ImagePreview->setPixmap(QPixmap());
     if( ! QFile::exists( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + CurrentImage ) )
         setCurrentImage( o );
     QFile::remove( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + CurrentImage ) ;
-    QUrl url;
+    //QUrl url;
     dss = true;
     qDebug() << "FIXME: Removed support for SDSS. Until reintroduction, we will supply a DSS image";
     KSDssDownloader *dler = new KSDssDownloader( o, QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + CurrentImage );
@@ -1134,7 +1160,8 @@ void ObservingList::downloadReady( bool success ) {
           //The default image is around 8689 bytes
         */
         CurrentImagePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + CurrentImage;
-        ui->ImagePreview->showPreview( QUrl::fromLocalFile( CurrentImagePath ) );
+        //ui->ImagePreview->showPreview( QUrl::fromLocalFile( CurrentImagePath ) );
+        ui->ImagePreview->setPixmap(QPixmap(CurrentImagePath).scaledToHeight(ui->ImagePreview->width()));
         saveThumbImage();
         ui->ImagePreview->show();
         ui->ImagePreview->setCursor( Qt::PointingHandCursor );
@@ -1229,7 +1256,8 @@ void ObservingList::slotDeleteAllImages() {
     //Clear the selection in the Tables
     ui->TableView->clearSelection();
     ui->SessionView->clearSelection();
-    ui->ImagePreview->clearPreview();
+    //ui->ImagePreview->clearPreview();
+    ui->ImagePreview->setPixmap(QPixmap());
     QDirIterator iterator( QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "" ) ;
     while( iterator.hasNext() )
     {
@@ -1302,13 +1330,16 @@ bool ObservingList::eventFilter( QObject *obj, QEvent *event ) {
 void ObservingList::slotSearchImage() {
     QPixmap *pm = new QPixmap;
     QPointer<ThumbnailPicker> tp = new ThumbnailPicker( currentObject(), *pm, this, 600, 600, i18n( "Image Chooser" ) );
-    if ( tp->exec() == QDialog::Accepted ) {
+    if ( tp->exec() == QDialog::Accepted )
+    {
+        CurrentImagePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + CurrentImage;
         QFile f( CurrentImagePath );
 
         //If a real image was set, save it.
         if ( tp->imageFound() ) {
             tp->image()->save( f.fileName(), "PNG" );
-            ui->ImagePreview->showPreview( QUrl::fromLocalFile( f.fileName() ) );
+            //ui->ImagePreview->showPreview( QUrl::fromLocalFile( f.fileName() ) );
+            ui->ImagePreview->setPixmap(QPixmap(f.fileName() ).scaledToHeight(ui->ImagePreview->width()));
             saveThumbImage();
             slotNewSelection();
         }
@@ -1318,6 +1349,7 @@ void ObservingList::slotSearchImage() {
 
 void ObservingList::slotDeleteCurrentImage() {
     QFile::remove( CurrentImagePath );
+    ImagePreviewHash.remove(m_CurrentObject);
     slotNewSelection();
 }
 
@@ -1382,13 +1414,9 @@ void ObservingList::selectObject( const SkyObject *o ) {
     }
 }
 
-void ObservingList::setDefaultImage() {
-    QFile file;
-    if ( KSUtils::openDataFile( file, "noimage.png" ) ) {
-        file.close();
-        ui->ImagePreview->showPreview( QUrl::fromLocalFile( file.fileName() ) );
-    } else
-        ui->ImagePreview->hide();
+void ObservingList::setDefaultImage()
+{
+    ui->ImagePreview->setPixmap(m_NoImagePixmap);
 }
 
 QString ObservingList::getObjectName(const SkyObject *o, bool translated)
diff --git a/kstars/tools/observinglist.h b/kstars/tools/observinglist.h
index dd81bdd..7bfb42c 100644
--- a/kstars/tools/observinglist.h
+++ b/kstars/tools/observinglist.h
@@ -22,7 +22,7 @@
 #include <QAbstractTableModel>
 
 #include <QDialog>
-#include <KIO/CopyJob>
+//#include <KIO/CopyJob>
 
 #include "ui_observinglist.h"
 #include "kstarsdatetime.h"
@@ -389,10 +389,11 @@ private:
     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;
     ObsListPopupMenu *pmenu;
     KSDssDownloader *m_dl;
+    QHash<SkyObject *, QPixmap> ImagePreviewHash;
+    QPixmap m_NoImagePixmap;
 };
 
 #endif // OBSERVINGLIST_H_
diff --git a/kstars/tools/observinglist.ui b/kstars/tools/observinglist.ui
index afa6bba..d7de155 100644
--- a/kstars/tools/observinglist.ui
+++ b/kstars/tools/observinglist.ui
@@ -262,7 +262,17 @@
       </widget>
      </item>
      <item>
-      <widget class="KDateComboBox" name="DateEdit"/>
+      <widget class="QDateEdit" name="DateEdit">
+       <property name="showGroupSeparator" stdset="0">
+        <bool>false</bool>
+       </property>
+       <property name="displayFormat">
+        <string>dd/mm/yy</string>
+       </property>
+       <property name="calendarPopup">
+        <bool>true</bool>
+       </property>
+      </widget>
      </item>
      <item>
       <widget class="QPushButton" name="Update">
@@ -565,32 +575,22 @@
       </spacer>
      </item>
      <item>
-      <widget class="KSeparator" name="kseparator">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="orientation">
-        <enum>Qt::Vertical</enum>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="KImageFilePreview" name="ImagePreview">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
+      <widget class="QLabel" name="ImagePreview">
        <property name="minimumSize">
         <size>
          <width>200</width>
          <height>200</height>
         </size>
        </property>
+       <property name="maximumSize">
+        <size>
+         <width>200</width>
+         <height>200</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>TextLabel</string>
+       </property>
       </widget>
      </item>
      <item>
@@ -697,26 +697,13 @@
    <class>KPlotWidget</class>
    <extends>QFrame</extends>
    <header>kplotwidget.h</header>
-  </customwidget>
-  <customwidget>
-   <class>KDateComboBox</class>
-   <extends>QComboBox</extends>
-   <header>kdatecombobox.h</header>
-  </customwidget>
-  <customwidget>
-   <class>KImageFilePreview</class>
-   <extends>QWidget</extends>
-   <header>kimagefilepreview.h</header>
-  </customwidget>
-  <customwidget>
-   <class>KSeparator</class>
-   <extends>QFrame</extends>
-   <header>kseparator.h</header>
+   <container>1</container>
   </customwidget>
   <customwidget>
    <class>AVTPlotWidget</class>
    <extends>KPlotWidget</extends>
    <header>tools/avtplotwidget.h</header>
+   <container>1</container>
   </customwidget>
  </customwidgets>
  <resources/>
diff --git a/kstars/widgets/dmsbox.h b/kstars/widgets/dmsbox.h
index f974ebc..936133c 100644
--- a/kstars/widgets/dmsbox.h
+++ b/kstars/widgets/dmsbox.h
@@ -19,7 +19,8 @@
 #define DMSBOX_H
 
 #include <QFocusEvent>
-#include <klineedit.h>
+#include <QLineEdit>
+//#include <klineedit.h>
 
 #include "dms.h"
 


More information about the Kstars-devel mailing list