Satellites.cpp   Satellites.cpp 
skipping to change at line 398 skipping to change at line 398
{ {
if (sat->getCatalogNumberString() == numberS tring) if (sat->getCatalogNumberString() == numberS tring)
return qSharedPointerCast<StelObject >(sat); return qSharedPointerCast<StelObject >(sat);
} }
} }
} }
return StelObjectP(); return StelObjectP();
} }
QStringList Satellites::listMatchingObjectsI18n(const QString& objPrefix, i nt maxNbItem) const QStringList Satellites::listMatchingObjectsI18n(const QString& objPrefix, i nt maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName())
return result; return result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
QString numberPrefix; QString numberPrefix;
QRegExp regExp("^(NORAD)\\s*(\\d+)\\s*$"); QRegExp regExp("^(NORAD)\\s*(\\d+)\\s*$");
if (regExp.exactMatch(objw)) if (regExp.exactMatch(objw))
{ {
QString numberString = regExp.capturedTexts().at(2); QString numberString = regExp.capturedTexts().at(2);
bool ok; bool ok;
/* int number = */ numberString.toInt(&ok); /* int number = */ numberString.toInt(&ok);
if (ok) if (ok)
numberPrefix = numberString; numberPrefix = numberString;
} }
bool find;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->displayed) if (sat->initialized && sat->displayed)
{ {
if (sat->getNameI18n().toUpper().contains(objw, Qt:: find = false;
CaseInsensitive)) if (useStartOfWords)
{
if (sat->getNameI18n().toUpper().left(objw.l
ength()) == objw)
{
find = true;
}
}
else
{
if (sat->getNameI18n().toUpper().contains(ob
jw, Qt::CaseInsensitive))
{
find = true;
}
}
if (find)
{ {
result << sat->getNameI18n().toUpper(); result << sat->getNameI18n().toUpper();
} }
else if (!numberPrefix.isEmpty() && sat->getCatalogN umberString().left(numberPrefix.length()) == numberPrefix) else if (!numberPrefix.isEmpty() && sat->getCatalogN umberString().left(numberPrefix.length()) == numberPrefix)
{ {
result << QString("NORAD %1").arg(sat->getCa talogNumberString()); result << QString("NORAD %1").arg(sat->getCa talogNumberString());
} }
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end()); if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end());
return result; return result;
} }
QStringList Satellites::listMatchingObjects(const QString& objPrefix, int m axNbItem) const QStringList Satellites::listMatchingObjects(const QString& objPrefix, int m axNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName())
return result; return result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
QString numberPrefix; QString numberPrefix;
QRegExp regExp("^(NORAD)\\s*(\\d+)\\s*$"); QRegExp regExp("^(NORAD)\\s*(\\d+)\\s*$");
if (regExp.exactMatch(objw)) if (regExp.exactMatch(objw))
{ {
QString numberString = regExp.capturedTexts().at(2); QString numberString = regExp.capturedTexts().at(2);
bool ok; bool ok;
/* int number = */ numberString.toInt(&ok); /* int number = */ numberString.toInt(&ok);
if (ok) if (ok)
numberPrefix = numberString; numberPrefix = numberString;
} }
bool find;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->displayed) if (sat->initialized && sat->displayed)
{ {
if (sat->getEnglishName().toUpper().contains(objw, Q find = false;
t::CaseInsensitive)) if (useStartOfWords)
{
if (sat->getEnglishName().toUpper().left(obj
w.length()) == objw)
{
find = true;
}
}
else
{
if (sat->getEnglishName().toUpper().contains
(objw, Qt::CaseInsensitive))
{
find = true;
}
}
if (find)
{ {
result << sat->getEnglishName().toUpper(); result << sat->getEnglishName().toUpper();
} }
else if (!numberPrefix.isEmpty() && sat->getCatalogN umberString().left(numberPrefix.length()) == numberPrefix) else if (find==false && !numberPrefix.isEmpty() && s at->getCatalogNumberString().left(numberPrefix.length()) == numberPrefix)
{ {
result << QString("NORAD %1").arg(sat->getCa talogNumberString()); result << QString("NORAD %1").arg(sat->getCa talogNumberString());
} }
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end()); if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end());
return result; return result;
 End of changes. 7 change blocks. 
7 lines changed or deleted 42 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/