SearchDialog.cpp   SearchDialog.cpp 
skipping to change at line 45 skipping to change at line 45
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QtAlgorithms> #include <QtAlgorithms>
#include <QTextEdit> #include <QTextEdit>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox> #include <QComboBox>
#include <QMenu> #include <QMenu>
#include <QMetaEnum>
#include "SimbadSearcher.hpp" #include "SimbadSearcher.hpp"
// Start of members for class CompletionLabel // Start of members for class CompletionLabel
CompletionLabel::CompletionLabel(QWidget* parent) : QLabel(parent), selecte dIdx(0) CompletionLabel::CompletionLabel(QWidget* parent) : QLabel(parent), selecte dIdx(0)
{ {
} }
CompletionLabel::~CompletionLabel() CompletionLabel::~CompletionLabel()
{ {
skipping to change at line 164 skipping to change at line 165
greekLetters.insert("rho", QString(QChar(0x03C1))); greekLetters.insert("rho", QString(QChar(0x03C1)));
greekLetters.insert("sigma", QString(QChar(0x03C3))); // second lowe r-case sigma shouldn't affect anything greekLetters.insert("sigma", QString(QChar(0x03C3))); // second lowe r-case sigma shouldn't affect anything
greekLetters.insert("tau", QString(QChar(0x03C4))); greekLetters.insert("tau", QString(QChar(0x03C4)));
greekLetters.insert("upsilon", QString(QChar(0x03C5))); greekLetters.insert("upsilon", QString(QChar(0x03C5)));
greekLetters.insert("phi", QString(QChar(0x03C6))); greekLetters.insert("phi", QString(QChar(0x03C6)));
greekLetters.insert("chi", QString(QChar(0x03C7))); greekLetters.insert("chi", QString(QChar(0x03C7)));
greekLetters.insert("psi", QString(QChar(0x03C8))); greekLetters.insert("psi", QString(QChar(0x03C8)));
greekLetters.insert("omega", QString(QChar(0x03C9))); greekLetters.insert("omega", QString(QChar(0x03C9)));
QSettings* conf = StelApp::getInstance().getSettings(); conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf);
useSimbad = conf->value("search/flag_search_online", true).toBool(); useSimbad = conf->value("search/flag_search_online", true).toBool();
useStartOfWords = conf->value("search/flag_start_words", false).toBo ol(); useStartOfWords = conf->value("search/flag_start_words", false).toBo ol();
simbadServerUrl = conf->value("search/simbad_server_url", DEF_SIMBAD _URL).toString(); simbadServerUrl = conf->value("search/simbad_server_url", DEF_SIMBAD _URL).toString();
setCurrentCoordinateSystemKey(conf->value("search/coordinate_system" , "equatorialJ2000").toString());
} }
SearchDialog::~SearchDialog() SearchDialog::~SearchDialog()
{ {
delete ui; delete ui;
if (simbadReply) if (simbadReply)
{ {
simbadReply->deleteLater(); simbadReply->deleteLater();
simbadReply = NULL; simbadReply = NULL;
} }
} }
void SearchDialog::retranslate() void SearchDialog::retranslate()
{ {
if (dialog) if (dialog)
{ {
QString text(ui->lineEditSearchSkyObject->text()); QString text(ui->lineEditSearchSkyObject->text());
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
ui->lineEditSearchSkyObject->setText(text); ui->lineEditSearchSkyObject->setText(text);
populateSimbadServerList(); populateSimbadServerList();
populateCoordinateSystemsList();
populateCoordinateAxis();
updateListTab(); updateListTab();
} }
} }
void SearchDialog::styleChanged() void SearchDialog::styleChanged()
{ {
// Nothing for now // Nothing for now
} }
void SearchDialog::setCurrentCoordinateSystemKey(QString key)
{
const QMetaEnum& en = metaObject()->enumerator(metaObject()->indexOf
Enumerator("CoordinateSystem"));
CoordinateSystem coordSystem = (CoordinateSystem)en.keyToValue(key.t
oLatin1().data());
if (coordSystem<0)
{
qWarning() << "[Search Tool] Unknown coordinate system: " <<
key << "setting \"equatorialJ2000\" instead";
coordSystem = equatorialJ2000;
}
setCurrentCoordinateSystem(coordSystem);
}
QString SearchDialog::getCurrentCoordinateSystemKey() const
{
return metaObject()->enumerator(metaObject()->indexOfEnumerator("Coo
rdinateSystem")).key(currentCoordinateSystem);
}
void SearchDialog::populateCoordinateSystemsList()
{
Q_ASSERT(ui->coordinateSystemComboBox);
QComboBox* csys = ui->coordinateSystemComboBox;
//Save the current selection to be restored later
csys->blockSignals(true);
int index = csys->currentIndex();
QVariant selectedSystemId = csys->itemData(index);
csys->clear();
//For each coordinate system, display the localized name and store t
he key as user
//data. Unfortunately, there's no other way to do this than with a c
ycle.
csys->addItem(qc_("Equatorial (J2000.0)", "coordinate system"), "equ
atorialJ2000");
csys->addItem(qc_("Equatorial", "coordinate system"), "equatorial");
csys->addItem(qc_("Horizontal", "coordinate system"), "horizontal");
csys->addItem(qc_("Galactic", "coordinate system"), "galactic");
//Restore the selection
index = csys->findData(selectedSystemId, Qt::UserRole, Qt::MatchCase
Sensitive);
csys->setCurrentIndex(index);
csys->blockSignals(false);
}
void SearchDialog::populateCoordinateAxis()
{
switch (getCurrentCoordinateSystem()) {
case equatorialJ2000:
case equatorial:
{
ui->AxisXLabel->setText(q_("Right ascension"));
ui->AxisXSpinBox->setDisplayFormat(AngleSpinBox::HMS
Letters);
ui->AxisYLabel->setText(q_("Declination"));
ui->AxisYSpinBox->setDisplayFormat(AngleSpinBox::DMS
Symbols);
ui->AxisYSpinBox->setPrefixType(AngleSpinBox::Normal
Plus);
break;
}
case horizontal:
{
ui->AxisXLabel->setText(q_("Azimuth"));
ui->AxisXSpinBox->setDisplayFormat(AngleSpinBox::DMS
Letters);
ui->AxisXSpinBox->setPrefixType(AngleSpinBox::Normal
Plus);
ui->AxisYLabel->setText(q_("Altitude"));
ui->AxisYSpinBox->setDisplayFormat(AngleSpinBox::DMS
Symbols);
ui->AxisYSpinBox->setPrefixType(AngleSpinBox::Normal
Plus);
break;
}
case galactic:
{
ui->AxisXLabel->setText(q_("Longitude"));
ui->AxisXSpinBox->setDisplayFormat(AngleSpinBox::DMS
Letters);
ui->AxisXSpinBox->setPrefixType(AngleSpinBox::Normal
Plus);
ui->AxisYLabel->setText(q_("Latitude"));
ui->AxisYSpinBox->setDisplayFormat(AngleSpinBox::DMS
Symbols);
ui->AxisYSpinBox->setPrefixType(AngleSpinBox::Normal
Plus);
break;
}
}
}
void SearchDialog::setCoordinateSystem(int csID)
{
QString currentCoordinateSystemID = ui->coordinateSystemComboBox->it
emData(csID).toString();
setCurrentCoordinateSystemKey(currentCoordinateSystemID);
populateCoordinateAxis();
ui->AxisXSpinBox->setRadians(0.);
ui->AxisYSpinBox->setRadians(0.);
conf->setValue("search/coordinate_system", currentCoordinateSystemID
);
}
// Initialize the dialog widgets and connect the signals/slots // Initialize the dialog widgets and connect the signals/slots
void SearchDialog::createDialogContent() void SearchDialog::createDialogContent()
{ {
ui->setupUi(dialog); ui->setupUi(dialog);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate())); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate()));
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->lineEditSearchSkyObject, SIGNAL(textChanged(const QStrin g&)), connect(ui->lineEditSearchSkyObject, SIGNAL(textChanged(const QStrin g&)),
this, SLOT(onSearchTextChanged(const QString&))); this, SLOT(onSearchTextChanged(const QString&)));
connect(ui->pushButtonGotoSearchSkyObject, SIGNAL(clicked()), this, SLOT(gotoObject())); connect(ui->pushButtonGotoSearchSkyObject, SIGNAL(clicked()), this, SLOT(gotoObject()));
onSearchTextChanged(ui->lineEditSearchSkyObject->text()); onSearchTextChanged(ui->lineEditSearchSkyObject->text());
connect(ui->lineEditSearchSkyObject, SIGNAL(returnPressed()), this, SLOT(gotoObject())); connect(ui->lineEditSearchSkyObject, SIGNAL(returnPressed()), this, SLOT(gotoObject()));
connect(ui->lineEditSearchSkyObject, SIGNAL(selectionChanged()), thi s, SLOT(setHasSelectedFlag())); connect(ui->lineEditSearchSkyObject, SIGNAL(selectionChanged()), thi s, SLOT(setHasSelectedFlag()));
connect(ui->lineEditSearchSkyObject, SIGNAL(customContextMenuRequest ed(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(ui->lineEditSearchSkyObject, SIGNAL(customContextMenuRequest ed(QPoint)), this, SLOT(showContextMenu(QPoint)));
ui->lineEditSearchSkyObject->installEventFilter(this); ui->lineEditSearchSkyObject->installEventFilter(this);
ui->RAAngleSpinBox->setDisplayFormat(AngleSpinBox::HMSLetters);
ui->DEAngleSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols);
ui->DEAngleSpinBox->setPrefixType(AngleSpinBox::NormalPlus);
connect(ui->RAAngleSpinBox, SIGNAL(valueChanged()), this, SLOT(manua //Kinetic scrolling for tablet pc and pc
lPositionChanged())); QList<QWidget *> addscroll;
connect(ui->DEAngleSpinBox, SIGNAL(valueChanged()), this, SLOT(manua addscroll << ui->objectsListWidget;
lPositionChanged())); installKineticScrolling(addscroll);
populateCoordinateSystemsList();
populateCoordinateAxis();
int idx = ui->coordinateSystemComboBox->findData(getCurrentCoordinat
eSystemKey(), Qt::UserRole, Qt::MatchCaseSensitive);
if (idx==-1)
{
// Use equatorialJ2000 as default
idx = ui->coordinateSystemComboBox->findData(QVariant("equat
orialJ2000"), Qt::UserRole, Qt::MatchCaseSensitive);
}
ui->coordinateSystemComboBox->setCurrentIndex(idx);
connect(ui->coordinateSystemComboBox, SIGNAL(currentIndexChanged(int
)), this, SLOT(setCoordinateSystem(int)));
connect(ui->AxisXSpinBox, SIGNAL(valueChanged()), this, SLOT(manualP
ositionChanged()));
connect(ui->AxisYSpinBox, SIGNAL(valueChanged()), this, SLOT(manualP
ositionChanged()));
connect(ui->alphaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked())); connect(ui->alphaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked()));
connect(ui->betaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL etterClicked())); connect(ui->betaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL etterClicked()));
connect(ui->gammaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked())); connect(ui->gammaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked()));
connect(ui->deltaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked())); connect(ui->deltaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked()));
connect(ui->epsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(gre ekLetterClicked())); connect(ui->epsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(gre ekLetterClicked()));
connect(ui->zetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL etterClicked())); connect(ui->zetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL etterClicked()));
connect(ui->etaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked())); connect(ui->etaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked()));
connect(ui->thetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked())); connect(ui->thetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked()));
connect(ui->iotaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL etterClicked())); connect(ui->iotaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL etterClicked()));
skipping to change at line 249 skipping to change at line 351
connect(ui->upsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(gre ekLetterClicked())); connect(ui->upsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(gre ekLetterClicked()));
connect(ui->phiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked())); connect(ui->phiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked()));
connect(ui->chiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked())); connect(ui->chiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked()));
connect(ui->psiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked())); connect(ui->psiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked()));
connect(ui->omegaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked())); connect(ui->omegaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked()));
connect(ui->checkBoxUseSimbad, SIGNAL(clicked(bool)), this, SLOT(ena bleSimbadSearch(bool))); connect(ui->checkBoxUseSimbad, SIGNAL(clicked(bool)), this, SLOT(ena bleSimbadSearch(bool)));
ui->checkBoxUseSimbad->setChecked(useSimbad); ui->checkBoxUseSimbad->setChecked(useSimbad);
populateSimbadServerList(); populateSimbadServerList();
int idx = ui->serverListComboBox->findData(simbadServerUrl, Qt::User Role, Qt::MatchCaseSensitive); idx = ui->serverListComboBox->findData(simbadServerUrl, Qt::UserRole , Qt::MatchCaseSensitive);
if (idx==-1) if (idx==-1)
{ {
// Use University of Strasbourg as default // Use University of Strasbourg as default
idx = ui->serverListComboBox->findData(QVariant(DEF_SIMBAD_U RL), Qt::UserRole, Qt::MatchCaseSensitive); idx = ui->serverListComboBox->findData(QVariant(DEF_SIMBAD_U RL), Qt::UserRole, Qt::MatchCaseSensitive);
} }
ui->serverListComboBox->setCurrentIndex(idx); ui->serverListComboBox->setCurrentIndex(idx);
connect(ui->serverListComboBox, SIGNAL(currentIndexChanged(int)), th is, SLOT(selectSimbadServer(int))); connect(ui->serverListComboBox, SIGNAL(currentIndexChanged(int)), th is, SLOT(selectSimbadServer(int)));
connect(ui->checkBoxUseStartOfWords, SIGNAL(clicked(bool)), this, SL OT(enableStartOfWordsAutofill(bool))); connect(ui->checkBoxUseStartOfWords, SIGNAL(clicked(bool)), this, SL OT(enableStartOfWordsAutofill(bool)));
ui->checkBoxUseStartOfWords->setChecked(useStartOfWords); ui->checkBoxUseStartOfWords->setChecked(useStartOfWords);
skipping to change at line 280 skipping to change at line 382
} }
void SearchDialog::setHasSelectedFlag() void SearchDialog::setHasSelectedFlag()
{ {
flagHasSelectedText = true; flagHasSelectedText = true;
} }
void SearchDialog::enableSimbadSearch(bool enable) void SearchDialog::enableSimbadSearch(bool enable)
{ {
useSimbad = enable; useSimbad = enable;
QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf);
conf->setValue("search/flag_search_online", useSimbad); conf->setValue("search/flag_search_online", useSimbad);
} }
void SearchDialog::enableStartOfWordsAutofill(bool enable) void SearchDialog::enableStartOfWordsAutofill(bool enable)
{ {
useStartOfWords = enable; useStartOfWords = enable;
QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf);
conf->setValue("search/flag_start_words", useStartOfWords); conf->setValue("search/flag_start_words", useStartOfWords);
} }
void SearchDialog::setSimpleStyle() void SearchDialog::setSimpleStyle()
{ {
ui->RAAngleSpinBox->setVisible(false); ui->AxisXSpinBox->setVisible(false);
ui->DEAngleSpinBox->setVisible(false); ui->AxisXSpinBox->setVisible(false);
ui->simbadStatusLabel->setVisible(false); ui->simbadStatusLabel->setVisible(false);
ui->raDecLabel->setVisible(false); ui->AxisXLabel->setVisible(false);
ui->AxisYLabel->setVisible(false);
ui->coordinateSystemLabel->setVisible(false);
ui->coordinateSystemComboBox->setVisible(false);
} }
void SearchDialog::manualPositionChanged() void SearchDialog::manualPositionChanged()
{ {
ui->completionLabel->clearValues(); ui->completionLabel->clearValues();
StelCore* core = StelApp::getInstance().getCore();
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
Vec3d pos; Vec3d pos;
StelUtils::spheToRect(ui->RAAngleSpinBox->valueRadians(), ui->DEAngl switch (getCurrentCoordinateSystem()) {
eSpinBox->valueRadians(), pos); case equatorialJ2000:
{
StelUtils::spheToRect(ui->AxisXSpinBox->valueRadians
(), ui->AxisYSpinBox->valueRadians(), pos);
break;
}
case equatorial:
{
StelUtils::spheToRect(ui->AxisXSpinBox->valueRadians
(), ui->AxisYSpinBox->valueRadians(), pos);
pos = core->equinoxEquToJ2000(pos);
break;
}
case horizontal:
{
double cx;
cx = 3.*M_PI - ui->AxisXSpinBox->valueRadians(); //
N is zero, E is 90 degrees
if (cx > M_PI*2)
cx -= M_PI*2;
StelUtils::spheToRect(cx, ui->AxisYSpinBox->valueRad
ians(), pos);
pos = core->altAzToJ2000(pos);
break;
}
case galactic:
{
StelUtils::spheToRect(ui->AxisXSpinBox->valueRadians
(), ui->AxisYSpinBox->valueRadians(), pos);
pos = core->galacticToJ2000(pos);
break;
}
}
mvmgr->setFlagTracking(false); mvmgr->setFlagTracking(false);
mvmgr->moveToJ2000(pos, 0.05); mvmgr->moveToJ2000(pos, 0.05);
} }
void SearchDialog::onSearchTextChanged(const QString& text) void SearchDialog::onSearchTextChanged(const QString& text)
{ {
// This block needs to go before the trimmedText.isEmpty() or the SI MBAD result does not // This block needs to go before the trimmedText.isEmpty() or the SI MBAD result does not
// get properly cleared. // get properly cleared.
if (useSimbad) { if (useSimbad) {
if (simbadReply) { if (simbadReply) {
skipping to change at line 571 skipping to change at line 699
servers->blockSignals(false); servers->blockSignals(false);
} }
void SearchDialog::selectSimbadServer(int index) void SearchDialog::selectSimbadServer(int index)
{ {
if (index < 0) if (index < 0)
simbadServerUrl = DEF_SIMBAD_URL; simbadServerUrl = DEF_SIMBAD_URL;
else else
simbadServerUrl = ui->serverListComboBox->itemData(index).to String(); simbadServerUrl = ui->serverListComboBox->itemData(index).to String();
QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf);
conf->setValue("search/simbad_server_url", simbadServerUrl); conf->setValue("search/simbad_server_url", simbadServerUrl);
} }
void SearchDialog::updateListWidget(int index) void SearchDialog::updateListWidget(int index)
{ {
QString moduleId = ui->objectTypeComboBox->itemData(index).toString( ); QString moduleId = ui->objectTypeComboBox->itemData(index).toString( );
ui->objectsListWidget->clear(); ui->objectsListWidget->clear();
bool englishNames = ui->searchInEnglishCheckBox->isChecked(); bool englishNames = ui->searchInEnglishCheckBox->isChecked();
ui->objectsListWidget->addItems(objectMgr->listAllModuleObjects(modu leId, englishNames)); ui->objectsListWidget->addItems(objectMgr->listAllModuleObjects(modu leId, englishNames));
ui->objectsListWidget->sortItems(Qt::AscendingOrder); ui->objectsListWidget->sortItems(Qt::AscendingOrder);
 End of changes. 15 change blocks. 
23 lines changed or deleted 177 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/