Commit 3c5965ae authored by Akarsh Simha's avatar Akarsh Simha

Implement CatalogComponent::findByName method for custom catalogs.

parent bcaa1304
Pipeline #48400 passed with stages
in 63 minutes and 59 seconds
......@@ -128,11 +128,13 @@ void CatalogComponent::_loadData(bool includeCatalogDesignation)
if (!dupName)
{
objectLists(obj->type()).append(QPair<QString, const SkyObject *>(name, obj));
nameHash[name.toLower()] = obj;
}
if (!longname.isEmpty() && !dupLongname && name != longname)
{
objectLists(obj->type()).append(QPair<QString, const SkyObject *>(longname, obj));
nameHash[longname.toLower()] = obj;
}
}
}
......@@ -255,3 +257,10 @@ bool CatalogComponent::selected()
return false;
}
SkyObject *CatalogComponent::findByName(const QString &name)
{
if (nameHash.contains(name.toLower()))
return nameHash[name.toLower()];
return nullptr;
}
......@@ -53,6 +53,8 @@ class CatalogComponent : public ListComponent
void update(KSNumbers *num) override;
SkyObject *findByName(const QString &name) override;
/** @return the name of the catalog */
inline QString name() const { return m_catName; }
......@@ -97,4 +99,10 @@ class CatalogComponent : public ListComponent
bool m_Showerrs { false };
int m_ccIndex { 0 };
quint32 updateID { 0 };
private:
// FIXME: Keeping both the objectNames data structure and the
// nameHash seems overkill -- asimha
QHash<QString, SkyObject *> nameHash;
};
......@@ -171,6 +171,8 @@ class DeepSkyComponent : public SkyComponent
void appendIndex(DeepSkyObject *o, DeepSkyIndex *dsIndex, Trixel trixel);
// FIXME: Keeping both the objectNames data structure and the
// nameHash seems overkill -- asimha
QHash<QString, DeepSkyObject *> nameHash;
/** @short adds a label to the lists of labels to be drawn prioritized by magnitude. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment