SearchDialog.cpp   SearchDialog.cpp 
skipping to change at line 120 skipping to change at line 120
newText += ", "; newText += ", ";
} }
setText(newText); setText(newText);
} }
// 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);
Q_ASSERT(objectMgr);
greekLetters["alpha"] = QString(QChar(0x03B1));
greekLetters["beta"] = QString(QChar(0x03B2));
greekLetters["gamma"] = QString(QChar(0x03B3));
greekLetters["delta"] = QString(QChar(0x03B4));
greekLetters["epsilon"] = QString(QChar(0x03B5));
greekLetters["zeta"] = QString(QChar(0x03B6));
greekLetters["eta"] = QString(QChar(0x03B7));
greekLetters["theta"] = QString(QChar(0x03B8));
greekLetters["iota"] = QString(QChar(0x03B9));
greekLetters["kappa"] = QString(QChar(0x03BA));
greekLetters["lambda"] = QString(QChar(0x03BB));
greekLetters["mu"] = QString(QChar(0x03BC));
greekLetters["nu"] = QString(QChar(0x03BD));
greekLetters["xi"] = QString(QChar(0x03BE));
greekLetters["omicron"] = QString(QChar(0x03BF));
greekLetters["pi"] = QString(QChar(0x03C0));
greekLetters["rho"] = QString(QChar(0x03C1));
greekLetters["sigma"] = QString(QChar(0x03C3)); // second lower-case
sigma shouldn't affect anything
greekLetters["tau"] = QString(QChar(0x03C4));
greekLetters["upsilon"] = QString(QChar(0x03C5));
greekLetters["phi"] = QString(QChar(0x03C6));
greekLetters["chi"] = QString(QChar(0x03C7));
greekLetters["psi"] = QString(QChar(0x03C8));
greekLetters["omega"] = QString(QChar(0x03C9));
} }
SearchDialog::~SearchDialog() SearchDialog::~SearchDialog()
{ {
delete ui; delete ui;
if (simbadReply) if (simbadReply)
{ {
simbadReply->deleteLater(); simbadReply->deleteLater();
simbadReply = NULL; simbadReply = NULL;
} }
skipping to change at line 183 skipping to change at line 210
// 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(bool b)
{ {
ui->RAAngleSpinBox->setVisible(!b); ui->RAAngleSpinBox->setVisible(!b);
ui->DEAngleSpinBox->setVisible(!b); ui->DEAngleSpinBox->setVisible(!b);
ui->simbadStatusLabel->setVisible(!b); ui->simbadStatusLabel->setVisible(false);
ui->raDecLabel->setVisible(!b); ui->raDecLabel->setVisible(!b);
} }
void SearchDialog::manualPositionChanged() void SearchDialog::manualPositionChanged()
{ {
ui->completionLabel->clearValues(); ui->completionLabel->clearValues();
StelMovementMgr* mvmgr = (StelMovementMgr*)GETSTELMODULE("StelMoveme ntMgr"); 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->moveTo(pos, 0.05); mvmgr->moveTo(pos, 0.05);
} }
void SearchDialog::onTextChanged(const QString& text) void SearchDialog::onTextChanged(const QString& text)
{ {
if (text.isEmpty()) if (simbadReply)
{
disconnect(simbadReply, SIGNAL(statusChanged()), this, SLOT(
onSimbadStatusChanged()));
delete simbadReply;
simbadReply=NULL;
}
simbadResults.clear();
QString trimmedText = text.trimmed().toLower();
if (trimmedText.isEmpty())
{ {
ui->completionLabel->setText(""); ui->completionLabel->clearValues();
ui->completionLabel->selectFirst(); ui->completionLabel->selectFirst();
ui->simbadStatusLabel->setText(""); ui->simbadStatusLabel->setText("");
ui->pushButtonGotoSearchSkyObject->setEnabled(false);
} }
else else
{ {
if (simbadReply) simbadReply = simbadSearcher->lookup(trimmedText, 3);
{
disconnect(simbadReply, SIGNAL(statusChanged()), thi
s, SLOT(onSimbadStatusChanged()));
delete simbadReply;
}
simbadResults.clear();
simbadReply = simbadSearcher->lookup(text, 3);
onSimbadStatusChanged(); onSimbadStatusChanged();
connect(simbadReply, SIGNAL(statusChanged()), this, SLOT(onS imbadStatusChanged())); connect(simbadReply, SIGNAL(statusChanged()), this, SLOT(onS imbadStatusChanged()));
QStringList matches = StelApp::getInstance().getStelObjectMg
r().listMatchingObjectsI18n(text, 5); QString greekText = substituteGreek(trimmedText);
QStringList matches;
if(greekText != trimmedText)
{
matches = objectMgr->listMatchingObjectsI18n(trimmed
Text, 3);
matches += objectMgr->listMatchingObjectsI18n(greekT
ext, (5 - matches.size()));
}
else
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
ui->pushButtonGotoSearchSkyObject->setEnabled(true);
} }
} }
// Called when the current simbad query status changes // Called when the current simbad query status changes
void SearchDialog::onSimbadStatusChanged() void SearchDialog::onSimbadStatusChanged()
{ {
Q_ASSERT(simbadReply); Q_ASSERT(simbadReply);
if (simbadReply->getCurrentStatus()==SimbadLookupReply::SimbadLookup ErrorOccured) if (simbadReply->getCurrentStatus()==SimbadLookupReply::SimbadLookup ErrorOccured)
{
ui->simbadStatusLabel->setText(QString("Simbad Lookup Error: ")+simbadReply->getErrorString()); ui->simbadStatusLabel->setText(QString("Simbad Lookup Error: ")+simbadReply->getErrorString());
if (ui->completionLabel->isEmpty())
ui->pushButtonGotoSearchSkyObject->setEnabled(false)
;
}
else else
{
ui->simbadStatusLabel->setText(QString("Simbad Lookup: ")+si mbadReply->getCurrentStatusString()); ui->simbadStatusLabel->setText(QString("Simbad Lookup: ")+si mbadReply->getCurrentStatusString());
// Query not over, don't disable button
ui->pushButtonGotoSearchSkyObject->setEnabled(true);
}
if (simbadReply->getCurrentStatus()==SimbadLookupReply::SimbadLookup Finished) if (simbadReply->getCurrentStatus()==SimbadLookupReply::SimbadLookup Finished)
{ {
simbadResults = simbadReply->getResults(); simbadResults = simbadReply->getResults();
ui->completionLabel->appendValues(simbadResults.keys()); ui->completionLabel->appendValues(simbadResults.keys());
// Update push button enabled state
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
ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completio
nLabel->isEmpty());
} }
} }
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 = (StelMovementMgr*)GETSTELMODULE("StelMoveme ntMgr"); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
if (simbadResults.contains(name)) if (simbadResults.contains(name))
{ {
close(); close();
Vec3d pos = simbadResults[name]; Vec3d pos = simbadResults[name];
StelApp::getInstance().getStelObjectMgr().unSelect(); objectMgr->unSelect();
pos = StelApp::getInstance().getCore()->getNavigator()->j200 0ToEquinoxEqu(pos); pos = StelApp::getInstance().getCore()->getNavigator()->j200 0ToEquinoxEqu(pos);
mvmgr->moveTo(pos, mvmgr->getAutoMoveDuration()); mvmgr->moveTo(pos, mvmgr->getAutoMoveDuration());
ui->lineEditSearchSkyObject->clear(); ui->lineEditSearchSkyObject->clear();
ui->completionLabel->clearValues(); ui->completionLabel->clearValues();
} }
else if (StelApp::getInstance().getStelObjectMgr().findAndSelectI18n (name)) else if (objectMgr->findAndSelectI18n(name))
{ {
const QList<StelObjectP> newSelected = StelApp::getInstance( ).getStelObjectMgr().getSelectedObject(); 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();
mvmgr->moveTo(newSelected[0]->getEquinoxEquatorialPo // Can't point to home planet
s(StelApp::getInstance().getCore()->getNavigator()),mvmgr->getAutoMoveDurat if (newSelected[0].get()!= (StelObject*)(StelApp::ge
ion()); tInstance().getCore()->getNavigator()->getHomePlanet()))
mvmgr->setFlagTracking(true); {
mvmgr->moveTo(newSelected[0]->getEquinoxEqua
torialPos(StelApp::getInstance().getCore()->getNavigator()),mvmgr->getAutoM
oveDuration());
mvmgr->setFlagTracking(true);
}
else
{
GETSTELMODULE(StelObjectMgr)->unSelect();
}
} }
} }
simbadResults.clear(); simbadResults.clear();
} }
bool SearchDialog::eventFilter(QObject *object, QEvent *event) bool SearchDialog::eventFilter(QObject *object, 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();
return true; return true;
} }
} }
return false; return false;
} }
QString SearchDialog::substituteGreek(const QString& keyString)
{
if (!keyString.contains(' '))
return getGreekLetterByName(keyString);
else
{
QStringList nameComponents = keyString.split(" ", QString::S
kipEmptyParts);
if(!nameComponents.empty())
nameComponents[0] = getGreekLetterByName(nameCompone
nts[0]);
return nameComponents.join(" ");
}
}
QString SearchDialog::getGreekLetterByName(const QString& potentialGreekLet
terName)
{
if(greekLetters.contains(potentialGreekLetterName))
return greekLetters[potentialGreekLetterName.toLower()];
// There can be indices (e.g. "α1 Cen" instead of "α Cen A"), so str
ip
// any trailing digit.
int lastCharacterIndex = potentialGreekLetterName.length()-1;
if(potentialGreekLetterName.at(lastCharacterIndex).isDigit())
{
QChar digit = potentialGreekLetterName.at(lastCharacterIndex
);
QString name = potentialGreekLetterName.left(lastCharacterIn
dex);
if(greekLetters.contains(name))
return greekLetters[name.toLower()] + digit;
}
return potentialGreekLetterName;
}
 End of changes. 23 change blocks. 
22 lines changed or deleted 104 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/