NovaeDialog.cpp   NovaeDialog.cpp 
skipping to change at line 21 skipping to change at line 21
* 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "config.h"
#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 "ui_novaeDialog.h" #include "ui_novaeDialog.h"
#include "NovaeDialog.hpp" #include "NovaeDialog.hpp"
#include "Novae.hpp" #include "Novae.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" #include "StelFileMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
NovaeDialog::NovaeDialog() : updateTimer(NULL) NovaeDialog::NovaeDialog()
: nova(NULL)
, updateTimer(NULL)
{ {
ui = new Ui_novaeDialog; ui = new Ui_novaeDialog;
} }
NovaeDialog::~NovaeDialog() NovaeDialog::~NovaeDialog()
{ {
if (updateTimer) if (updateTimer)
{ {
updateTimer->stop(); updateTimer->stop();
delete updateTimer; delete updateTimer;
skipping to change at line 69 skipping to change at line 72
{ {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
refreshUpdateValues(); refreshUpdateValues();
setAboutHtml(); setAboutHtml();
} }
} }
// Initialize the dialog widgets and connect the signals/slots // Initialize the dialog widgets and connect the signals/slots
void NovaeDialog::createDialogContent() void NovaeDialog::createDialogContent()
{ {
nova = GETSTELMODULE(Novae);
ui->setupUi(dialog); ui->setupUi(dialog);
ui->tabs->setCurrentIndex(0); ui->tabs->setCurrentIndex(0);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), connect(&StelApp::getInstance(), SIGNAL(languageChanged()),
this, SLOT(retranslate())); 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(updateJSON() )); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateJSON() ));
connect(GETSTELMODULE(Novae), SIGNAL(updateStateChanged(Novae::Updat connect(nova, SIGNAL(updateStateChanged(Novae::UpdateState)), this,
eState)), this, SLOT(updateStateReceiver(Novae::UpdateState))); SLOT(updateStateReceiver(Novae::UpdateState)));
connect(GETSTELMODULE(Novae), SIGNAL(jsonUpdateComplete(void)), this connect(nova, SIGNAL(jsonUpdateComplete(void)), this, SLOT(updateCom
, SLOT(updateCompleteReceiver(void))); pleteReceiver(void)));
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());
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())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
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()));
// 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); if(gui!=NULL)
ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui-> ui->aboutTextBrowser->document()->setDefaultStyleSheet(QStri
getStelStyle().htmlStyleSheet)); ng(gui->getStelStyle().htmlStyleSheet));
updateGuiFromSettings(); updateGuiFromSettings();
} }
void NovaeDialog::setAboutHtml(void) void NovaeDialog::setAboutHtml(void)
{ {
QString html = "<html><head></head><body>"; QString html = "<html><head></head><body>";
html += "<h2>" + q_("Bright Novae Plug-in") + "</h2><table width=\"9 0%\">"; html += "<h2>" + q_("Bright Novae Plug-in") + "</h2><table width=\"9 0%\">";
html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + NOVAE_PLUGIN_VERSION + "</td></tr>"; html += "<tr width=\"30%\"><td><strong>" + q_("Version") + ":</stron g></td><td>" + NOVAE_PLUGIN_VERSION + "</td></tr>";
html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Alex ander Wolf &lt;alex.v.wolf@gmail.com&gt;</td></tr>"; html += "<tr><td><strong>" + q_("Author") + ":</strong></td><td>Alex ander Wolf &lt;alex.v.wolf@gmail.com&gt;</td></tr>";
html += "</table>"; html += "</table>";
html += "<p>" + q_("A plugin that shows some bright novae in the Mil ky Way galaxy."); html += "<p>" + q_("A plugin that shows some bright novae in the Mil ky Way galaxy.");
html += " " + q_("You can find novae via search tool by entering des ignation of nova or its common name (e.g. 'Nova Cygni 1975' or 'V1500 Cyg') .") + "</p>"; html += " " + q_("You can find novae via search tool by entering des ignation of nova or its common name (e.g. 'Nova Cygni 1975' or 'V1500 Cyg') .") + "</p>";
html += "<p>" + q_("This plugin allows you to see recent bright nova
e: ");
html += nova->getNovaeList();
html += ". " + q_("This list altogether contains %1 stars.").arg(nov
a->getCountNovae());
html += " " + q_("All those novae are brighter than %1 at peak of br
ightness.").arg(QString::number(nova->getLowerLimitBrightness(), 'f', 2) +
"<sup>m</sup>") + "</p>";
html += "<h3>" + q_("Light curves") + "</h3>"; html += "<h3>" + q_("Light curves") + "</h3>";
html += q_("This plugin uses a very simple model for calculation of light curves for novae stars.") + " "; html += q_("This plugin uses a very simple model for calculation of light curves for novae stars.") + " ";
html += q_("This model is based on time for decay by %1 magnitudes f rom the maximum value, where %1 is 2, 3, 6 and 9.").arg("<em>N</em>") + " " ; html += q_("This model is based on time for decay by %1 magnitudes f rom the maximum value, where %1 is 2, 3, 6 and 9.").arg("<em>N</em>") + " " ;
html += q_("If a nova has no values for decay of magnitude then this plugin will use generalized values for it."); html += q_("If a nova has no values for decay of magnitude then this plugin will use generalized values for it.");
html += "<p>"; html += "<p>";
html += "<h3>" + q_("Links") + "</h3>"; html += "<h3>" + q_("Links") + "</h3>";
html += "<p>" + QString(q_("Support is provided via the Launchpad we bsite. Be sure to put \"%1\" in the subject when posting.")).arg("Bright N ovae plugin") + "</p>"; html += "<p>" + QString(q_("Support is provided via the Launchpad we bsite. Be sure to put \"%1\" in the subject when posting.")).arg("Bright N ovae plugin") + "</p>";
html += "<p><ul>"; html += "<p><ul>";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + QString(q_("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>" + QString(q_("If you have a question, you can %1get a n answer here%2").arg("<a href=\"https://answers.launchpad.net/stellarium\" >")).arg("</a>") + "</li>";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // 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 >"; 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 // 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> ";
// TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link // TRANSLATORS: The numbers contain the opening and closing tag of a n HTML link
html += "<li>" + q_("If you want to read full information about this plugin, its history and catalog format, you can %1get info here%2.").arg(" <a href=\"http://stellarium.org/wiki/index.php/Bright_Novae_plugin\">").arg ("</a>") + "</li>"; html += "<li>" + q_("If you want to read full information about this plugin, its history and catalog format, you can %1get info here%2.").arg(" <a href=\"http://stellarium.org/wiki/index.php/Bright_Novae_plugin\">").arg ("</a>") + "</li>";
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); if(gui!=NULL)
QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet); {
ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleShee QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet);
t); ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlS
tyleSheet);
}
ui->aboutTextBrowser->setHtml(html); ui->aboutTextBrowser->setHtml(html);
} }
void NovaeDialog::refreshUpdateValues(void) void NovaeDialog::refreshUpdateValues(void)
{ {
ui->lastUpdateDateTimeEdit->setDateTime(GETSTELMODULE(Novae)->getLas ui->lastUpdateDateTimeEdit->setDateTime(nova->getLastUpdate());
tUpdate()); ui->updateFrequencySpinBox->setValue(nova->getUpdateFrequencyDays())
ui->updateFrequencySpinBox->setValue(GETSTELMODULE(Novae)->getUpdate ;
FrequencyDays()); int secondsToUpdate = nova->getSecondsToUpdate();
int secondsToUpdate = GETSTELMODULE(Novae)->getSecondsToUpdate(); ui->internetUpdatesCheckbox->setChecked(nova->getUpdatesEnabled());
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Novae)->getUpd if (!nova->getUpdatesEnabled())
atesEnabled());
if (!GETSTELMODULE(Novae)->getUpdatesEnabled())
ui->nextUpdateLabel->setText(q_("Internet updates disabled") ); ui->nextUpdateLabel->setText(q_("Internet updates disabled") );
else if (GETSTELMODULE(Novae)->getUpdateState() == Novae::Updating) else if (nova->getUpdateState() == Novae::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 if (secondsToUpdate < 86400) else if (secondsToUpdate < 86400)
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));
else else
ui->nextUpdateLabel->setText(QString(q_("Next update: %1 day s")).arg((secondsToUpdate/86400)+1)); ui->nextUpdateLabel->setText(QString(q_("Next update: %1 day s")).arg((secondsToUpdate/86400)+1));
} }
void NovaeDialog::setUpdateValues(int days) void NovaeDialog::setUpdateValues(int days)
{ {
GETSTELMODULE(Novae)->setUpdateFrequencyDays(days); nova->setUpdateFrequencyDays(days);
refreshUpdateValues(); refreshUpdateValues();
} }
void NovaeDialog::setUpdatesEnabled(int checkState) void NovaeDialog::setUpdatesEnabled(int checkState)
{ {
bool b = checkState != Qt::Unchecked; bool b = checkState != Qt::Unchecked;
GETSTELMODULE(Novae)->setUpdatesEnabled(b); nova->setUpdatesEnabled(b);
ui->updateFrequencySpinBox->setEnabled(b); ui->updateFrequencySpinBox->setEnabled(b);
if(b) if(b)
ui->updateButton->setText(q_("Update now")); ui->updateButton->setText(q_("Update now"));
else else
ui->updateButton->setText(q_("Update from files")); ui->updateButton->setText(q_("Update from files"));
refreshUpdateValues(); refreshUpdateValues();
} }
void NovaeDialog::updateStateReceiver(Novae::UpdateState state) void NovaeDialog::updateStateReceiver(Novae::UpdateState state)
skipping to change at line 197 skipping to change at line 207
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 NovaeDialog::updateCompleteReceiver(void) void NovaeDialog::updateCompleteReceiver(void)
{ {
ui->nextUpdateLabel->setText(QString(q_("Novae is updated"))); ui->nextUpdateLabel->setText(QString(q_("Novae is updated")));
// 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(Novae)->getLas tUpdate()); ui->lastUpdateDateTimeEdit->setDateTime(nova->getLastUpdate());
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 NovaeDialog::restoreDefaults(void) void NovaeDialog::restoreDefaults(void)
{ {
qDebug() << "Novae::restoreDefaults"; qDebug() << "Novae::restoreDefaults";
GETSTELMODULE(Novae)->restoreDefaults(); nova->restoreDefaults();
GETSTELMODULE(Novae)->readSettingsFromConfig(); nova->readSettingsFromConfig();
updateGuiFromSettings(); updateGuiFromSettings();
} }
void NovaeDialog::updateGuiFromSettings(void) void NovaeDialog::updateGuiFromSettings(void)
{ {
ui->internetUpdatesCheckbox->setChecked(GETSTELMODULE(Novae)->getUpd atesEnabled()); ui->internetUpdatesCheckbox->setChecked(nova->getUpdatesEnabled());
refreshUpdateValues(); refreshUpdateValues();
} }
void NovaeDialog::saveSettings(void) void NovaeDialog::saveSettings(void)
{ {
GETSTELMODULE(Novae)->saveSettingsToConfig(); nova->saveSettingsToConfig();
} }
void NovaeDialog::updateJSON(void) void NovaeDialog::updateJSON(void)
{ {
if(GETSTELMODULE(Novae)->getUpdatesEnabled()) if(nova->getUpdatesEnabled())
{ {
GETSTELMODULE(Novae)->updateJSON(); nova->updateJSON();
} }
} }
 End of changes. 18 change blocks. 
31 lines changed or deleted 43 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/