SearchDialog.cpp   SearchDialog.cpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "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 "StelObjectMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelNavigator.hpp"
#include "StelObjectMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include <QTextEdit> #include <QDebug>
#include <QFrame>
#include <QLabel> #include <QLabel>
#include <QPushButton>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QDebug> #include <QTextEdit>
#include <QFrame>
#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 127 skipping to change at line 128
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);
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)));
} }
SearchDialog::~SearchDialog() SearchDialog::~SearchDialog()
{ {
delete ui; delete ui;
if (simbadReply) if (simbadReply)
{ {
skipping to change at line 177 skipping to change at line 182
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);
setSimpleStyle(true); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL
OT(languageChanged()));
// setSimpleStyle();
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->lineEditSearchSkyObject, SIGNAL(textChanged(const QStrin connect(ui->lineEditSearchSkyObject, SIGNAL(textChanged(const QStrin
g&)), this, SLOT(onTextChanged(const QString&))); g&)),
this, SLOT(onSearchTextChanged(const QString&)));
connect(ui->pushButtonGotoSearchSkyObject, SIGNAL(clicked()), this, SLOT(gotoObject())); connect(ui->pushButtonGotoSearchSkyObject, SIGNAL(clicked()), this, SLOT(gotoObject()));
onTextChanged(ui->lineEditSearchSkyObject->text()); onSearchTextChanged(ui->lineEditSearchSkyObject->text());
connect(ui->lineEditSearchSkyObject, SIGNAL(returnPressed()), this, SLOT(gotoObject())); connect(ui->lineEditSearchSkyObject, SIGNAL(returnPressed()), this, SLOT(gotoObject()));
dialog->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);
// This simply doesn't work. Probably a Qt bug
ui->RAAngleSpinBox->setFocusPolicy(Qt::NoFocus);
ui->DEAngleSpinBox->setFocusPolicy(Qt::NoFocus);
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
terClicked()));
connect(ui->betaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLett
erClicked()));
connect(ui->gammaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
terClicked()));
connect(ui->deltaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
terClicked()));
connect(ui->epsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL
etterClicked()));
connect(ui->zetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLett
erClicked()));
connect(ui->etaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette
rClicked()));
connect(ui->thetaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
terClicked()));
connect(ui->iotaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLett
erClicked()));
connect(ui->kappaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
terClicked()));
connect(ui->lambdaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe
tterClicked()));
connect(ui->muPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetter
Clicked()));
connect(ui->nuPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetter
Clicked()));
connect(ui->xiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetter
Clicked()));
connect(ui->omicronPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL
etterClicked()));
connect(ui->piPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetter
Clicked()));
connect(ui->rhoPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette
rClicked()));
connect(ui->sigmaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
terClicked()));
connect(ui->tauPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette
rClicked()));
connect(ui->upsilonPushButton, SIGNAL(clicked(bool)), this, SLOT(greekL
etterClicked()));
connect(ui->phiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette
rClicked()));
connect(ui->chiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette
rClicked()));
connect(ui->psiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLette
rClicked()));
connect(ui->omegaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLet
terClicked()));
} }
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();
} }
void SearchDialog::setSimpleStyle(bool b) void SearchDialog::setSimpleStyle()
{ {
ui->RAAngleSpinBox->setVisible(!b); ui->RAAngleSpinBox->setVisible(false);
ui->DEAngleSpinBox->setVisible(!b); ui->DEAngleSpinBox->setVisible(false);
ui->simbadStatusLabel->setVisible(false); ui->simbadStatusLabel->setVisible(false);
ui->raDecLabel->setVisible(!b); ui->raDecLabel->setVisible(false);
} }
void SearchDialog::manualPositionChanged() void SearchDialog::manualPositionChanged()
{ {
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::onTextChanged(const QString& text) void SearchDialog::onSearchTextChanged(const QString& text)
{ {
if (simbadReply) if (simbadReply)
{ {
disconnect(simbadReply, SIGNAL(statusChanged()), this, SLOT( onSimbadStatusChanged())); disconnect(simbadReply, SIGNAL(statusChanged()), this, SLOT( onSimbadStatusChanged()));
delete simbadReply; delete simbadReply;
simbadReply=NULL; simbadReply=NULL;
} }
simbadResults.clear(); simbadResults.clear();
QString trimmedText = text.trimmed().toLower(); QString trimmedText = text.trimmed().toLower();
skipping to change at line 255 skipping to change at line 284
connect(simbadReply, SIGNAL(statusChanged()), this, SLOT(onS imbadStatusChanged())); connect(simbadReply, SIGNAL(statusChanged()), this, SLOT(onS imbadStatusChanged()));
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 297 skipping to change at line 328
ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completio nLabel->isEmpty()); ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completio nLabel->isEmpty());
} }
if (simbadReply->getCurrentStatus()!=SimbadLookupReply::SimbadLookup Querying) if (simbadReply->getCurrentStatus()!=SimbadLookupReply::SimbadLookup Querying)
{ {
disconnect(simbadReply, SIGNAL(statusChanged()), this, SLOT( onSimbadStatusChanged())); disconnect(simbadReply, SIGNAL(statusChanged()), this, SLOT( onSimbadStatusChanged()));
delete simbadReply; delete simbadReply;
simbadReply=NULL; simbadReply=NULL;
// Update push button enabled state // 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()
{
QPushButton *sender = reinterpret_cast<QPushButton *>(this->sender());
if (sender) {
ui->lineEditSearchSkyObject->setText(ui->lineEditSearchSkyObject->t
ext() + sender->text());
}
ui->lineEditSearchSkyObject->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);
if (simbadResults.contains(name)) if (simbadResults.contains(name))
{ {
skipping to change at line 328 skipping to change at line 367
} }
else if (objectMgr->findAndSelectI18n(name)) else if (objectMgr->findAndSelectI18n(name))
{ {
const QList<StelObjectP> newSelected = objectMgr->getSelecte dObject(); const QList<StelObjectP> newSelected = objectMgr->getSelecte dObject();
if (!newSelected.empty()) if (!newSelected.empty())
{ {
close(); close();
ui->lineEditSearchSkyObject->clear(); ui->lineEditSearchSkyObject->clear();
ui->completionLabel->clearValues(); ui->completionLabel->clearValues();
// Can't point to home planet // Can't point to home planet
if (newSelected[0]->getEnglishName()!=StelApp::getIn stance().getCore()->getNavigator()->getCurrentLocation().name) if (newSelected[0]->getEnglishName()!=StelApp::getIn stance().getCore()->getCurrentLocation().name)
{ {
mvmgr->moveToObject(newSelected[0], mvmgr->g etAutoMoveDuration()); mvmgr->moveToObject(newSelected[0], mvmgr->g etAutoMoveDuration());
mvmgr->setFlagTracking(true); mvmgr->setFlagTracking(true);
} }
else else
{ {
GETSTELMODULE(StelObjectMgr)->unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
} }
} }
} }
simbadResults.clear(); simbadResults.clear();
} }
bool SearchDialog::eventFilter(QObject*, QEvent *event) bool SearchDialog::eventFilter(QObject*, QEvent *event)
{ {
if (event->type() == QEvent::KeyRelease) if (event->type() == QEvent::KeyRelease)
{ {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
// Kludgy workaround for Qt focusPolicy bug. Get rid of this
if
// they ever fix it.
if(keyEvent->key() == Qt::Key_Tab)
ui->lineEditSearchSkyObject->setFocus(Qt::OtherFocus
Reason);
if (keyEvent->key() == Qt::Key_Tab || keyEvent->key() == Qt: :Key_Down) if (keyEvent->key() == Qt::Key_Tab || keyEvent->key() == Qt: :Key_Down)
{ {
ui->completionLabel->selectNext(); ui->completionLabel->selectNext();
event->accept(); event->accept();
return true; return true;
} }
if (keyEvent->key() == Qt::Key_Up) if (keyEvent->key() == Qt::Key_Up)
{ {
ui->completionLabel->selectPrevious(); ui->completionLabel->selectPrevious();
event->accept(); event->accept();
 End of changes. 25 change blocks. 
31 lines changed or deleted 89 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/