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 "StelLocaleMgr.hpp"
#include "StelTranslator.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>
skipping to change at line 185 skipping to change at line 186
} }
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(); populateSimbadServerList();
updateListTab();
} }
} }
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 253 skipping to change at line 255
populateSimbadServerList(); populateSimbadServerList();
int idx = ui->serverListComboBox->findData(simbadServerUrl, Qt::User Role, Qt::MatchCaseSensitive); int idx = ui->serverListComboBox->findData(simbadServerUrl, Qt::User Role, Qt::MatchCaseSensitive);
if (idx==-1) if (idx==-1)
{ {
// Use University of Strasbourg as default // Use University of Strasbourg as default
idx = ui->serverListComboBox->findData(QVariant(DEF_SIMBAD_U RL), Qt::UserRole, Qt::MatchCaseSensitive); idx = ui->serverListComboBox->findData(QVariant(DEF_SIMBAD_U RL), Qt::UserRole, Qt::MatchCaseSensitive);
} }
ui->serverListComboBox->setCurrentIndex(idx); ui->serverListComboBox->setCurrentIndex(idx);
connect(ui->serverListComboBox, SIGNAL(currentIndexChanged(int)), connect(ui->serverListComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(selectSimbadServer(int))); this, SLOT(selectSimbadServer(int)));
// list views initialization
connect(ui->objectTypeComboBox, SIGNAL(activated(int)), this, SLOT(u
pdateListWidget(int)));
connect(ui->searchInListLineEdit, SIGNAL(textChanged(QString)), this
, SLOT(searchListChanged(QString)));
connect(ui->searchInEnglishCheckBox, SIGNAL(toggled(bool)), this, SL
OT(updateListTab()));
updateListTab();
} }
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 402 skipping to change at line 410
} }
else else
sso->setText(sso->text() + sender->text()); sso->setText(sso->text() + sender->text());
} }
sso->setFocus(); sso->setFocus();
} }
void SearchDialog::gotoObject() void SearchDialog::gotoObject()
{ {
QString name = ui->completionLabel->getSelected(); QString name = ui->completionLabel->getSelected();
gotoObject(name);
}
if (name.isEmpty()) void SearchDialog::gotoObject(const QString &nameI18n)
{
if (nameI18n.isEmpty())
return; return;
StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr); StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
if (simbadResults.contains(name)) if (simbadResults.contains(nameI18n))
{ {
close(); close();
Vec3d pos = simbadResults[name]; Vec3d pos = simbadResults[nameI18n];
objectMgr->unSelect(); objectMgr->unSelect();
mvmgr->moveToJ2000(pos, mvmgr->getAutoMoveDuration()); mvmgr->moveToJ2000(pos, mvmgr->getAutoMoveDuration());
ui->lineEditSearchSkyObject->clear(); ui->lineEditSearchSkyObject->clear();
ui->completionLabel->clearValues(); ui->completionLabel->clearValues();
} }
else if (objectMgr->findAndSelectI18n(name)) else if (objectMgr->findAndSelectI18n(nameI18n))
{ {
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()->getCurrentLocation().planetName) if (newSelected[0]->getEnglishName()!=StelApp::getIn stance().getCore()->getCurrentLocation().planetName)
{ {
skipping to change at line 439 skipping to change at line 451
} }
else else
{ {
GETSTELMODULE(StelObjectMgr)->unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
} }
} }
} }
simbadResults.clear(); simbadResults.clear();
} }
void SearchDialog::gotoObject(QListWidgetItem *item)
{
QString objName = item->text();
gotoObject(objName);
}
void SearchDialog::searchListChanged(const QString &newText)
{
QList<QListWidgetItem*> items = ui->objectsListWidget->findItems(new
Text, Qt::MatchStartsWith);
ui->objectsListWidget->clearSelection();
if (!items.isEmpty())
{
items.at(0)->setSelected(true);
ui->objectsListWidget->scrollToItem(items.at(0));
}
}
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);
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();
skipping to change at line 496 skipping to change at line 525
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() void SearchDialog::populateSimbadServerList()
{ {
Q_ASSERT(ui);
Q_ASSERT(ui->serverListComboBox); Q_ASSERT(ui->serverListComboBox);
QComboBox* servers = ui->serverListComboBox; QComboBox* servers = ui->serverListComboBox;
//Save the current selection to be restored later //Save the current selection to be restored later
servers->blockSignals(true); servers->blockSignals(true);
int index = servers->currentIndex(); int index = servers->currentIndex();
QVariant selectedUrl = servers->itemData(index); QVariant selectedUrl = servers->itemData(index);
servers->clear(); servers->clear();
//For each server, display the localized description and store the U RL as user data. //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_("University of Strasbourg (France)"), DEF_SIMBAD _URL);
skipping to change at line 527 skipping to change at line 555
{ {
if (index < 0) if (index < 0)
simbadServerUrl = DEF_SIMBAD_URL; simbadServerUrl = DEF_SIMBAD_URL;
else else
simbadServerUrl = ui->serverListComboBox->itemData(index).to String(); simbadServerUrl = ui->serverListComboBox->itemData(index).to String();
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
conf->setValue("search/simbad_server_url", simbadServerUrl); conf->setValue("search/simbad_server_url", simbadServerUrl);
} }
void SearchDialog::updateListWidget(int index)
{
QString moduleId = ui->objectTypeComboBox->itemData(index).toString(
);
ui->objectsListWidget->clear();
bool englishNames = ui->searchInEnglishCheckBox->isChecked();
ui->objectsListWidget->addItems(objectMgr->listAllModuleObjects(modu
leId, englishNames));
ui->objectsListWidget->sortItems(Qt::AscendingOrder);
connect(ui->objectsListWidget, SIGNAL(itemActivated(QListWidgetItem*
)), this, SLOT(gotoObject(QListWidgetItem*)));
}
void SearchDialog::updateListTab()
{
if (StelApp::getInstance().getLocaleMgr().getAppLanguage() == "en")
{
// hide "names in English" checkbox
ui->searchInEnglishCheckBox->hide();
}
else
{
ui->searchInEnglishCheckBox->show();
}
ui->objectTypeComboBox->clear();
QMap<QString, QString> modulesMap = objectMgr->objectModulesMap();
for (QMap<QString, QString>::const_iterator it = modulesMap.begin();
it != modulesMap.end(); ++it)
{
if (!objectMgr->listAllModuleObjects(it.key(), ui->searchInE
nglishCheckBox->isChecked()).isEmpty())
{
QString moduleName = (ui->searchInEnglishCheckBox->i
sChecked() ?
it.value(): q_(it.value()));
ui->objectTypeComboBox->addItem(moduleName, QVariant
(it.key()));
}
}
updateListWidget(ui->objectTypeComboBox->currentIndex());
}
 End of changes. 11 change blocks. 
5 lines changed or deleted 37 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/