TelescopeControl.cpp   TelescopeControl.cpp 
skipping to change at line 392 skipping to change at line 392
StelObjectP TelescopeControl::searchByName(const QString &name) const StelObjectP TelescopeControl::searchByName(const QString &name) const
{ {
foreach (const TelescopeClientP& telescope, telescopeClients) foreach (const TelescopeClientP& telescope, telescopeClients)
{ {
if (telescope->getEnglishName() == name) if (telescope->getEnglishName() == name)
return qSharedPointerCast<StelObject>(telescope); return qSharedPointerCast<StelObject>(telescope);
} }
return 0; return 0;
} }
QStringList TelescopeControl::listMatchingObjectsI18n(const QString& objPre fix, int maxNbItem) const QStringList TelescopeControl::listMatchingObjectsI18n(const QString& objPre fix, int maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) if (maxNbItem==0)
return result; return result;
QString tn;
bool find;
foreach (const TelescopeClientP& telescope, telescopeClients) foreach (const TelescopeClientP& telescope, telescopeClients)
{ {
QString tn = telescope->getNameI18n(); tn = telescope->getNameI18n();
if (tn.contains(objPrefix, Qt::CaseInsensitive)) find = false;
if (useStartOfWords)
{
if (objPrefix.toUpper()==tn.mid(0, objPrefix.size())
.toUpper())
find = true;
}
else
{
if (tn.contains(objPrefix, Qt::CaseInsensitive))
find = true;
}
if (find)
{ {
result << tn; result << tn;
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) if (result.size()>maxNbItem)
{ {
result.erase(result.begin() + maxNbItem, result.end()); result.erase(result.begin() + maxNbItem, result.end());
} }
return result; return result;
} }
QStringList TelescopeControl::listMatchingObjects(const QString& objPrefix, int maxNbItem) const QStringList TelescopeControl::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) if (maxNbItem==0)
return result; return result;
QString tn;
bool find;
foreach (const TelescopeClientP& telescope, telescopeClients) foreach (const TelescopeClientP& telescope, telescopeClients)
{ {
QString tn = telescope->getEnglishName(); QString tn = telescope->getEnglishName();
if (tn.contains(objPrefix, Qt::CaseInsensitive)) find = false;
if (useStartOfWords)
{
if (objPrefix.toUpper()==tn.mid(0, objPrefix.size())
.toUpper())
find = true;
}
else
{
if (tn.contains(objPrefix, Qt::CaseInsensitive))
find = true;
}
if (find)
{ {
result << tn; result << tn;
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) if (result.size()>maxNbItem)
{ {
result.erase(result.begin() + maxNbItem, result.end()); result.erase(result.begin() + maxNbItem, result.end());
} }
return result; return result;
 End of changes. 6 change blocks. 
5 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/