SearchDialog.cpp   SearchDialog.cpp 
skipping to change at line 27 skipping to change at line 27
* 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 "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 "StelTranslator.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 <QSettings>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QTextEdit> #include <QTextEdit>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox>
#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 118 skipping to change at line 120
newText+="<b>"+values[i]+"</b>"; newText+="<b>"+values[i]+"</b>";
else else
newText+=values[i]; newText+=values[i];
if (i!=values.size()-1) if (i!=values.size()-1)
newText += ", "; newText += ", ";
} }
setText(newText); setText(newText);
} }
// Start of members for class SearchDialog // Start of members for class SearchDialog
const char* SearchDialog::DEF_SIMBAD_URL = "http://simbad.u-strasbg.fr/";
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; flagHasSelectedText = false;
greekLetters.insert("alpha", QString(QChar(0x03B1))); greekLetters.insert("alpha", QString(QChar(0x03B1)));
skipping to change at line 159 skipping to change at line 164
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(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
useSimbad = conf->value("search/flag_search_online", true).toBool(); useSimbad = conf->value("search/flag_search_online", true).toBool();
simbadServerUrl = conf->value("search/simbad_server_url", DEF_SIMBAD _URL).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();
} }
} }
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()
skipping to change at line 235 skipping to change at line 242
connect(ui->tauPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked())); connect(ui->tauPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLe tterClicked()));
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)), connect(ui->checkBoxUseSimbad, SIGNAL(clicked(bool)),
this, SLOT(enableSimbadSearch(bool))); this, SLOT(enableSimbadSearch(bool)));
ui->checkBoxUseSimbad->setChecked(useSimbad); ui->checkBoxUseSimbad->setChecked(useSimbad);
populateSimbadServerList();
int idx = ui->serverListComboBox->findData(simbadServerUrl, Qt::User
Role, Qt::MatchCaseSensitive);
if (idx==-1)
{
// Use University of Strasbourg as default
idx = ui->serverListComboBox->findData(QVariant(DEF_SIMBAD_U
RL), Qt::UserRole, Qt::MatchCaseSensitive);
}
ui->serverListComboBox->setCurrentIndex(idx);
connect(ui->serverListComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(selectSimbadServer(int)));
} }
void SearchDialog::setHasSelectedFlag() void SearchDialog::setHasSelectedFlag()
{ {
flagHasSelectedText = true; flagHasSelectedText = true;
} }
void SearchDialog::enableSimbadSearch(bool enable) void SearchDialog::enableSimbadSearch(bool enable)
{ {
useSimbad = enable; useSimbad = enable;
skipping to change at line 301 skipping to change at line 319
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) { if (useSimbad)
simbadReply = simbadSearcher->lookup(trimmedText, 3) {
; simbadReply = simbadSearcher->lookup(simbadServerUrl
, trimmedText, 3);
onSimbadStatusChanged(); onSimbadStatusChanged();
connect(simbadReply, SIGNAL(statusChanged()), this, SLOT(onSimbadStatusChanged())); connect(simbadReply, SIGNAL(statusChanged()), this, 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 {
skipping to change at line 330 skipping to change at line 349
ui->pushButtonGotoSearchSkyObject->setEnabled(true); 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: ui->simbadStatusLabel->setText(QString("%1: %2")
")+simbadReply->getErrorString()); .arg(q_("Simbad Lookup Error"
))
.arg(simbadReply->getErrorStr
ing()));
if (ui->completionLabel->isEmpty()) if (ui->completionLabel->isEmpty())
ui->pushButtonGotoSearchSkyObject->setEnabled(false) ; ui->pushButtonGotoSearchSkyObject->setEnabled(false) ;
} }
else else
{ {
ui->simbadStatusLabel->setText(QString("Simbad Lookup: ")+si ui->simbadStatusLabel->setText(QString("%1: %2")
mbadReply->getCurrentStatusString()); .arg(q_("Simbad Lookup"))
.arg(simbadReply->getCurrentS
tatusString()));
// Query not over, don't disable button // Query not over, don't disable button
ui->pushButtonGotoSearchSkyObject->setEnabled(true); 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 // Update push button enabled state
ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completio nLabel->isEmpty()); ui->pushButtonGotoSearchSkyObject->setEnabled(!ui->completio nLabel->isEmpty());
skipping to change at line 470 skipping to change at line 493
if(potentialGreekLetterName.at(lastCharacterIndex).isDigit()) if(potentialGreekLetterName.at(lastCharacterIndex).isDigit())
{ {
QChar digit = potentialGreekLetterName.at(lastCharacterIndex ); QChar digit = potentialGreekLetterName.at(lastCharacterIndex );
QString name = potentialGreekLetterName.left(lastCharacterIn dex); QString name = potentialGreekLetterName.left(lastCharacterIn dex);
if(greekLetters.contains(name)) if(greekLetters.contains(name))
return greekLetters[name.toLower()] + digit; return greekLetters[name.toLower()] + digit;
} }
return potentialGreekLetterName; return potentialGreekLetterName;
} }
void SearchDialog::populateSimbadServerList()
{
Q_ASSERT(ui);
Q_ASSERT(ui->serverListComboBox);
QComboBox* servers = ui->serverListComboBox;
//Save the current selection to be restored later
servers->blockSignals(true);
int index = servers->currentIndex();
QVariant selectedUrl = servers->itemData(index);
servers->clear();
//For each server, display the localized description and store the U
RL as user data.
servers->addItem(q_("University of Strasbourg (France)"), DEF_SIMBAD
_URL);
servers->addItem(q_("Harvard University (USA)"), "http://simbad.harv
ard.edu/");
//Restore the selection
index = servers->findData(selectedUrl, Qt::UserRole, Qt::MatchCaseSe
nsitive);
servers->setCurrentIndex(index);
servers->model()->sort(0);
servers->blockSignals(false);
}
void SearchDialog::selectSimbadServer(int index)
{
if (index < 0)
simbadServerUrl = DEF_SIMBAD_URL;
else
simbadServerUrl = ui->serverListComboBox->itemData(index).to
String();
QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf);
conf->setValue("search/simbad_server_url", simbadServerUrl);
}
 End of changes. 10 change blocks. 
7 lines changed or deleted 33 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/