SearchDialog.cpp   SearchDialog.cpp 
skipping to change at line 40 skipping to change at line 40
#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 <QtAlgorithms>
#include <QTextEdit> #include <QTextEdit>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox> #include <QComboBox>
#include <QMenu>
#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 124 skipping to change at line 126
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/"; const char* SearchDialog::DEF_SIMBAD_URL = "http://simbad.u-strasbg.fr/";
SearchDialog::SearchDialog() : simbadReply(NULL) SearchDialog::SearchDialog(QObject* parent) : StelDialog(parent), simbadRep ly(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)));
greekLetters.insert("beta", QString(QChar(0x03B2))); greekLetters.insert("beta", QString(QChar(0x03B2)));
skipping to change at line 208 skipping to change at line 210
{ {
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)));
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(greek LetterClicked())); connect(ui->alphaPushButton, SIGNAL(clicked(bool)), this, SLOT(greek LetterClicked()));
skipping to change at line 263 skipping to change at line 266
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);
// list views initialization // list views initialization
connect(ui->objectTypeComboBox, SIGNAL(activated(int)), this, SLOT(u pdateListWidget(int))); connect(ui->objectTypeComboBox, SIGNAL(activated(int)), this, SLOT(u pdateListWidget(int)));
connect(ui->searchInListLineEdit, SIGNAL(textChanged(QString)), this , SLOT(searchListChanged(QString))); connect(ui->searchInListLineEdit, SIGNAL(textChanged(QString)), this , SLOT(searchListChanged(QString)));
connect(ui->searchInEnglishCheckBox, SIGNAL(toggled(bool)), this, SL OT(updateListTab())); connect(ui->searchInEnglishCheckBox, SIGNAL(toggled(bool)), this, SL OT(updateListTab()));
updateListTab(); updateListTab();
// Set the focus directly on the line edit
if (ui->lineEditSearchSkyObject->isEnabled())
ui->lineEditSearchSkyObject->setFocus();
} }
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 288 skipping to change at line 295
void SearchDialog::enableStartOfWordsAutofill(bool enable) void SearchDialog::enableStartOfWordsAutofill(bool enable)
{ {
useStartOfWords = enable; useStartOfWords = enable;
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
conf->setValue("search/flag_start_words", useStartOfWords); conf->setValue("search/flag_start_words", useStartOfWords);
} }
void SearchDialog::setVisible(bool v)
{
StelDialog::setVisible(v);
// Set the focus directly on the line edit
if (ui->lineEditSearchSkyObject->isVisible())
ui->lineEditSearchSkyObject->setFocus();
}
void SearchDialog::setSimpleStyle() void SearchDialog::setSimpleStyle()
{ {
ui->RAAngleSpinBox->setVisible(false); ui->RAAngleSpinBox->setVisible(false);
ui->DEAngleSpinBox->setVisible(false); ui->DEAngleSpinBox->setVisible(false);
ui->simbadStatusLabel->setVisible(false); ui->simbadStatusLabel->setVisible(false);
ui->raDecLabel->setVisible(false); ui->raDecLabel->setVisible(false);
} }
void SearchDialog::manualPositionChanged() void SearchDialog::manualPositionChanged()
{ {
skipping to change at line 359 skipping to change at line 357
matches += objectMgr->listMatchingObjects(trimmedTex t, 3, useStartOfWords); matches += objectMgr->listMatchingObjects(trimmedTex t, 3, useStartOfWords);
matches += objectMgr->listMatchingObjectsI18n(greekT ext, (8 - matches.size()), useStartOfWords); matches += objectMgr->listMatchingObjectsI18n(greekT ext, (8 - matches.size()), useStartOfWords);
} else { } else {
matches = objectMgr->listMatchingObjectsI18n(trimmed Text, 5, useStartOfWords); matches = objectMgr->listMatchingObjectsI18n(trimmed Text, 5, useStartOfWords);
matches += objectMgr->listMatchingObjects(trimmedTex t, 5, useStartOfWords); matches += objectMgr->listMatchingObjects(trimmedTex t, 5, useStartOfWords);
} }
// remove possible duplicates from completion list // remove possible duplicates from completion list
matches.removeDuplicates(); matches.removeDuplicates();
matches.sort(Qt::CaseInsensitive);
// objects with short names should be searched first
// examples: Moon, Hydra (moon); Jupiter, Ghost of Jupiter
stringLengthCompare comparator;
qSort(matches.begin(), matches.end(), comparator);
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
void SearchDialog::onSimbadStatusChanged() void SearchDialog::onSimbadStatusChanged()
skipping to change at line 579 skipping to change at line 583
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);
connect(ui->objectsListWidget, SIGNAL(itemActivated(QListWidgetItem* )), this, SLOT(gotoObject(QListWidgetItem*))); connect(ui->objectsListWidget, SIGNAL(itemClicked(QListWidgetItem*)) , this, SLOT(gotoObject(QListWidgetItem*)));
} }
void SearchDialog::updateListTab() void SearchDialog::updateListTab()
{ {
if (StelApp::getInstance().getLocaleMgr().getAppLanguage() == "en") if (StelApp::getInstance().getLocaleMgr().getAppLanguage().startsWit h("en"))
{ {
// hide "names in English" checkbox // hide "names in English" checkbox
ui->searchInEnglishCheckBox->hide(); ui->searchInEnglishCheckBox->hide();
} }
else else
{ {
ui->searchInEnglishCheckBox->show(); ui->searchInEnglishCheckBox->show();
} }
ui->objectTypeComboBox->clear(); ui->objectTypeComboBox->clear();
QMap<QString, QString> modulesMap = objectMgr->objectModulesMap(); QMap<QString, QString> modulesMap = objectMgr->objectModulesMap();
for (QMap<QString, QString>::const_iterator it = modulesMap.begin(); it != modulesMap.end(); ++it) for (QMap<QString, QString>::const_iterator it = modulesMap.begin(); it != modulesMap.end(); ++it)
{ {
if (!objectMgr->listAllModuleObjects(it.key(), ui->searchInE nglishCheckBox->isChecked()).isEmpty()) if (!objectMgr->listAllModuleObjects(it.key(), ui->searchInE nglishCheckBox->isChecked()).isEmpty())
{ {
QString moduleName = (ui->searchInEnglishCheckBox->i sChecked() ? it.value(): q_(it.value())); QString moduleName = (ui->searchInEnglishCheckBox->i sChecked() ? it.value(): q_(it.value()));
ui->objectTypeComboBox->addItem(moduleName, QVariant (it.key())); ui->objectTypeComboBox->addItem(moduleName, QVariant (it.key()));
} }
} }
updateListWidget(ui->objectTypeComboBox->currentIndex()); updateListWidget(ui->objectTypeComboBox->currentIndex());
} }
void SearchDialog::showContextMenu(const QPoint &pt)
{
QMenu *menu = ui->lineEditSearchSkyObject->createStandardContextMenu
();
menu->addSeparator();
menu->addAction(q_("Paste and Search"), this, SLOT(pasteAndGo()));
menu->exec(ui->lineEditSearchSkyObject->mapToGlobal(pt));
delete menu;
}
void SearchDialog::pasteAndGo()
{
ui->lineEditSearchSkyObject->clear(); // clear current text
ui->lineEditSearchSkyObject->paste(); // paste text from clipboard
gotoObject(); // go to first finded object
}
 End of changes. 10 change blocks. 
12 lines changed or deleted 16 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/