MpcImportWindow.cpp   MpcImportWindow.cpp 
skipping to change at line 57 skipping to change at line 57
#include <QString> #include <QString>
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QTimer> #include <QTimer>
#include <QUrl> #include <QUrl>
#include <QUrlQuery> #include <QUrlQuery>
#include <QDir> #include <QDir>
MpcImportWindow::MpcImportWindow() MpcImportWindow::MpcImportWindow()
: StelDialog("SolarSystemEditorMPCimport") : StelDialog("SolarSystemEditorMPCimport")
, importType(ImportType()) , importType(ImportType())
, downloadReply(0) , downloadReply(Q_NULLPTR)
, queryReply(0) , queryReply(Q_NULLPTR)
, downloadProgressBar(0) , downloadProgressBar(Q_NULLPTR)
, queryProgressBar(0) , queryProgressBar(Q_NULLPTR)
, countdown(0) , countdown(0)
{ {
ui = new Ui_mpcImportWindow(); ui = new Ui_mpcImportWindow();
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;
skipping to change at line 334 skipping to change at line 334
void MpcImportWindow::pasteClipboardURL() void MpcImportWindow::pasteClipboardURL()
{ {
ui->lineEditURL->setText(QGuiApplication::clipboard()->text()); ui->lineEditURL->setText(QGuiApplication::clipboard()->text());
} }
void MpcImportWindow::selectFile() void MpcImportWindow::selectFile()
{ {
QStringList directories = QStandardPaths::standardLocations(QStandar dPaths::DesktopLocation) + QStringList directories = QStandardPaths::standardLocations(QStandar dPaths::DesktopLocation) +
QStandardPaths::st andardLocations(QStandardPaths::HomeLocation) << "/"; QStandardPaths::st andardLocations(QStandardPaths::HomeLocation) << "/";
QString filePath = QFileDialog::getOpenFileName(NULL, "Select a text file", directories[0]); QString filePath = QFileDialog::getOpenFileName(Q_NULLPTR, "Select a text file", directories[0]);
ui->lineEditFilePath->setText(filePath); ui->lineEditFilePath->setText(filePath);
} }
void MpcImportWindow::bookmarkSelected(QString bookmarkTitle) void MpcImportWindow::bookmarkSelected(QString bookmarkTitle)
{ {
if (bookmarkTitle.isEmpty() || bookmarks.value(importType).value(boo kmarkTitle).isEmpty()) if (bookmarkTitle.isEmpty() || bookmarks.value(importType).value(boo kmarkTitle).isEmpty())
{ {
ui->lineEditURL->clear(); ui->lineEditURL->clear();
return; return;
} }
skipping to change at line 531 skipping to change at line 531
QStandardItem * item = candidateObjectsModel->item(row); QStandardItem * item = candidateObjectsModel->item(row);
if (item) if (item)
{ {
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
} }
} }
} }
void MpcImportWindow::updateDownloadProgress(qint64 bytesReceived, qint64 b ytesTotal) void MpcImportWindow::updateDownloadProgress(qint64 bytesReceived, qint64 b ytesTotal)
{ {
if (downloadProgressBar == NULL) if (downloadProgressBar == Q_NULLPTR)
return; return;
int currentValue = 0; int currentValue = 0;
int endValue = 0; int endValue = 0;
if (bytesTotal > -1 && bytesReceived <= bytesTotal) if (bytesTotal > -1 && bytesReceived <= bytesTotal)
{ {
//Round to the greatest possible derived unit //Round to the greatest possible derived unit
while (bytesTotal > 1024) while (bytesTotal > 1024)
{ {
skipping to change at line 555 skipping to change at line 555
currentValue = bytesReceived; currentValue = bytesReceived;
endValue = bytesTotal; endValue = bytesTotal;
} }
downloadProgressBar->setValue(currentValue); downloadProgressBar->setValue(currentValue);
downloadProgressBar->setRange(0, endValue); downloadProgressBar->setRange(0, endValue);
} }
void MpcImportWindow::updateQueryProgress(qint64, qint64) void MpcImportWindow::updateQueryProgress(qint64, qint64)
{ {
if (queryProgressBar == NULL) if (queryProgressBar == Q_NULLPTR)
return; return;
//Just show activity //Just show activity
queryProgressBar->setValue(0); queryProgressBar->setValue(0);
queryProgressBar->setRange(0, 0); queryProgressBar->setRange(0, 0);
} }
void MpcImportWindow::startDownload(QString urlString) void MpcImportWindow::startDownload(QString urlString)
{ {
if (downloadReply) if (downloadReply)
skipping to change at line 598 skipping to change at line 598
enableInterface(false); enableInterface(false);
ui->pushButtonAbortDownload->setVisible(true); ui->pushButtonAbortDownload->setVisible(true);
connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT (downloadComplete(QNetworkReply*))); connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT (downloadComplete(QNetworkReply*)));
downloadReply = networkManager->get(QNetworkRequest(url)); downloadReply = networkManager->get(QNetworkRequest(url));
connect(downloadReply, SIGNAL(downloadProgress(qint64,qint64)), this , SLOT(updateDownloadProgress(qint64,qint64))); connect(downloadReply, SIGNAL(downloadProgress(qint64,qint64)), this , SLOT(updateDownloadProgress(qint64,qint64)));
} }
void MpcImportWindow::abortDownload() void MpcImportWindow::abortDownload()
{ {
if (downloadReply == NULL || downloadReply->isFinished()) if (downloadReply == Q_NULLPTR || downloadReply->isFinished())
return; return;
qDebug() << "Aborting download..."; qDebug() << "Aborting download...";
disconnect(networkManager, SIGNAL(finished(QNetworkReply*)), this, S LOT(downloadComplete(QNetworkReply*))); disconnect(networkManager, SIGNAL(finished(QNetworkReply*)), this, S LOT(downloadComplete(QNetworkReply*)));
deleteDownloadProgressBar(); deleteDownloadProgressBar();
downloadReply->abort(); downloadReply->abort();
downloadReply->deleteLater(); downloadReply->deleteLater();
downloadReply = NULL; downloadReply = Q_NULLPTR;
enableInterface(true); enableInterface(true);
ui->pushButtonAbortDownload->setVisible(false); ui->pushButtonAbortDownload->setVisible(false);
} }
void MpcImportWindow::downloadComplete(QNetworkReply *reply) void MpcImportWindow::downloadComplete(QNetworkReply *reply)
{ {
disconnect(networkManager, SIGNAL(finished(QNetworkReply*)), this, S LOT(downloadComplete(QNetworkReply*))); disconnect(networkManager, SIGNAL(finished(QNetworkReply*)), this, S LOT(downloadComplete(QNetworkReply*)));
deleteDownloadProgressBar(); deleteDownloadProgressBar();
ui->pushButtonAbortDownload->setVisible(false); ui->pushButtonAbortDownload->setVisible(false);
skipping to change at line 634 skipping to change at line 634
*/ */
if(reply->error()) if(reply->error())
{ {
qWarning() << "Download error: While downloading" qWarning() << "Download error: While downloading"
<< reply->url().toString() << reply->url().toString()
<< "the following error occured:" << "the following error occured:"
<< reply->errorString(); << reply->errorString();
enableInterface(true); enableInterface(true);
reply->deleteLater(); reply->deleteLater();
downloadReply = NULL; downloadReply = Q_NULLPTR;
return; return;
} }
QList<SsoElements> objects; QList<SsoElements> objects;
QTemporaryFile file; QTemporaryFile file;
if (file.open()) if (file.open())
{ {
file.write(reply->readAll()); file.write(reply->readAll());
file.close(); file.close();
objects = readElementsFromFile(importType, file.fileName()); objects = readElementsFromFile(importType, file.fileName());
skipping to change at line 676 skipping to change at line 676
if (!bookmarks.value(importType).values().contains(u rl)) if (!bookmarks.value(importType).values().contains(u rl))
{ {
bookmarks[importType].insert(title, url); bookmarks[importType].insert(title, url);
populateBookmarksList(); populateBookmarksList();
saveBookmarks(); saveBookmarks();
} }
} }
} }
reply->deleteLater(); reply->deleteLater();
downloadReply = NULL; downloadReply = Q_NULLPTR;
//Temporary, until the slot/socket mechanism is ready //Temporary, until the slot/socket mechanism is ready
populateCandidateObjects(objects); populateCandidateObjects(objects);
ui->stackedWidget->setCurrentIndex(1); ui->stackedWidget->setCurrentIndex(1);
//As this window is persistent, if the Solar System is changed //As this window is persistent, if the Solar System is changed
//while there is a list, it should be reset. //while there is a list, it should be reset.
connect(ssoManager, SIGNAL(solarSystemChanged()), this, SLOT(resetDi alog())); connect(ssoManager, SIGNAL(solarSystemChanged()), this, SLOT(resetDi alog()));
} }
void MpcImportWindow::deleteDownloadProgressBar() void MpcImportWindow::deleteDownloadProgressBar()
{ {
disconnect(this, SLOT(updateDownloadProgress(qint64,qint64))); disconnect(this, SLOT(updateDownloadProgress(qint64,qint64)));
if (downloadProgressBar) if (downloadProgressBar)
{ {
StelApp::getInstance().removeProgressBar(downloadProgressBar ); StelApp::getInstance().removeProgressBar(downloadProgressBar );
downloadProgressBar = NULL; downloadProgressBar = Q_NULLPTR;
} }
} }
void MpcImportWindow::sendQuery() void MpcImportWindow::sendQuery()
{ {
if (queryReply != 0) if (queryReply != 0)
return; return;
query = ui->lineEditQuery->text().trimmed(); query = ui->lineEditQuery->text().trimmed();
if (query.isEmpty()) if (query.isEmpty())
skipping to change at line 909 skipping to change at line 909
ui->stackedWidget->setCurrentIndex(1); ui->stackedWidget->setCurrentIndex(1);
} }
} }
void MpcImportWindow::deleteQueryProgressBar() void MpcImportWindow::deleteQueryProgressBar()
{ {
disconnect(this, SLOT(updateQueryProgress(qint64,qint64))); disconnect(this, SLOT(updateQueryProgress(qint64,qint64)));
if (queryProgressBar) if (queryProgressBar)
{ {
StelApp::getInstance().removeProgressBar(queryProgressBar); StelApp::getInstance().removeProgressBar(queryProgressBar);
queryProgressBar = NULL; queryProgressBar = Q_NULLPTR;
} }
} }
void MpcImportWindow::startCountdown() void MpcImportWindow::startCountdown()
{ {
if (!countdownTimer->isActive()) if (!countdownTimer->isActive())
countdownTimer->start(1000);//1 second countdownTimer->start(1000);//1 second
//Disable the interface //Disable the interface
ui->lineEditQuery->setEnabled(false); ui->lineEditQuery->setEnabled(false);
 End of changes. 10 change blocks. 
13 lines changed or deleted 13 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/