SatellitesDialog.cpp   SatellitesDialog.cpp 
/* /*
* Stellarium Satellites plugin config dialog * Stellarium Satellites plugin config dialog
* *
* Copyright (C) 2009 Matthew Gates * Copyright (C) 2009, 2012 Matthew Gates
* *
* 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.
* *
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QDateTime> #include <QDateTime>
#include <QUrl> #include <QUrl>
#include <QFileDialog> #include <QFileDialog>
#include "StelApp.hpp" #include "StelApp.hpp"
#include <plugin_config.h>
#include "ui_satellitesDialog.h" #include "ui_satellitesDialog.h"
#include "SatellitesDialog.hpp" #include "SatellitesDialog.hpp"
#include "SatellitesImportDialog.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 "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTranslator.hpp"
// When i18n is implemented, uncomment the StelTranslator.hpp include SatellitesDialog::SatellitesDialog() : updateTimer(NULL), importWindow(0)
// and remove the definition of q_
//#include "StelTranslator.hpp"
#define q_ QString
SatellitesDialog::SatellitesDialog() : updateTimer(NULL)
{ {
ui = new Ui_satellitesDialog; ui = new Ui_satellitesDialog;
} }
SatellitesDialog::~SatellitesDialog() SatellitesDialog::~SatellitesDialog()
{ {
if (updateTimer) if (updateTimer)
{ {
updateTimer->stop(); updateTimer->stop();
delete updateTimer; delete updateTimer;
updateTimer = NULL; updateTimer = NULL;
} }
if (importWindow)
{
delete importWindow;
importWindow = 0;
}
delete ui; delete ui;
} }
void SatellitesDialog::languageChanged() void SatellitesDialog::retranslate()
{ {
if (dialog) if (dialog)
{
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
refreshUpdateValues();
setAboutHtml();
// This may be a problem if we add group name translations,
as the
// sorting order may be different. --BM
int index = ui->groupsCombo->currentIndex();
populateGroupsList();
ui->groupsCombo->setCurrentIndex(index);
}
} }
// 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);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
OT(languageChanged())); this, SLOT(retranslate()));
// Settings tab / updates group // Settings tab / updates group
connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this , SLOT(setUpdatesEnabled(int))); connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this , SLOT(setUpdatesEnabled(int)));
connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateTLEs() )); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateTLEs() ));
connect(GETSTELMODULE(Satellites), SIGNAL(updateStateChanged(Satelli tes::UpdateState)), this, SLOT(updateStateReceiver(Satellites::UpdateState) )); connect(GETSTELMODULE(Satellites), SIGNAL(updateStateChanged(Satelli tes::UpdateState)), this, SLOT(updateStateReceiver(Satellites::UpdateState) ));
connect(GETSTELMODULE(Satellites), SIGNAL(tleUpdateComplete(int, int , int)), this, SLOT(updateCompleteReceiver(int, int, int))); connect(GETSTELMODULE(Satellites), SIGNAL(tleUpdateComplete(int, int , int)), this, SLOT(updateCompleteReceiver(int, int, int)));
connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int))); connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int)));
refreshUpdateValues(); // fetch values for last updated and so on refreshUpdateValues(); // fetch values for last updated and so on
// if the state didn't change, setUpdatesEnabled will not be called, so we force it // if the state didn't change, setUpdatesEnabled will not be called, so we force it
setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState()); setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState());
skipping to change at line 108 skipping to change at line 121
ui->orbitSegmentsSpin->setValue(Satellite::orbitLineSegments); ui->orbitSegmentsSpin->setValue(Satellite::orbitLineSegments);
ui->orbitFadeSpin->setValue(Satellite::orbitLineFadeSegments); ui->orbitFadeSpin->setValue(Satellite::orbitLineFadeSegments);
ui->orbitDurationSpin->setValue(Satellite::orbitLineSegmentDuration) ; ui->orbitDurationSpin->setValue(Satellite::orbitLineSegmentDuration) ;
connect(ui->orbitLinesGroup, SIGNAL(toggled(bool)), GETSTELMODULE(Sa tellites), SLOT(setOrbitLinesFlag(bool))); connect(ui->orbitLinesGroup, SIGNAL(toggled(bool)), GETSTELMODULE(Sa tellites), SLOT(setOrbitLinesFlag(bool)));
connect(ui->orbitSegmentsSpin, SIGNAL(valueChanged(int)), this, SLOT (setOrbitParams())); connect(ui->orbitSegmentsSpin, SIGNAL(valueChanged(int)), this, SLOT (setOrbitParams()));
connect(ui->orbitFadeSpin, SIGNAL(valueChanged(int)), this, SLOT(set OrbitParams())); connect(ui->orbitFadeSpin, SIGNAL(valueChanged(int)), this, SLOT(set OrbitParams()));
connect(ui->orbitDurationSpin, SIGNAL(valueChanged(int)), this, SLOT (setOrbitParams())); connect(ui->orbitDurationSpin, SIGNAL(valueChanged(int)), this, SLOT (setOrbitParams()));
// Satellites tab // Satellites tab
connect(ui->satellitesList, SIGNAL(currentTextChanged(const QString& connect(ui->satellitesList,
)), this, SLOT(selectedSatelliteChanged(const QString&))); SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)
),
this,
SLOT(updateSelectedSatelliteInfo(QListWidgetItem*,QListWidge
tItem*)));
connect(ui->satellitesList, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(satelliteDoubleClick(QListWidgetItem*))); connect(ui->satellitesList, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(satelliteDoubleClick(QListWidgetItem*)));
connect(ui->groupsCombo, SIGNAL(currentIndexChanged(int)), this, SLO T(groupFilterChanged(int))); connect(ui->groupsCombo, SIGNAL(currentIndexChanged(int)), this, SLO T(listSatelliteGroup(int)));
connect(ui->saveSatellitesButton, SIGNAL(clicked()), this, SLOT(save Satellites())); connect(ui->saveSatellitesButton, SIGNAL(clicked()), this, SLOT(save Satellites()));
connect(ui->removeSatellitesButton, SIGNAL(clicked()), this, SLOT(re moveSatellites()));
connectSatelliteGuiForm(); connectSatelliteGuiForm();
importWindow = new SatellitesImportDialog();
connect(ui->addSatellitesButton, SIGNAL(clicked()),
importWindow, SLOT(setVisible()));
connect(importWindow, SIGNAL(satellitesAccepted(TleDataList)),
this, SLOT(addSatellites(TleDataList)));
// 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->sourceEdit, SIGNAL(editingFinished()), this, SLOT(source EditingDone())); connect(ui->sourceEdit, SIGNAL(editingFinished()), this, SLOT(source EditingDone()));
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()));
// About tab // About tab
setAboutHtml(); setAboutHtml();
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
));
Q_ASSERT(gui);
ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui->
getStelStyle().htmlStyleSheet));
updateGuiFromSettings(); updateGuiFromSettings();
} }
void SatellitesDialog::groupFilterChanged(int index) void SatellitesDialog::listSatelliteGroup(int index)
{ {
QStringList prevMultiSelection; QVariantList prevMultiSelection;
foreach (QListWidgetItem* i, ui->satellitesList->selectedItems()) foreach (QListWidgetItem* i, ui->satellitesList->selectedItems())
{ {
prevMultiSelection << i->text(); prevMultiSelection << i->data(Qt::UserRole);
} }
ui->satellitesList->clear(); ui->satellitesList->clear();
if (ui->groupsCombo->itemData(index).toString() == "all") QHash<QString,QString> satellites;
ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- Satellites* plugin = GETSTELMODULE(Satellites);
>getSatellites()); QString selectedGroup = ui->groupsCombo->itemData(index).toString();
else if (ui->groupsCombo->itemData(index).toString() == "visible") if (selectedGroup == "all")
ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- satellites = plugin->getSatellites();
>getSatellites(QString(), Satellites::Visible)); else if (selectedGroup == "visible")
else if (ui->groupsCombo->itemData(index).toString() == "notvisible" satellites = plugin->getSatellites(QString(), Satellites::Vi
) sible);
ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- else if (selectedGroup == "notvisible")
>getSatellites(QString(), Satellites::NotVisible)); satellites = plugin->getSatellites(QString(), Satellites::No
tVisible);
else if (selectedGroup == "newlyadded")
satellites = plugin->getSatellites(QString(), Satellites::Ne
wlyAdded);
else if (selectedGroup == "orbiterror")
satellites = plugin->getSatellites(QString(), Satellites::Or
bitError);
else else
ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- satellites = plugin->getSatellites(ui->groupsCombo->currentT
>getSatellites(ui->groupsCombo->currentText())); ext());
ui->satellitesList->setSortingEnabled(false);
QHashIterator<QString,QString> i(satellites);
while (i.hasNext())
{
i.next();
QListWidgetItem* item = new QListWidgetItem(i.value());
item->setData(Qt::UserRole, i.key());
ui->satellitesList->addItem(item);
}
ui->satellitesList->sortItems();
// If any previously selected items are still in the list after the update, select them, // If any previously selected items are still in the list after the update, select them,
QListWidgetItem* item; QListWidgetItem* item;
for (int i=0; (item = ui->satellitesList->item(i))!=NULL; i++) for (int i=0; (item = ui->satellitesList->item(i))!=NULL; i++)
{ {
item->setSelected(prevMultiSelection.contains(item->text())) QVariant id = item->data(Qt::UserRole);
; if (prevMultiSelection.contains(id))
item->setSelected(true);
} }
QList<QListWidgetItem*> selectedItems = ui->satellitesList->selected Items(); QList<QListWidgetItem*> selectedItems = ui->satellitesList->selected Items();
if (selectedItems.count() > 0) if (selectedItems.count() > 0)
{ {
// make sure the first selected item is visible... // make sure the first selected item is visible...
ui->satellitesList->scrollToItem(selectedItems.at(0)); ui->satellitesList->scrollToItem(selectedItems.at(0));
} }
else if (ui->satellitesList->count() > 0) else if (ui->satellitesList->count() > 0)
{ {
// otherwise if there are any items in the listbox, select t he first and scroll to the top // otherwise if there are any items in the listbox, select t he first and scroll to the top
ui->satellitesList->setCurrentRow(0); ui->satellitesList->setCurrentRow(0);
ui->satellitesList->scrollToTop(); ui->satellitesList->scrollToTop();
} }
} }
void SatellitesDialog::selectedSatelliteChanged(const QString& id) void SatellitesDialog::reloadSatellitesList()
{
listSatelliteGroup(ui->groupsCombo->currentIndex());
}
void SatellitesDialog::updateSelectedSatelliteInfo(QListWidgetItem* curItem
,
QListWidgetItem* prevIte
m)
{ {
//qDebug() << "SatellitesDialog::selectedSatelliteChanged for " << i Q_UNUSED(prevItem);
d; if (!curItem)
if (id.isEmpty() || id=="") return;
QString id = curItem->data(Qt::UserRole).toString();
if (id.isEmpty())
return; return;
satelliteModified = false; satelliteModified = false;
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id); SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id);
if (sat.isNull())
return;
if (!sat->initialized) if (!sat->initialized)
return; return;
disconnectSatelliteGuiForm(); disconnectSatelliteGuiForm();
ui->idLineEdit->setText(sat->designation); ui->idLineEdit->setText(sat->name);
ui->lineEditCatalogNumber->setText(sat->id);
ui->descriptionTextEdit->setText(sat->description); ui->descriptionTextEdit->setText(sat->description);
ui->groupsTextEdit->setText(sat->groupIDs.join(", ")); ui->groupsTextEdit->setText(sat->groupIDs.join(", "));
ui->tleTextEdit->setText(QString("%1\n%2").arg(sat->tleElements.firs QString tleStr = QString("%1\n%2").arg(sat->tleElements.first.data()
t.data()).arg(sat->tleElements.second.data())); ).arg(sat->tleElements.second.data());
ui->tleTextEdit->setText(tleStr);
ui->visibleCheckbox->setChecked(sat->visible); ui->visibleCheckbox->setChecked(sat->visible);
ui->orbitCheckbox->setChecked(sat->orbitVisible); ui->orbitCheckbox->setChecked(sat->orbitVisible);
ui->commsButton->setEnabled(sat->comms.count()>0); ui->commsButton->setEnabled(sat->comms.count()>0);
connectSatelliteGuiForm(); connectSatelliteGuiForm();
} }
void SatellitesDialog::saveSatellites(void) void SatellitesDialog::saveSatellites(void)
{ {
GETSTELMODULE(Satellites)->saveTleData(); GETSTELMODULE(Satellites)->saveTleData();
} }
void SatellitesDialog::setAboutHtml(void) void SatellitesDialog::setAboutHtml(void)
{ {
QString jsonFileName("<tt>satellites.json</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>" + q_("Version:") + "</td><td>" + PL html += "<tr width=\"30%\"><td><strong>" + q_("Version") + "</strong
UGIN_VERSION + "</td></td>"; ></td><td>" + SATELLITES_PLUGIN_VERSION + "</td></td>";
html += "<tr><td>" + q_("Authors:") + "</td><td>Matthew Gates &lt;ma html += "<tr><td rowspan=2><strong>" + q_("Authors") + "</strong></t
tthew@porpoisehead.net&gt;</td></td>"; d><td>Matthew Gates &lt;matthew@porpoisehead.net&gt;</td></td>";
html += "<tr><td></td><td>Jose Luis Canales &lt;jlcanales.gasco@gmai html += "<tr><td>Jose Luis Canales &lt;jlcanales.gasco@gmail.com&gt;
l.com&gt;</td></tr></table>"; </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>";
html += "<li>" + q_("Clicking the \"Restore default settings\" butto // TRANSLATORS: The translated names of the button and the tab are f
n in the \"Settings\" tab of this dialog will revert to the default satelli illed in automatically. You can check the original names in Stellarium. Fil
te.json file. The old file will be backed up as \"satellites.json.old\". e names are not translated.
This can be found in the user data directory, under \"modules/Satellites/\" QString resetSettingsText = QString(q_("Clicking the \"%1\" button i
.") + "</li>"; 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->tabs->tabText(ui->tabs->indexOf(ui->settingsTab)))
.arg(jsonFileName)
.arg(oldJsonFileName);
html += "<li>" + resetSettingsText + "</li>";
html += "<li>" + q_("The Satellites plugin is still under developmen t. Some features are incomplete, missing or buggy.") + "</li>"; html += "<li>" + q_("The Satellites plugin is still under developmen t. Some features are incomplete, missing or buggy.") + "</li>";
html += "</ul></p>"; html += "</ul></p>";
// TRANSLATORS: Title of a section in the About tab of the Satellite s window
html += "<h3>" + q_("TLE data updates") + "</h3>"; html += "<h3>" + q_("TLE data updates") + "</h3>";
html += "<p>" + q_("The Satellites plugin can automatically download TLE data from Internet sources, and by default the plugin will do this if the existing data is more than 72 hours old. "); html += "<p>" + q_("The Satellites plugin can automatically download TLE data from Internet sources, and by default the plugin will do this if the existing data is more than 72 hours old. ");
html += "</p><p>" + q_(QString("If you disable Internet updates, you html += "</p><p>" + QString(q_("If you disable Internet updates, you
may update from a file on your computer. This file must be in the same fo may update from a file on your computer. This file must be in the same fo
rmat as the Celestrak updates (see %1 for an example).").arg("<a href=\"htt rmat as the Celestrak updates (see %1 for an example).").arg("<a href=\"htt
p://celestrak.com/NORAD/elements/visual.txt\">visual.txt</a>")); p://celestrak.com/NORAD/elements/visual.txt\">visual.txt</a>"));
html += "</p><p><b>" + q_("Note") + ":</b> " + q_("if the name of a html += "</p><p>" + q_("<b>Note:</b> if the name of a satellite in u
satellite in update data has anything in square brackets at the end, it wil pdate data has anything in square brackets at the end, it will be removed b
l be removed before the data is used."); efore the data is used.");
html += "</p>"; html += "</p>";
html += "<h3>" + q_("Adding new satellites") + "</h3>"; html += "<h3>" + q_("Adding new satellites") + "</h3>";
html += "<p>" + q_("At the moment you must manually edit the satelli tes.json file to add new satellites to the database. Making this easier is still on the TODO list...") + "</p>"; html += "<p>" + QString(q_("1. Make sure the satellite(s) you wish t o add are included in one of the URLs listed in the Sources tab of the sate llites configuration dialog. 2. Go to the Satellites tab, and click the '+' button. Select the satellite(s) you wish to add and select the \"add\" bu tton.")) + "</p>";
html += "<h3>" + q_("Technical Notes") + "</h3>"; html += "<h3>" + q_("Technical notes") + "</h3>";
html += "<p>" + q_("Positions are calculated using the SGP4 & SDP4 m ethods, using NORAD TLE data as the input. "); html += "<p>" + q_("Positions are calculated using the SGP4 & SDP4 m ethods, using NORAD TLE data as the input. ");
html += q_("The orbital calculation code is written by Jose Luis Can html += q_("The orbital calculation code is written by Jose Luis Can
ales according to the revised Spacetrack report N#3 (including Spacetrack r ales according to the revised Spacetrack Report #3 (including Spacetrack Re
eport N#6). "); port #6). ");
html += q_(QString("See %1this document%2 for details.").arg("<a hre // TRANSLATORS: The numbers contain the opening and closing tag of a
f=\"http://www.celestrak.com/publications/AIAA/2006-6753\">").arg("</a>")) n HTML link
+ "</p>"; html += QString(q_("See %1this document%2 for details.")).arg("<a hr
ef=\"http://www.celestrak.com/publications/AIAA/2006-6753\">").arg("</a>")
+ "</p>";
"&lt;/p&gt;";
html += "<h3>" + q_("Links") + "</h3>"; html += "<h3>" + q_("Links") + "</h3>";
html += "<p>" + q_("Support is provided via the Launchpad website. Be sure to put \"Satellites plugin\" in the subject when posting.") + "</p> "; html += "<p>" + q_("Support is provided via the Launchpad website. Be sure to put \"Satellites plugin\" in the subject when posting.") + "</p> ";
html += "<p><ul>"; html += "<p><ul>";
html += "<li>" + q_(QString("If you have a question, you can %1get a // TRANSLATORS: The numbers contain the opening and closing tag of a
n answer here%2").arg("<a href=\"https://answers.launchpad.net/stellarium\" n HTML link
>").arg("</a>")) + "</li>"; html += "<li>" + QString(q_("If you have a question, you can %1get a
html += "<li>" + q_(QString("Bug reports can be made %1here%2.").arg n answer here%2").arg("<a href=\"https://answers.launchpad.net/stellarium\"
("<a href=\"https://bugs.launchpad.net/stellarium\">").arg("</a>")) + "</li >")).arg("</a>") + "</li>";
>"; // TRANSLATORS: The numbers contain the opening and closing tag of a
n HTML link
html += "<li>" + QString(q_("Bug reports can be made %1here%2.")).ar
g("<a href=\"https://bugs.launchpad.net/stellarium\">").arg("</a>") + "</li
>";
// TRANSLATORS: The numbers contain the opening and closing tag of a
n HTML link
html += "<li>" + q_("If you would like to make a feature request, yo u can create a bug report, and set the severity to \"wishlist\".") + "</li> "; html += "<li>" + q_("If you would like to make a feature request, yo u can create a bug report, and set the severity to \"wishlist\".") + "</li> ";
html += "</ul></p></body></html>"; html += "</ul></p></body></html>";
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
));
Q_ASSERT(gui);
QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleShee
t);
ui->aboutTextBrowser->setHtml(html); ui->aboutTextBrowser->setHtml(html);
} }
void SatellitesDialog::refreshUpdateValues(void) void SatellitesDialog::refreshUpdateValues(void)
{ {
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Satellites)->g etLastUpdate()); ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Satellites)->g etLastUpdate());
ui->updateFrequencySpinBox->setValue(GETSTELMODULE(Satellites)->getU pdateFrequencyHours()); ui->updateFrequencySpinBox->setValue(GETSTELMODULE(Satellites)->getU pdateFrequencyHours());
int secondsToUpdate = GETSTELMODULE(Satellites)->getSecondsToUpdate( ); int secondsToUpdate = GETSTELMODULE(Satellites)->getSecondsToUpdate( );
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Satellites)->g etUpdatesEnabled()); ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Satellites)->g etUpdatesEnabled());
if (!GETSTELMODULE(Satellites)->getUpdatesEnabled()) if (!GETSTELMODULE(Satellites)->getUpdatesEnabled())
skipping to change at line 375 skipping to change at line 447
refreshUpdateValues(); refreshUpdateValues();
ui->labelsGroup->setChecked(GETSTELMODULE(Satellites)->getFlagLabels ()); ui->labelsGroup->setChecked(GETSTELMODULE(Satellites)->getFlagLabels ());
ui->fontSizeSpinBox->setValue(GETSTELMODULE(Satellites)->getLabelFon tSize()); ui->fontSizeSpinBox->setValue(GETSTELMODULE(Satellites)->getLabelFon tSize());
ui->orbitLinesGroup->setChecked(GETSTELMODULE(Satellites)->getOrbitL inesFlag()); ui->orbitLinesGroup->setChecked(GETSTELMODULE(Satellites)->getOrbitL inesFlag());
ui->orbitSegmentsSpin->setValue(Satellite::orbitLineSegments); ui->orbitSegmentsSpin->setValue(Satellite::orbitLineSegments);
ui->orbitFadeSpin->setValue(Satellite::orbitLineFadeSegments); ui->orbitFadeSpin->setValue(Satellite::orbitLineFadeSegments);
ui->orbitDurationSpin->setValue(Satellite::orbitLineSegmentDuration) ; ui->orbitDurationSpin->setValue(Satellite::orbitLineSegmentDuration) ;
ui->groupsCombo->clear(); populateGroupsList();
ui->groupsCombo->addItems(GETSTELMODULE(Satellites)->getGroups());
ui->groupsCombo->insertItem(0, q_("[all not visible]"), QVariant("no
tvisible"));
ui->groupsCombo->insertItem(0, q_("[all visible]"), QVariant("visibl
e"));
ui->groupsCombo->insertItem(0, q_("[all]"), QVariant("all"));
ui->satellitesList->clearSelection(); ui->satellitesList->clearSelection();
ui->groupsCombo->setCurrentIndex(0); ui->groupsCombo->setCurrentIndex(0);
ui->sourceList->clear(); ui->sourceList->clear();
ui->sourceList->addItems(GETSTELMODULE(Satellites)->getTleSources()) ; ui->sourceList->addItems(GETSTELMODULE(Satellites)->getTleSources()) ;
if (ui->sourceList->count() > 0) ui->sourceList->setCurrentRow(0); if (ui->sourceList->count() > 0) ui->sourceList->setCurrentRow(0);
} }
void SatellitesDialog::populateGroupsList()
{
ui->groupsCombo->clear();
ui->groupsCombo->addItems(GETSTELMODULE(Satellites)->getGroups());
ui->groupsCombo->insertItem(0, q_("[orbit calculation error]"), QVar
iant("orbiterror"));
ui->groupsCombo->insertItem(0, q_("[all newly added]"), QVariant("ne
wlyadded"));
ui->groupsCombo->insertItem(0, q_("[all not displayed]"), QVariant("
notvisible"));
ui->groupsCombo->insertItem(0, q_("[all displayed]"), QVariant("visi
ble"));
ui->groupsCombo->insertItem(0, q_("[all]"), QVariant("all"));
}
void SatellitesDialog::saveSettings(void) void SatellitesDialog::saveSettings(void)
{ {
GETSTELMODULE(Satellites)->saveSettingsToConfig(); GETSTELMODULE(Satellites)->saveSettingsToConfig();
} }
void SatellitesDialog::visibleCheckChanged(int state) void SatellitesDialog::addSatellites(const TleDataList& newSatellites)
{
GETSTELMODULE(Satellites)->add(newSatellites);
saveSatellites();
// Trigger re-loading the list to display the new satellites
int index = ui->groupsCombo->findData(QVariant("newlyadded"));
if (ui->groupsCombo->currentIndex() == index)
listSatelliteGroup(index);
else
ui->groupsCombo->setCurrentIndex(index); //Triggers the same
operation
// Select the satellites that were added just now
QListWidget* list = ui->satellitesList;
list->clearSelection();
int firstAddedIndex = -1;
QSet<QString> newIds;
foreach (const TleData& sat, newSatellites)
newIds.insert(sat.id);
for (int i = 0; i < list->count(); i++)
{
QString id = list->item(i)->data(Qt::UserRole).toString();
if (newIds.remove(id))
{
list->item(i)->setSelected(true);
if (firstAddedIndex < 0)
firstAddedIndex = i;
}
}
if (firstAddedIndex >= 0)
list->scrollToItem(list->item(firstAddedIndex),
QAbstractItemView::PositionAtTop);
else
list->setCurrentRow(0);
}
void SatellitesDialog::removeSatellites()
{ {
QStringList idList;
foreach (QListWidgetItem* i, ui->satellitesList->selectedItems()) foreach (QListWidgetItem* i, ui->satellitesList->selectedItems())
{ {
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(i->text( QString id = i->data(Qt::UserRole).toString();
)); idList.append(id);
sat->visible = (state==Qt::Checked); }
if (!idList.isEmpty())
{
GETSTELMODULE(Satellites)->remove(idList);
reloadSatellitesList();
saveSatellites();
} }
groupFilterChanged(ui->groupsCombo->currentIndex());
} }
void SatellitesDialog::orbitCheckChanged(int state) void SatellitesDialog::setDisplayFlag(bool display)
{ {
foreach (QListWidgetItem* i, ui->satellitesList->selectedItems()) foreach (QListWidgetItem* i, ui->satellitesList->selectedItems())
{ {
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(i->text( QString id = i->data(Qt::UserRole).toString();
)); SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id);
sat->orbitVisible = (state==Qt::Checked); sat->visible = display;
} }
groupFilterChanged(ui->groupsCombo->currentIndex()); reloadSatellitesList();
}
void SatellitesDialog::setOrbitFlag(bool display)
{
foreach (QListWidgetItem* i, ui->satellitesList->selectedItems())
{
QString id = i->data(Qt::UserRole).toString();
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id);
if (sat)
sat->orbitVisible = display;
}
reloadSatellitesList();
} }
void SatellitesDialog::satelliteDoubleClick(QListWidgetItem* item) void SatellitesDialog::satelliteDoubleClick(QListWidgetItem* item)
{ {
qDebug() << "SatellitesDialog::satelliteDoubleClick for " << item->t Satellites* SatellitesMgr = GETSTELMODULE(Satellites);
ext(); Q_ASSERT(SatellitesMgr);
GETSTELMODULE(Satellites)->getByID(item->text())->visible = true; QString id = item->data(Qt::UserRole).toString();
SatelliteP sat = SatellitesMgr->getByID(id);
if (sat.isNull())
return;
if (!sat->orbitValid)
return;
// Turn on Satellite rendering if it is not already on
sat->visible = true;
// If Satellites are not currently displayed, make them visible.
if (!SatellitesMgr->getFlagHints())
{
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance()
.getGui());
QAction* setHintsAction = gui->getGuiActions("actionShow_Sat
ellite_Hints");
Q_ASSERT(setHintsAction);
setHintsAction->setChecked(true);
}
//TODO: We need to find a way to deal with duplicates... --BM
if (StelApp::getInstance().getStelObjectMgr().findAndSelect(item->te xt())) if (StelApp::getInstance().getStelObjectMgr().findAndSelect(item->te xt()))
{ {
GETSTELMODULE(StelMovementMgr)->autoZoomIn(); GETSTELMODULE(StelMovementMgr)->autoZoomIn();
GETSTELMODULE(StelMovementMgr)->setFlagTracking(true); GETSTELMODULE(StelMovementMgr)->setFlagTracking(true);
} }
} }
void SatellitesDialog::setOrbitParams(void) void SatellitesDialog::setOrbitParams(void)
{ {
Satellite::orbitLineSegments = ui->orbitSegmentsSpin->value(); Satellite::orbitLineSegments = ui->orbitSegmentsSpin->value();
skipping to change at line 452 skipping to change at line 607
Stel FileMgr::getDesktopDir(), Stel FileMgr::getDesktopDir(),
"*.* "); "*.* ");
GETSTELMODULE(Satellites)->updateFromFiles(updateFiles, fals e); GETSTELMODULE(Satellites)->updateFromFiles(updateFiles, fals e);
} }
} }
void SatellitesDialog::connectSatelliteGuiForm(void) void SatellitesDialog::connectSatelliteGuiForm(void)
{ {
// make sure we don't connect more than once // make sure we don't connect more than once
disconnectSatelliteGuiForm(); disconnectSatelliteGuiForm();
connect(ui->visibleCheckbox, SIGNAL(stateChanged(int)), this, SLOT(v connect(ui->visibleCheckbox, SIGNAL(clicked(bool)), this, SLOT(setDi
isibleCheckChanged(int))); splayFlag(bool)));
connect(ui->orbitCheckbox, SIGNAL(stateChanged(int)), this, SLOT(orb connect(ui->orbitCheckbox, SIGNAL(clicked(bool)), this, SLOT(setOrbi
itCheckChanged(int))); tFlag(bool)));
} }
void SatellitesDialog::disconnectSatelliteGuiForm(void) void SatellitesDialog::disconnectSatelliteGuiForm(void)
{ {
disconnect(ui->visibleCheckbox, SIGNAL(stateChanged(int)), this, SLO disconnect(ui->visibleCheckbox, SIGNAL(clicked(bool)), this, SLOT(se
T(visibleCheckChanged(int))); tDisplayFlag(bool)));
disconnect(ui->orbitCheckbox, SIGNAL(stateChanged(int)), this, SLOT( disconnect(ui->orbitCheckbox, SIGNAL(clicked(bool)), this, SLOT(setO
orbitCheckChanged(int))); rbitFlag(bool)));
} }
 End of changes. 51 change blocks. 
105 lines changed or deleted 269 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/