11#include "auxiliary/kspaths.h"
12#include "skycomponents/supernovaecomponent.h"
13#include "skycomponents/skymapcomposite.h"
14#include "ksnotification.h"
15#include "skyobjectuserdata.h"
16#include <kio/job_base.h>
17#include <kio/filecopyjob.h>
20#include "imageexporter.h"
22#include "observinglist.h"
24#include "dialogs/detaildialog.h"
25#include "oal/execute.h"
34#include <QtConcurrent>
36#include "kstars_debug.h"
39#include <qtskipemptyparts.h>
45void fatalErrorMessage(
QString fname)
47 qCCritical(KSTARS) <<
i18n(
"Critical File not Found: %1", fname);
48 KSNotification::sorry(
i18n(
"The file %1 could not be found. "
49 "KStars cannot run properly without this file. "
50 "KStars searches for this file in following locations:\n\n\t"
52 "It appears that your setup is broken.",
54 i18n(
"Critical File Not Found: %1", fname));
106 : m_Geo(
dms(0),
dms(0)), m_ksuserdb(),
107 temporaryTrail(false),
109 m_preUpdateID(0), m_updateID(0), m_preUpdateNumID(0), m_updateNumID(0), m_preUpdateNum(J2000), m_updateNum(J2000)
112 m_LogObject.reset(
new OAL::Log);
125 qDeleteAll(ADVtreeList);
135 if (!readTimeZoneRulebook())
137 fatalErrorMessage(
"TZrules.dat");
142 i18n(
"Upgrade existing user city db to support geographic elevation."));
164 "alter table city add column Elevation real default -10;") ==
168 "table in mycitydb.sqlite: &1")
169 .arg(query.lastError().text()));
188 fatalErrorMessage(
"citydb.sqlite");
207#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
209 SkyObjectUserdata::Type::image);
212 SkyObjectUserdata::Type::image);
220#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
222 SkyObjectUserdata::Type::website);
225 SkyObjectUserdata::Type::website);
247 LTime =
geo->UTtoLT(
ut());
258 if (
ut() > NextDSTChange)
259 resetToNewDST(
geo, automaticDSTchange);
265 if (
ut() < NextDSTChange)
266 resetToNewDST(
geo, automaticDSTchange);
272 if (std::abs(
ut().djd() - LastNumUpdate.
djd()) > 1.0)
280 if (std::abs(
ut().djd() - LastPlanetUpdate.
djd()) > 0.01)
287 if (std::abs(
ut().djd() - LastMoonUpdate.
djd()) > 0.00069444)
289 LastMoonUpdate =
ut();
295 if (std::abs(
ut().djd() - LastSkyUpdate.
djd()) > 0.1 / Options::zoomFactor() ||
clock()->isManualMode())
297 LastSkyUpdate =
ut();
306void KStarsData::syncUpdateIDs()
308 m_updateID = m_preUpdateID;
309 if (m_updateNumID == m_preUpdateNumID)
311 m_updateNumID = m_preUpdateNumID;
315unsigned int KStarsData::incUpdateID()
334 LST =
geo()->GSTtoLST(
ut().gst());
344 LTime =
geo()->UTtoLT(
ut());
358void KStarsData::resetToNewDST(
GeoLocation *geo,
const bool automaticDSTchange)
366 LTime =
geo->UTtoLT(
ut());
371 TimeRunsForward = scale >= 0;
390 double distance = 1e6;
392 dms lng(longitude), lat(latitude);
393 for (
auto oneCity : geoList)
395 double newDistance = oneCity->distanceTo(lng, lat);
396 if (newDistance < distance)
398 distance = newDistance;
409 Options::provinceName(), Options::countryName(), Options::timeZone(),
410 &(Rulebook[Options::dST()]), Options::elevation(),
false, 4));
422 Options::setCityName(m_Geo.
name());
423 Options::setProvinceName(m_Geo.
province());
424 Options::setCountryName(m_Geo.
country());
425 Options::setTimeZone(m_Geo.
TZ0());
426 Options::setElevation(m_Geo.
elevation());
427 Options::setLongitude(m_Geo.
lng()->
Degrees());
433 Options::setDST(key);
441 if ((name ==
"star") || (name ==
"nothing") || name.
isEmpty())
446bool KStarsData::readCityData()
451 if (citydb.
open() ==
false)
453 qCCritical(KSTARS) <<
"Unable to open city database file " << dbfile << citydb.
lastError().
text();
460 if (!get_query.exec(
"SELECT * FROM city"))
462 qCCritical(KSTARS) << get_query.lastError();
466 bool citiesFound =
false;
468 while (get_query.next())
472 QString province = get_query.value(2).toString();
474 dms lat =
dms(get_query.value(4).toString());
475 dms lng =
dms(get_query.value(5).toString());
476 double TZ = get_query.value(6).toDouble();
478 double elevation = get_query.value(8).toDouble();
481 geoList.
append(
new GeoLocation(lng, lat, name, province, country, TZ, TZrule, elevation,
true, 4));
496 if (!get_query.exec(
"SELECT * FROM city"))
498 qDebug() << Q_FUNC_INFO << get_query.lastError();
501 while (get_query.next())
504 QString province = get_query.value(2).toString();
506 dms lat =
dms(get_query.value(4).toString());
507 dms lng =
dms(get_query.value(5).toString());
508 double TZ = get_query.value(6).toDouble();
510 double elevation = get_query.value(8).toDouble();
513 geoList.
append(
new GeoLocation(lng, lat, name, province, country, TZ, TZrule, elevation,
false, 4));
522bool KStarsData::readTimeZoneRulebook()
526 if (KSUtils::openDataFile(file,
"TZrules.dat"))
530 while (!stream.atEnd())
537 QTime stime =
QTime(fields[3].
left(fields[3].indexOf(
':')).toInt(),
538 fields[3].mid(fields[3].indexOf(
':') + 1, fields[3].length()).toInt());
539 QTime rtime =
QTime(fields[6].
left(fields[6].indexOf(
':')).toInt(),
540 fields[6].mid(fields[6].indexOf(
':') + 1, fields[6].length()).toInt());
542 Rulebook[id] =
TimeZoneRule(fields[1], fields[2], stime, fields[4], fields[5], rtime);
553bool KStarsData::openUrlFile(
const QString &urlfile,
QFile &file)
557 bool fileFound =
false;
565 if (!localFile.
isEmpty() && KSUtils::openDataFile(file, localFile))
577 bool newDataFound(
false);
580 while (!lStream.atEnd())
581 urlData.
append(lStream.readLine());
588 for (
int i = 0; i < flist.
size(); i++)
595 if (fi_global.lastModified() > fi_local.lastModified())
600 QFile globalFile(flist[i]);
604 while (!gStream.atEnd())
606 QString line = gStream.readLine();
617 bool linefound(
false);
618 for (
int j = 0; j < urlData.
size(); ++j)
651 for (
int i = 0; i < urlData.
size(); i++)
653 outStream << urlData[i] <<
'\n';
664 if (KSUtils::openDataFile(file, urlfile))
667 qDebug() << Q_FUNC_INFO <<
"No localized URL file; using default English file.";
674 while (!readStream.atEnd())
676 QString line = readStream.readLine();
678 writeStream << line <<
'\n';
686 qDebug() << Q_FUNC_INFO <<
"Failed to copy default URL file to locale folder, modifying default object links is "
696bool KStarsData::readURLData(
const QString &urlfile, SkyObjectUserdata::Type type)
704 if (!openUrlFile(urlfile, file))
710 while (!stream.atEnd())
712 QString line = stream.readLine();
740 auto &data_element = m_user_data[
name];
741 data_element.addLink(title,
QUrl{ url },
type);
770bool KStarsData::readUserLog()
775 if (!KSUtils::openDataFile(file,
"userlog.dat"))
781 fullContents = stream.readAll();
786 const QLatin1String logStart(
"[KSLABEL:"), logEnd(
"[KSLogEnd]");
787 std::size_t currentEntryIndex = 0;
788 while (!buffer.isEmpty())
790 int startIndex, endIndex;
793 startIndex = buffer.indexOf(logStart) + logStart.size();
796 currentEntryIndex += startIndex;
797 endIndex = buffer.indexOf(logEnd, startIndex);
799 auto malformatError = [&]()
803 i18n(
"The user notes log file %1 is malformatted in the opening of the entry starting at %2. "
804 "KStars can still run without fully reading this file. "
805 "Press Continue to run KStars with whatever partial reading was successful. "
806 "The file may get truncated if KStars writes to the file later. Press Cancel to instead abort now and manually fix the problem. ",
824 int nameEndIndex = startIndex, openBracketCount = 1;
825 while (openBracketCount > 0 && nameEndIndex < endIndex)
827 if (buffer[nameEndIndex] ==
']')
829 else if (buffer[nameEndIndex] ==
'[')
833 if (openBracketCount > 0)
838 name = buffer.
mid(startIndex, (nameEndIndex - 1) - startIndex);
841 if (buffer[nameEndIndex] ==
'\n')
843 data = buffer.
mid(nameEndIndex, endIndex - nameEndIndex);
844 buffer = buffer.
mid(endIndex + logEnd.size() + 1);
845 currentEntryIndex += (endIndex + logEnd.size() + 1 - startIndex);
847 auto &data_element = m_user_data[
name];
848 data_element.userLog = data;
855bool KStarsData::readADVTreeData()
861 if (!KSUtils::openDataFile(file,
"advinterface.dat"))
867 while (!stream.atEnd())
869 int Type, interfaceIndex;
871 Line = stream.readLine();
882 Interface = Line.
mid(13);
889 Name = Line.
left(idx);
898 Link.remove(interfaceIndex, 11);
905 ADVTreeData *ADVData =
new ADVTreeData;
907 ADVData->Name = Name;
908 ADVData->Link =
Link;
909 ADVData->Type = Type;
911 ADVtreeList.
append(ADVData);
930 qDebug() << Q_FUNC_INFO <<
"Could not open file " << f.fileName();
935 while (!istream.
atEnd())
948 QString funcprefix =
"org.kde.kstars.SimClock.";
956 funcprefix =
"org.kde.kstars.";
965 qWarning() <<
"Could not parse line: " << line;
974 if (fn[0] ==
"lookTowards" && fn.
size() >= 2)
978 if (arg ==
"n" || arg ==
"north")
980 if (arg ==
"ne" || arg ==
"northeast")
982 if (arg ==
"e" || arg ==
"east")
984 if (arg ==
"se" || arg ==
"southeast")
986 if (arg ==
"s" || arg ==
"south")
988 if (arg ==
"sw" || arg ==
"southwest")
990 if (arg ==
"w" || arg ==
"west")
992 if (arg ==
"nw" || arg ==
"northwest")
997 map->setFocusAltAz(
dms(90.0), map->focus()->az());
998 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
999 map->setDestination(*map->focus());
1003 if (arg ==
"z" || arg ==
"zenith")
1006 map->setFocusAltAz(
dms(90.0), map->focus()->az());
1007 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
1008 map->setDestination(*map->focus());
1019 map->setFocus(target);
1020 map->focus()->EquatorialToHorizontal(&LST,
geo()->lat());
1021 map->setDestination(*map->focus());
1025 else if (fn[0] ==
"setRaDec" && fn.
size() == 3)
1030 ok = r.setFromString(fn[1],
false);
1032 ok = d.setFromString(fn[2],
true);
1035 map->setFocus(r, d);
1036 map->focus()->EquatorialToHorizontal(&LST,
geo()->lat());
1040 else if (fn[0] ==
"setAltAz" && fn.
size() == 3)
1043 dms az(0.0), alt(0.0);
1047 ok = az.setFromString(fn[2]);
1050 map->setFocusAltAz(alt, az);
1051 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
1055 else if (fn[0] ==
"loadColorScheme")
1059 qCDebug(KSTARS) <<
"Loading Color scheme: " << csName;
1065 if (csName ==
i18nc(
"use default color scheme",
"Default Colors"))
1066 filename =
"classic.colors";
1067 if (csName ==
i18nc(
"use 'star chart' color scheme",
"Star Chart"))
1068 filename =
"chart.colors";
1069 if (csName ==
i18nc(
"use 'night vision' color scheme",
"Night Vision"))
1070 filename =
"night.colors";
1082 for (
int i = 0; i < filename.
length(); ++i)
1083 if (filename.
at(i) ==
' ')
1086 filename = filename.
append(
".colors");
1091 qDebug() << Q_FUNC_INFO <<
QString(
"Unable to load color scheme named %1. Also tried %2.")
1092 .
arg(csName, filename);
1095 else if (fn[0] ==
"zoom" && fn.
size() == 2)
1098 double z = fn[1].toDouble(&ok);
1105 Options::setZoomFactor(z);
1109 else if (fn[0] ==
"zoomIn")
1111 if (Options::zoomFactor() < MAXZOOM)
1113 Options::setZoomFactor(Options::zoomFactor() * DZOOM);
1117 else if (fn[0] ==
"zoomOut")
1119 if (Options::zoomFactor() > MINZOOM)
1121 Options::setZoomFactor(Options::zoomFactor() / DZOOM);
1125 else if (fn[0] ==
"defaultZoom")
1127 Options::setZoomFactor(DEFAULTZOOM);
1130 else if (fn[0] ==
"setLocalTime" && fn.
size() == 7)
1134 int yr(0), mth(0), day(0), hr(0), mnt(0), sec(0);
1135 yr = fn[1].toInt(&ok);
1137 mth = fn[2].toInt(&ok);
1139 day = fn[3].toInt(&ok);
1141 hr = fn[4].toInt(&ok);
1143 mnt = fn[5].toInt(&ok);
1145 sec = fn[6].toInt(&ok);
1153 qWarning() <<
ki18n(
"Could not set time: %1 / %2 / %3 ; %4:%5:%6")
1163 else if (fn[0] ==
"changeViewOption" && fn.
size() == 3)
1165 bool bOk(
false), dOk(
false);
1169 if (fn[2].toLower() ==
"true")
1174 if (fn[2].toLower() ==
"false")
1191 double dVal = fn[2].toDouble(&dOk);
1199 if (fn[1] ==
"ShowStars" && bOk)
1201 Options::setShowStars(bVal);
1204 if (fn[1] ==
"ShowCLines" && bOk)
1206 Options::setShowCLines(bVal);
1209 if (fn[1] ==
"ShowCNames" && bOk)
1211 Options::setShowCNames(bVal);
1214 if (fn[1] ==
"ShowMilkyWay" && bOk)
1216 Options::setShowMilkyWay(bVal);
1219 if (fn[1] ==
"ShowEquatorialGrid" && bOk)
1221 Options::setShowEquatorialGrid(bVal);
1224 if (fn[1] ==
"ShowHorizontalGrid" && bOk)
1226 Options::setShowHorizontalGrid(bVal);
1229 if (fn[1] ==
"ShowEquator" && bOk)
1231 Options::setShowEquator(bVal);
1234 if (fn[1] ==
"ShowEcliptic" && bOk)
1236 Options::setShowEcliptic(bVal);
1239 if (fn[1] ==
"ShowHorizon" && bOk)
1241 Options::setShowHorizon(bVal);
1244 if (fn[1] ==
"ShowGround" && bOk)
1246 Options::setShowGround(bVal);
1249 if (fn[1] ==
"ShowSun" && bOk)
1251 Options::setShowSun(bVal);
1254 if (fn[1] ==
"ShowMoon" && bOk)
1256 Options::setShowMoon(bVal);
1259 if (fn[1] ==
"ShowMercury" && bOk)
1261 Options::setShowMercury(bVal);
1264 if (fn[1] ==
"ShowVenus" && bOk)
1266 Options::setShowVenus(bVal);
1269 if (fn[1] ==
"ShowMars" && bOk)
1271 Options::setShowMars(bVal);
1274 if (fn[1] ==
"ShowJupiter" && bOk)
1276 Options::setShowJupiter(bVal);
1279 if (fn[1] ==
"ShowSaturn" && bOk)
1281 Options::setShowSaturn(bVal);
1284 if (fn[1] ==
"ShowUranus" && bOk)
1286 Options::setShowUranus(bVal);
1289 if (fn[1] ==
"ShowNeptune" && bOk)
1291 Options::setShowNeptune(bVal);
1295 if (fn[1] ==
"ShowAsteroids" && bOk)
1297 Options::setShowAsteroids(bVal);
1300 if (fn[1] ==
"ShowComets" && bOk)
1302 Options::setShowComets(bVal);
1305 if (fn[1] ==
"ShowSolarSystem" && bOk)
1307 Options::setShowSolarSystem(bVal);
1310 if (fn[1] ==
"ShowDeepSky" && bOk)
1312 Options::setShowDeepSky(bVal);
1315 if (fn[1] ==
"ShowSupernovae" && bOk)
1317 Options::setShowSupernovae(bVal);
1320 if (fn[1] ==
"ShowStarNames" && bOk)
1322 Options::setShowStarNames(bVal);
1325 if (fn[1] ==
"ShowStarMagnitudes" && bOk)
1327 Options::setShowStarMagnitudes(bVal);
1330 if (fn[1] ==
"ShowAsteroidNames" && bOk)
1332 Options::setShowAsteroidNames(bVal);
1335 if (fn[1] ==
"ShowCometNames" && bOk)
1337 Options::setShowCometNames(bVal);
1340 if (fn[1] ==
"ShowPlanetNames" && bOk)
1342 Options::setShowPlanetNames(bVal);
1345 if (fn[1] ==
"ShowPlanetImages" && bOk)
1347 Options::setShowPlanetImages(bVal);
1351 if (fn[1] ==
"UseAltAz" && bOk)
1353 Options::setUseAltAz(bVal);
1356 if (fn[1] ==
"UseRefraction" && bOk)
1358 Options::setUseRefraction(bVal);
1361 if (fn[1] ==
"UseAutoLabel" && bOk)
1363 Options::setUseAutoLabel(bVal);
1366 if (fn[1] ==
"UseAutoTrail" && bOk)
1368 Options::setUseAutoTrail(bVal);
1371 if (fn[1] ==
"UseAnimatedSlewing" && bOk)
1373 Options::setUseAnimatedSlewing(bVal);
1376 if (fn[1] ==
"FadePlanetTrails" && bOk)
1378 Options::setFadePlanetTrails(bVal);
1381 if (fn[1] ==
"SlewTimeScale" && dOk)
1383 Options::setSlewTimeScale(dVal);
1386 if (fn[1] ==
"ZoomFactor" && dOk)
1388 Options::setZoomFactor(dVal);
1392 if (fn[1] ==
"StarDensity" && dOk)
1394 Options::setStarDensity(dVal);
1398 if (fn[1] ==
"MagLimitDrawDeepSky" && dOk)
1400 Options::setMagLimitDrawDeepSky(dVal);
1403 if (fn[1] ==
"MagLimitDrawDeepSkyZoomOut" && dOk)
1405 Options::setMagLimitDrawDeepSkyZoomOut(dVal);
1408 if (fn[1] ==
"StarLabelDensity" && dOk)
1410 Options::setStarLabelDensity(dVal);
1413 if (fn[1] ==
"MagLimitHideStar" && dOk)
1415 Options::setMagLimitHideStar(dVal);
1418 if (fn[1] ==
"MagLimitAsteroid" && dOk)
1420 Options::setMagLimitAsteroid(dVal);
1423 if (fn[1] ==
"AsteroidLabelDensity" && dOk)
1425 Options::setAsteroidLabelDensity(dVal);
1428 if (fn[1] ==
"MaxRadCometName" && dOk)
1430 Options::setMaxRadCometName(dVal);
1435 if (fn[1] ==
"UseLatinConstellationNames" && bOk)
1437 Options::setUseLatinConstellNames(
true);
1438 Options::setUseLocalConstellNames(
false);
1439 Options::setUseAbbrevConstellNames(
false);
1442 if (fn[1] ==
"UseLocalConstellationNames" && bOk)
1444 Options::setUseLatinConstellNames(
false);
1445 Options::setUseLocalConstellNames(
true);
1446 Options::setUseAbbrevConstellNames(
false);
1449 if (fn[1] ==
"UseAbbrevConstellationNames" && bOk)
1451 Options::setUseLatinConstellNames(
false);
1452 Options::setUseLocalConstellNames(
false);
1453 Options::setUseAbbrevConstellNames(
true);
1457 else if (fn[0] ==
"setGeoLocation" && (fn.
size() == 3 || fn.
size() == 4))
1459 QString city(fn[1]), province, country(fn[2]);
1467 bool cityFound(
false);
1482 qWarning() <<
i18n(
"Could not set location named %1, %2, %3", city, province, country);
1491 Q_UNUSED(scriptname)
1499 visibleFOVs.
clear();
1501 foreach (
FOV *fov, availFOVs)
1503 if (Options::fOVNames().contains(fov->name()))
1507 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
1510 const QStringList m_fOVNames = Options::fOVNames();
1514 foreach (
FOV *fov, visibleFOVs)
1518 Options::setFOVNames(all.
intersect(names).values());
1522Execute *KStarsData::executeSession()
1524 if (!m_Execute.get())
1525 m_Execute.reset(
new Execute());
1527 return m_Execute.get();
1533 if (!m_ImageExporter.get())
1536 return m_ImageExporter.get();
1540std::pair<bool, QString>
1545 findUserData(name).links[data.type].push_back(data);
1549 const auto isImage = data.type == SkyObjectUserdata::Type::image;
1562 i18n(
"Custom image-links file could not be opened.\nLink cannot "
1563 "be recorded for future sessions.") :
1564 i18n(
"Custom information-links file could not be opened.\nLink "
1565 "cannot be recorded for future sessions.") };
1568 entry = name +
':' + data.title +
':' + data.url.
toString();
1570 stream << entry <<
'\n';
1574 return {
true, {} };
1577std::pair<bool, QString> updateLocalDatabase(SkyObjectUserdata::Type type,
1581 QString TempFileName, file_line;
1587 bool replace = !replace_line.
isEmpty();
1590 return {
false,
"Invalid update request." };
1592 TempFileName = TempFile.
fileName();
1597 case SkyObjectUserdata::Type::website:
1605 case SkyObjectUserdata::Type::image:
1620 return {
false,
"Failed to open " + URLFile.
fileName() +
1621 "KStars cannot save to user database" };
1629 while (!temp_stream.atEnd())
1631 file_line = temp_stream.readLine();
1633 if (file_line == search_line)
1637 (out_stream) << replace_line <<
'\n';
1642 (out_stream) << file_line <<
'\n';
1646 if (!found && replace)
1648 out_stream << replace_line <<
'\n';
1653 return {
true, {} };
1657 const unsigned int index,
1662 auto &entry = findUserData(name);
1663 if (index >= entry.links[data.type].size())
1664 return {
false,
i18n(
"Userdata at index %1 does not exist.", index) };
1666 entry.links[data.type][index] = data;
1670 search_line += data.title;
1672 search_line += data.url.
toString();
1674 QString replace_line = name +
':' + data.title +
':' + data.url.
toString();
1675 return updateLocalDatabase(data.type, search_line, replace_line);
1679 const unsigned int index,
1680 SkyObjectUserdata::Type type)
1684 auto &linkList = findUserData(name).links[type];
1685 if (index >= linkList.size())
1686 return {
false,
i18n(
"Userdata at index %1 does not exist.", index) };
1688 const auto data = linkList[index];
1689 linkList.
erase(linkList.begin() + index);
1693 search_line += data.title;
1695 search_line += data.url.toString();
1697 QString replace_line = name +
':' + data.title +
':' + data.url.toString();
1698 return updateLocalDatabase(data.type, search_line,
"");
1712 if (newLog == (
i18n(
"Record here observation logs and/or data on %1.", name)) ||
1714 return {
true, {} };
1717 QString KSLabel =
"[KSLABEL:" + name +
']';
1731 const auto &userLog = m_user_data[name].userLog;
1734 if (!userLog.isEmpty())
1736 int startIndex, endIndex;
1739 startIndex = logs.
indexOf(KSLabel);
1740 sub = logs.
mid(startIndex);
1741 endIndex = sub.
indexOf(
"[KSLogEnd]");
1743 logs.
remove(startIndex, endIndex + 11);
1747 logs.
append(KSLabel +
'\n' + newLog.
trimmed() +
"\n[KSLogEnd]\n");
1752 return {
false,
"Cannot write to user log file" };
1761 findUserData(name).userLog = newLog;
1762 return {
true, {} };
1769 return findUserData(name);
1774 auto element = m_user_data.find(name);
1775 if (element != m_user_data.end())
1777 return element->second;
1782 const auto *
object = m_SkyComposite->findByName(name);
1783 if (
object !=
nullptr)
1785 return m_user_data[
object->name()];
1788 return m_user_data[
name];
bool load(const QString &filename)
Load a color scheme from a *.colors file filename the filename of the color scheme to be loaded.
Executes an observation session.
A simple class encapsulating a Field-of-View symbol.
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
const CachingDms * lat() const
const CachingDms * lng() const
QString translatedCountry() const
void setLat(const dms &l)
Set latitude according to dms argument.
QString translatedName() const
QString translatedProvince() const
Backends for exporting a sky image, either raster or vector, with a legend.
KLocalizedString subs(const KLocalizedString &a, int fieldWidth=0, QChar fillChar=QLatin1Char(' ')) const
There are several time-dependent values used in position calculations, that are not specific to an ob...
bool Initialize()
Initialize KStarsDB while running splash screen.
KStarsData is the backbone of KStars.
void setNextDSTChange(const KStarsDateTime &dt)
Set the NextDSTChange member.
void setLocation(const GeoLocation &l)
Set the GeoLocation according to the argument.
std::pair< bool, QString > deleteUserData(const QString &name, const unsigned int index, SkyObjectUserdata::Type type)
Remove data of type from the user data at index for the object with name, both in memory and on disk.
void changeDateTime(const KStarsDateTime &newDate)
Change the current simulation date/time to the KStarsDateTime argument.
~KStarsData() override
Destructor.
std::pair< bool, QString > editUserData(const QString &name, const unsigned int index, const SkyObjectUserdata::LinkData &data)
Replace data in the user data at index for the object with name, both in memory and on disk.
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
void updateTime(GeoLocation *geo, const bool automaticDSTchange=true)
Update the Simulation Clock.
bool initialize()
Initialize KStarsData while running splash screen.
SkyObject * objectNamed(const QString &name)
Find object by name.
GeoLocation * nearestLocation(double longitude, double latitude)
nearestLocation Return nearest location to the given longitude and latitude coordinates
void setTimeDirection(float scale)
Sets the direction of time and stores it in bool TimeRunForwards.
std::pair< bool, QString > updateUserLog(const QString &name, const QString &newLog)
Update the user log of the object with the name to contain newLog (find and replace).
ColorScheme * colorScheme()
const SkyObjectUserdata::Data & getUserData(const QString &name)
Get a reference to the user data of an object with the name name.
void skyUpdate(bool)
Should be used to refresh skymap.
void syncLST()
Sync the LST with the simulation clock.
const KStarsDateTime & ut() const
void syncFOV()
Synchronize list of visible FOVs and list of selected FOVs in Options.
bool executeScript(const QString &name, SkyMap *map)
Execute a script.
void progressText(const QString &text)
Signal that specifies the text that should be drawn in the KStarsSplash window.
bool isTimeRunningForward() const
Returns true if time is running forward else false.
Q_INVOKABLE SimClock * clock()
void geoChanged()
Emitted when geo location changed.
void setLocationFromOptions()
Set the GeoLocation according to the values stored in the configuration file.
SkyMapComposite * skyComposite()
void setSnapNextFocus(bool b=true)
Disable or re-enable the slewing animation for the next Focus change.
std::pair< bool, QString > addToUserData(const QString &name, const SkyObjectUserdata::LinkData &data)
Adds a link data to the user data for the object with name, both in memory and on disk.
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
static KStars * Instance()
static bool Closing
Set to true when the application is being closed.
Tool window for managing a custom list of objects.
Q_SCRIPTABLE Q_NOREPLY void setUTC(const KStarsDateTime &newtime)
DBUS function to set the time of the SimClock.
SkyMapComposite is the root object in the object hierarchy of the sky map.
SkyObject * findByName(const QString &name, bool exact=true) override
Search the children of this SkyMapComposite for a SkyObject whose name matches the argument.
void updateSolarSystemBodies(KSNumbers *num) override
Delegate planet position updates to the SolarSystemComposite.
void update(KSNumbers *num=nullptr) override
Delegate update-position requests to all sub components.
void updateMoons(KSNumbers *num) override
Delegate moon position updates to the SolarSystemComposite.
This is the canvas on which the sky is painted.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
This class provides the information needed to determine whether Daylight Savings Time (DST; a....
KStarsDateTime nextDSTChange() const
bool equals(TimeZoneRule *r)
void reset_with_ltime(KStarsDateTime <ime, const double TZoffset, const bool time_runs_forward, const bool automaticDSTchange=false)
Recalculate next dst change and if DST is active by a given local time with timezone offset and time ...
An angle, stored as degrees, but expressible in many ways.
virtual bool setFromString(const QString &s, bool isDeg=true)
Attempt to parse the string argument as a dms value, and set the dms object accordingly.
const double & Degrees() const
KLocalizedString KI18N_EXPORT ki18n(const char *text)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
QString name(GameStandardAction id)
KIOCORE_EXPORT FileCopyJob * file_copy(const QUrl &src, const QUrl &dest, int permissions=-1, JobFlags flags=DefaultFlags)
ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
QStringView country(QStringView ifopt)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
QString filePath(const QString &fileName) const const
bool exists() const const
virtual QString fileName() const const override
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
void setFileName(const QString &name)
virtual void close() override
void append(QList< T > &&value)
qsizetype removeAll(const AT &t)
void removeAt(qsizetype i)
void replace(qsizetype i, parameter_type value)
qsizetype size() const const
QString languageToString(Language language)
QList< Key > keys() const const
iterator insert(const T &value)
QSet< T > & intersect(const QSet< T > &other)
QSqlDatabase addDatabase(QSqlDriver *driver, const QString &connectionName)
QSqlError lastError() const const
QSqlRecord record(const QString &tablename) const const
void setDatabaseName(const QString &name)
QStringList tables(QSql::TableType type) const const
QString text() const const
bool contains(const QString &name) const const
QStringList standardLocations(StandardLocation type)
QString & append(QChar ch)
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
iterator erase(const_iterator first, const_iterator last)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
QString number(double n, char format, int precision)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString toLower() const const
QString trimmed() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
qsizetype indexOf(const QRegularExpression &re, qsizetype from) const const
QString join(QChar separator) const const
bool isEmpty() const const
QString toString() const const
QTextStream & left(QTextStream &stream)
QFuture< T > run(Function function,...)
virtual QString fileName() const const override
void setAutoRemove(bool b)
QString readLine(qint64 maxlen)
QUrl fromLocalFile(const QString &localFile)
QString toString(FormattingOptions options) const const
Stores Users' Logs, Pictures and Websites regarding an object in the sky.
Stores the tite and URL of a webpage.