SatellitesDialog.cpp   SatellitesDialog.cpp 
skipping to change at line 25 skipping to change at line 25
* *
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QDateTime> #include <QDateTime>
#include <QUrl> #include <QUrl>
#include <QFileDialog>
#include "StelApp.hpp" #include "StelApp.hpp"
#include <plugin_config.h> #include <plugin_config.h>
#include "ui_satellitesDialog.h" #include "ui_satellitesDialog.h"
#include "SatellitesDialog.hpp" #include "SatellitesDialog.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 "StelFileMgr.hpp"
// When i18n is implemented, uncomment the StelTranslator.hpp include // When i18n is implemented, uncomment the StelTranslator.hpp include
// and remove the definition of q_ // and remove the definition of q_
//#include "StelTranslator.hpp" //#include "StelTranslator.hpp"
#define q_ QString #define q_ QString
SatellitesDialog::SatellitesDialog() : updateTimer(NULL) SatellitesDialog::SatellitesDialog() : updateTimer(NULL)
{ {
ui = new Ui_satellitesDialog; ui = new Ui_satellitesDialog;
} }
skipping to change at line 64 skipping to change at line 67
} }
delete ui; delete ui;
} }
void SatellitesDialog::languageChanged() void SatellitesDialog::languageChanged()
{ {
if (dialog) if (dialog)
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
} }
void SatellitesDialog::updateStyle()
{
if (dialog)
{
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance()
.getGui());
Q_ASSERT(gui);
const StelStyle pluginStyle = GETSTELMODULE(Satellites)->get
ModuleStyleSheet(gui->getStelStyle());
dialog->setStyleSheet(pluginStyle.qtStyleSheet);
ui->aboutTextBrowser->document()->setDefaultStyleSheet(QStri
ng(pluginStyle.htmlStyleSheet));
}
}
// 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);
// Settings tab / updates group // Settings tab / updates group
connect(ui->updateFromInternetCheckbox, SIGNAL(toggled(bool)), this, connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this
SLOT(setUpdatesEnabled(bool))); , SLOT(setUpdatesEnabled(int)));
refreshUpdateValues(); // fetch values for last updated and so on connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateTLEs()
connect(ui->updateNowButton, SIGNAL(clicked()), GETSTELMODULE(Satell ));
ites), 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)), t his, SLOT(updateCompleteReceiver(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
// if the state didn't change, setUpdatesEnabled will not be called,
so we force it
setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState());
updateTimer = new QTimer(this); updateTimer = new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValu es())); connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValu es()));
updateTimer->start(7000); updateTimer->start(7000);
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()))
;
// Settings tab / General settings group // Settings tab / General settings group
connect(ui->showLabelsCheckbox, SIGNAL(toggled(bool)), StelApp::getI nstance().getGui()->getGuiActions("actionShow_Satellite_Labels"), SLOT(setC hecked(bool))); connect(ui->labelsGroup, SIGNAL(toggled(bool)), StelApp::getInstance ().getGui()->getGuiActions("actionShow_Satellite_Labels"), SLOT(setChecked( bool)));
connect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)), GETSTELMODUL E(Satellites), SLOT(setLabelFontSize(int))); connect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)), GETSTELMODUL E(Satellites), SLOT(setLabelFontSize(int)));
connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(res toreDefaults())); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(res toreDefaults()));
connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSe ttings())); connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSe ttings()));
// Settings tab / orbit lines group
ui->orbitLinesGroup->setChecked(GETSTELMODULE(Satellites)->getOrbitL
inesFlag());
ui->orbitSegmentsSpin->setValue(Satellite::orbitLineSegments);
ui->orbitFadeSpin->setValue(Satellite::orbitLineFadeSegments);
ui->orbitDurationSpin->setValue(Satellite::orbitLineSegmentDuration)
;
connect(ui->orbitLinesGroup, SIGNAL(toggled(bool)), GETSTELMODULE(Sa
tellites), SLOT(setOrbitLinesFlag(bool)));
connect(ui->orbitSegmentsSpin, SIGNAL(valueChanged(int)), this, SLOT
(setOrbitParams()));
connect(ui->orbitFadeSpin, SIGNAL(valueChanged(int)), this, SLOT(set
OrbitParams()));
connect(ui->orbitDurationSpin, SIGNAL(valueChanged(int)), this, SLOT
(setOrbitParams()));
// Satellites tab // Satellites tab
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->satellitesList, SIGNAL(currentTextChanged(const QString& )), this, SLOT(selectedSatelliteChanged(const QString&))); connect(ui->satellitesList, SIGNAL(currentTextChanged(const QString& )), this, SLOT(selectedSatelliteChanged(const QString&)));
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(groupFilterChanged(int)));
connect(ui->showButton, SIGNAL(clicked()), this, SLOT(showSelectedSa connect(ui->saveSatellitesButton, SIGNAL(clicked()), this, SLOT(save
tellites())); Satellites()));
connect(ui->hideButton, SIGNAL(clicked()), this, SLOT(hideSelectedSa connectSatelliteGuiForm();
tellites()));
connect(ui->visibleCheckbox, SIGNAL(stateChanged(int)), this, SLOT(v
isibleCheckChanged(int)));
// 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( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); Q_ASSERT(gui);
ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui-> getStelStyle().htmlStyleSheet)); ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui-> getStelStyle().htmlStyleSheet));
updateGuiFromSettings(); updateGuiFromSettings();
//Initialize the style
updateStyle();
} }
void SatellitesDialog::groupFilterChanged(int index) void SatellitesDialog::groupFilterChanged(int index)
{ {
QString prevSelection; QStringList prevMultiSelection;
if (ui->satellitesList->currentItem()) foreach (QListWidgetItem* i, ui->satellitesList->selectedItems())
prevSelection = ui->satellitesList->currentItem()->text(); {
prevMultiSelection << i->text();
}
ui->satellitesList->clear(); ui->satellitesList->clear();
if (ui->groupsCombo->itemData(index).toString() == "all") if (ui->groupsCombo->itemData(index).toString() == "all")
ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- >getSatellites()); ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- >getSatellites());
else if (ui->groupsCombo->itemData(index).toString() == "visible") else if (ui->groupsCombo->itemData(index).toString() == "visible")
ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- >getSatellites(QString(), Satellites::Visible)); ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- >getSatellites(QString(), Satellites::Visible));
else if (ui->groupsCombo->itemData(index).toString() == "notvisible" ) else if (ui->groupsCombo->itemData(index).toString() == "notvisible" )
ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- >getSatellites(QString(), Satellites::NotVisible)); ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- >getSatellites(QString(), Satellites::NotVisible));
else else
ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- >getSatellites(ui->groupsCombo->currentText())); ui->satellitesList->insertItems(0,GETSTELMODULE(Satellites)- >getSatellites(ui->groupsCombo->currentText()));
// If the previously selected item is still in the list after the up // If any previously selected items are still in the list after the
date, select it, update, select them,
// else selected the first item in the list. QListWidgetItem* item;
QList<QListWidgetItem*> foundItems = ui->satellitesList->findItems(p for (int i=0; (item = ui->satellitesList->item(i))!=NULL; i++)
revSelection, Qt::MatchExactly);
if (foundItems.count() > 0 && !prevSelection.isEmpty())
{ {
foundItems.at(0)->setSelected(true); item->setSelected(prevMultiSelection.contains(item->text()))
ui->satellitesList->scrollToItem(foundItems.at(0)); ;
}
QList<QListWidgetItem*> selectedItems = ui->satellitesList->selected
Items();
if (selectedItems.count() > 0)
{
// make sure the first selected item is visible...
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
ui->satellitesList->setCurrentRow(0); ui->satellitesList->setCurrentRow(0);
ui->satellitesList->scrollToTop(); ui->satellitesList->scrollToTop();
} }
} }
void SatellitesDialog::selectedSatelliteChanged(const QString& id) void SatellitesDialog::selectedSatelliteChanged(const QString& id)
{ {
qDebug() << "SatellitesDialog::selectedSatelliteChanged for " << id; //qDebug() << "SatellitesDialog::selectedSatelliteChanged for " << i d;
if (id.isEmpty() || id=="") if (id.isEmpty() || id=="")
return; return;
satelliteModified = false; satelliteModified = false;
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id); SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id);
if (!sat->initialized) if (!sat->initialized)
return; return;
disconnectSatelliteGuiForm();
ui->idLineEdit->setText(sat->designation); ui->idLineEdit->setText(sat->designation);
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(sat->elements[1]) + "\n" + QString( sat->elements[2])); ui->tleTextEdit->setText(QString("%1\n%2").arg(sat->tleElements.firs t.data()).arg(sat->tleElements.second.data()));
ui->visibleCheckbox->setChecked(sat->visible); ui->visibleCheckbox->setChecked(sat->visible);
ui->orbitCheckbox->setChecked(sat->orbitVisible);
ui->commsButton->setEnabled(sat->comms.count()>0); ui->commsButton->setEnabled(sat->comms.count()>0);
connectSatelliteGuiForm();
} }
void SatellitesDialog::saveSatellite(const QString& id) void SatellitesDialog::saveSatellites(void)
{ {
qDebug() << "Saving satellite" << id; GETSTELMODULE(Satellites)->saveTleData();
} }
void SatellitesDialog::setAboutHtml(void) void SatellitesDialog::setAboutHtml(void)
{ {
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 UGIN_VERSION + "</td></td>"; html += "<tr width=\"30%\"><td>" + q_("Version:") + "</td><td>" + PL UGIN_VERSION + "</td></td>";
html += "<tr><td>" + q_("Author:") + "</td><td>Matthew Gates &lt;mat html += "<tr><td>" + q_("Authors:") + "</td><td>Matthew Gates &lt;ma
thew@porpoisehead.net&gt;</td></td>"; tthew@porpoisehead.net&gt;</td></td>";
html += "<tr><td>" + q_("Website:") + "</td><td><a href=\"http://ste html += "<tr><td></td><td>Jose Luis Canales &lt;jlcanales.gasco@gmai
llarium.org/\">stellarium.org</a></td></td></table>"; l.com&gt;</td></tr></table>";
html += "<p>";
html += q_("This is the Satellites plugin for Stellarium. "); html += "<p>" + q_("The Satellites plugin predicts the positions of
html += q_("Please leave feedback in the Stellarium forums, post bug artificial satellites in Earth orbit.") + "</p>";
s to the bug tracker and consider making a donation to Stellarium if you fi
nd this plugin to be useful or interesting."); html += "<h3>" + q_("Notes for users") + "</h3><p><ul>";
html += q_(""); html += "<li>" + q_("Satellites and their orbits are only shown when
html += "</body></html>"; 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_("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
n in the \"Settings\" tab of this dialog will revert to the default satelli
te.json file. The old file will be backed up as \"satellites.json.old\".
This can be found in the user data directory, under \"modules/Satellites/\"
.") + "</li>";
html += "<li>" + q_("The Satellites plugin is still under developmen
t. Some features are incomplete, missing or buggy.") + "</li>";
html += "</ul></p>";
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><p>" + q_(QString("If you disable Internet updates, you
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
p://celestrak.com/NORAD/elements/visual.txt\">visual.txt</a>"));
html += "</p><p><b>" + q_("Note") + ":</b> " + q_("if the name of a
satellite in update data has anything in square brackets at the end, it wil
l be removed before the data is used.");
html += "</p>";
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 += "<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 += q_("The orbital calculation code is written by Jose Luis Can
ales according to the revised Spacetrack report N#3 (including Spacetrack r
eport N#6). ");
html += q_(QString("See %1this document%2 for details.").arg("<a hre
f=\"http://www.celestrak.com/publications/AIAA/2006-6753\">").arg("</a>"))
+ "</p>";
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><ul>";
html += "<li>" + q_(QString("If you have a question, you can %1get a
n answer here%2").arg("<a href=\"https://answers.launchpad.net/stellarium\"
>").arg("</a>")) + "</li>";
html += "<li>" + q_(QString("Bug reports can be made %1here%2.").arg
("<a href=\"https://bugs.launchpad.net/stellarium\">").arg("</a>")) + "</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>";
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());
if (!GETSTELMODULE(Satellites)->getUpdatesEnabled()) if (!GETSTELMODULE(Satellites)->getUpdatesEnabled())
ui->nextUpdateLabel->setText(q_("Updates disabled")); ui->nextUpdateLabel->setText(q_("Internet updates disabled") );
else if (GETSTELMODULE(Satellites)->getUpdateState() == Satellites:: Updating) else if (GETSTELMODULE(Satellites)->getUpdateState() == Satellites:: Updating)
ui->nextUpdateLabel->setText(q_("Updating now...")); ui->nextUpdateLabel->setText(q_("Updating now..."));
else if (secondsToUpdate <= 60) else if (secondsToUpdate <= 60)
ui->nextUpdateLabel->setText(q_("Next update: < 1 minute")); ui->nextUpdateLabel->setText(q_("Next update: < 1 minute"));
else if (secondsToUpdate < 3600) else if (secondsToUpdate < 3600)
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 min utes")).arg((secondsToUpdate/60)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 min utes")).arg((secondsToUpdate/60)+1));
else else
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 hou rs")).arg((secondsToUpdate/3600)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 hou rs")).arg((secondsToUpdate/3600)+1));
} }
void SatellitesDialog::setUpdateValues(int hours) void SatellitesDialog::setUpdateValues(int hours)
{ {
GETSTELMODULE(Satellites)->setUpdateFrequencyHours(hours); GETSTELMODULE(Satellites)->setUpdateFrequencyHours(hours);
refreshUpdateValues(); refreshUpdateValues();
} }
void SatellitesDialog::setUpdatesEnabled(bool b) void SatellitesDialog::setUpdatesEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Satellites)->setUpdatesEnabled(b); GETSTELMODULE(Satellites)->setUpdatesEnabled(b);
ui->updateFrequencySpinBox->setEnabled(b); ui->updateFrequencySpinBox->setEnabled(b);
ui->updateNowButton->setEnabled(b); if(b)
ui->updateButton->setText(q_("Update now"));
else
ui->updateButton->setText(q_("Update from files"));
refreshUpdateValues();
} }
void SatellitesDialog::updateStateReceiver(Satellites::UpdateState state) void SatellitesDialog::updateStateReceiver(Satellites::UpdateState state)
{ {
qDebug() << "SatellitesDialog::updateStateReceiver got a signal"; //qDebug() << "SatellitesDialog::updateStateReceiver got a signal";
if (state==Satellites::Updating) if (state==Satellites::Updating)
ui->nextUpdateLabel->setText(q_("Updating now...")); ui->nextUpdateLabel->setText(q_("Updating now..."));
else if (state==Satellites::DownloadError || state==Satellites::Othe rError) else if (state==Satellites::DownloadError || state==Satellites::Othe rError)
{ {
ui->nextUpdateLabel->setText(q_("Update error")); ui->nextUpdateLabel->setText(q_("Update error"));
updateTimer->start(); // make sure message is displayed for a while... updateTimer->start(); // make sure message is displayed for a while...
} }
} }
void SatellitesDialog::updateCompleteReceiver(int numUpdated) void SatellitesDialog::updateCompleteReceiver(int numUpdated, int total, in t missing)
{ {
ui->nextUpdateLabel->setText(QString(q_("Updated %1 satellite(s)")). arg(numUpdated)); ui->nextUpdateLabel->setText(QString(q_("Updated %1/%2 satellite(s); %3 missing")).arg(numUpdated).arg(total).arg(missing));
// display the status for another full interval before refreshing st atus // display the status for another full interval before refreshing st atus
updateTimer->start(); updateTimer->start();
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Satellites)->g etLastUpdate()); ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Satellites)->g etLastUpdate());
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())) ; connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())) ;
} }
void SatellitesDialog::close(void)
{
qDebug() << "Closing Satellites Configure Dialog";
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
));
gui->getGuiActions("actionShow_Satellite_ConfigDialog")->setChecked(
false);
}
void SatellitesDialog::sourceEditingDone(void) void SatellitesDialog::sourceEditingDone(void)
{ {
// don't update the currently selected item in the source list if th e text is empty or not a valid URL. // don't update the currently selected item in the source list if th e text is empty or not a valid URL.
QString u = ui->sourceEdit->text(); QString u = ui->sourceEdit->text();
if (u.isEmpty() || u=="") if (u.isEmpty() || u=="")
{ {
qDebug() << "SatellitesDialog::sourceEditingDone empty strin g - not saving"; qDebug() << "SatellitesDialog::sourceEditingDone empty strin g - not saving";
return; return;
} }
skipping to change at line 322 skipping to change at line 363
void SatellitesDialog::restoreDefaults(void) void SatellitesDialog::restoreDefaults(void)
{ {
qDebug() << "Satellites::restoreDefaults"; qDebug() << "Satellites::restoreDefaults";
GETSTELMODULE(Satellites)->restoreDefaults(); GETSTELMODULE(Satellites)->restoreDefaults();
GETSTELMODULE(Satellites)->readSettingsFromConfig(); GETSTELMODULE(Satellites)->readSettingsFromConfig();
updateGuiFromSettings(); updateGuiFromSettings();
} }
void SatellitesDialog::updateGuiFromSettings(void) void SatellitesDialog::updateGuiFromSettings(void)
{ {
ui->updateFromInternetCheckbox->setChecked(GETSTELMODULE(Satellites) ->getUpdatesEnabled()); ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Satellites)->g etUpdatesEnabled());
refreshUpdateValues(); refreshUpdateValues();
ui->showLabelsCheckbox->setChecked(GETSTELMODULE(Satellites)->getFla gLabels()); 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->orbitSegmentsSpin->setValue(Satellite::orbitLineSegments);
ui->orbitFadeSpin->setValue(Satellite::orbitLineFadeSegments);
ui->orbitDurationSpin->setValue(Satellite::orbitLineSegmentDuration)
;
ui->groupsCombo->clear(); ui->groupsCombo->clear();
ui->groupsCombo->addItems(GETSTELMODULE(Satellites)->getGroups()); ui->groupsCombo->addItems(GETSTELMODULE(Satellites)->getGroups());
ui->groupsCombo->insertItem(0, q_("[all satellites]"), QVariant("all "));
ui->groupsCombo->insertItem(0, q_("[all not visible]"), QVariant("no tvisible")); 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 visible]"), QVariant("visibl e"));
ui->groupsCombo->insertItem(0, q_("[all]"), QVariant("all"));
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::saveSettings(void) void SatellitesDialog::saveSettings(void)
{ {
qDebug() << "Satellites::saveSettings not implemented yet!"; GETSTELMODULE(Satellites)->saveSettingsToConfig();
}
void SatellitesDialog::showSelectedSatellites(void)
{
foreach (QListWidgetItem* i, ui->satellitesList->selectedItems())
{
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(i->text(
));
sat->visible = true;
}
groupFilterChanged(ui->groupsCombo->currentIndex());
} }
void SatellitesDialog::hideSelectedSatellites(void) void SatellitesDialog::visibleCheckChanged(int state)
{ {
foreach (QListWidgetItem* i, ui->satellitesList->selectedItems()) foreach (QListWidgetItem* i, ui->satellitesList->selectedItems())
{ {
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(i->text( )); SatelliteP sat = GETSTELMODULE(Satellites)->getByID(i->text( ));
sat->visible = false; sat->visible = (state==Qt::Checked);
} }
groupFilterChanged(ui->groupsCombo->currentIndex()); groupFilterChanged(ui->groupsCombo->currentIndex());
} }
void SatellitesDialog::visibleCheckChanged(int state) void SatellitesDialog::orbitCheckChanged(int state)
{ {
foreach (QListWidgetItem* i, ui->satellitesList->selectedItems()) foreach (QListWidgetItem* i, ui->satellitesList->selectedItems())
{ {
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(i->text( )); SatelliteP sat = GETSTELMODULE(Satellites)->getByID(i->text( ));
sat->visible = (state==Qt::Checked); sat->orbitVisible = (state==Qt::Checked);
} }
groupFilterChanged(ui->groupsCombo->currentIndex()); groupFilterChanged(ui->groupsCombo->currentIndex());
} }
void SatellitesDialog::satelliteDoubleClick(QListWidgetItem* item) void SatellitesDialog::satelliteDoubleClick(QListWidgetItem* item)
{ {
qDebug() << "SatellitesDialog::satelliteDoubleClick for " << item->t ext(); qDebug() << "SatellitesDialog::satelliteDoubleClick for " << item->t ext();
GETSTELMODULE(Satellites)->getByID(item->text())->visible = true; GETSTELMODULE(Satellites)->getByID(item->text())->visible = true;
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)
{
Satellite::orbitLineSegments = ui->orbitSegmentsSpin->value();
Satellite::orbitLineFadeSegments = ui->orbitFadeSpin->value();
Satellite::orbitLineSegmentDuration = ui->orbitDurationSpin->value()
;
GETSTELMODULE(Satellites)->recalculateOrbitLines();
}
void SatellitesDialog::updateTLEs(void)
{
if(GETSTELMODULE(Satellites)->getUpdatesEnabled())
{
GETSTELMODULE(Satellites)->updateTLEs();
}
else
{
QStringList updateFiles = QFileDialog::getOpenFileNames(&Ste
lMainGraphicsView::getInstance(),
q_("
Select TLE Update File"),
Stel
FileMgr::getDesktopDir(),
"*.*
");
GETSTELMODULE(Satellites)->updateFromFiles(updateFiles, fals
e);
}
}
void SatellitesDialog::connectSatelliteGuiForm(void)
{
// make sure we don't connect more than once
disconnectSatelliteGuiForm();
connect(ui->visibleCheckbox, SIGNAL(stateChanged(int)), this, SLOT(v
isibleCheckChanged(int)));
connect(ui->orbitCheckbox, SIGNAL(stateChanged(int)), this, SLOT(orb
itCheckChanged(int)));
}
void SatellitesDialog::disconnectSatelliteGuiForm(void)
{
disconnect(ui->visibleCheckbox, SIGNAL(stateChanged(int)), this, SLO
T(visibleCheckChanged(int)));
disconnect(ui->orbitCheckbox, SIGNAL(stateChanged(int)), this, SLOT(
orbitCheckChanged(int)));
}
 End of changes. 45 change blocks. 
93 lines changed or deleted 165 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/