7#include "modelmanager.h"
9#include "ksfilereader.h"
11#include "kstarsdata.h"
12#include "obsconditions.h"
13#include "skymapcomposite.h"
14#include "skyobjitem.h"
15#include "skyobjlistmodel.h"
16#include "starobject.h"
17#include "catalogsdb.h"
19#include <QtConcurrent>
23 m_ObsConditions =
obs;
34 for (
int i = 0; i < NumberOfLists; i++)
43ModelManager::~ModelManager()
51void ModelManager::loadLists()
56 emit loadProgressUpdated(0);
60 for (
int i = 0; i <
listStars.size(); i++)
68 for (
int i = 0; i < m_ObjectList[Stars].
size(); i++)
90 if (line.
length() == 0 || line[0] ==
'#')
99 case SkyObject::OPEN_CLUSTER:
100 case SkyObject::GLOBULAR_CLUSTER:
101 case SkyObject::GALAXY_CLUSTER:
104 case SkyObject::PLANETARY_NEBULA:
105 case SkyObject::DARK_NEBULA:
106 case SkyObject::GASEOUS_NEBULA:
109 case SkyObject::GALAXY:
116 emit loadProgressUpdated(0.20);
118 loadObjectList(m_ObjectList[Asteroids], SkyObject::ASTEROID);
119 emit loadProgressUpdated(0.30);
120 loadObjectList(m_ObjectList[Comets], SkyObject::COMET);
121 emit loadProgressUpdated(0.40);
122 loadObjectList(m_ObjectList[Satellites], SkyObject::SATELLITE);
123 loadObjectList(m_ObjectList[Supernovas], SkyObject::SUPERNOVA);
124 emit loadProgressUpdated(0.50);
125 loadObjectList(m_ObjectList[Constellations], SkyObject::CONSTELLATION);
126 emit loadProgressUpdated(0.55);
127 loadObjectList(m_ObjectList[Planets], SkyObject::PLANET);
128 emit loadProgressUpdated(0.60);
130 loadObjectList(m_ObjectList[Galaxies], SkyObject::GALAXY);
131 emit loadProgressUpdated(0.70);
133 loadObjectList(m_ObjectList[Clusters], SkyObject::OPEN_CLUSTER);
134 loadObjectList(m_ObjectList[Clusters], SkyObject::GLOBULAR_CLUSTER);
135 loadObjectList(m_ObjectList[Clusters], SkyObject::GALAXY_CLUSTER);
136 emit loadProgressUpdated(0.80);
138 loadObjectList(m_ObjectList[Nebulas], SkyObject::PLANETARY_NEBULA);
139 loadObjectList(m_ObjectList[Nebulas], SkyObject::SUPERNOVA_REMNANT);
140 loadObjectList(m_ObjectList[Nebulas], SkyObject::GASEOUS_NEBULA);
141 loadObjectList(m_ObjectList[Nebulas], SkyObject::DARK_NEBULA);
143 emit loadProgressUpdated(0.90);
144 emit loadProgressUpdated(1);
149 m_ObsConditions =
obs;
152 for (
int i = 0; i < NumberOfLists; i++)
153 loadObjectsIntoModel(*m_ModelList[i], m_ObjectList[i]);
158 m_ObsConditions =
obs;
165 if (showOnlyFavorites &&
modelName ==
"galaxies")
166 loadObjectsIntoModel(*m_ModelList[
modelNumber], favoriteGalaxies);
167 else if (showOnlyFavorites &&
modelName ==
"nebulas")
168 loadObjectsIntoModel(*m_ModelList[
modelNumber], favoriteNebulas);
169 else if (showOnlyFavorites &&
modelName ==
"clusters")
170 loadObjectsIntoModel(*m_ModelList[
modelNumber], favoriteClusters);
185 for (
int i = 0; i < objects.size(); i++)
238 return Constellations;
276 const auto id = getModelNumber(name);
277 if (m_CatalogMap.count(
id) > 0)
281 {
"ngc",
"NGC " }, {
"ic",
"IC " }, {
"messier",
"M " }, {
"sharpless",
"Sh2 " }
287 const int offset = prefix.size();
289 m_CatalogMap[id] = std::get<2>(manager.general_master_query(
290 QString(
"name LIKE '%1'").arg(prefix +
"%"),
291 QString(
"CAST(SUBSTR(name,%1) AS INT)").arg(offset)));
293 auto &lst = m_CatalogSkyObjItems[id];
295 for (
auto &obj : m_CatalogMap[id])
297 obj.updateCoordsNow(KStarsData::Instance()->updateNum());
298 lst.emplace_back(&obj);
301 auto &
p_lst = m_ObjectList[id];
302 for (
auto &obj : lst)
305 updateModel(m_ObsConditions, name);
306 emit loadProgressUpdated(1);
Manages the catalog database and provides an interface to provide an interface to query and modify th...
I totally rewrote this because the earlier scheme of reading all the lines of a file into a buffer be...
KStarsData is the backbone of KStars.
SkyMapComposite * skyComposite()
static bool Closing
Set to true when the application is being closed.
void resetAllModels()
Clears all sky-objects list models.
void loadCatalog(const QString &name)
Load objects from the dso db for the catalog with name can be used to retreive the object lists later...
ModelManager(ObsConditions *obs)
Constructor - Creates models for different sky-object types.
SkyObjListModel * returnModel(QString modelName)
Returns model of given type.
void updateAllModels(ObsConditions *obs)
Updates sky-object list models.
This class deals with the observing conditions of the night sky.
bool isVisible(GeoLocation *geo, dms *lst, SkyObject *so)
Evaluate visibility of sky-object based on current observing conditions.
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument.
Represents an item in the list of interesting sky-objects.
QString getName() const
Get name of sky-object associated with the SkyObjItem.
Represents a model for the list of interesting sky-objects to be displayed in the QML interface.
void resetModel()
Erase all data in model.
void addSkyObject(SkyObjItem *sobj)
Add a sky-object to the model.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
This is a subclass of SkyObject.
bool hasLatinName() const
QString i18n(const char *text, const TYPE &arg...)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
void removeAt(qsizetype i)
qsizetype size() const const
qsizetype length() const const
QFuture< T > run(Function function,...)