Novae.cpp   Novae.cpp 
skipping to change at line 280 skipping to change at line 280
{ {
foreach(const NovaP& n, nova) foreach(const NovaP& n, nova)
{ {
if (n->getNameI18n().toUpper() == nameI18n.toUpper() || n->g etDesignation().toUpper() == nameI18n.toUpper()) if (n->getNameI18n().toUpper() == nameI18n.toUpper() || n->g etDesignation().toUpper() == nameI18n.toUpper())
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
return NULL; return NULL;
} }
QStringList Novae::listMatchingObjectsI18n(const QString& objPrefix, int ma xNbItem, bool useStartOfWords) const QStringList Novae::listMatchingObjects(const QString& objPrefix, int maxNbI tem, bool useStartOfWords, bool inEnglish) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) if (maxNbItem <= 0)
{
return result; return result;
}
QString sn; QStringList names;
bool find; if (inEnglish)
foreach(const NovaP& n, nova)
{ {
sn = n->getNameI18n(); foreach(const NovaP& n, nova)
find = false;
if (useStartOfWords)
{
if (objPrefix.toUpper()==sn.toUpper().left(objPrefix
.length()))
find = true;
}
else
{ {
if (sn.contains(objPrefix, Qt::CaseInsensitive)) names.append(n->getEnglishName());
find = true; names.append(n->getDesignation());
} }
if (find) }
else
{
foreach(const NovaP& n, nova)
{ {
result << sn; names.append(n->getNameI18n());
} }
} }
result.sort(); foreach (const QString& name, names)
if (result.size()>maxNbItem)
result.erase(result.begin()+maxNbItem, result.end());
return result;
}
QStringList Novae::listMatchingObjects(const QString& objPrefix, int maxNbI
tem, bool useStartOfWords) const
{
QStringList result;
if (maxNbItem==0)
return result;
QString sn;
bool find;
foreach(const NovaP& n, nova)
{ {
sn = n->getEnglishName(); if (!matchObjectName(name, objPrefix, useStartOfWords))
find = false;
if (useStartOfWords)
{ {
if (objPrefix.toUpper()==sn.toUpper().left(objPrefix continue;
.length()))
find = true;
}
else
{
if (sn.contains(objPrefix, Qt::CaseInsensitive))
find = true;
}
if (find)
{
result << sn;
} }
sn = n->getDesignation(); result.append(name);
find = false; if (result.size() >= maxNbItem)
if (useStartOfWords)
{
if (objPrefix.toUpper()==sn.toUpper().left(objPrefix
.length()))
find = true;
}
else
{
if (sn.contains(objPrefix, Qt::CaseInsensitive))
find = true;
}
if (find)
{ {
result << sn; break;
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem)
result.erase(result.begin()+maxNbItem, result.end());
return result; return result;
} }
QStringList Novae::listAllObjects(bool inEnglish) const QStringList Novae::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
foreach (const NovaP& n, nova) foreach (const NovaP& n, nova)
{ {
skipping to change at line 745 skipping to change at line 701
QVariantMap map; QVariantMap map;
map = StelJsonParser::parse(&novaeJsonFile).toMap(); map = StelJsonParser::parse(&novaeJsonFile).toMap();
if (map.contains("limit")) if (map.contains("limit"))
{ {
lowerLimit = map.value("limit").toFloat(); lowerLimit = map.value("limit").toFloat();
} }
novaeJsonFile.close(); novaeJsonFile.close();
return lowerLimit; return lowerLimit;
} }
void Novae::reloadCatalog(void)
{
bool hasSelection = false;
StelObjectMgr* objMgr = GETSTELMODULE(StelObjectMgr);
// Whether any nova are selected? Save the current selection...
const QList<StelObjectP> selectedObject = objMgr->getSelectedObject(
"Nova");
if (!selectedObject.isEmpty())
{
// ... unselect current nova.
hasSelection = true;
objMgr->unSelect();
}
readJsonFile();
if (hasSelection)
{
// Restore selection...
objMgr->setSelectedObject(selectedObject);
}
}
 End of changes. 15 change blocks. 
68 lines changed or deleted 20 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/