StarMgr.cpp   StarMgr.cpp 
skipping to change at line 32 skipping to change at line 32
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelToneReproducer.hpp" #include "StelToneReproducer.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelGeodesicGrid.hpp" #include "StelGeodesicGrid.hpp"
#include "StelTranslator.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
skipping to change at line 66 skipping to change at line 65
#include <QCryptographicHash> #include <QCryptographicHash>
#include <errno.h> #include <errno.h>
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 = 6; static const int StarCatalogFormatVersion = 7;
// 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; 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;
QHash<int,QString> StarMgr::sciAdditionalNamesMapI18n; QHash<int,QString> StarMgr::sciAdditionalNamesMapI18n;
skipping to change at line 136 skipping to change at line 135
, gravityLabel(false) , gravityLabel(false)
, hipIndex(new HipIndexStruct[NR_OF_HIP+1]) , hipIndex(new HipIndexStruct[NR_OF_HIP+1])
{ {
setObjectName("StarMgr"); setObjectName("StarMgr");
if (hipIndex == 0) if (hipIndex == 0)
{ {
qFatal("ERROR: StarMgr::StarMgr: no memory"); qFatal("ERROR: StarMgr::StarMgr: no memory");
} }
maxGeodesicGridLevel = -1; maxGeodesicGridLevel = -1;
lastMaxSearchLevel = -1; lastMaxSearchLevel = -1;
starFont.setPixelSize(StelApp::getInstance().getSettings()->value("g ui/base_font_size", 13).toInt());
objectMgr = GETSTELMODULE(StelObjectMgr); objectMgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(objectMgr); Q_ASSERT(objectMgr);
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double StarMgr::getCallOrder(StelModuleActionName actionName) const double StarMgr::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
skipping to change at line 168 skipping to change at line 166
} }
QString StarMgr::getCommonName(int hip) QString StarMgr::getCommonName(int hip)
{ {
QHash<int,QString>::const_iterator it(commonNamesMapI18n.find(hip)); QHash<int,QString>::const_iterator it(commonNamesMapI18n.find(hip));
if (it!=commonNamesMapI18n.end()) if (it!=commonNamesMapI18n.end())
return it.value(); return it.value();
return QString(); return QString();
} }
QString StarMgr::getCommonEnglishName(int hip)
{
QHash<int,QString>::const_iterator it(commonNamesMap.find(hip));
if (it!=commonNamesMap.end())
return it.value();
return QString();
}
QString StarMgr::getSciName(int hip) QString StarMgr::getSciName(int hip)
{ {
QHash<int,QString>::const_iterator it(sciNamesMapI18n.find(hip)); QHash<int,QString>::const_iterator it(sciNamesMapI18n.find(hip));
if (it!=sciNamesMapI18n.end()) if (it!=sciNamesMapI18n.end())
return it.value(); return it.value();
return QString(); return QString();
} }
QString StarMgr::getSciAdditionalName(int hip) QString StarMgr::getSciAdditionalName(int hip)
{ {
skipping to change at line 316 skipping to change at line 322
copyDefaultConfigFile(); copyDefaultConfigFile();
QFile fic2(starConfigFileFullPath); QFile fic2(starConfigFileFullPath);
if(fic2.open(QIODevice::ReadOnly)) if(fic2.open(QIODevice::ReadOnly))
{ {
starSettings = StelJsonParser::parse(&fic2).toMap(); starSettings = StelJsonParser::parse(&fic2).toMap();
fic2.close(); fic2.close();
} }
} }
loadData(starSettings); loadData(starSettings);
starFont.setPixelSize(StelApp::getInstance().getSettings()->value("g ui/base_font_size", 13).toInt()); starFont.setPixelSize(StelApp::getInstance().getBaseFontSize());
setFlagStars(conf->value("astro/flag_stars", true).toBool()); setFlagStars(conf->value("astro/flag_stars", true).toBool());
setFlagLabels(conf->value("astro/flag_star_name",true).toBool()); setFlagLabels(conf->value("astro/flag_star_name",true).toBool());
setLabelsAmount(conf->value("stars/labels_amount",3.f).toFloat()); setLabelsAmount(conf->value("stars/labels_amount",3.f).toFloat());
objectMgr->registerStelObjectMgr(this); objectMgr->registerStelObjectMgr(this);
texPointer = StelApp::getInstance().getTextureManager().createTextur e(StelFileMgr::getInstallationDir()+"/textures/pointeur2.png"); // Load p ointer texture texPointer = StelApp::getInstance().getTextureManager().createTextur e(StelFileMgr::getInstallationDir()+"/textures/pointeur2.png"); // Load p ointer texture
StelApp::getInstance().getCore()->getGeodesicGrid(maxGeodesicGridLev el)->visitTriangles(maxGeodesicGridLevel,initTriangleFunc,this); StelApp::getInstance().getCore()->getGeodesicGrid(maxGeodesicGridLev el)->visitTriangles(maxGeodesicGridLevel,initTriangleFunc,this);
foreach(ZoneArray* z, gridLevels) foreach(ZoneArray* z, gridLevels)
skipping to change at line 556 skipping to change at line 562
if (!cnFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!cnFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(commonNameFile); qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(commonNameFile);
return 0; return 0;
} }
int readOk=0; int readOk=0;
int totalRecords=0; int totalRecords=0;
int lineNumber=0; int lineNumber=0;
QString record; QString record;
// Allow empty and comment lines where first char (after optional bl anks) is #
QRegExp commentRx("^(\\s*#.*|\\s*)$"); QRegExp commentRx("^(\\s*#.*|\\s*)$");
// record structure is delimited with a | character. We will // record structure is delimited with a | character. We will
// use a QRegExp to extract the fields. with whitespace padding perm itted // use a QRegExp to extract the fields. with whitespace padding perm itted
// (i.e. it will be stripped automatically) Example record strings: // (i.e. it will be stripped automatically) Example record strings:
// " 10819|c_And" // " 677|_("Alpheratz")"
// "113726|1_And" // "113368|_("Fomalhaut")"
QRegExp recordRx("^\\s*(\\d+)\\s*\\|(.*)\\n"); // Note: Stellarium doesn't support sky cultures made prior version
0.10.6 now!
QRegExp recordRx("^\\s*(\\d+)\\s*\\|_[(]\"(.*)\"[)]\\s*\\n");
while(!cnFile.atEnd()) while(!cnFile.atEnd())
{ {
record = QString::fromUtf8(cnFile.readLine()); record = QString::fromUtf8(cnFile.readLine());
lineNumber++; lineNumber++;
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
totalRecords++; totalRecords++;
if (!recordRx.exactMatch(record)) if (!recordRx.exactMatch(record))
skipping to change at line 597 skipping to change at line 605
continue; continue;
} }
QString englishCommonName = recordRx.capturedTexts() .at(2).trimmed(); QString englishCommonName = recordRx.capturedTexts() .at(2).trimmed();
if (englishCommonName.isEmpty()) if (englishCommonName.isEmpty())
{ {
qWarning() << "WARNING - parse error at line " << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile) qWarning() << "WARNING - parse error at line " << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile)
<< " - empty name field"; << " - empty name field";
continue; continue;
} }
// Fix for translate star names const QString commonNameI18n = englishCommonName;
// englishCommonName.replace('_', ' ');
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; commonNamesIndex[englishCommonName.toUpper()] = hip;
readOk++; readOk++;
} }
} }
cnFile.close(); cnFile.close();
skipping to change at line 932 skipping to change at line 938
//qDebug() << " " << zone; //qDebug() << " " << zone;
} }
} }
return result; return result;
} }
//! Update i18 names from english names according to passed translator. //! Update i18 names from english names according to passed translator.
//! The translation is done using gettext with translated strings defined i n translations.h //! The translation is done using gettext with translated strings defined i n translations.h
void StarMgr::updateI18n() void StarMgr::updateI18n()
{ {
QRegExp transRx("_[(]\"(.*)\"[)]");
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator();
commonNamesMapI18n.clear(); commonNamesMapI18n.clear();
commonNamesIndexI18n.clear(); commonNamesIndexI18n.clear();
for (QHash<int,QString>::ConstIterator it(commonNamesMap.constBegin( ));it!=commonNamesMap.constEnd();it++) for (QHash<int,QString>::ConstIterator it(commonNamesMap.constBegin( ));it!=commonNamesMap.constEnd();it++)
{ {
const int i = it.key(); const int i = it.key();
transRx.exactMatch(it.value()); const QString t(trans.qtranslate(it.value()));
QString tt = transRx.capturedTexts().at(1);
const QString t = trans.qtranslate(tt);
//const QString t(trans.qtranslate(it.value()));
commonNamesMapI18n[i] = t; commonNamesMapI18n[i] = t;
commonNamesIndexI18n[t.toUpper()] = i; commonNamesIndexI18n[t.toUpper()] = i;
} }
} }
// Search the star by HP number // Search the star by HP number
StelObjectP StarMgr::searchHP(int hp) const StelObjectP StarMgr::searchHP(int hp) const
{ {
if (0 < hp && hp <= NR_OF_HIP) if (0 < hp && hp <= NR_OF_HIP)
{ {
skipping to change at line 1017 skipping to change at line 1019
{ {
QString objw = name.toUpper(); QString objw = name.toUpper();
// Search by HP number if it's an HP formated number // Search by HP number if it's an HP formated number
QRegExp rx("^\\s*(HP|HIP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx("^\\s*(HP|HIP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx.exactMatch(objw)) if (rx.exactMatch(objw))
{ {
return searchHP(rx.capturedTexts().at(2).toInt()); return searchHP(rx.capturedTexts().at(2).toInt());
} }
// Search by sci name // Search by I18n common name
QMap<QString,int>::const_iterator it = sciNamesIndexI18n.find(objw); QMap<QString,int>::const_iterator it(commonNamesIndex.find(objw));
if (it!=sciNamesIndexI18n.end()) if (it!=commonNamesIndex.end())
{ {
return searchHP(it.value()); return searchHP(it.value());
} }
// Search by additional sci name // Search by sci name
QMap<QString,int>::const_iterator it2 = sciAdditionalNamesIndexI18n. QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw)
find(objw); ;
if (it2!=sciAdditionalNamesIndexI18n.end()) if (it2!=sciNamesIndexI18n.end())
{ {
return searchHP(it2.value()); return searchHP(it2.value());
} }
// Search by additional sci name
QMap<QString,int>::const_iterator it3 = sciAdditionalNamesIndexI18n.
find(objw);
if (it3!=sciAdditionalNamesIndexI18n.end())
{
return searchHP(it3.value());
}
return StelObjectP(); return StelObjectP();
} }
//! Find and return the list of at most maxNbItem objects auto-completing //! Find and return the list of at most maxNbItem objects auto-completing
//! the passed object I18n name. //! the passed object I18n name.
QStringList StarMgr::listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const QStringList StarMgr::listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
skipping to change at line 1162 skipping to change at line 1171
// Search for common names // Search for common names
if (useStartOfWords) if (useStartOfWords)
{ {
for (QMap<QString,int>::const_iterator it(commonNamesIndex.l owerBound(objw)); it!=commonNamesIndex.end(); ++it) for (QMap<QString,int>::const_iterator it(commonNamesIndex.l owerBound(objw)); it!=commonNamesIndex.end(); ++it)
{ {
if (it.key().startsWith(objw)) if (it.key().startsWith(objw))
{ {
if (maxNbItem==0) if (maxNbItem==0)
break; break;
result << getCommonName(it.value()); result << getCommonEnglishName(it.value());
--maxNbItem; --maxNbItem;
} }
else else
break; break;
} }
} }
else else
{ {
QMapIterator<QString, int> i(commonNamesIndex); QMapIterator<QString, int> i(commonNamesIndex);
while (i.hasNext()) while (i.hasNext())
{ {
i.next(); i.next();
if (i.key().contains(objw)) if (i.key().contains(objw))
{ {
if (maxNbItem==0) if (maxNbItem==0)
break; break;
result << getCommonName(i.value()); result << getCommonEnglishName(i.value());
--maxNbItem; --maxNbItem;
} }
} }
} }
// 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
skipping to change at line 1287 skipping to change at line 1296
fic = StelFileMgr::findFile("stars/default/gcvs_hip_part.dat"); fic = StelFileMgr::findFile("stars/default/gcvs_hip_part.dat");
if (fic.isEmpty()) if (fic.isEmpty())
qWarning() << "WARNING: could not load variable stars file: stars/default/gcvs_hip_part.dat"; qWarning() << "WARNING: could not load variable stars file: stars/default/gcvs_hip_part.dat";
else else
loadGcvs(fic); loadGcvs(fic);
// Turn on sci names/catalog names for western culture only // Turn on sci names/catalog names for western culture only
setFlagSciNames(skyCultureDir.startsWith("western")); setFlagSciNames(skyCultureDir.startsWith("western"));
updateI18n(); updateI18n();
} }
QStringList StarMgr::listAllObjects(bool inEnglish) const
{
QStringList result;
if (inEnglish)
{
QMapIterator<QString, int> i(commonNamesIndex);
while (i.hasNext())
{
i.next();
result << getCommonEnglishName(i.value());
}
}
else
{
QMapIterator<QString, int> i(commonNamesIndexI18n);
while (i.hasNext())
{
i.next();
result << getCommonName(i.value());
}
}
return result;
}
 End of changes. 16 change blocks. 
25 lines changed or deleted 35 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/