Kstars

modelmanager.h
1/*
2 SPDX-FileCopyrightText: 2012 Samikshan Bairagya <samikshan@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "catalogobject.h"
10#include "skyobjitem.h"
11#include "catalogsdb.h"
12#include <QList>
13#include <QObject>
14
15#include "polyfills/qstring_hash.h"
16#include <unordered_map>
17
18class ObsConditions;
19class SkyObjListModel;
20
21/**
22 * @class ModelManager
23 * @brief Manages models for QML listviews of different types of sky-objects.
24 *
25 * @author Samikshan Bairagya
26 */
27class ModelManager : public QObject
28{
30 public:
31 /**
32 * @enum ObjectList
33 * @brief Model type for different types of sky-objects.
34 */
36 {
37 Planets,
38 Stars,
39 Constellations,
40 Galaxies,
41 Clusters,
42 Nebulas,
43 Satellites,
44 Asteroids,
45 Comets,
46 Supernovas,
47 Messier,
48 NGC,
49 IC,
50 Sharpless,
51 NumberOfLists
52 };
53
54 /**
55 * @brief Constructor - Creates models for different sky-object types.
56 * @param obs Pointer to an ObsConditions object.
57 */
58 explicit ModelManager(ObsConditions *obs);
59 ~ModelManager() override;
60
61 /** Updates sky-object list models. */
63
64 void updateModel(ObsConditions *obs, QString modelName);
65
66 /** Clears all sky-objects list models. */
67 void resetAllModels();
68
69 void setShowOnlyVisibleObjects(bool show) { showOnlyVisible = show; }
70
71 bool showOnlyVisibleObjects() { return showOnlyVisible; }
72
73 void setShowOnlyFavoriteObjects(bool show) { showOnlyFavorites = show; }
74
75 bool showOnlyFavoriteObjects() { return showOnlyFavorites; }
76
77 /**
78 * Load objects from the dso db for the catalog with \p name can
79 * be used to retreive the object lists later.
80 *
81 * This is implemented by searching the dso database for objects
82 * whichs name starts with a prefix to capture subsets of a catalog.
83 */
84 void loadCatalog(const QString &name);
85
86 /**
87 * @brief Returns model of given type.
88 * @return Pointer to SkyObjListModel of given type.
89 * @param modelName Name of sky-object model to be returned.
90 */
92
93 int getModelNumber(QString modelName);
94
95 SkyObjListModel *getTempModel() { return tempModel; }
96
97 signals:
98 void loadProgressUpdated(double progress);
99 void modelUpdated();
100
101 private:
102 void loadLists();
103 void loadObjectList(QList<SkyObjItem *> &skyObjectList, int type);
104 void loadNamedStarList();
105 void loadObjectsIntoModel(SkyObjListModel &model, QList<SkyObjItem *> &skyObjectList);
106
107 ObsConditions *m_ObsConditions{ nullptr };
108 QList<QList<SkyObjItem *>> m_ObjectList;
109 QList<SkyObjListModel *> m_ModelList;
110 bool showOnlyVisible{ true };
111 bool showOnlyFavorites{ true };
112 QList<SkyObjItem *> favoriteGalaxies;
113 QList<SkyObjItem *> favoriteNebulas;
114 QList<SkyObjItem *> favoriteClusters;
115 SkyObjListModel *tempModel{ nullptr };
116 std::unordered_map<int, CatalogsDB::CatalogObjectList> m_CatalogMap;
117 std::unordered_map<int, std::list<SkyObjItem>> m_CatalogSkyObjItems;
118};
Manages models for QML listviews of different types of sky-objects.
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...
ObjectList
Model type for different types of sky-objects.
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.
Represents a model for the list of interesting sky-objects to be displayed in the QML interface.
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:57:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.