Kstars
11#include <kstars_debug.h>
17 if (jsonData[
"version"].
toString() !=
"1.0.0")
19 qCCritical(KSTARS) <<
"Unhandled SkyMapView JSON schema version " << jsonData[
"version"].toString();
22 useAltAz = jsonData[
"useAltAz"].toBool();
23 viewAngle = jsonData[
"viewAngle"].toDouble();
24 mirror = jsonData[
"mirror"].toBool();
25 inverted = jsonData[
"inverted"].toBool();
26 fov = jsonData[
"fov"].isNull() ? NaN::d : jsonData[
"fov"].toDouble();
27 erectObserver = jsonData[
"erectObserver"].toBool();
35 {
"useAltAz", useAltAz},
36 {
"viewAngle", viewAngle},
38 {
"inverted", inverted},
40 {
"erectObserver", erectObserver}
50 QList<SkyMapView> views;
54 view.name =
i18nc(
"Set the sky-map view to zenith up",
"Zenith Up");
58 view.inverted =
false;
60 view.erectObserver =
false;
63 view.name =
i18nc(
"Set the sky-map view to zenith down",
"Zenith Down");
69 view.erectObserver =
false;
72 view.name =
i18nc(
"Set the sky-map view to north up",
"North Up");
73 view.useAltAz =
false;
76 view.inverted =
false;
78 view.erectObserver =
false;
81 view.name =
i18nc(
"Set the sky-map view to north down",
"North Down");
82 view.useAltAz =
false;
87 view.erectObserver =
false;
90 view.name =
i18nc(
"Set the sky-map view to match a Schmidt-Cassegrain telescope with erecting prism pointed upwards",
91 "SCT with upward diagonal");
95 view.inverted =
false;
97 view.erectObserver =
false;
100 view.name =
i18nc(
"Set the sky-map view to match the view through a typical Dobsonian telescope",
"Typical Dobsonian");
101 view.useAltAz =
true;
104 view.inverted =
true;
106 view.erectObserver =
true;
116 Q_ASSERT(!!KStarsData::Instance());
117 if (!KStarsData::Instance())
119 qCCritical(KSTARS) <<
"Cannot save sky map views, no KStarsData instance.";
122 KSUserDB *db = KStarsData::Instance()->userdb();
126 qCCritical(KSTARS) <<
"Cannot save sky map views, no KSUserDB instance.";
132 qCCritical(KSTARS) <<
"Failed to flush sky map views from the database";
135 for (
const auto &view : m_views)
138 success = success && result;
142 qCCritical(KSTARS) <<
"Failed to commit Sky Map View " << view.name <<
" to the database!";
150 Q_ASSERT(!!KStarsData::Instance());
151 if (!KStarsData::Instance())
153 qCCritical(KSTARS) <<
"Cannot read sky map views, no KStarsData instance.";
156 KSUserDB *db = KStarsData::Instance()->userdb();
160 qCCritical(KSTARS) <<
"Cannot save sky map views, no KSUserDB instance.";
168 qCCritical(KSTARS) <<
"Failed to read sky map views from the database!";
170 if (m_views.isEmpty())
172 m_views = defaults();
184 for (
auto it = m_views.begin(); it != m_views.end(); ++it)
186 if (it->name == name)
196 for (
auto it = m_views.begin(); it != m_views.end(); ++it)
198 if (it->name == name)
Single class to delegate all User database I/O.
bool AddSkyMapView(const SkyMapView &view)
Adds a new sky map view row in the database.
bool GetAllSkyMapViews(QList< SkyMapView > &skyMapViewList)
Gets all the sky map view rows from the database.
bool DeleteAllSkyMapViews()
Deletes all the sky map views stored in the database.
static void drop()
Drop the list.
static bool save()
Commit the list of views to the database.
static bool removeView(const QString &name)
Remove a view Note: This is currently an O(N) operation.
static std::optional< SkyMapView > viewNamed(const QString &name)
Get the view with the given name.
static const QList< SkyMapView > & readViews()
Read the list of views from the database.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
QString name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:53:00 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.