SearchDialog.cpp   SearchDialog.cpp 
skipping to change at line 17 skipping to change at line 17
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "Dialog.hpp" #include "Dialog.hpp"
#include "SearchDialog.hpp" #include "SearchDialog.hpp"
#include "ui_searchDialogGui.h" #include "ui_searchDialogGui.h"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include <QDebug> #include <QDebug>
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QSettings>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QTextEdit> #include <QTextEdit>
#include <QLineEdit>
#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 123 skipping to change at line 125
} }
// Start of members for class SearchDialog // Start of members for class SearchDialog
SearchDialog::SearchDialog() : simbadReply(NULL) SearchDialog::SearchDialog() : simbadReply(NULL)
{ {
ui = new Ui_searchDialogForm; ui = new Ui_searchDialogForm;
simbadSearcher = new SimbadSearcher(this); simbadSearcher = new SimbadSearcher(this);
objectMgr = GETSTELMODULE(StelObjectMgr); objectMgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(objectMgr); Q_ASSERT(objectMgr);
flagHasSelectedText = false;
greekLetters.insert("alpha", QString(QChar(0x03B1))); greekLetters.insert("alpha", QString(QChar(0x03B1)));
greekLetters.insert("beta", QString(QChar(0x03B2))); greekLetters.insert("beta", QString(QChar(0x03B2)));
greekLetters.insert("gamma", QString(QChar(0x03B3))); greekLetters.insert("gamma", QString(QChar(0x03B3)));
greekLetters.insert("delta", QString(QChar(0x03B4))); greekLetters.insert("delta", QString(QChar(0x03B4)));
greekLetters.insert("epsilon", QString(QChar(0x03B5))); greekLetters.insert("epsilon", QString(QChar(0x03B5)));
greekLetters.insert("zeta", QString(QChar(0x03B6))); greekLetters.insert("zeta", QString(QChar(0x03B6)));
greekLetters.insert("eta", QString(QChar(0x03B7))); greekLetters.insert("eta", QString(QChar(0x03B7)));
greekLetters.insert("theta", QString(QChar(0x03B8))); greekLetters.insert("theta", QString(QChar(0x03B8)));
greekLetters.insert("iota", QString(QChar(0x03B9))); greekLetters.insert("iota", QString(QChar(0x03B9)));
greekLetters.insert("kappa", QString(QChar(0x03BA))); greekLetters.insert("kappa", QString(QChar(0x03BA)));
greekLetters.insert("lambda", QString(QChar(0x03BB))); greekLetters.insert("lambda", QString(QChar(0x03BB)));
greekLetters.insert("mu", QString(QChar(0x03BC))); greekLetters.insert("mu", QString(QChar(0x03BC)));
greekLetters.insert("nu", QString(QChar(0x03BD))); greekLetters.insert("nu", QString(QChar(0x03BD)));
greekLetters.insert("xi", QString(QChar(0x03BE))); greekLetters.insert("xi", QString(QChar(0x03BE)));
greekLetters.insert("omicron", QString(QChar(0x03BF))); greekLetters.insert("omicron", QString(QChar(0x03BF)));
greekLetters.insert("pi", QString(QChar(0x03C0))); greekLetters.insert("pi", QString(QChar(0x03C0)));
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();
Q_ASSERT(conf);
useSimbad = conf->value("search/flag_search_online", true).toBool();
} }
SearchDialog::~SearchDialog() SearchDialog::~SearchDialog()
{ {
delete ui; delete ui;
if (simbadReply) if (simbadReply)
{ {
simbadReply->deleteLater(); simbadReply->deleteLater();
simbadReply = NULL; simbadReply = NULL;
} }
} }
void SearchDialog::languageChanged() 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);
} }
} }
void SearchDialog::styleChanged() void SearchDialog::styleChanged()
{ {
// Nothing for now // Nothing for now
} }
// 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 connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL
OT(languageChanged())); OT(retranslate()));
// setSimpleStyle();
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()));
ui->lineEditSearchSkyObject->installEventFilter(this); ui->lineEditSearchSkyObject->installEventFilter(this);
ui->RAAngleSpinBox->setDisplayFormat(AngleSpinBox::HMSLetters); ui->RAAngleSpinBox->setDisplayFormat(AngleSpinBox::HMSLetters);
ui->DEAngleSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols); ui->DEAngleSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols);
ui->DEAngleSpinBox->setPrefixType(AngleSpinBox::NormalPlus); ui->DEAngleSpinBox->setPrefixType(AngleSpinBox::NormalPlus);
connect(ui->RAAngleSpinBox, SIGNAL(valueChanged()), this, SLOT(manua lPositionChanged())); connect(ui->RAAngleSpinBox, SIGNAL(valueChanged()), this, SLOT(manua lPositionChanged()));
connect(ui->DEAngleSpinBox, SIGNAL(valueChanged()), this, SLOT(manua lPositionChanged())); connect(ui->DEAngleSpinBox, SIGNAL(valueChanged()), this, SLOT(manua lPositionChanged()));
connect(ui->alphaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet connect(ui->alphaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek
terClicked())); LetterClicked()));
connect(ui->betaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLett connect(ui->betaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL
erClicked())); etterClicked()));
connect(ui->gammaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet connect(ui->gammaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek
terClicked())); LetterClicked()));
connect(ui->deltaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet connect(ui->deltaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek
terClicked())); LetterClicked()));
connect(ui->epsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL connect(ui->epsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(gre
etterClicked())); ekLetterClicked()));
connect(ui->zetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLett connect(ui->zetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL
erClicked())); etterClicked()));
connect(ui->etaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette connect(ui->etaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe
rClicked())); tterClicked()));
connect(ui->thetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet connect(ui->thetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek
terClicked())); LetterClicked()));
connect(ui->iotaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLett connect(ui->iotaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL
erClicked())); etterClicked()));
connect(ui->kappaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet connect(ui->kappaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek
terClicked())); LetterClicked()));
connect(ui->lambdaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe connect(ui->lambdaPushButton, SIGNAL(clicked(bool)), this, SLOT(gree
tterClicked())); kLetterClicked()));
connect(ui->muPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetter connect(ui->muPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
Clicked())); terClicked()));
connect(ui->nuPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetter connect(ui->nuPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
Clicked())); terClicked()));
connect(ui->xiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetter connect(ui->xiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
Clicked())); terClicked()));
connect(ui->omicronPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL connect(ui->omicronPushButton, SIGNAL(clicked(bool)), this, SLOT(gre
etterClicked())); ekLetterClicked()));
connect(ui->piPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetter connect(ui->piPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
Clicked())); terClicked()));
connect(ui->rhoPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette connect(ui->rhoPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe
rClicked())); tterClicked()));
connect(ui->sigmaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet connect(ui->sigmaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek
terClicked())); LetterClicked()));
connect(ui->tauPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette connect(ui->tauPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe
rClicked())); tterClicked()));
connect(ui->upsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL connect(ui->upsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(gre
etterClicked())); ekLetterClicked()));
connect(ui->phiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette connect(ui->phiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe
rClicked())); tterClicked()));
connect(ui->chiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette connect(ui->chiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe
rClicked())); tterClicked()));
connect(ui->psiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette connect(ui->psiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe
rClicked())); tterClicked()));
connect(ui->omegaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet connect(ui->omegaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek
terClicked())); LetterClicked()));
connect(ui->checkBoxUseSimbad, SIGNAL(clicked(bool)),
this, SLOT(enableSimbadSearch(bool)));
ui->checkBoxUseSimbad->setChecked(useSimbad);
}
void SearchDialog::setHasSelectedFlag()
{
flagHasSelectedText = true;
}
void SearchDialog::enableSimbadSearch(bool enable)
{
useSimbad = enable;
QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf);
conf->setValue("search/flag_search_online", useSimbad);
} }
void SearchDialog::setVisible(bool v) void SearchDialog::setVisible(bool v)
{ {
StelDialog::setVisible(v); StelDialog::setVisible(v);
// Set the focus directly on the line edit // Set the focus directly on the line edit
if (ui->lineEditSearchSkyObject->isVisible()) if (ui->lineEditSearchSkyObject->isVisible())
ui->lineEditSearchSkyObject->setFocus(); ui->lineEditSearchSkyObject->setFocus();
} }
skipping to change at line 254 skipping to change at line 280
ui->completionLabel->clearValues(); ui->completionLabel->clearValues();
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
Vec3d pos; Vec3d pos;
StelUtils::spheToRect(ui->RAAngleSpinBox->valueRadians(), ui->DEAngl eSpinBox->valueRadians(), pos); StelUtils::spheToRect(ui->RAAngleSpinBox->valueRadians(), ui->DEAngl eSpinBox->valueRadians(), pos);
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)
{ {
if (simbadReply) // This block needs to go before the trimmedText.isEmpty() or the SI
{ MBAD result does not
disconnect(simbadReply, SIGNAL(statusChanged()), this, SLOT( // get properly cleared.
onSimbadStatusChanged())); if (useSimbad) {
delete simbadReply; if (simbadReply) {
simbadReply=NULL; disconnect(simbadReply,
SIGNAL(statusChanged()),
this,
SLOT(onSimbadStatusChanged()));
delete simbadReply;
simbadReply=NULL;
}
simbadResults.clear();
} }
simbadResults.clear();
QString trimmedText = text.trimmed().toLower(); QString trimmedText = text.trimmed().toLower();
if (trimmedText.isEmpty()) if (trimmedText.isEmpty()) {
{
ui->completionLabel->clearValues(); ui->completionLabel->clearValues();
ui->completionLabel->selectFirst(); ui->completionLabel->selectFirst();
ui->simbadStatusLabel->setText(""); ui->simbadStatusLabel->setText("");
ui->pushButtonGotoSearchSkyObject->setEnabled(false); ui->pushButtonGotoSearchSkyObject->setEnabled(false);
} } else {
else if (useSimbad) {
{ simbadReply = simbadSearcher->lookup(trimmedText, 3)
simbadReply = simbadSearcher->lookup(trimmedText, 3); ;
onSimbadStatusChanged(); onSimbadStatusChanged();
connect(simbadReply, SIGNAL(statusChanged()), this, SLOT(onS connect(simbadReply, SIGNAL(statusChanged()), this,
imbadStatusChanged())); SLOT(onSimbadStatusChanged()));
}
QString greekText = substituteGreek(trimmedText); QString greekText = substituteGreek(trimmedText);
QStringList matches; QStringList matches;
if(greekText != trimmedText) if(greekText != trimmedText) {
{
matches = objectMgr->listMatchingObjectsI18n(trimmed Text, 3); matches = objectMgr->listMatchingObjectsI18n(trimmed Text, 3);
matches += objectMgr->listMatchingObjectsI18n(greekT ext, (5 - matches.size())); matches += objectMgr->listMatchingObjectsI18n(greekT ext, (5 - matches.size()));
} } else {
else
{
matches = objectMgr->listMatchingObjectsI18n(trimmed Text, 5); matches = objectMgr->listMatchingObjectsI18n(trimmed Text, 5);
} }
ui->completionLabel->setValues(matches); ui->completionLabel->setValues(matches);
ui->completionLabel->selectFirst(); ui->completionLabel->selectFirst();
// Update push button enabled state // Update push button enabled state
ui->pushButtonGotoSearchSkyObject->setEnabled(true); ui->pushButtonGotoSearchSkyObject->setEnabled(true);
} }
} }
// Called when the current simbad query status changes // Called when the current simbad query status changes
skipping to change at line 334 skipping to change at line 362
delete simbadReply; delete simbadReply;
simbadReply=NULL; simbadReply=NULL;
// Update push button enabled state // Update push button enabled state
ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completio nLabel->isEmpty()); ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completio nLabel->isEmpty());
} }
} }
void SearchDialog::greekLetterClicked() void SearchDialog::greekLetterClicked()
{ {
QPushButton *sender = reinterpret_cast<QPushButton *>(this->sender()); QPushButton *sender = reinterpret_cast<QPushButton *>(this->sender()
if (sender) { );
ui->lineEditSearchSkyObject->setText(ui->lineEditSearchSkyObject->t QLineEdit* sso = ui->lineEditSearchSkyObject;
ext() + sender->text()); if (sender) {
} if (flagHasSelectedText)
ui->lineEditSearchSkyObject->setFocus(); {
sso->setText(sender->text());
flagHasSelectedText = false;
}
else
sso->setText(sso->text() + sender->text());
}
sso->setFocus();
} }
void SearchDialog::gotoObject() void SearchDialog::gotoObject()
{ {
QString name = ui->completionLabel->getSelected(); QString name = ui->completionLabel->getSelected();
if (name.isEmpty()) if (name.isEmpty())
return; return;
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
 End of changes. 21 change blocks. 
85 lines changed or deleted 121 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/