MpcImportWindow.cpp   MpcImportWindow.cpp 
skipping to change at line 33 skipping to change at line 33
#include "MpcImportWindow.hpp" #include "MpcImportWindow.hpp"
#include "ui_mpcImportWindow.h" #include "ui_mpcImportWindow.h"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StelProgressController.hpp" #include "StelProgressController.hpp"
#include "SearchDialog.hpp"
#include "StelUtils.hpp"
#include <QGuiApplication> #include <QGuiApplication>
#include <QClipboard> #include <QClipboard>
#include <QDesktopServices> #include <QDesktopServices>
#include <QFileDialog> #include <QFileDialog>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QHash> #include <QHash>
#include <QList> #include <QList>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkRequest> #include <QNetworkRequest>
skipping to change at line 61 skipping to change at line 63
MpcImportWindow::MpcImportWindow() MpcImportWindow::MpcImportWindow()
: importType(ImportType()) : importType(ImportType())
, downloadReply(0) , downloadReply(0)
, queryReply(0) , queryReply(0)
, downloadProgressBar(0) , downloadProgressBar(0)
, queryProgressBar(0) , queryProgressBar(0)
, countdown(0) , countdown(0)
{ {
ui = new Ui_mpcImportWindow(); ui = new Ui_mpcImportWindow();
dialogName = "SolarSystemEditorMPCimport";
ssoManager = GETSTELMODULE(SolarSystemEditor); ssoManager = GETSTELMODULE(SolarSystemEditor);
networkManager = StelApp::getInstance().getNetworkAccessManager(); networkManager = StelApp::getInstance().getNetworkAccessManager();
countdownTimer = new QTimer(this); countdownTimer = new QTimer(this);
QHash<QString,QString> asteroidBookmarks; QHash<QString,QString> asteroidBookmarks;
QHash<QString,QString> cometBookmarks; QHash<QString,QString> cometBookmarks;
bookmarks.insert(MpcComets, cometBookmarks); bookmarks.insert(MpcComets, cometBookmarks);
bookmarks.insert(MpcMinorPlanets, asteroidBookmarks); bookmarks.insert(MpcMinorPlanets, asteroidBookmarks);
skipping to change at line 98 skipping to change at line 101
StelApp::getInstance().removeProgressBar(queryProgressBar); StelApp::getInstance().removeProgressBar(queryProgressBar);
} }
void MpcImportWindow::createDialogContent() void MpcImportWindow::createDialogContent()
{ {
ui->setupUi(dialog); ui->setupUi(dialog);
//Signals //Signals
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate())); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate()));
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMove dTo(QPoint)));
connect(ui->pushButtonAcquire, SIGNAL(clicked()), connect(ui->pushButtonAcquire, SIGNAL(clicked()),
this, SLOT(acquireObjectData())); this, SLOT(acquireObjectData()));
connect(ui->pushButtonAbortDownload, SIGNAL(clicked()), connect(ui->pushButtonAbortDownload, SIGNAL(clicked()),
this, SLOT(abortDownload())); this, SLOT(abortDownload()));
connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(addObjects( ))); connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(addObjects( )));
connect(ui->pushButtonDiscard, SIGNAL(clicked()), connect(ui->pushButtonDiscard, SIGNAL(clicked()),
this, SLOT(discardObjects())); this, SLOT(discardObjects()));
connect(ui->pushButtonBrowse, SIGNAL(clicked()), this, SLOT(selectFi le())); connect(ui->pushButtonBrowse, SIGNAL(clicked()), this, SLOT(selectFi le()));
skipping to change at line 262 skipping to change at line 266
QList<QString> checkedObjectsNames; QList<QString> checkedObjectsNames;
//Extract the marked objects //Extract the marked objects
//TODO: Something smarter? //TODO: Something smarter?
for (int row = 0; row < candidateObjectsModel->rowCount(); row++) for (int row = 0; row < candidateObjectsModel->rowCount(); row++)
{ {
QStandardItem * item = candidateObjectsModel->item(row); QStandardItem * item = candidateObjectsModel->item(row);
if (item->checkState() == Qt::Checked) if (item->checkState() == Qt::Checked)
{ {
checkedObjectsNames.append(item->text()); checkedObjectsNames.append(item->text());
if (row==0)
SearchDialog::extSearchText = item->text();
} }
} }
//qDebug() << "Checked:" << checkedObjectsNames; //qDebug() << "Checked:" << checkedObjectsNames;
QList<SsoElements> approvedForAddition; QList<SsoElements> approvedForAddition;
for (int i = 0; i < candidatesForAddition.count(); i++) for (int i = 0; i < candidatesForAddition.count(); i++)
{ {
QString name = candidatesForAddition.at(i).value("name").toS tring(); QString name = candidatesForAddition.at(i).value("name").toS tring();
if (checkedObjectsNames.contains(name)) if (checkedObjectsNames.contains(name))
approvedForAddition.append(candidatesForAddition.at( i)); approvedForAddition.append(candidatesForAddition.at( i));
skipping to change at line 810 skipping to change at line 816
deleteQueryProgressBar(); deleteQueryProgressBar();
//Hide the abort button - a reply has been received //Hide the abort button - a reply has been received
ui->pushButtonAbortQuery->setVisible(false); ui->pushButtonAbortQuery->setVisible(false);
if (reply->error()) if (reply->error())
{ {
qWarning() << "Download error: While trying to access" qWarning() << "Download error: While trying to access"
<< reply->url().toString() << reply->url().toString()
<< "the following error occured:" << "the following error occured:"
<< reply->errorString(); << reply->errorString();
ui->labelQueryMessage->setText(reply->errorString());//TODO: Decide if this is a good idea ui->labelQueryMessage->setText(reply->errorString());//TODO: Decide if this is a good idea
ui->labelQueryMessage->setVisible(true); ui->labelQueryMessage->setVisible(true);
enableInterface(true); enableInterface(true);
reply->deleteLater(); reply->deleteLater();
queryReply = 0; queryReply = 0;
return; return;
} }
QString contentType = reply->header(QNetworkRequest::ContentTypeHead er).toString(); QString contentType = reply->header(QNetworkRequest::ContentTypeHead er).toString();
QString contentDisposition = reply->rawHeader(QByteArray("Content-di sposition")); QString contentDisposition = reply->rawHeader(QByteArray("Content-di sposition"));
if (contentType == "text/ascii" && if (contentType == "text/ascii" &&
contentDisposition == "attachment; filename=elements.txt") contentDisposition == "attachment; filename=elements.txt")
{ {
readQueryReply(reply); readQueryReply(reply);
} }
else else
{ {
ui->labelQueryMessage->setText("Object not found."); ui->labelQueryMessage->setText("Object not found.");
ui->labelQueryMessage->setVisible(true); ui->labelQueryMessage->setVisible(true);
enableInterface(true); enableInterface(true);
} }
reply->deleteLater(); reply->deleteLater();
queryReply = 0; queryReply = 0;
} }
void MpcImportWindow::readQueryReply(QNetworkReply * reply) void MpcImportWindow::readQueryReply(QNetworkReply * reply)
{ {
skipping to change at line 973 skipping to change at line 979
bookmarks[MpcMinorPlanets].clear(); bookmarks[MpcMinorPlanets].clear();
QString bookmarksFilePath(StelFileMgr::getUserDir() + "/modules/Sola rSystemEditor/bookmarks.json"); QString bookmarksFilePath(StelFileMgr::getUserDir() + "/modules/Sola rSystemEditor/bookmarks.json");
if (StelFileMgr::isReadable(bookmarksFilePath)) if (StelFileMgr::isReadable(bookmarksFilePath))
{ {
QFile bookmarksFile(bookmarksFilePath); QFile bookmarksFile(bookmarksFilePath);
if (bookmarksFile.open(QFile::ReadOnly | QFile::Text)) if (bookmarksFile.open(QFile::ReadOnly | QFile::Text))
{ {
QVariantMap jsonRoot = StelJsonParser::parse(bookmar ksFile.readAll()).toMap(); QVariantMap jsonRoot = StelJsonParser::parse(bookmar ksFile.readAll()).toMap();
QString fileVersion = jsonRoot.value("version").toSt
ring();
if (fileVersion.isEmpty())
fileVersion = "0.0.0";
loadBookmarksGroup(jsonRoot.value("mpcMinorPlanets") .toMap(), bookmarks[MpcMinorPlanets]); loadBookmarksGroup(jsonRoot.value("mpcMinorPlanets") .toMap(), bookmarks[MpcMinorPlanets]);
loadBookmarksGroup(jsonRoot.value("mpcComets").toMap (), bookmarks[MpcComets]); loadBookmarksGroup(jsonRoot.value("mpcComets").toMap (), bookmarks[MpcComets]);
bookmarksFile.close(); bookmarksFile.close();
//If nothing was read, continue //If nothing was read, continue
if (!bookmarks.value(MpcComets).isEmpty() && !bookma rks[MpcMinorPlanets].isEmpty()) if (!bookmarks.value(MpcComets).isEmpty() && !bookma rks[MpcMinorPlanets].isEmpty() && StelUtils::compareVersions(fileVersion, S OLARSYSTEMEDITOR_VERSION)==0)
return; return;
} }
} }
qDebug() << "Bookmarks file can't be read. Hard-coded bookmarks will be used."; qDebug() << "Bookmarks file can't be read. Hard-coded bookmarks will be used.";
//Initialize with hard-coded values //Initialize with hard-coded values
bookmarks[MpcMinorPlanets].insert("MPC's list of bright minor planet bookmarks[MpcMinorPlanets].insert("MPC's list of bright minor planet
s at opposition in 2011", "http://www.minorplanetcenter.net/iau/Ephemerides s at opposition in 2016", "http://www.minorplanetcenter.net/iau/Ephemerides
/Bright/2011/Soft00Bright.txt"); /Bright/2016/Soft00Bright.txt");
bookmarks[MpcMinorPlanets].insert("MPC's list of bright minor planet
s at opposition in 2013", "http://www.minorplanetcenter.net/iau/Ephemerides
/Bright/2013/Soft00Bright.txt");
bookmarks[MpcMinorPlanets].insert("MPC's list of bright minor planet
s at opposition in 2014", "http://www.minorplanetcenter.net/iau/Ephemerides
/Bright/2014/Soft00Bright.txt");
bookmarks[MpcMinorPlanets].insert("MPC's list of bright minor planet
s at opposition in 2015", "http://www.minorplanetcenter.net/iau/Ephemerides
/Bright/2015/Soft00Bright.txt");
bookmarks[MpcMinorPlanets].insert("MPC's list of observable distant minor planets", "http://www.minorplanetcenter.net/iau/Ephemerides/Distant/S oft00Distant.txt"); bookmarks[MpcMinorPlanets].insert("MPC's list of observable distant minor planets", "http://www.minorplanetcenter.net/iau/Ephemerides/Distant/S oft00Distant.txt");
bookmarks[MpcMinorPlanets].insert("MPCORB: near-Earth asteroids (NEA s)", "http://www.minorplanetcenter.net/iau/MPCORB/NEA.txt"); bookmarks[MpcMinorPlanets].insert("MPCORB: near-Earth asteroids (NEA s)", "http://www.minorplanetcenter.net/iau/MPCORB/NEA.txt");
bookmarks[MpcMinorPlanets].insert("MPCORB: potentially hazardous ast eroids (PHAs)", "http://www.minorplanetcenter.net/iau/MPCORB/PHA.txt"); bookmarks[MpcMinorPlanets].insert("MPCORB: potentially hazardous ast eroids (PHAs)", "http://www.minorplanetcenter.net/iau/MPCORB/PHA.txt");
bookmarks[MpcMinorPlanets].insert("MPCORB: TNOs, Centaurs and SDOs", "http://www.minorplanetcenter.net/iau/MPCORB/Distant.txt"); bookmarks[MpcMinorPlanets].insert("MPCORB: TNOs, Centaurs and SDOs", "http://www.minorplanetcenter.net/iau/MPCORB/Distant.txt");
bookmarks[MpcMinorPlanets].insert("MPCORB: other unusual objects", " http://www.minorplanetcenter.net/iau/MPCORB/Unusual.txt"); bookmarks[MpcMinorPlanets].insert("MPCORB: other unusual objects", " http://www.minorplanetcenter.net/iau/MPCORB/Unusual.txt");
bookmarks[MpcMinorPlanets].insert("MPCORB: orbits from the latest DO U MPEC", "http://www.minorplanetcenter.net/iau/MPCORB/DAILY.DAT"); bookmarks[MpcMinorPlanets].insert("MPCORB: orbits from the latest DO U MPEC", "http://www.minorplanetcenter.net/iau/MPCORB/DAILY.DAT");
bookmarks[MpcMinorPlanets].insert("MPCAT: Unusual minor planets (inc
luding NEOs)", "http://www.minorplanetcenter.net/iau/ECS/MPCAT/unusual.txt"
);
bookmarks[MpcMinorPlanets].insert("MPCAT: Distant minor planets (Cen
taurs and transneptunians)", "http://www.minorplanetcenter.net/iau/ECS/MPCA
T/distant.txt");
bookmarks[MpcComets].insert("MPC's list of observable comets", "http ://www.minorplanetcenter.net/iau/Ephemerides/Comets/Soft00Cmt.txt"); bookmarks[MpcComets].insert("MPC's list of observable comets", "http ://www.minorplanetcenter.net/iau/Ephemerides/Comets/Soft00Cmt.txt");
bookmarks[MpcComets].insert("MPCORB: comets", "http://www.minorplane tcenter.net/iau/MPCORB/CometEls.txt"); bookmarks[MpcComets].insert("MPCORB: comets", "http://www.minorplane tcenter.net/iau/MPCORB/CometEls.txt");
//Try to save them to a file //Try to save them to a file
saveBookmarks(); saveBookmarks();
} }
void MpcImportWindow::loadBookmarksGroup(QVariantMap source, Bookmarks & bo okmarkGroup) void MpcImportWindow::loadBookmarksGroup(QVariantMap source, Bookmarks & bo okmarkGroup)
{ {
if (source.isEmpty()) if (source.isEmpty())
skipping to change at line 1041 skipping to change at line 1049
if (bookmarksFile.open(QFile::ReadOnly | QFile::Text )) if (bookmarksFile.open(QFile::ReadOnly | QFile::Text ))
{ {
jsonRoot = StelJsonParser::parse(bookmarksFi le.readAll()).toMap(); jsonRoot = StelJsonParser::parse(bookmarksFi le.readAll()).toMap();
bookmarksFile.close(); bookmarksFile.close();
} }
} }
QFile bookmarksFile(bookmarksFilePath); QFile bookmarksFile(bookmarksFilePath);
if (bookmarksFile.open(QFile::WriteOnly | QFile::Truncate | QFile::Text)) if (bookmarksFile.open(QFile::WriteOnly | QFile::Truncate | QFile::Text))
{ {
jsonRoot.insert("version", SOLARSYSTEMEDITOR_VERSION
);
QVariantMap minorPlanetsObject; QVariantMap minorPlanetsObject;
saveBookmarksGroup(bookmarks[MpcMinorPlanets], minor PlanetsObject); saveBookmarksGroup(bookmarks[MpcMinorPlanets], minor PlanetsObject);
//qDebug() << minorPlanetsObject.keys(); //qDebug() << minorPlanetsObject.keys();
jsonRoot.insert("mpcMinorPlanets", minorPlanetsObjec t); jsonRoot.insert("mpcMinorPlanets", minorPlanetsObjec t);
QVariantMap cometsObject; QVariantMap cometsObject;
saveBookmarksGroup(bookmarks[MpcComets], cometsObjec t); saveBookmarksGroup(bookmarks[MpcComets], cometsObjec t);
jsonRoot.insert("mpcComets", cometsObject); jsonRoot.insert("mpcComets", cometsObject);
StelJsonParser::write(jsonRoot, &bookmarksFile); StelJsonParser::write(jsonRoot, &bookmarksFile);
 End of changes. 11 change blocks. 
15 lines changed or deleted 25 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/