Commit 62cf5aee authored by Jasem Mutlaq's avatar Jasem Mutlaq
Browse files

Using Qt5 builtin JSon support and removing dependency on external QJSon library

parent 7f6e7742
......@@ -61,16 +61,13 @@ find_package(WCSLIB)
set(HAVE_WCSLIB WCSLIB_FOUND)
set_package_properties(WCSLIB PROPERTIES DESCRIPTION "World Coordinate System library" URL "http://www.atnf.csiro.au/people/mcalabre/WCS" TYPE OPTIONAL PURPOSE "WCS enables KStars to read and process world coordinate systems in FITS header.")
# FIXME QJSON is not needed in Qt5
find_package(QJSON)
find_package(Xplanet)
set(HAVE_XPLANET XPLANET_FOUND)
set_package_properties(Xplanet PROPERTIES DESCRIPTION "Renders an image of all the major planets and most satellites" URL "http://xplanet.sourceforge.net" TYPE OPTIONAL PURPOSE "Gives KStars support for xplanet.")
find_package(AstrometryNet)
set(HAVE_ASTROMETRYNET ASTROMETRYNET_FOUND)
set_package_properties(OpenGL PROPERTIES DESCRIPTION "Astrometrics Library" URL "http://www.astrometry.net" TYPE OPTIONAL PURPOSE "Support for plate solving in KStars.")
set_package_properties(AstrometryNet PROPERTIES DESCRIPTION "Astrometrics Library" URL "http://www.astrometry.net" TYPE OPTIONAL PURPOSE "Support for plate solving in KStars.")
find_package(OpenGL)
set_package_properties(OpenGL PROPERTIES DESCRIPTION "Open Graphics Library" URL "http://www.opengl.org" TYPE OPTIONAL PURPOSE "Support for hardware rendering in KStars.")
......
......@@ -75,6 +75,7 @@ if (CFITSIO_FOUND)
ekos/align.cpp
ekos/astrometryparser.cpp
ekos/offlineastrometryparser.cpp
ekos/onlineastrometryparser.cpp
ekos/opsekos.cpp
ekos/QProgressIndicator.cpp
ekos/guide/common.cpp
......@@ -89,11 +90,6 @@ if (CFITSIO_FOUND)
endif(CFITSIO_FOUND)
if (QJSON_FOUND)
include_directories( ${QJSON_INCLUDE_DIR} )
set(onlineparser_SRCS ekos/onlineastrometryparser.cpp)
endif(QJSON_FOUND)
include_directories(${INDI_INCLUDE_DIR})
endif(INDI_FOUND)
......@@ -518,9 +514,6 @@ endif (WCSLIB_FOUND)
# ${QT_QTOPENGL_LIBRARY}
# )
#endif( OPENGL_FOUND )
if (QJSON_FOUND)
target_link_libraries(KStarsLib ${QJSON_LIBRARIES})
endif(QJSON_FOUND)
target_link_libraries(kstars KStarsLib)
......@@ -541,4 +534,3 @@ install( FILES fitsviewer.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kstars )
if (WIN32)
install( FILES kstarsui-win.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kstars )
endif (WIN32)
......@@ -29,9 +29,7 @@
#include "ekosmanager.h"
#include "kstars.h"
#ifdef HAVE_QJSON
#include "onlineastrometryparser.h"
#endif
#include "offlineastrometryparser.h"
#include <basedevice.h>
......@@ -58,9 +56,7 @@ Align::Align()
parser = NULL;
#ifdef HAVE_QJSON
onlineParser = NULL;
#endif
offlineParser = NULL;
connect(solveB, SIGNAL(clicked()), this, SLOT(capture()));
......@@ -98,29 +94,15 @@ Align::Align()
altStage = ALT_INIT;
azStage = AZ_INIT;
#ifndef HAVE_QJSON
kcfg_onlineSolver->setChecked(false);
kcfg_onlineSolver->setEnabled(false);
#else
kcfg_onlineSolver->setChecked(Options::solverOnline());
#endif
kcfg_offlineSolver->setChecked(Options::solverOnline() == false);
connect(kcfg_onlineSolver, SIGNAL(toggled(bool)), SLOT(updateSolverType(bool)));
if (kcfg_onlineSolver->isChecked())
{
#ifdef HAVE_QJSON
onlineParser = new Ekos::OnlineAstrometryParser();
parser = onlineParser;
#else
kcfg_onlineSolver->setChecked(false);
kcfg_onlineSolver->setEnabled(false);
kcfg_offlineSolver->setChecked(true);
offlineParser = new OfflineAstrometryParser();
parser = offlineParser;
#endif
parser = onlineParser;
}
else
{
......@@ -169,7 +151,6 @@ void Align::updateSolverType(bool useOnline)
if (useOnline)
{
#ifdef HAVE_QJSON
if (onlineParser != NULL)
{
parser = onlineParser;
......@@ -178,7 +159,6 @@ void Align::updateSolverType(bool useOnline)
onlineParser = new Ekos::OnlineAstrometryParser();
parser = onlineParser;
#endif
}
else
{
......
......@@ -129,9 +129,7 @@ private:
static const float SIDRATE;
AstrometryParser *parser;
#ifdef HAVE_QJSON
OnlineAstrometryParser *onlineParser;
#endif
OfflineAstrometryParser *offlineParser;
......
......@@ -14,6 +14,8 @@
#include <QDebug>
#include <QHttpMultiPart>
#include <QFile>
#include <QJsonObject>
#include <QJsonDocument>
#include <KLocalizedString>
......@@ -184,7 +186,6 @@ bool OnlineAstrometryParser::stopSolver()
void OnlineAstrometryParser::authenticate()
{
QNetworkRequest request;
bool ok;
//request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
......@@ -195,9 +196,11 @@ void OnlineAstrometryParser::authenticate()
QVariantMap apiReq;
apiReq.insert("apikey", Options::astrometryAPIKey());
QByteArray json = serializer.serialize(apiReq, &ok);
//QByteArray json = serializer.serialize(apiReq, &ok);
QJsonObject json = QJsonObject::fromVariantMap(apiReq);
QJsonDocument json_doc(json);
QString json_request = QString("request-json=%1").arg(QString(json));
QString json_request = QString("request-json=%1").arg(QString(json_doc.toJson(QJsonDocument::Compact)));
workflowStage = AUTH_STAGE;
......@@ -206,7 +209,6 @@ void OnlineAstrometryParser::authenticate()
void OnlineAstrometryParser::uploadFile()
{
bool ok;
QNetworkRequest request;
QFile fitsFile(filename);
......@@ -240,12 +242,14 @@ void OnlineAstrometryParser::uploadFile()
if (downsample_factor != 0)
uploadReq.insert("downsample_factor", downsample_factor);
QByteArray json = serializer.serialize(uploadReq, &ok);
QJsonObject json = QJsonObject::fromVariantMap(uploadReq);
QJsonDocument json_doc(json);
QHttpPart jsonPart;
jsonPart.setHeader(QNetworkRequest::ContentTypeHeader, "application/text/plain");
jsonPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"request-json\"");
jsonPart.setBody(json);
jsonPart.setBody(json_doc.toJson(QJsonDocument::Compact));
QHttpPart filePart;
......@@ -309,6 +313,7 @@ void OnlineAstrometryParser::checkJobCalibration()
void OnlineAstrometryParser::onResult(QNetworkReply* reply)
{
bool ok;
QJsonParseError parseError;
QString status;
QList<QVariant> jsonArray;
int elapsed;
......@@ -325,17 +330,20 @@ void OnlineAstrometryParser::onResult(QNetworkReply* reply)
QString json = (QString) reply->readAll();
QVariantMap result = parser.parse (json.toUtf8(), &ok).toMap();
QJsonDocument json_doc = QJsonDocument::fromJson(json.toUtf8(), &parseError);
if (ok == false)
if (parseError.error != QJsonParseError::NoError)
{
align->appendLogText(QString("JSon error during parsing."));
align->appendLogText(xi18n("JSon error during parsing (%1).", parseError.errorString()));
emit solverFailed();
return;
}
QVariant json_result = json_doc.toVariant();
QVariantMap result = json_result.toMap();
if (align->isVerbose())
align->appendLogText(json);
align->appendLogText(json_doc.toJson(QJsonDocument::Compact));
switch (workflowStage)
{
......@@ -421,6 +429,7 @@ void OnlineAstrometryParser::onResult(QNetworkReply* reply)
else
{
align->appendLogText(xi18n("Solver timed out."));
solver_retries=0;
emit solverFailed();
return;
}
......
......@@ -10,9 +10,6 @@
#ifndef ONLINEASTROMETRYPARSER_H
#define ONLINEASTROMETRYPARSER_H
#include <qjson/parser.h>
#include <qjson/serializer.h>
#include <QTime>
#include <QtNetwork/QNetworkAccessManager>
......@@ -65,8 +62,6 @@ private:
int job_retries, solver_retries;
QTime solverTimer;
QJson::Parser parser;
QJson::Serializer serializer;
QString filename, apiURL;
double lowerScale, upperScale, center_ra, center_dec, radius;
double parity,ra,dec,orientation;
......
......@@ -14,7 +14,6 @@
#include <QStringList>
#include <QComboBox>
#include <klineedit.h>
#include <KConfigDialog>
#include "opsekos.h"
......@@ -27,12 +26,11 @@ OpsEkos::OpsEkos( KStars *_ks )
{
setupUi(this);
//Get a pointer to the KConfigDialog
m_ConfigDialog = KConfigDialog::exists( "settings" );
connect( m_ConfigDialog, SIGNAL( applyClicked() ), SLOT( slotApply() ) );
connect( m_ConfigDialog, SIGNAL( okClicked() ), SLOT( slotApply() ) );
connect( m_ConfigDialog, SIGNAL(okClicked()), SLOT( slotApply() ) );
connect( m_ConfigDialog, SIGNAL( cancelClicked() ), SLOT( slotCancel() ) );
}
......@@ -50,6 +48,6 @@ void OpsEkos::slotApply()
void OpsEkos::slotCancel()
{
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment