SatellitesDialog.cpp   SatellitesDialog.cpp 
/* /*
* Stellarium Satellites plugin config dialog * Stellarium Satellites plugin config dialog
* *
* Copyright (C) 2009, 2012 Matthew Gates * Copyright (C) 2009, 2012 Matthew Gates
* Copyright (C) 2015 Nick Fedoseev (Iridium flares)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 28 skipping to change at line 29
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include <QDebug> #include <QDebug>
#include <QDateTime> #include <QDateTime>
#include <QFileDialog> #include <QFileDialog>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTimer> #include <QTimer>
#include <QUrl> #include <QUrl>
#include <QTabWidget>
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp"
#include "ui_satellitesDialog.h" #include "ui_satellitesDialog.h"
#include "SatellitesDialog.hpp" #include "SatellitesDialog.hpp"
#include "SatellitesImportDialog.hpp" #include "SatellitesImportDialog.hpp"
#include "SatellitesListModel.hpp" #include "SatellitesListModel.hpp"
#include "SatellitesListFilterModel.hpp" #include "SatellitesListFilterModel.hpp"
#include "Satellites.hpp" #include "Satellites.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelStyle.hpp" #include "StelStyle.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelMainView.hpp" #include "StelMainView.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelUtils.hpp"
SatellitesDialog::SatellitesDialog() SatellitesDialog::SatellitesDialog()
: satelliteModified(false) : satelliteModified(false)
, updateTimer(0) , updateTimer(0)
, importWindow(0) , importWindow(0)
, filterModel(0) , filterModel(0)
, checkStateRole(Qt::UserRole) , checkStateRole(Qt::UserRole)
{ {
ui = new Ui_satellitesDialog; ui = new Ui_satellitesDialog;
} }
skipping to change at line 82 skipping to change at line 86
} }
void SatellitesDialog::retranslate() void SatellitesDialog::retranslate()
{ {
if (dialog) if (dialog)
{ {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
updateSettingsPage(); // For the button; also calls updateCo untdown() updateSettingsPage(); // For the button; also calls updateCo untdown()
populateAboutPage(); populateAboutPage();
populateFilterMenu(); populateFilterMenu();
initListIridiumFlares();
} }
} }
// Initialize the dialog widgets and connect the signals/slots // Initialize the dialog widgets and connect the signals/slots
void SatellitesDialog::createDialogContent() void SatellitesDialog::createDialogContent()
{ {
ui->setupUi(dialog); ui->setupUi(dialog);
ui->tabs->setCurrentIndex(0); ui->tabs->setCurrentIndex(0);
ui->labelAutoAdd->setVisible(false); ui->labelAutoAdd->setVisible(false);
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
skipping to change at line 210 skipping to change at line 215
// Sources tab // Sources tab
connect(ui->sourceList, SIGNAL(currentTextChanged(const QString&)), ui->sourceEdit, SLOT(setText(const QString&))); connect(ui->sourceList, SIGNAL(currentTextChanged(const QString&)), ui->sourceEdit, SLOT(setText(const QString&)));
connect(ui->sourceList, SIGNAL(itemChanged(QListWidgetItem*)), connect(ui->sourceList, SIGNAL(itemChanged(QListWidgetItem*)),
this, SLOT(saveSourceList())); this, SLOT(saveSourceList()));
connect(ui->sourceEdit, SIGNAL(editingFinished()), connect(ui->sourceEdit, SIGNAL(editingFinished()),
this, SLOT(saveEditedSource())); this, SLOT(saveEditedSource()));
connect(ui->deleteSourceButton, SIGNAL(clicked()), this, SLOT(delete SourceRow())); connect(ui->deleteSourceButton, SIGNAL(clicked()), this, SLOT(delete SourceRow()));
connect(ui->addSourceButton, SIGNAL(clicked()), this, SLOT(addSource Row())); connect(ui->addSourceButton, SIGNAL(clicked()), this, SLOT(addSource Row()));
connect(plugin, SIGNAL(settingsChanged()), connect(plugin, SIGNAL(settingsChanged()),
this, SLOT(toggleCheckableSources())); this, SLOT(toggleCheckableSources()));
connect(ui->sourceList, SIGNAL(currentRowChanged(int)), this, SLOT(r
epaintSourceList())); // bug #1350669 (https://bugs.launchpad.net/stellarium/+bug/1350669)
connect(ui->sourceList, SIGNAL(currentRowChanged(int)), ui->sourceLi
st, SLOT(repaint()));
// About tab // About tab
populateAboutPage(); populateAboutPage();
populateFilterMenu(); populateFilterMenu();
populateSourcesList(); populateSourcesList();
}
void SatellitesDialog::repaintSourceList() initListIridiumFlares();
{ connect(ui->pushButtonPredictIridiumFlares, SIGNAL(clicked()), this,
// Enable force repaint sourceList to avoiding artifacts SLOT(predictIridiumFlares()));
// Seems bug in Qt5. Details: https://bugs.launchpad.net/stellarium/ connect(ui->iridiumFlaresTreeWidget, SIGNAL(doubleClicked(QModelInde
+bug/1350669 x)), this, SLOT(selectCurrentIridiumFlare(QModelIndex)));
ui->sourceList->repaint();
} }
void SatellitesDialog::filterListByGroup(int index) void SatellitesDialog::filterListByGroup(int index)
{ {
if (index < 0) if (index < 0)
return; return;
QString groupId = ui->groupFilterCombo->itemData(index).toString(); QString groupId = ui->groupFilterCombo->itemData(index).toString();
if (groupId == "all") if (groupId == "all")
filterModel->setSecondaryFilters(QString(), SatNoFlags); filterModel->setSecondaryFilters(QString(), SatNoFlags);
skipping to change at line 297 skipping to change at line 301
ui->nameEdit->setText(index.data(Qt::DisplayRole).toString() ); ui->nameEdit->setText(index.data(Qt::DisplayRole).toString() );
ui->noradNumberEdit->setText(index.data(Qt::UserRole).toStri ng()); ui->noradNumberEdit->setText(index.data(Qt::UserRole).toStri ng());
// NOTE: Description is deliberately displayed untranslated! // NOTE: Description is deliberately displayed untranslated!
ui->descriptionTextEdit->setText(index.data(SatDescriptionRo le).toString()); ui->descriptionTextEdit->setText(index.data(SatDescriptionRo le).toString());
ui->tleFirstLineEdit->setText(index.data(FirstLineRole).toSt ring()); ui->tleFirstLineEdit->setText(index.data(FirstLineRole).toSt ring());
ui->tleFirstLineEdit->setCursorPosition(0); ui->tleFirstLineEdit->setCursorPosition(0);
ui->tleSecondLineEdit->setText(index.data(SecondLineRole).to String()); ui->tleSecondLineEdit->setText(index.data(SecondLineRole).to String());
ui->tleSecondLineEdit->setCursorPosition(0); ui->tleSecondLineEdit->setCursorPosition(0);
} }
// Enable force repaint satellitesList to avoiding artifacts // bug #1350669 (https://bugs.launchpad.net/stellarium/+bug/1350669)
// Seems bug in Qt5. Details: https://bugs.launchpad.net/stellarium/
+bug/1350669
ui->satellitesList->repaint(); ui->satellitesList->repaint();
// TODO: Fix the comms button... // TODO: Fix the comms button...
// ui->commsButton->setEnabled(sat->comms.count()>0); // ui->commsButton->setEnabled(sat->comms.count()>0);
// Things that are cumulative in a multi-selection // Things that are cumulative in a multi-selection
GroupSet globalGroups = GETSTELMODULE(Satellites)->getGroups(); GroupSet globalGroups = GETSTELMODULE(Satellites)->getGroups();
GroupSet groupsUsedBySome; GroupSet groupsUsedBySome;
GroupSet groupsUsedByAll = globalGroups; GroupSet groupsUsedByAll = globalGroups;
ui->displayedCheckbox->setChecked(false); ui->displayedCheckbox->setChecked(false);
skipping to change at line 403 skipping to change at line 406
GETSTELMODULE(Satellites)->saveCatalog(); GETSTELMODULE(Satellites)->saveCatalog();
} }
void SatellitesDialog::populateAboutPage() void SatellitesDialog::populateAboutPage()
{ {
QString jsonFileName("<tt>satellites.json</tt>"); QString jsonFileName("<tt>satellites.json</tt>");
QString oldJsonFileName("<tt>satellites.json.old</tt>"); QString oldJsonFileName("<tt>satellites.json.old</tt>");
QString html = "<html><head></head><body>"; QString html = "<html><head></head><body>";
html += "<h2>" + q_("Stellarium Satellites Plugin") + "</h2><table w idth=\"90%\">"; html += "<h2>" + q_("Stellarium Satellites Plugin") + "</h2><table w idth=\"90%\">";
html += "<tr width=\"30%\"><td><strong>" + q_("Version") + "</strong ></td><td>" + SATELLITES_PLUGIN_VERSION + "</td></td>"; html += "<tr width=\"30%\"><td><strong>" + q_("Version") + "</strong ></td><td>" + SATELLITES_PLUGIN_VERSION + "</td></td>";
html += "<tr><td rowspan=3><strong>" + q_("Authors") + "</strong></t d><td>Matthew Gates &lt;matthewg42@gmail.com&gt;</td></td>"; html += "<tr><td rowspan=4><strong>" + q_("Authors") + "</strong></t d><td>Matthew Gates &lt;matthewg42@gmail.com&gt;</td></td>";
html += "<tr><td>Jose Luis Canales &lt;jlcanales.gasco@gmail.com&gt; </td></tr>"; html += "<tr><td>Jose Luis Canales &lt;jlcanales.gasco@gmail.com&gt; </td></tr>";
html += "<tr><td>Bogdan Marinov &lt;bogdan.marinov84@gmail.com&gt;</ html += "<tr><td>Bogdan Marinov &lt;bogdan.marinov84@gmail.com&gt;</
td></tr></table>"; td></tr>";
html += "<tr><td>Nick Fedoseev &lt;nick.ut2uz@gmail.com&gt; (" + q_(
"Iridium flares") + ")</td></tr></table>";
html += "<p>" + q_("The Satellites plugin predicts the positions of artificial satellites in Earth orbit.") + "</p>"; html += "<p>" + q_("The Satellites plugin predicts the positions of artificial satellites in Earth orbit.") + "</p>";
html += "<h3>" + q_("Notes for users") + "</h3><p><ul>"; html += "<h3>" + q_("Notes for users") + "</h3><p><ul>";
html += "<li>" + q_("Satellites and their orbits are only shown when the observer is on Earth.") + "</li>"; html += "<li>" + q_("Satellites and their orbits are only shown when the observer is on Earth.") + "</li>";
html += "<li>" + q_("Predicted positions are only good for a fairly short time (on the order of days, weeks or perhaps a month into the past an d future). Expect high weirdness when looking at dates outside this range." ) + "</li>"; html += "<li>" + q_("Predicted positions are only good for a fairly short time (on the order of days, weeks or perhaps a month into the past an d future). Expect high weirdness when looking at dates outside this range." ) + "</li>";
html += "<li>" + q_("Orbital elements go out of date pretty quickly (over mere weeks, sometimes days). To get useful data out, you need to upd ate the TLE data regularly.") + "</li>"; html += "<li>" + q_("Orbital elements go out of date pretty quickly (over mere weeks, sometimes days). To get useful data out, you need to upd ate the TLE data regularly.") + "</li>";
// TRANSLATORS: The translated names of the button and the tab are f illed in automatically. You can check the original names in Stellarium. Fil e names are not translated. // TRANSLATORS: The translated names of the button and the tab are f illed in automatically. You can check the original names in Stellarium. Fil e names are not translated.
QString resetSettingsText = QString(q_("Clicking the \"%1\" button i n the \"%2\" tab of this dialog will revert to the default %3 file. The ol d file will be backed up as %4. This can be found in the user data directo ry, under \"modules/Satellites/\".")) QString resetSettingsText = QString(q_("Clicking the \"%1\" button i n the \"%2\" tab of this dialog will revert to the default %3 file. The ol d file will be backed up as %4. This can be found in the user data directo ry, under \"modules/Satellites/\"."))
.arg(ui->restoreDefaultsButton->text()) .arg(ui->restoreDefaultsButton->text())
skipping to change at line 931 skipping to change at line 935
} }
} }
void SatellitesDialog::enableSatelliteDataForm(bool enabled) void SatellitesDialog::enableSatelliteDataForm(bool enabled)
{ {
// NOTE: I'm still not sure if this is necessary, if the right signa ls are used to trigger changes...--BM // NOTE: I'm still not sure if this is necessary, if the right signa ls are used to trigger changes...--BM
ui->displayedCheckbox->blockSignals(!enabled); ui->displayedCheckbox->blockSignals(!enabled);
ui->orbitCheckbox->blockSignals(!enabled); ui->orbitCheckbox->blockSignals(!enabled);
ui->userCheckBox->blockSignals(!enabled); ui->userCheckBox->blockSignals(!enabled);
} }
void SatellitesDialog::setIridiumFlaresHeaderNames()
{
QStringList headerStrings;
headerStrings << q_("Time");
headerStrings << q_("Brightness");
headerStrings << q_("Altitude");
headerStrings << q_("Azimuth");
headerStrings << q_("Satellite");
ui->iridiumFlaresTreeWidget->setHeaderLabels(headerStrings);
// adjust the column width
for(int i = 0; i < IridiumFlaresCount; ++i)
{
ui->iridiumFlaresTreeWidget->resizeColumnToContents(i);
}
// sort-by-date
ui->iridiumFlaresTreeWidget->sortItems(IridiumFlaresDate, Qt::Ascend
ingOrder);
}
void SatellitesDialog::initListIridiumFlares()
{
ui->iridiumFlaresTreeWidget->clear();
ui->iridiumFlaresTreeWidget->setColumnCount(IridiumFlaresCount);
setIridiumFlaresHeaderNames();
ui->iridiumFlaresTreeWidget->header()->setSectionsMovable(false);
}
void SatellitesDialog::predictIridiumFlares()
{
IridiumFlaresPredictionList predictions = GETSTELMODULE(Satellites)-
>getIridiumFlaresPrediction();
ui->iridiumFlaresTreeWidget->clear();
foreach (const IridiumFlaresPrediction& flare, predictions)
{
SatPIFTreeWidgetItem *treeItem = new SatPIFTreeWidgetItem(ui
->iridiumFlaresTreeWidget);
QString dt = flare.datetime;
treeItem->setText(IridiumFlaresDate, QString("%1 %2").arg(dt
.left(10)).arg(dt.right(8)));
treeItem->setText(IridiumFlaresMagnitude, QString::number(fl
are.magnitude,'f',1));
treeItem->setTextAlignment(IridiumFlaresMagnitude, Qt::Align
Right);
treeItem->setText(IridiumFlaresAltitude, StelUtils::radToDms
Str(flare.altitude));
treeItem->setTextAlignment(IridiumFlaresAltitude, Qt::AlignR
ight);
treeItem->setText(IridiumFlaresAzimuth, StelUtils::radToDmsS
tr(flare.azimuth));
treeItem->setTextAlignment(IridiumFlaresAzimuth, Qt::AlignRi
ght);
treeItem->setText(IridiumFlaresSatellite, flare.satellite);
}
for(int i = 0; i < IridiumFlaresCount; ++i)
{
ui->iridiumFlaresTreeWidget->resizeColumnToContents(i);
}
}
void SatellitesDialog::selectCurrentIridiumFlare(const QModelIndex &modelIn
dex)
{
// Find the object
QString name = modelIndex.sibling(modelIndex.row(), IridiumFlaresSat
ellite).data().toString();
QString date = modelIndex.sibling(modelIndex.row(), IridiumFlaresDat
e).data().toString();
bool ok;
double JD = StelUtils::getJulianDayFromISO8601String(date.left(10)
+ "T" + date.right(8), &ok);
JD -= StelUtils::getGMTShiftFromQT(JD)/24.;
StelObjectMgr* objectMgr = GETSTELMODULE(StelObjectMgr);
if (objectMgr->findAndSelectI18n(name) || objectMgr->findAndSelect(n
ame))
{
StelApp::getInstance().getCore()->setJD(JD);
const QList<StelObjectP> newSelected = objectMgr->getSelecte
dObject();
if (!newSelected.empty())
{
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementM
gr);
mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMo
veDuration());
mvmgr->setFlagTracking(true);
}
}
}
 End of changes. 12 change blocks. 
15 lines changed or deleted 20 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/