StarMgr.cpp   StarMgr.cpp 
skipping to change at line 67 skipping to change at line 67
#include <unistd.h> #include <unistd.h>
using namespace BigStarCatalogExtension; using namespace BigStarCatalogExtension;
static QStringList spectral_array; static QStringList spectral_array;
static QStringList component_array; static QStringList component_array;
// This number must be incremented each time the content or file format of the stars catalogs change // This number must be incremented each time the content or file format of the stars catalogs change
// It can also be incremented when the defaultStarsConfig.json file change. // It can also be incremented when the defaultStarsConfig.json file change.
// It should always matchs the version field of the defaultStarsConfig.json file // It should always matchs the version field of the defaultStarsConfig.json file
static const int StarCatalogFormatVersion = 2; static const int StarCatalogFormatVersion = 3;
// Initialise statics // Initialise statics
bool StarMgr::flagSciNames = true; bool StarMgr::flagSciNames = true;
QHash<int,QString> StarMgr::commonNamesMap; QHash<int,QString> StarMgr::commonNamesMap;
QHash<int,QString> StarMgr::commonNamesMapI18n; QHash<int,QString> StarMgr::commonNamesMapI18n;
QMap<QString,int> StarMgr::commonNamesIndexI18n; QMap<QString,int> StarMgr::commonNamesIndexI18n;
QMap<QString,int> StarMgr::commonNamesIndex;
QHash<int,QString> StarMgr::sciNamesMapI18n; QHash<int,QString> StarMgr::sciNamesMapI18n;
QMap<QString,int> StarMgr::sciNamesIndexI18n; QMap<QString,int> StarMgr::sciNamesIndexI18n;
QStringList initStringListFromFile(const QString& file_name) QStringList initStringListFromFile(const QString& file_name)
{ {
QStringList list; QStringList list;
QFile f(file_name); QFile f(file_name);
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) if (f.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
while (!f.atEnd()) while (!f.atEnd())
skipping to change at line 478 skipping to change at line 479
lastMaxSearchLevel = maxGeodesicGridLevel; lastMaxSearchLevel = maxGeodesicGridLevel;
qDebug() << "Finished loading star catalogue data, max_geodesic_leve l: " << maxGeodesicGridLevel; qDebug() << "Finished loading star catalogue data, max_geodesic_leve l: " << maxGeodesicGridLevel;
} }
// Load common names from file // Load common names from file
int StarMgr::loadCommonNames(const QString& commonNameFile) int StarMgr::loadCommonNames(const QString& commonNameFile)
{ {
commonNamesMap.clear(); commonNamesMap.clear();
commonNamesMapI18n.clear(); commonNamesMapI18n.clear();
commonNamesIndexI18n.clear(); commonNamesIndexI18n.clear();
commonNamesIndex.clear();
qDebug() << "Loading star names from" << commonNameFile; qDebug() << "Loading star names from" << commonNameFile;
QFile cnFile(commonNameFile); QFile cnFile(commonNameFile);
if (!cnFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!cnFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "WARNING - could not open" << commonNameFile; qWarning() << "WARNING - could not open" << commonNameFile;
return 0; return 0;
} }
int readOk=0; int readOk=0;
skipping to change at line 540 skipping to change at line 542
} }
// Fix for translate star names // Fix for translate star names
// englishCommonName.replace('_', ' '); // englishCommonName.replace('_', ' ');
const QString commonNameI18n = q_(englishCommonName) ; const QString commonNameI18n = q_(englishCommonName) ;
QString commonNameI18n_cap = commonNameI18n.toUpper( ); QString commonNameI18n_cap = commonNameI18n.toUpper( );
commonNamesMap[hip] = englishCommonName; commonNamesMap[hip] = englishCommonName;
commonNamesMapI18n[hip] = commonNameI18n; commonNamesMapI18n[hip] = commonNameI18n;
commonNamesIndexI18n[commonNameI18n_cap] = hip; commonNamesIndexI18n[commonNameI18n_cap] = hip;
commonNamesIndex[englishCommonName.toUpper()] = hip;
readOk++; readOk++;
} }
} }
cnFile.close(); cnFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "common sta r names"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "common sta r names";
return 1; return 1;
} }
// Load scientific names from file // Load scientific names from file
skipping to change at line 885 skipping to change at line 888
{ {
if (it.key().startsWith(objw)) if (it.key().startsWith(objw))
{ {
if (maxNbItem==0) if (maxNbItem==0)
break; break;
result << getCommonName(it.value()); result << getCommonName(it.value());
--maxNbItem; --maxNbItem;
} }
else else
break; break;
}
// Search for sci names
QString bayerPattern = objw;
QRegExp bayerRegEx(bayerPattern);
// if the first character is a Greek letter, check if there's an ind
ex
// after it, such as "alpha1 Cen".
if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9
)
bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?"));
for (QMap<QString,int>::const_iterator it(sciNamesIndexI18n.lowerBou
nd(objw)); it!=sciNamesIndexI18n.end(); ++it)
{
if (it.key().indexOf(bayerRegEx)==0)
{
if (maxNbItem==0)
break;
result << getSciName(it.value());
--maxNbItem;
}
else if (it.key().at(0) != objw.at(0))
break;
}
// Add exact Hp catalogue numbers
QRegExp hpRx("^(HIP|HP)\\s*(\\d+)\\s*$");
hpRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hpRx.exactMatch(objw))
{
bool ok;
int hpNum = hpRx.capturedTexts().at(2).toInt(&ok);
if (ok)
{
StelObjectP s = searchHP(hpNum);
if (s && maxNbItem>0)
{
result << QString("HIP%1").arg(hpNum);
maxNbItem--;
}
}
}
result.sort();
return result;
}
//! Find and return the list of at most maxNbItem objects auto-completing
//! the passed object English name.
QStringList StarMgr::listMatchingObjects(const QString& objPrefix, int maxN
bItem) const
{
QStringList result;
if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper();
// Search for common names
for (QMap<QString,int>::const_iterator it(commonNamesIndex.lowerBoun
d(objw)); it!=commonNamesIndex.end(); ++it)
{
if (it.key().startsWith(objw))
{
if (maxNbItem==0)
break;
result << getCommonName(it.value());
--maxNbItem;
}
else
break;
} }
// Search for sci names // Search for sci names
QString bayerPattern = objw; QString bayerPattern = objw;
QRegExp bayerRegEx(bayerPattern); QRegExp bayerRegEx(bayerPattern);
// if the first character is a Greek letter, check if there's an ind ex // if the first character is a Greek letter, check if there's an ind ex
// after it, such as "alpha1 Cen". // after it, such as "alpha1 Cen".
if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9 ) if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9 )
bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?")); bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?"));
 End of changes. 5 change blocks. 
1 lines changed or deleted 76 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/