NebulaMgr.cpp   NebulaMgr.cpp 
skipping to change at line 436 skipping to change at line 436
qDebug() << "Loaded" << totalRecords << "NGC records"; qDebug() << "Loaded" << totalRecords << "NGC records";
return true; return true;
} }
bool NebulaMgr::loadNGCNames(const QString& catNGCNames) bool NebulaMgr::loadNGCNames(const QString& catNGCNames)
{ {
qDebug() << "Loading NGC name data ..."; qDebug() << "Loading NGC name data ...";
QFile ngcNameFile(catNGCNames); QFile ngcNameFile(catNGCNames);
if (!ngcNameFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!ngcNameFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "NGC name data file" << catNGCNames << "not fo und."; qWarning() << "NGC name data file" << QDir::toNativeSeparato rs(catNGCNames) << "not found.";
return false; return false;
} }
// Read the names of the NGC objects // Read the names of the NGC objects
QString name, record; QString name, record;
int totalRecords=0; int totalRecords=0;
int lineNumber=0; int lineNumber=0;
int readOk=0; int readOk=0;
int nb; int nb;
NebulaP e; NebulaP e;
skipping to change at line 495 skipping to change at line 495
{ {
// If it's a caldwellnumber, we will call it a caldwell if there is no better name // If it's a caldwellnumber, we will call it a caldwell if there is no better name
name = name.mid(2); // remove "C " name = name.mid(2); // remove "C "
// read the Caldwell number // read the Caldwell number
QTextStream istr(&name); QTextStream istr(&name);
int num; int num;
istr >> num; istr >> num;
if (istr.status()!=QTextStream::Ok) if (istr.status()!=QTextStream::Ok)
{ {
qWarning() << "cannot read Caldwell number at line" << lineNumber << "of" << catNGCNames; qWarning() << "cannot read Caldwell number at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNam es);
continue; continue;
} }
e->C_nb=(unsigned int)(num); e->C_nb=(unsigned int)(num);
e->englishName = QString("C%1").arg(num); e->englishName = QString("C%1").arg(num);
} }
else if (name.left(2).toUpper() == "M " && name.left (2).toUpper() != "C ") else if (name.left(2).toUpper() == "M " && name.left (2).toUpper() != "C ")
{ {
// If it's a messiernumber, we will call it a messier if there is no better name // If it's a messiernumber, we will call it a messier if there is no better name
name = name.mid(2); // remove "M " name = name.mid(2); // remove "M "
// read the Messier number // read the Messier number
QTextStream istr(&name); QTextStream istr(&name);
int num; int num;
istr >> num; istr >> num;
if (istr.status()!=QTextStream::Ok) if (istr.status()!=QTextStream::Ok)
{ {
qWarning() << "cannot read Messier n umber at line" << lineNumber << "of" << catNGCNames; qWarning() << "cannot read Messier n umber at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCName s);
continue; continue;
} }
e->M_nb=(unsigned int)(num); e->M_nb=(unsigned int)(num);
e->englishName = QString("M%1").arg(num); e->englishName = QString("M%1").arg(num);
} }
readOk++; readOk++;
} }
else else
qWarning() << "no position data for " << name << "at line" << lineNumber << "of" << catNGCNames; qWarning() << "no position data for " << name << "at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNames);
} }
ngcNameFile.close(); ngcNameFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC name r ecords successfully"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC name r ecords successfully";
return true; return true;
} }
void NebulaMgr::updateI18n() void NebulaMgr::updateI18n()
{ {
StelTranslator trans = StelApp::getInstance().getLocaleMgr().getSkyT ranslator(); StelTranslator trans = StelApp::getInstance().getLocaleMgr().getSkyT ranslator();
skipping to change at line 562 skipping to change at line 562
} }
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
QString objwcap = n->nameI18.toUpper(); QString objwcap = n->nameI18.toUpper();
if (objwcap==objw) if (objwcap==objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
// Search by IC numbers (possible formats are "IC466" or "IC 466")
if (objw.mid(0, 2) == "IC")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("IC%1").arg(n->IC_nb) == objw || QString
("IC %1").arg(n->IC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Messier numbers (possible formats are "M31" or "M 31") // Search by Messier numbers (possible formats are "M31" or "M 31")
if (objw.mid(0, 1) == "M") if (objw.mid(0, 1) == "M")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (QString("M%1").arg(n->M_nb) == objw || QString(" M %1").arg(n->M_nb) == objw) if (QString("M%1").arg(n->M_nb) == objw || QString(" M %1").arg(n->M_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
skipping to change at line 609 skipping to change at line 619
} }
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
QString objwcap = n->englishName.toUpper(); QString objwcap = n->englishName.toUpper();
if (objwcap==objw) if (objwcap==objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
// Search by IC numbers (possible formats are "IC466" or "IC 466")
if (objw.mid(0, 2) == "IC")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("IC%1").arg(n->IC_nb) == objw || QString
("IC %1").arg(n->IC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Messier numbers (possible formats are "M31" or "M 31") // Search by Messier numbers (possible formats are "M31" or "M 31")
if (objw.mid(0, 1) == "M") if (objw.mid(0, 1) == "M")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (QString("M%1").arg(n->M_nb) == objw || QString(" M %1").arg(n->M_nb) == objw) if (QString("M%1").arg(n->M_nb) == objw || QString(" M %1").arg(n->M_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
skipping to change at line 638 skipping to change at line 658
return NULL; return NULL;
} }
//! Find and return the list of at most maxNbItem objects auto-completing t he passed object I18n name //! Find and return the list of at most maxNbItem objects auto-completing t he passed object I18n name
QStringList NebulaMgr::listMatchingObjectsI18n(const QString& objPrefix, in t maxNbItem) const QStringList NebulaMgr::listMatchingObjectsI18n(const QString& objPrefix, in t maxNbItem) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString dson;
// Search by Messier objects number (possible formats are "M31" or "
// Search by messier objects number (possible formats are "M31" or " M 31")
M 31") if (objPrefix.size()>=1 && objPrefix[0]=='M')
if (objw.size()>=1 && objw[0]=='M')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->M_nb==0) continue; if (n->M_nb==0) continue;
QString constw = QString("M%1").arg(n->M_nb); dson = QString("M%1").arg(n->M_nb);
QString constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw)
{ {
result << constw; result << dson;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("M %1").arg(n->M_nb); dson = QString("M %1").arg(n->M_nb);
constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw) result << dson;
result << constw; }
}
// Search by IC objects number (possible formats are "IC466" or "IC
466")
if (objPrefix.size()>=1 && objPrefix[0]=='I')
{
foreach (const NebulaP& n, nebArray)
{
if (n->IC_nb==0) continue;
dson = QString("IC%1").arg(n->IC_nb);
if (dson.contains(objPrefix, Qt::CaseInsensitive))
{
result << dson;
continue; // Prevent adding both forms
for name
}
dson = QString("IC %1").arg(n->IC_nb);
if (dson.contains(objPrefix, Qt::CaseInsensitive))
result << dson;
} }
} }
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31") // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->NGC_nb==0) continue; if (n->NGC_nb==0) continue;
QString constw = QString("NGC%1").arg(n->NGC_nb); dson = QString("NGC%1").arg(n->NGC_nb);
QString constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw)
{ {
result << constw; result << dson;
continue; continue;
} }
constw = QString("NGC %1").arg(n->NGC_nb); dson = QString("NGC %1").arg(n->NGC_nb);
constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw) result << dson;
result << constw;
} }
// Search by caldwell objects number (possible formats are "C31" or "C 31") // Search by caldwell objects number (possible formats are "C31" or "C 31")
if (objw.size()>=1 && objw[0]=='C') if (objPrefix.size()>=1 && objPrefix[0]=='C')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->C_nb==0) continue; if (n->C_nb==0) continue;
QString constw = QString("C%1").arg(n->C_nb); dson = QString("C%1").arg(n->C_nb);
QString constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw)
{ {
result << constw; result << dson;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("C %1").arg(n->C_nb); dson = QString("C %1").arg(n->C_nb);
constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw) result << dson;
result << constw;
} }
} }
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
QString constw = n->nameI18.mid(0, objw.size()).toUpper(); dson = n->nameI18;
if (constw==objw) if (dson.contains(objPrefix, Qt::CaseInsensitive))
result << n->nameI18; result << dson;
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, if (maxNbItem > 0)
result.end()); {
if (result.size()>maxNbItem) result.erase(result.begin()+max
NbItem, result.end());
}
return result; return result;
} }
//! Find and return the list of at most maxNbItem objects auto-completing t he passed object English name //! Find and return the list of at most maxNbItem objects auto-completing t he passed object English name
QStringList NebulaMgr::listMatchingObjects(const QString& objPrefix, int ma xNbItem) const QStringList NebulaMgr::listMatchingObjects(const QString& objPrefix, int ma xNbItem) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString dson;
// Search by Messier objects number (possible formats are "M31" or "
// Search by messier objects number (possible formats are "M31" or " M 31")
M 31") if (objPrefix.size()>=1 && objPrefix[0]=='M')
if (objw.size()>=1 && objw[0]=='M')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->M_nb==0) continue; if (n->M_nb==0) continue;
QString constw = QString("M%1").arg(n->M_nb); dson = QString("M%1").arg(n->M_nb);
QString constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw)
{ {
result << constw; result << dson;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("M %1").arg(n->M_nb); dson = QString("M %1").arg(n->M_nb);
constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw) result << dson;
result << constw; }
}
// Search by IC objects number (possible formats are "IC466" or "IC
466")
if (objPrefix.size()>=1 && objPrefix[0]=='I')
{
foreach (const NebulaP& n, nebArray)
{
if (n->IC_nb==0) continue;
dson = QString("IC%1").arg(n->IC_nb);
if (dson.contains(objPrefix,Qt::CaseInsensitive))
{
result << dson;
continue; // Prevent adding both forms
for name
}
dson = QString("IC %1").arg(n->IC_nb);
if (dson.contains(objPrefix, Qt::CaseInsensitive))
result << dson;
} }
} }
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31") // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->NGC_nb==0) continue; if (n->NGC_nb==0) continue;
QString constw = QString("NGC%1").arg(n->NGC_nb); dson = QString("NGC%1").arg(n->NGC_nb);
QString constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw)
{ {
result << constw; result << dson;
continue; continue;
} }
constw = QString("NGC %1").arg(n->NGC_nb); dson = QString("NGC %1").arg(n->NGC_nb);
constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw) result << dson;
result << constw;
} }
// Search by caldwell objects number (possible formats are "C31" or "C 31") // Search by caldwell objects number (possible formats are "C31" or "C 31")
if (objw.size()>=1 && objw[0]=='C') if (objPrefix.size()>=1 && objPrefix[0]=='C')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->C_nb==0) continue; if (n->C_nb==0) continue;
QString constw = QString("C%1").arg(n->C_nb); dson = QString("C%1").arg(n->C_nb);
QString constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw)
{ {
result << constw; result << dson;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("C %1").arg(n->C_nb); dson = QString("C %1").arg(n->C_nb);
constws = constw.mid(0, objw.size()); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constws==objw) result << dson;
result << constw;
} }
} }
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
QString constw = n->englishName.mid(0, objw.size()).toUpper( dson = n->englishName;
); if (dson.contains(objPrefix, Qt::CaseInsensitive))
if (constw==objw) result << dson;
result << n->englishName;
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, if (maxNbItem > 0)
result.end()); {
if (result.size()>maxNbItem) result.erase(result.begin()+max
NbItem, result.end());
}
return result; return result;
} }
 End of changes. 32 change blocks. 
76 lines changed or deleted 128 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/