SatellitesImportDialog.cpp   SatellitesImportDialog.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 1, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130 1, USA.
*/ */
#include "SatellitesImportDialog.hpp" #include "SatellitesImportDialog.hpp"
#include "ui_satellitesImportDialog.h" #include "ui_satellitesImportDialog.h"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelMainGraphicsView.hpp" //for the QFileDialog? Why? #include "StelMainView.hpp" //for the QFileDialog? Why?
#include "StelModuleMgr.hpp" // for the GETSTELMODULE macro :( #include "StelModuleMgr.hpp" // for the GETSTELMODULE macro :(
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelProgressController.hpp"
#include <QDesktopServices> #include <QDesktopServices>
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QNetworkReply> #include <QNetworkReply>
#include <QProgressBar> #include <QProgressBar>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QDir> #include <QDir>
SatellitesImportDialog::SatellitesImportDialog() : SatellitesImportDialog::SatellitesImportDialog()
downloadMgr(0), : isGettingData(false)
progressBar(0) , numberDownloadsComplete(0)
, downloadMgr(0)
, progressBar(0)
, filterProxyModel(NULL)
{ {
ui = new Ui_satellitesImportDialog; ui = new Ui_satellitesImportDialog;
newSatellitesModel = new QStandardItemModel(this); newSatellitesModel = new QStandardItemModel(this);
} }
SatellitesImportDialog::~SatellitesImportDialog() SatellitesImportDialog::~SatellitesImportDialog()
{ {
delete ui; delete ui;
// Do I need to explicitly delete this? // Do I need to explicitly delete this?
if (progressBar) if (progressBar)
{ {
delete progressBar; StelApp::getInstance().removeProgressBar(progressBar);
progressBar = 0; progressBar = 0;
} }
if (newSatellitesModel) if (newSatellitesModel)
{ {
newSatellitesModel->clear(); newSatellitesModel->clear();
delete newSatellitesModel; delete newSatellitesModel;
newSatellitesModel = 0; newSatellitesModel = 0;
} }
} }
skipping to change at line 133 skipping to change at line 137
if (satMgr->getUpdatesEnabled()) if (satMgr->getUpdatesEnabled())
{ {
sourceUrls = satMgr->getTleSources(); sourceUrls = satMgr->getTleSources();
qDeleteAll(sourceFiles); qDeleteAll(sourceFiles);
sourceFiles.clear(); sourceFiles.clear();
numberDownloadsComplete = 0; numberDownloadsComplete = 0;
// Reusing some code from Satellites::updateTLEs() // Reusing some code from Satellites::updateTLEs()
if (progressBar == 0) if (progressBar == 0)
progressBar = StelApp::getInstance().getGui()->addPr ogressBar(); progressBar = StelApp::getInstance().addProgressBar( );
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setMaximum(sourceUrls.size()); progressBar->setRange(0, sourceUrls.size());
progressBar->setVisible(true);
progressBar->setFormat("TLE download %v/%m"); progressBar->setFormat("TLE download %v/%m");
ui->pushButtonGetData->setVisible(false); ui->pushButtonGetData->setVisible(false);
ui->pushButtonAbort->setVisible(true); ui->pushButtonAbort->setVisible(true);
ui->groupBoxWorking->setTitle(q_("Downloading data...")); ui->groupBoxWorking->setTitle(q_("Downloading data..."));
displayMessage(q_("Stellarium is downloading satellite data from the update sources. Please wait...")); displayMessage(q_("Stellarium is downloading satellite data from the update sources. Please wait..."));
for (int i = 0; i < sourceUrls.size(); i++) for (int i = 0; i < sourceUrls.size(); i++)
{ {
QUrl url(sourceUrls.at(i)); QUrl url(sourceUrls.at(i));
QNetworkReply* reply = downloadMgr->get(QNetworkRequ est(url)); QNetworkReply* reply = downloadMgr->get(QNetworkRequ est(url));
activeDownloads.append(reply); activeDownloads.append(reply);
} }
} }
else else
{ {
QStringList sourceFilePaths; QStringList sourceFilePaths;
QString homeDirPath = QDesktopServices::storageLocation(QDes // XXX: we should check that there is at least one home loca
ktopServices::HomeLocation); tion.
QString homeDirPath = QStandardPaths::standardLocations(QSta
ndardPaths::HomeLocation)[0];
sourceFilePaths = QFileDialog::getOpenFileNames( sourceFilePaths = QFileDialog::getOpenFileNames(
&StelMainGraphicsView::getInstance(), &StelMainView::getInstance(),
q_("Select TLE source file(s)..."), q_("Select TLE source file(s)..."),
homeDirPath, "*.*"); homeDirPath, "*.*");
if (sourceFilePaths.isEmpty()) if (sourceFilePaths.isEmpty())
return; return;
foreach (QString filePath, sourceFilePaths) foreach (QString filePath, sourceFilePaths)
{ {
QFileInfo fileInfo(filePath); QFileInfo fileInfo(filePath);
if (fileInfo.exists() && fileInfo.isReadable()) if (fileInfo.exists() && fileInfo.isReadable())
{ {
QFile* file = new QFile(filePath); QFile* file = new QFile(filePath);
skipping to change at line 220 skipping to change at line 224
} }
else else
{ {
qWarning() << "Satellites: could not save to file" << url; qWarning() << "Satellites: could not save to file" << url;
} }
if (numberDownloadsComplete >= sourceUrls.count()) if (numberDownloadsComplete >= sourceUrls.count())
{ {
if (progressBar) if (progressBar)
{ {
delete progressBar; StelApp::getInstance().removeProgressBar(progressBar );
progressBar = 0; progressBar = 0;
} }
if (sourceFiles.isEmpty()) if (sourceFiles.isEmpty())
{ {
reset(); reset();
displayMessage(q_("No data could be downloaded. Try again later.")); displayMessage(q_("No data could be downloaded. Try again later."));
} }
else else
{ {
skipping to change at line 310 skipping to change at line 314
qDeleteAll(activeDownloads); qDeleteAll(activeDownloads);
activeDownloads.clear(); activeDownloads.clear();
qDeleteAll(sourceFiles); qDeleteAll(sourceFiles);
sourceFiles.clear(); sourceFiles.clear();
numberDownloadsComplete = 0; numberDownloadsComplete = 0;
if (progressBar) if (progressBar)
{ {
delete progressBar; StelApp::getInstance().removeProgressBar(progressBar);
progressBar = 0; progressBar = 0;
} }
} }
void SatellitesImportDialog::populateList() void SatellitesImportDialog::populateList()
{ {
newSatellites.clear(); newSatellites.clear();
newSatellitesModel->clear(); newSatellitesModel->clear();
Satellites* satMgr = GETSTELMODULE(Satellites); Satellites* satMgr = GETSTELMODULE(Satellites);
 End of changes. 10 change blocks. 
13 lines changed or deleted 18 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/