SatellitesDialog.cpp   SatellitesDialog.cpp 
skipping to change at line 33 skipping to change at line 33
#include <QFileDialog> #include <QFileDialog>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTimer> #include <QTimer>
#include <QUrl> #include <QUrl>
#include "StelApp.hpp" #include "StelApp.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 "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 "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
SatellitesDialog::SatellitesDialog() : SatellitesDialog::SatellitesDialog() :
updateTimer(0), updateTimer(0),
importWindow(0), importWindow(0),
satellitesModel(0), filterModel(0),
filterProxyModel(0) checkStateRole(Qt::UserRole)
{ {
ui = new Ui_satellitesDialog; ui = new Ui_satellitesDialog;
satellitesModel = new QStandardItemModel(this);
} }
SatellitesDialog::~SatellitesDialog() SatellitesDialog::~SatellitesDialog()
{ {
if (updateTimer) if (updateTimer)
{ {
updateTimer->stop(); updateTimer->stop();
delete updateTimer; delete updateTimer;
updateTimer = NULL; updateTimer = NULL;
} }
skipping to change at line 77 skipping to change at line 77
} }
delete ui; delete ui;
} }
void SatellitesDialog::retranslate() void SatellitesDialog::retranslate()
{ {
if (dialog) if (dialog)
{ {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
refreshUpdateValues(); updateSettingsPage(); // For the button; also calls updateCo
setAboutHtml(); untdown()
// This may be a problem if we add group name translations, populateAboutPage();
as the populateFilterMenu();
// 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);
ui->labelAutoAdd->setVisible(false);
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()))
;
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslate())); this, SLOT(retranslate()));
Satellites* plugin = GETSTELMODULE(Satellites);
// Settings tab / updates group // Settings tab / updates group
connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this // These controls are refreshed by updateSettingsPage(), which in
, SLOT(setUpdatesEnabled(int))); // turn is triggered by setting any of these values. Because
// clicked() is issued only by user input, there's no endless loop.
connect(ui->internetUpdatesCheckbox, SIGNAL(clicked(bool)),
plugin, SLOT(enableInternetUpdates(bool)));
connect(ui->checkBoxAutoAdd, SIGNAL(clicked(bool)),
plugin, SLOT(enableAutoAdd(bool)));
connect(ui->checkBoxAutoRemove, SIGNAL(clicked(bool)),
plugin, SLOT(enableAutoRemove(bool)));
connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)),
plugin, SLOT(setUpdateFrequencyHours(int)));
connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateTLEs() )); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateTLEs() ));
connect(GETSTELMODULE(Satellites), SIGNAL(updateStateChanged(Satelli connect(ui->jumpToSourcesButton, SIGNAL(clicked()),
tes::UpdateState)), this, SLOT(updateStateReceiver(Satellites::UpdateState) this, SLOT(jumpToSourcesTab()));
)); connect(plugin, SIGNAL(updateStateChanged(Satellites::UpdateState)),
connect(GETSTELMODULE(Satellites), SIGNAL(tleUpdateComplete(int, int this, SLOT(showUpdateState(Satellites::UpdateState)));
, int)), this, SLOT(updateCompleteReceiver(int, int, int))); connect(plugin, SIGNAL(tleUpdateComplete(int, int, int, int)),
connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, this, SLOT(showUpdateCompleted(int, int, int, int)));
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(updateCountdown() ));
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->labelsGroup, SIGNAL(toggled(bool)), dynamic_cast<StelGui // This does call Satellites::setFlagLabels() indirectly.
*>(StelApp::getInstance().getGui())->getGuiAction("actionShow_Satellite_Lab QAction* action = dynamic_cast<StelGui*>(StelApp::getInstance().getG
els"), SLOT(setChecked(bool))); ui())->getGuiAction("actionShow_Satellite_Labels");
connect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)), GETSTELMODUL connect(ui->labelsGroup, SIGNAL(clicked(bool)),
E(Satellites), SLOT(setLabelFontSize(int))); action, SLOT(setChecked(bool)));
connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(res connect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)),
toreDefaults())); plugin, SLOT(setLabelFontSize(int)));
connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSe connect(ui->restoreDefaultsButton, SIGNAL(clicked()),
ttings())); this, SLOT(restoreDefaults()));
connect(ui->saveSettingsButton, SIGNAL(clicked()),
this, SLOT(saveSettings()));
// Settings tab / orbit lines group // Settings tab / orbit lines group
ui->orbitLinesGroup->setChecked(GETSTELMODULE(Satellites)->getOrbitL connect(ui->orbitLinesGroup, SIGNAL(clicked(bool)),
inesFlag()); plugin, SLOT(setOrbitLinesFlag(bool)));
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->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()));
// Settings tab - populate all values
updateSettingsPage();
// Satellites tab // Satellites tab
filterProxyModel = new QSortFilterProxyModel(this); filterModel = new SatellitesListFilterModel(this);
filterProxyModel->setSourceModel(satellitesModel); filterModel->setSourceModel(GETSTELMODULE(Satellites)->getSatellites
filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); ListModel());
ui->satellitesList->setModel(filterProxyModel); filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->satellitesList->setModel(filterModel);
connect(ui->lineEditSearch, SIGNAL(textEdited(QString)), connect(ui->lineEditSearch, SIGNAL(textEdited(QString)),
filterProxyModel, SLOT(setFilterWildcard(QString))); filterModel, SLOT(setFilterWildcard(QString)));
QItemSelectionModel* selectionModel = ui->satellitesList->selectionM odel(); QItemSelectionModel* selectionModel = ui->satellitesList->selectionM odel();
connect(selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelI connect(selectionModel,
ndex)), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(updateSelectedInfo(QModelIndex,QModelIndex))); this,
SLOT(updateSatelliteData()));
connect(ui->satellitesList, SIGNAL(doubleClicked(QModelIndex)), connect(ui->satellitesList, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(handleDoubleClick(QModelIndex))); this, SLOT(trackSatellite(QModelIndex)));
connect(ui->groupsCombo, SIGNAL(currentIndexChanged(int)), this, SLO
T(listSatelliteGroup(int))); // Two-state input, three-state display
connect(ui->displayedCheckbox, SIGNAL(clicked(bool)),
ui->displayedCheckbox, SLOT(setChecked(bool)));
connect(ui->orbitCheckbox, SIGNAL(clicked(bool)),
ui->orbitCheckbox, SLOT(setChecked(bool)));
connect(ui->userCheckBox, SIGNAL(clicked(bool)),
ui->userCheckBox, SLOT(setChecked(bool)));
// Because the previous signals and slots were connected first,
// they will be executed before these.
connect(ui->displayedCheckbox, SIGNAL(clicked()),
this, SLOT(setFlags()));
connect(ui->orbitCheckbox, SIGNAL(clicked()),
this, SLOT(setFlags()));
connect(ui->userCheckBox, SIGNAL(clicked()),
this, SLOT(setFlags()));
connect(ui->groupsListWidget, SIGNAL(itemChanged(QListWidgetItem*)),
this, SLOT(handleGroupChanges(QListWidgetItem*)));
connect(ui->groupFilterCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(filterListByGroup(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())); connect(ui->removeSatellitesButton, SIGNAL(clicked()), this, SLOT(re moveSatellites()));
connectSatelliteGuiForm();
importWindow = new SatellitesImportDialog(); importWindow = new SatellitesImportDialog();
connect(ui->addSatellitesButton, SIGNAL(clicked()), connect(ui->addSatellitesButton, SIGNAL(clicked()),
importWindow, SLOT(setVisible())); importWindow, SLOT(setVisible()));
connect(importWindow, SIGNAL(satellitesAccepted(TleDataList)), connect(importWindow, SIGNAL(satellitesAccepted(TleDataList)),
this, SLOT(addSatellites(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 connect(ui->sourceList, SIGNAL(itemChanged(QListWidgetItem*)),
EditingDone())); this, SLOT(saveSourceList()));
connect(ui->sourceEdit, SIGNAL(editingFinished()),
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()),
this, SLOT(toggleCheckableSources()));
// About tab // About tab
setAboutHtml(); populateAboutPage();
updateGuiFromSettings();
populateFilterMenu();
populateSourcesList();
} }
void SatellitesDialog::listSatelliteGroup(int index) void SatellitesDialog::filterListByGroup(int index)
{ {
QItemSelectionModel* selectionModel = ui->satellitesList->selectionM if (index < 0)
odel(); return;
QModelIndexList selectedIndexes = selectionModel->selectedRows();
QVariantList prevMultiSelection;
foreach (const QModelIndex& index, selectedIndexes)
{
prevMultiSelection << index.data(Qt::UserRole);
}
satellitesModel->clear();
QHash<QString,QString> satellites; QString groupId = ui->groupFilterCombo->itemData(index).toString();
Satellites* plugin = GETSTELMODULE(Satellites); if (groupId == "all")
QString selectedGroup = ui->groupsCombo->itemData(index).toString(); filterModel->setSecondaryFilters(QString(), SatNoFlags);
if (selectedGroup == "all") else if (groupId == "[displayed]")
satellites = plugin->getSatellites(); filterModel->setSecondaryFilters(QString(), SatDisplayed);
else if (selectedGroup == "visible") else if (groupId == "[undisplayed]")
satellites = plugin->getSatellites(QString(), Satellites::Vi filterModel->setSecondaryFilters(QString(), SatNotDisplayed)
sible); ;
else if (selectedGroup == "notvisible") else if (groupId == "[newlyadded]")
satellites = plugin->getSatellites(QString(), Satellites::No filterModel->setSecondaryFilters(QString(), SatNew);
tVisible); else if (groupId == "[orbiterror]")
else if (selectedGroup == "newlyadded") filterModel->setSecondaryFilters(QString(), SatError);
satellites = plugin->getSatellites(QString(), Satellites::Ne
wlyAdded);
else if (selectedGroup == "orbiterror")
satellites = plugin->getSatellites(QString(), Satellites::Or
bitError);
else else
satellites = plugin->getSatellites(ui->groupsCombo->currentT {
ext()); filterModel->setSecondaryFilters(groupId, SatNoFlags);
//satellitesModel->->setSortingEnabled(false);
QHashIterator<QString,QString> i(satellites);
while (i.hasNext())
{
i.next();
QStandardItem* item = new QStandardItem(i.value());
item->setData(i.key(), Qt::UserRole);
item->setEditable(false);
satellitesModel->appendRow(item);
// If a previously selected item is still in the list after
the update, select it
if (prevMultiSelection.contains(i.key()))
{
QModelIndex index = filterProxyModel->mapFromSource(
item->index());
//QModelIndex index = item->index();
selectionModel->select(index, QItemSelectionModel::S
electCurrent);
}
} }
// Sort the main list (don't sort the filter model directly,
// or the displayed list will be scrambled on emptying the filter).
satellitesModel->sort(0);
if (ui->satellitesList->model()->rowCount() <= 0)
return;
QItemSelectionModel* selectionModel = ui->satellitesList->selectionM
odel();
QModelIndex first;
if (selectionModel->hasSelection()) if (selectionModel->hasSelection())
{ {
//TODO: This is stupid... first = selectionModel->selectedRows().first();
for (int row = 0; row < ui->satellitesList->model()->rowCoun
t(); row++)
{
QModelIndex index = ui->satellitesList->model()->ind
ex(row, 0);
if (selectionModel->isSelected(index))
{
ui->satellitesList->scrollTo(index, QAbstrac
tItemView::PositionAtTop);
break;
}
}
} }
else if (ui->satellitesList->model()->rowCount() > 0) else
{ {
// If there are any items in the listbox, scroll to the top // Scroll to the top
QModelIndex index = ui->satellitesList->model()->index(0, 0) first = ui->satellitesList->model()->index(0, 0);
;
selectionModel->setCurrentIndex(index, QItemSelectionModel::
NoUpdate);
ui->satellitesList->scrollTo(index, QAbstractItemView::Posit
ionAtTop);
} }
selectionModel->setCurrentIndex(first, QItemSelectionModel::NoUpdate
);
ui->satellitesList->scrollTo(first);
} }
void SatellitesDialog::reloadSatellitesList() void SatellitesDialog::updateSatelliteData()
{ {
listSatelliteGroup(ui->groupsCombo->currentIndex()); // NOTE: This was probably going to be used for editing satellites?
}
void SatellitesDialog::updateSelectedInfo(const QModelIndex& curItem,
const QModelIndex& prevItem)
{
Q_UNUSED(prevItem);
if (!curItem.isValid())
return;
QString id = curItem.data(Qt::UserRole).toString();
if (id.isEmpty())
return;
satelliteModified = false; satelliteModified = false;
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id); QModelIndexList selection = ui->satellitesList->selectionModel()->se
if (sat.isNull()) lectedIndexes();
return; if (selection.isEmpty())
return; // TODO: Clear the fields?
enableSatelliteDataForm(false);
if (selection.count() > 1)
{
ui->nameEdit->clear();
ui->noradNumberEdit->clear();
ui->descriptionTextEdit->clear();
ui->tleFirstLineEdit->clear();
ui->tleSecondLineEdit->clear();
}
else
{
QModelIndex& index = selection.first();
ui->nameEdit->setText(index.data(Qt::DisplayRole).toString()
);
ui->noradNumberEdit->setText(index.data(Qt::UserRole).toStri
ng());
// NOTE: Description is deliberately displayed untranslated!
ui->descriptionTextEdit->setText(index.data(SatDescriptionRo
le).toString());
ui->tleFirstLineEdit->setText(index.data(FirstLineRole).toSt
ring());
ui->tleFirstLineEdit->setCursorPosition(0);
ui->tleSecondLineEdit->setText(index.data(SecondLineRole).to
String());
ui->tleSecondLineEdit->setCursorPosition(0);
}
// TODO: Fix the comms button...
// ui->commsButton->setEnabled(sat->comms.count()>0);
// Things that are cumulative in a multi-selection
GroupSet globalGroups = GETSTELMODULE(Satellites)->getGroups();
GroupSet groupsUsedBySome;
GroupSet groupsUsedByAll = globalGroups;
ui->displayedCheckbox->setChecked(false);
ui->orbitCheckbox->setChecked(false);
ui->userCheckBox->setChecked(false);
for (int i = 0; i < selection.size(); i++)
{
const QModelIndex& index = selection.at(i);
// "Displayed" checkbox
SatFlags flags = index.data(SatFlagsRole).value<SatFlags>();
if (flags.testFlag(SatDisplayed))
{
if (!ui->displayedCheckbox->isChecked())
{
if (i == 0)
ui->displayedCheckbox->setChecked(tr
ue);
else
ui->displayedCheckbox->setCheckState
(Qt::PartiallyChecked);
}
}
else
if (ui->displayedCheckbox->isChecked())
ui->displayedCheckbox->setCheckState(Qt::Par
tiallyChecked);
if (!sat->initialized) // "Orbit" box
return; if (flags.testFlag(SatOrbit))
{
if (!ui->orbitCheckbox->isChecked())
{
if (i == 0)
ui->orbitCheckbox->setChecked(true);
else
ui->orbitCheckbox->setCheckState(Qt:
:PartiallyChecked);
}
}
else
if (ui->orbitCheckbox->isChecked())
ui->orbitCheckbox->setCheckState(Qt::Partial
lyChecked);
disconnectSatelliteGuiForm(); // User ("do not update") box
ui->idLineEdit->setText(sat->name); if (flags.testFlag(SatUser))
ui->lineEditCatalogNumber->setText(sat->id); {
ui->descriptionTextEdit->setText(sat->description); if (!ui->userCheckBox->isChecked())
ui->groupsTextEdit->setText(sat->groupIDs.join(", ")); {
QString tleStr = QString("%1\n%2").arg(sat->tleElements.first.data() if (i == 0)
).arg(sat->tleElements.second.data()); ui->userCheckBox->setChecked(true);
ui->tleTextEdit->setText(tleStr); else
ui->visibleCheckbox->setChecked(sat->visible); ui->userCheckBox->setCheckState(Qt::
ui->orbitCheckbox->setChecked(sat->orbitVisible); PartiallyChecked);
ui->commsButton->setEnabled(sat->comms.count()>0); }
connectSatelliteGuiForm(); }
else
if (ui->userCheckBox->isChecked())
ui->userCheckBox->setCheckState(Qt::Partiall
yChecked);
// Accumulating groups
GroupSet groups = index.data(SatGroupsRole).value<GroupSet>(
);
groupsUsedBySome.unite(groups);
groupsUsedByAll.intersect(groups);
}
// Repopulate the group selector
// Nice list of checkable, translated groups that allows adding new
groups
ui->groupsListWidget->blockSignals(true);
ui->groupsListWidget->clear();
foreach (const QString& group, globalGroups)
{
QListWidgetItem* item = new QListWidgetItem(q_(group),
ui->groupsListWi
dget);
item->setData(Qt::UserRole, group);
Qt::CheckState state = Qt::Unchecked;
if (groupsUsedByAll.contains(group))
state = Qt::Checked;
else if (groupsUsedBySome.contains(group))
state = Qt::PartiallyChecked;
item->setData(Qt::CheckStateRole, state);
}
ui->groupsListWidget->sortItems();
addSpecialGroupItem(); // Add the "Add new..." line
ui->groupsListWidget->blockSignals(false);
enableSatelliteDataForm(true);
} }
void SatellitesDialog::saveSatellites(void) void SatellitesDialog::saveSatellites(void)
{ {
GETSTELMODULE(Satellites)->saveTleData(); GETSTELMODULE(Satellites)->saveCatalog();
} }
void SatellitesDialog::setAboutHtml(void) 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=2><strong>" + q_("Authors") + "</strong></t html += "<tr><td rowspan=3><strong>" + q_("Authors") + "</strong></t
d><td>Matthew Gates &lt;matthewg42@gmail.com&gt;</td></td>"; d><td>Matthew Gates &lt;matthewg42@gmail.com&gt;</td></td>";
html += "<tr><td>Jose Luis Canales &lt;jlcanales.gasco@gmail.com&gt; html += "<tr><td>Jose Luis Canales &lt;jlcanales.gasco@gmail.com&gt;
</td></tr></table>"; </td></tr>";
html += "<tr><td>Bogdan Marinov &lt;bogdan.marinov84@gmail.com&gt;</
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 341 skipping to change at line 433
html += "</ul></p></body></html>"; html += "</ul></p></body></html>";
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
Q_ASSERT(gui); Q_ASSERT(gui);
QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet); QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleShee t); ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleShee t);
ui->aboutTextBrowser->setHtml(html); ui->aboutTextBrowser->setHtml(html);
} }
void SatellitesDialog::refreshUpdateValues(void) void SatellitesDialog::jumpToSourcesTab()
{ {
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Satellites)->g ui->tabs->setCurrentWidget(ui->sourcesTab);
etLastUpdate());
ui->updateFrequencySpinBox->setValue(GETSTELMODULE(Satellites)->getU
pdateFrequencyHours());
int secondsToUpdate = GETSTELMODULE(Satellites)->getSecondsToUpdate(
);
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Satellites)->g
etUpdatesEnabled());
if (!GETSTELMODULE(Satellites)->getUpdatesEnabled())
ui->nextUpdateLabel->setText(q_("Internet updates disabled")
);
else if (GETSTELMODULE(Satellites)->getUpdateState() == Satellites::
Updating)
ui->nextUpdateLabel->setText(q_("Updating now..."));
else if (secondsToUpdate <= 60)
ui->nextUpdateLabel->setText(q_("Next update: < 1 minute"));
else if (secondsToUpdate < 3600)
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 min
utes")).arg((secondsToUpdate/60)+1));
else
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 hou
rs")).arg((secondsToUpdate/3600)+1));
} }
void SatellitesDialog::setUpdateValues(int hours) void SatellitesDialog::updateCountdown()
{ {
GETSTELMODULE(Satellites)->setUpdateFrequencyHours(hours); Satellites* plugin = GETSTELMODULE(Satellites);
refreshUpdateValues(); bool updatesEnabled = plugin->getUpdatesEnabled();
}
void SatellitesDialog::setUpdatesEnabled(int checkState) if (!updatesEnabled)
{ ui->nextUpdateLabel->setText(q_("Internet updates disabled")
bool b = checkState != Qt::Unchecked; );
GETSTELMODULE(Satellites)->setUpdatesEnabled(b); else if (plugin->getUpdateState() == Satellites::Updating)
ui->updateFrequencySpinBox->setEnabled(b); ui->nextUpdateLabel->setText(q_("Updating now..."));
if(b)
ui->updateButton->setText(q_("Update now"));
else else
ui->updateButton->setText(q_("Update from files")); {
int secondsToUpdate = plugin->getSecondsToUpdate();
refreshUpdateValues(); if (secondsToUpdate <= 60)
ui->nextUpdateLabel->setText(q_("Next update: < 1 mi
nute"));
else if (secondsToUpdate < 3600)
ui->nextUpdateLabel->setText(QString(q_("Next update
: %1 minutes")).arg((secondsToUpdate/60)+1));
else
ui->nextUpdateLabel->setText(QString(q_("Next update
: %1 hours")).arg((secondsToUpdate/3600)+1));
}
} }
void SatellitesDialog::updateStateReceiver(Satellites::UpdateState state) void SatellitesDialog::showUpdateState(Satellites::UpdateState state)
{ {
//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, int total, in void SatellitesDialog::showUpdateCompleted(int updated,
t missing) int total,
int added,
int missing)
{ {
ui->nextUpdateLabel->setText(QString(q_("Updated %1/%2 satellite(s); Satellites* plugin = GETSTELMODULE(Satellites);
%3 missing")).arg(numUpdated).arg(total).arg(missing)); QString message;
if (plugin->isAutoRemoveEnabled())
message = q_("Updated %1/%2 satellite(s); %3 added; %4 remov
ed");
else
message = q_("Updated %1/%2 satellite(s); %3 added; %4 missi
ng");
ui->nextUpdateLabel->setText(message.arg(updated).arg(total).arg(add
ed).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 ui->lastUpdateDateTimeEdit->setDateTime(plugin->getLastUpdate());
etLastUpdate()); QTimer *timer = new QTimer(this); // FIXME: What's the point of this
QTimer *timer = new QTimer(this); ? --BM
connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())) connect(timer, SIGNAL(timeout()), this, SLOT(updateCountdown()));
;
} }
void SatellitesDialog::sourceEditingDone(void) void SatellitesDialog::saveEditedSource()
{ {
// 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;
} }
if (!QUrl(u).isValid() || !u.contains("://")) if (!QUrl(u).isValid() || !u.contains("://"))
{ {
qDebug() << "SatellitesDialog::sourceEditingDone invalid URL - not saving : " << u; qDebug() << "SatellitesDialog::sourceEditingDone invalid URL - not saving : " << u;
return; return;
} }
// Changes to item data (text or check state) are connected to
// saveSourceList(), so there's no need to call it explicitly.
if (ui->sourceList->currentItem()!=NULL) if (ui->sourceList->currentItem()!=NULL)
ui->sourceList->currentItem()->setText(u); ui->sourceList->currentItem()->setText(u);
else if (ui->sourceList->findItems(u, Qt::MatchExactly).count() <= 0 ) else if (ui->sourceList->findItems(u, Qt::MatchExactly).count() <= 0 )
{ {
QListWidgetItem* i = new QListWidgetItem(u, ui->sourceList); QListWidgetItem* i = new QListWidgetItem(u, ui->sourceList);
;
i->setData(checkStateRole, Qt::Unchecked);
i->setSelected(true); i->setSelected(true);
} }
saveSourceList();
} }
void SatellitesDialog::saveSourceList(void) void SatellitesDialog::saveSourceList(void)
{ {
QStringList allSources; QStringList allSources;
for(int i=0; i<ui->sourceList->count(); i++) for(int i=0; i<ui->sourceList->count(); i++)
{ {
allSources << ui->sourceList->item(i)->text(); QString url = ui->sourceList->item(i)->text();
if (ui->sourceList->item(i)->data(checkStateRole) == Qt::Che
cked)
url.prepend("1,");
allSources << url;
} }
GETSTELMODULE(Satellites)->setTleSources(allSources); GETSTELMODULE(Satellites)->setTleSources(allSources);
} }
void SatellitesDialog::deleteSourceRow(void) void SatellitesDialog::deleteSourceRow(void)
{ {
ui->sourceEdit->clear(); ui->sourceEdit->clear();
if (ui->sourceList->currentItem()) if (ui->sourceList->currentItem())
delete ui->sourceList->currentItem(); delete ui->sourceList->currentItem();
skipping to change at line 454 skipping to change at line 547
} }
void SatellitesDialog::addSourceRow(void) void SatellitesDialog::addSourceRow(void)
{ {
ui->sourceList->setCurrentItem(NULL); ui->sourceList->setCurrentItem(NULL);
ui->sourceEdit->setText(q_("[new source]")); ui->sourceEdit->setText(q_("[new source]"));
ui->sourceEdit->selectAll(); ui->sourceEdit->selectAll();
ui->sourceEdit->setFocus(); ui->sourceEdit->setFocus();
} }
void SatellitesDialog::toggleCheckableSources()
{
QListWidget* list = ui->sourceList;
if (list->count() < 1)
return; // Saves effort checking it on every step
bool enabled = ui->checkBoxAutoAdd->isChecked(); // proxy :)
if (!enabled == list->item(0)->data(Qt::CheckStateRole).isNull())
return; // Nothing to do
ui->sourceList->blockSignals(true); // Prevents saving the list...
for (int row = 0; row < list->count(); row++)
{
QListWidgetItem* item = list->item(row);
if (enabled)
{
item->setData(Qt::CheckStateRole, item->data(Qt::Use
rRole));
}
else
{
item->setData(Qt::UserRole, item->data(Qt::CheckStat
eRole));
item->setData(Qt::CheckStateRole, QVariant());
}
}
ui->sourceList->blockSignals(false);
checkStateRole = enabled ? Qt::CheckStateRole : Qt::UserRole;
}
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)->loadSettings();
updateGuiFromSettings(); updateSettingsPage();
populateFilterMenu();
populateSourcesList();
} }
void SatellitesDialog::updateGuiFromSettings(void) void SatellitesDialog::updateSettingsPage()
{ {
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Satellites)->g Satellites* plugin = GETSTELMODULE(Satellites);
etUpdatesEnabled());
refreshUpdateValues();
ui->labelsGroup->setChecked(GETSTELMODULE(Satellites)->getFlagLabels // Update stuff
()); bool updatesEnabled = plugin->getUpdatesEnabled();
ui->fontSizeSpinBox->setValue(GETSTELMODULE(Satellites)->getLabelFon ui->internetUpdatesCheckbox->setChecked(updatesEnabled);
tSize()); if(updatesEnabled)
ui->updateButton->setText(q_("Update now"));
else
ui->updateButton->setText(q_("Update from files"));
ui->checkBoxAutoAdd->setChecked(plugin->isAutoAddEnabled());
ui->checkBoxAutoRemove->setChecked(plugin->isAutoRemoveEnabled());
ui->lastUpdateDateTimeEdit->setDateTime(plugin->getLastUpdate());
ui->updateFrequencySpinBox->setValue(plugin->getUpdateFrequencyHours
());
updateCountdown();
// Presentation stuff
ui->labelsGroup->setChecked(plugin->getFlagLabels());
ui->fontSizeSpinBox->setValue(plugin->getLabelFontSize());
ui->orbitLinesGroup->setChecked(GETSTELMODULE(Satellites)->getOrbitL inesFlag()); ui->orbitLinesGroup->setChecked(plugin->getOrbitLinesFlag());
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) ;
}
populateGroupsList(); void SatellitesDialog::populateFilterMenu()
ui->satellitesList->clearSelection(); {
ui->groupsCombo->setCurrentIndex(0); // Save current selection, if any...
QString selectedId;
int index = ui->groupFilterCombo->currentIndex();
if (ui->groupFilterCombo->count() > 0 && index >= 0)
{
selectedId = ui->groupFilterCombo->itemData(index).toString(
);
}
// Prevent the list from re-filtering
ui->groupFilterCombo->blockSignals(true);
// Populate with group names/IDs
ui->groupFilterCombo->clear();
foreach (const QString& group, GETSTELMODULE(Satellites)->getGroupId
List())
{
ui->groupFilterCombo->addItem(q_(group), group);
}
ui->groupFilterCombo->model()->sort(0);
// Add special groups - their IDs deliberately use JSON-incompatible
chars.
ui->groupFilterCombo->insertItem(0, q_("[orbit calculation error]"),
QVariant("[orbiterror]"));
ui->groupFilterCombo->insertItem(0, q_("[all newly added]"), QVarian
t("[newlyadded]"));
ui->groupFilterCombo->insertItem(0, q_("[all not displayed]"), QVari
ant("[undisplayed]"));
ui->groupFilterCombo->insertItem(0, q_("[all displayed]"), QVariant(
"[displayed]"));
ui->groupFilterCombo->insertItem(0, q_("[all]"), QVariant("all"));
// Restore current selection
index = 0;
if (!selectedId.isEmpty())
{
index = ui->groupFilterCombo->findData(selectedId);
if (index < 0)
index = 0;
}
ui->groupFilterCombo->setCurrentIndex(index);
ui->groupFilterCombo->blockSignals(false);
}
void SatellitesDialog::populateSourcesList()
{
ui->sourceList->blockSignals(true);
ui->sourceList->clear(); ui->sourceList->clear();
ui->sourceList->addItems(GETSTELMODULE(Satellites)->getTleSources())
; Satellites* plugin = GETSTELMODULE(Satellites);
QStringList urls = plugin->getTleSources();
checkStateRole = plugin->isAutoAddEnabled() ? Qt::CheckStateRole
: Qt::UserRole;
foreach (QString url, urls)
{
bool checked = false;
if (url.startsWith("1,"))
{
checked = true;
url.remove(0, 2);
}
else if (url.startsWith("0,"))
url.remove(0, 2);
QListWidgetItem* item = new QListWidgetItem(url, ui->sourceL
ist);
item->setData(checkStateRole, checked ? Qt::Checked : Qt::Un
checked);
}
ui->sourceList->blockSignals(false);
if (ui->sourceList->count() > 0) ui->sourceList->setCurrentRow(0); if (ui->sourceList->count() > 0) ui->sourceList->setCurrentRow(0);
} }
void SatellitesDialog::populateGroupsList() void SatellitesDialog::addSpecialGroupItem()
{
if (ui->groupsListWidget->count() == 0)
return;
// TRANSLATORS: Displayed in the satellite group selection box.
QListWidgetItem* item = new QListWidgetItem(q_("New group..."));
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsSelect
able);
QFont font = ui->groupsListWidget->item(0)->font();
font.setItalic(true);
item->setFont(font);
ui->groupsListWidget->insertItem(0, item);
}
void SatellitesDialog::setGroups()
{ {
ui->groupsCombo->clear(); QModelIndexList selection = ui->satellitesList->selectionModel()->se
ui->groupsCombo->addItems(GETSTELMODULE(Satellites)->getGroups()); lectedIndexes();
ui->groupsCombo->insertItem(0, q_("[orbit calculation error]"), QVar if (selection.isEmpty())
iant("orbiterror")); return;
ui->groupsCombo->insertItem(0, q_("[all newly added]"), QVariant("ne
wlyadded")); // Let's determine what to add or remove
ui->groupsCombo->insertItem(0, q_("[all not displayed]"), QVariant(" // (partially checked groups are not modified)
notvisible")); GroupSet groupsToAdd;
ui->groupsCombo->insertItem(0, q_("[all displayed]"), QVariant("visi GroupSet groupsToRemove;
ble")); for (int row = 0; row < ui->groupsListWidget->count(); row++)
ui->groupsCombo->insertItem(0, q_("[all]"), QVariant("all")); {
QListWidgetItem* item = ui->groupsListWidget->item(row);
if (item->flags().testFlag(Qt::ItemIsEditable))
continue;
if (item->checkState() == Qt::Checked)
groupsToAdd.insert(item->data(Qt::UserRole).toString
());
else if (item->checkState() == Qt::Unchecked)
groupsToRemove.insert(item->data(Qt::UserRole).toStr
ing());
}
for (int i = 0; i < selection.count(); i++)
{
const QModelIndex& index = selection.at(i);
GroupSet groups = index.data(SatGroupsRole).value<GroupSet>(
);
groups.subtract(groupsToRemove);
groups.unite(groupsToAdd);
QVariant newGroups = QVariant::fromValue<GroupSet>(groups);
ui->satellitesList->model()->setData(index, newGroups, SatGr
oupsRole);
}
} }
void SatellitesDialog::saveSettings(void) void SatellitesDialog::saveSettings(void)
{ {
GETSTELMODULE(Satellites)->saveSettingsToConfig(); GETSTELMODULE(Satellites)->saveSettings();
GETSTELMODULE(Satellites)->saveTleData(); GETSTELMODULE(Satellites)->saveCatalog();
} }
void SatellitesDialog::addSatellites(const TleDataList& newSatellites) void SatellitesDialog::addSatellites(const TleDataList& newSatellites)
{ {
GETSTELMODULE(Satellites)->add(newSatellites); GETSTELMODULE(Satellites)->add(newSatellites);
saveSatellites(); saveSatellites();
// Trigger re-loading the list to display the new satellites // Trigger re-loading the list to display the new satellites
int index = ui->groupsCombo->findData(QVariant("newlyadded")); int index = ui->groupFilterCombo->findData(QVariant("[newlyadded]"))
if (ui->groupsCombo->currentIndex() == index) ;
listSatelliteGroup(index); // TODO: Unnecessary once the model can handle changes? --BM
if (ui->groupFilterCombo->currentIndex() == index)
filterListByGroup(index);
else else
ui->groupsCombo->setCurrentIndex(index); //Triggers the same operation ui->groupFilterCombo->setCurrentIndex(index); //Triggers the same operation
// Select the satellites that were added just now // Select the satellites that were added just now
QItemSelectionModel* selectionModel = ui->satellitesList->selectionM odel(); QItemSelectionModel* selectionModel = ui->satellitesList->selectionM odel();
selectionModel->clearSelection(); selectionModel->clearSelection();
QModelIndex firstSelectedIndex; QModelIndex firstSelectedIndex;
QSet<QString> newIds; QSet<QString> newIds;
foreach (const TleData& sat, newSatellites) foreach (const TleData& sat, newSatellites)
newIds.insert(sat.id); newIds.insert(sat.id);
for (int row = 0; row < ui->satellitesList->model()->rowCount(); row ++) for (int row = 0; row < ui->satellitesList->model()->rowCount(); row ++)
{ {
skipping to change at line 550 skipping to change at line 782
QItemSelectionModel* selectionModel = ui->satellitesList->selectionM odel(); QItemSelectionModel* selectionModel = ui->satellitesList->selectionM odel();
QModelIndexList selectedIndexes = selectionModel->selectedRows(); QModelIndexList selectedIndexes = selectionModel->selectedRows();
foreach (const QModelIndex& index, selectedIndexes) foreach (const QModelIndex& index, selectedIndexes)
{ {
QString id = index.data(Qt::UserRole).toString(); QString id = index.data(Qt::UserRole).toString();
idList.append(id); idList.append(id);
} }
if (!idList.isEmpty()) if (!idList.isEmpty())
{ {
GETSTELMODULE(Satellites)->remove(idList); GETSTELMODULE(Satellites)->remove(idList);
reloadSatellitesList();
saveSatellites(); saveSatellites();
} }
} }
void SatellitesDialog::setDisplayFlag(bool display) void SatellitesDialog::setFlags()
{ {
QItemSelectionModel* selectionModel = ui->satellitesList->selectionM odel(); QItemSelectionModel* selectionModel = ui->satellitesList->selectionM odel();
QModelIndexList selectedIndexes = selectionModel->selectedRows(); QModelIndexList selection = selectionModel->selectedIndexes();
foreach (const QModelIndex& index, selectedIndexes) for (int row = 0; row < selection.count(); row++)
{ {
QString id = index.data(Qt::UserRole).toString(); const QModelIndex& index = selection.at(row);
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id); SatFlags flags = index.data(SatFlagsRole).value<SatFlags>();
if (sat)
sat->visible = display; // If a checkbox is partially checked, the respective flag i
s not
// changed.
if (ui->displayedCheckbox->isChecked())
flags |= SatDisplayed;
else if (ui->displayedCheckbox->checkState() == Qt::Unchecke
d)
flags &= ~SatDisplayed;
if (ui->orbitCheckbox->isChecked())
flags |= SatOrbit;
else if (ui->orbitCheckbox->checkState() == Qt::Unchecked)
flags &= ~SatOrbit;
if (ui->userCheckBox->isChecked())
flags |= SatUser;
else if (ui->userCheckBox->checkState() == Qt::Unchecked)
flags &= ~SatUser;
QVariant value = QVariant::fromValue<SatFlags>(flags);
ui->satellitesList->model()->setData(index, value, SatFlagsR
ole);
} }
reloadSatellitesList();
} }
void SatellitesDialog::setOrbitFlag(bool display) void SatellitesDialog::handleGroupChanges(QListWidgetItem* item)
{ {
QItemSelectionModel* selectionModel = ui->satellitesList->selectionM ui->groupsListWidget->blockSignals(true);
odel(); Qt::ItemFlags flags = item->flags();
QModelIndexList selectedIndexes = selectionModel->selectedRows(); if (flags.testFlag(Qt::ItemIsEditable))
foreach (const QModelIndex& index, selectedIndexes)
{ {
QString id = index.data(Qt::UserRole).toString(); // Harmonize the item with the rest...
SatelliteP sat = GETSTELMODULE(Satellites)->getByID(id); flags ^= Qt::ItemIsEditable;
if (sat) item->setFlags(flags | Qt::ItemIsUserCheckable | Qt::ItemIsT
sat->orbitVisible = display; ristate);
item->setCheckState(Qt::Checked);
QString groupId = item->text().trimmed();
item->setData(Qt::UserRole, groupId);
QFont font = item->font();
font.setItalic(false);
item->setFont(font);
// ...and add a new one in its place.
addSpecialGroupItem();
GETSTELMODULE(Satellites)->addGroup(groupId);
populateFilterMenu();
} }
reloadSatellitesList(); ui->groupsListWidget->blockSignals(false);
setGroups();
} }
void SatellitesDialog::handleDoubleClick(const QModelIndex& index) void SatellitesDialog::trackSatellite(const QModelIndex& index)
{ {
Satellites* SatellitesMgr = GETSTELMODULE(Satellites); Satellites* SatellitesMgr = GETSTELMODULE(Satellites);
Q_ASSERT(SatellitesMgr); Q_ASSERT(SatellitesMgr);
QString id = index.data(Qt::UserRole).toString(); QString id = index.data(Qt::UserRole).toString();
SatelliteP sat = SatellitesMgr->getByID(id); SatelliteP sat = SatellitesMgr->getById(id);
if (sat.isNull()) if (sat.isNull())
return; return;
if (!sat->orbitValid) if (!sat->orbitValid)
return; return;
// Turn on Satellite rendering if it is not already on // Turn on Satellite rendering if it is not already on
sat->visible = true; sat->displayed = true;
// If Satellites are not currently displayed, make them visible. // If Satellites are not currently displayed, make them visible.
if (!SatellitesMgr->getFlagHints()) if (!SatellitesMgr->getFlagHints())
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
QAction* setHintsAction = gui->getGuiAction("actionShow_Sate llite_Hints"); QAction* setHintsAction = gui->getGuiAction("actionShow_Sate llite_Hints");
Q_ASSERT(setHintsAction); Q_ASSERT(setHintsAction);
setHintsAction->setChecked(true); setHintsAction->setChecked(true);
} }
skipping to change at line 628 skipping to change at line 888
Satellite::orbitLineSegments = ui->orbitSegmentsSpin->value(); Satellite::orbitLineSegments = ui->orbitSegmentsSpin->value();
Satellite::orbitLineFadeSegments = ui->orbitFadeSpin->value(); Satellite::orbitLineFadeSegments = ui->orbitFadeSpin->value();
Satellite::orbitLineSegmentDuration = ui->orbitDurationSpin->value() ; Satellite::orbitLineSegmentDuration = ui->orbitDurationSpin->value() ;
GETSTELMODULE(Satellites)->recalculateOrbitLines(); GETSTELMODULE(Satellites)->recalculateOrbitLines();
} }
void SatellitesDialog::updateTLEs(void) void SatellitesDialog::updateTLEs(void)
{ {
if(GETSTELMODULE(Satellites)->getUpdatesEnabled()) if(GETSTELMODULE(Satellites)->getUpdatesEnabled())
{ {
GETSTELMODULE(Satellites)->updateTLEs(); GETSTELMODULE(Satellites)->updateFromOnlineSources();
} }
else else
{ {
QStringList updateFiles = QFileDialog::getOpenFileNames(&Ste lMainGraphicsView::getInstance(), QStringList updateFiles = QFileDialog::getOpenFileNames(&Ste lMainGraphicsView::getInstance(),
q_(" Select TLE Update File"), q_(" Select TLE Update File"),
Stel FileMgr::getDesktopDir(), Stel FileMgr::getDesktopDir(),
"*.* "); "*.* ");
GETSTELMODULE(Satellites)->updateFromFiles(updateFiles, fals e); GETSTELMODULE(Satellites)->updateFromFiles(updateFiles, fals e);
} }
} }
void SatellitesDialog::connectSatelliteGuiForm(void) void SatellitesDialog::enableSatelliteDataForm(bool enabled)
{
// make sure we don't connect more than once
disconnectSatelliteGuiForm();
connect(ui->visibleCheckbox, SIGNAL(clicked(bool)), this, SLOT(setDi
splayFlag(bool)));
connect(ui->orbitCheckbox, SIGNAL(clicked(bool)), this, SLOT(setOrbi
tFlag(bool)));
}
void SatellitesDialog::disconnectSatelliteGuiForm(void)
{ {
disconnect(ui->visibleCheckbox, SIGNAL(clicked(bool)), this, SLOT(se // NOTE: I'm still not sure if this is necessary, if the right signa
tDisplayFlag(bool))); ls are used to trigger changes...--BM
disconnect(ui->orbitCheckbox, SIGNAL(clicked(bool)), this, SLOT(setO ui->displayedCheckbox->blockSignals(!enabled);
rbitFlag(bool))); ui->orbitCheckbox->blockSignals(!enabled);
ui->userCheckBox->blockSignals(!enabled);
} }
 End of changes. 86 change blocks. 
303 lines changed or deleted 555 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/