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");
208 SkyObjectUserdata::Type::image);
216 SkyObjectUserdata::Type::website);
237 LTime =
geo->UTtoLT(
ut());
248 if (
ut() > NextDSTChange)
249 resetToNewDST(
geo, automaticDSTchange);
255 if (
ut() < NextDSTChange)
256 resetToNewDST(
geo, automaticDSTchange);
262 if (std::abs(
ut().djd() - LastNumUpdate.
djd()) > 1.0)
270 if (std::abs(
ut().djd() - LastPlanetUpdate.
djd()) > 0.01)
277 if (std::abs(
ut().djd() - LastMoonUpdate.
djd()) > 0.00069444)
279 LastMoonUpdate =
ut();
285 if (std::abs(
ut().djd() - LastSkyUpdate.
djd()) > 0.1 / Options::zoomFactor() ||
clock()->isManualMode())
287 LastSkyUpdate =
ut();
296void KStarsData::syncUpdateIDs()
298 m_updateID = m_preUpdateID;
299 if (m_updateNumID == m_preUpdateNumID)
301 m_updateNumID = m_preUpdateNumID;
305unsigned int KStarsData::incUpdateID()
324 LST =
geo()->GSTtoLST(
ut().gst());
334 LTime =
geo()->UTtoLT(
ut());
348void KStarsData::resetToNewDST(
GeoLocation *geo,
const bool automaticDSTchange)
356 LTime =
geo->UTtoLT(
ut());
361 TimeRunsForward = scale >= 0;
380 double distance = 1e6;
382 dms lng(longitude), lat(latitude);
383 for (
auto oneCity : geoList)
385 double newDistance = oneCity->distanceTo(lng, lat);
386 if (newDistance < distance)
388 distance = newDistance;
399 Options::provinceName(), Options::countryName(), Options::timeZone(),
400 &(Rulebook[Options::dST()]), Options::elevation(),
false, 4));
412 Options::setCityName(m_Geo.
name());
413 Options::setProvinceName(m_Geo.
province());
414 Options::setCountryName(m_Geo.
country());
415 Options::setTimeZone(m_Geo.
TZ0());
416 Options::setElevation(m_Geo.
elevation());
417 Options::setLongitude(m_Geo.
lng()->
Degrees());
423 Options::setDST(key);
431 if ((name ==
"star") || (name ==
"nothing") || name.
isEmpty())
436bool KStarsData::readCityData()
441 if (citydb.
open() ==
false)
443 qCCritical(KSTARS) <<
"Unable to open city database file " << dbfile << citydb.
lastError().
text();
450 if (!get_query.exec(
"SELECT * FROM city"))
452 qCCritical(KSTARS) << get_query.lastError();
456 bool citiesFound =
false;
458 while (get_query.next())
462 QString province = get_query.value(2).toString();
464 dms lat =
dms(get_query.value(4).toString());
465 dms lng =
dms(get_query.value(5).toString());
466 double TZ = get_query.value(6).toDouble();
468 double elevation = get_query.value(8).toDouble();
471 geoList.
append(
new GeoLocation(lng, lat, name, province, country, TZ, TZrule, elevation,
true, 4));
486 if (!get_query.exec(
"SELECT * FROM city"))
488 qDebug() << Q_FUNC_INFO << get_query.lastError();
491 while (get_query.next())
494 QString province = get_query.value(2).toString();
496 dms lat =
dms(get_query.value(4).toString());
497 dms lng =
dms(get_query.value(5).toString());
498 double TZ = get_query.value(6).toDouble();
500 double elevation = get_query.value(8).toDouble();
503 geoList.
append(
new GeoLocation(lng, lat, name, province, country, TZ, TZrule, elevation,
false, 4));
512bool KStarsData::readTimeZoneRulebook()
516 if (KSUtils::openDataFile(file,
"TZrules.dat"))
520 while (!stream.atEnd())
527 QTime stime =
QTime(fields[3].leftRef(fields[3].indexOf(
':')).toInt(),
528 fields[3].midRef(fields[3].indexOf(
':') + 1, fields[3].length()).toInt());
529 QTime rtime =
QTime(fields[6].leftRef(fields[6].indexOf(
':')).toInt(),
530 fields[6].midRef(fields[6].indexOf(
':') + 1, fields[6].length()).toInt());
532 Rulebook[id] =
TimeZoneRule(fields[1], fields[2], stime, fields[4], fields[5], rtime);
543bool KStarsData::openUrlFile(
const QString &urlfile,
QFile &file)
547 bool fileFound =
false;
555 if (!localFile.
isEmpty() && KSUtils::openDataFile(file, localFile))
567 bool newDataFound(
false);
570 while (!lStream.atEnd())
571 urlData.
append(lStream.readLine());
576 QStringList flist = KSPaths::locateAll(QStandardPaths::DataLocation, urlfile);
578 for (
int i = 0; i < flist.
size(); i++)
585 if (fi_global.lastModified() > fi_local.lastModified())
590 QFile globalFile(flist[i]);
594 while (!gStream.atEnd())
596 QString line = gStream.readLine();
607 bool linefound(
false);
608 for (
int j = 0; j < urlData.
size(); ++j)
641 for (
int i = 0; i < urlData.
size(); i++)
643 outStream << urlData[i] <<
'\n';
654 if (KSUtils::openDataFile(file, urlfile))
657 qDebug() << Q_FUNC_INFO <<
"No localized URL file; using default English file.";
664 while (!readStream.atEnd())
666 QString line = readStream.readLine();
668 writeStream << line <<
'\n';
676 qDebug() << Q_FUNC_INFO <<
"Failed to copy default URL file to locale folder, modifying default object links is "
686bool KStarsData::readURLData(
const QString &urlfile, SkyObjectUserdata::Type type)
694 if (!openUrlFile(urlfile, file))
700 while (!stream.atEnd())
702 QString line = stream.readLine();
730 auto &data_element = m_user_data[
name];
731 data_element.addLink(title,
QUrl{ url },
type);
760bool KStarsData::readUserLog()
765 if (!KSUtils::openDataFile(file,
"userlog.dat"))
771 fullContents = stream.readAll();
775 QStringRef buffer(&fullContents);
776 const QLatin1String logStart(
"[KSLABEL:"), logEnd(
"[KSLogEnd]");
777 std::size_t currentEntryIndex = 0;
778 while (!buffer.isEmpty())
780 int startIndex, endIndex;
781 QStringRef sub,
name, data;
783 startIndex = buffer.indexOf(logStart) + logStart.size();
786 currentEntryIndex += startIndex;
787 endIndex = buffer.indexOf(logEnd, startIndex);
789 auto malformatError = [&]()
793 i18n(
"The user notes log file %1 is malformatted in the opening of the entry starting at %2. "
794 "KStars can still run without fully reading this file. "
795 "Press Continue to run KStars with whatever partial reading was successful. "
796 "The file may get truncated if KStars writes to the file later. Press Cancel to instead abort now and manually fix the problem. ",
814 int nameEndIndex = startIndex, openBracketCount = 1;
815 while (openBracketCount > 0 && nameEndIndex < endIndex)
817 if (buffer[nameEndIndex] ==
']')
819 else if (buffer[nameEndIndex] ==
'[')
823 if (openBracketCount > 0)
828 name = buffer.
mid(startIndex, (nameEndIndex - 1) - startIndex);
831 if (buffer[nameEndIndex] ==
'\n')
833 data = buffer.mid(nameEndIndex, endIndex - nameEndIndex);
834 buffer = buffer.mid(endIndex + logEnd.size() + 1);
835 currentEntryIndex += (endIndex + logEnd.size() + 1 - startIndex);
837 auto &data_element = m_user_data[
name.toString()];
838 data_element.userLog = data.toString();
845bool KStarsData::readADVTreeData()
851 if (!KSUtils::openDataFile(file,
"advinterface.dat"))
857 while (!stream.atEnd())
859 int Type, interfaceIndex;
861 Line = stream.readLine();
872 Interface = Line.
mid(13);
879 Name = Line.
left(idx);
888 Link.remove(interfaceIndex, 11);
895 ADVTreeData *ADVData =
new ADVTreeData;
897 ADVData->Name = Name;
898 ADVData->Link =
Link;
899 ADVData->Type = Type;
901 ADVtreeList.
append(ADVData);
920 qDebug() << Q_FUNC_INFO <<
"Could not open file " << f.fileName();
925 while (!istream.
atEnd())
938 QString funcprefix =
"org.kde.kstars.SimClock.";
946 funcprefix =
"org.kde.kstars.";
955 qWarning() <<
"Could not parse line: " << line;
964 if (fn[0] ==
"lookTowards" && fn.
size() >= 2)
968 if (arg ==
"n" || arg ==
"north")
970 if (arg ==
"ne" || arg ==
"northeast")
972 if (arg ==
"e" || arg ==
"east")
974 if (arg ==
"se" || arg ==
"southeast")
976 if (arg ==
"s" || arg ==
"south")
978 if (arg ==
"sw" || arg ==
"southwest")
980 if (arg ==
"w" || arg ==
"west")
982 if (arg ==
"nw" || arg ==
"northwest")
987 map->setFocusAltAz(
dms(90.0), map->focus()->az());
988 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
989 map->setDestination(*map->focus());
993 if (arg ==
"z" || arg ==
"zenith")
996 map->setFocusAltAz(
dms(90.0), map->focus()->az());
997 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
998 map->setDestination(*map->focus());
1009 map->setFocus(target);
1010 map->focus()->EquatorialToHorizontal(&LST,
geo()->lat());
1011 map->setDestination(*map->focus());
1015 else if (fn[0] ==
"setRaDec" && fn.
size() == 3)
1020 ok = r.setFromString(fn[1],
false);
1022 ok = d.setFromString(fn[2],
true);
1025 map->setFocus(r, d);
1026 map->focus()->EquatorialToHorizontal(&LST,
geo()->lat());
1030 else if (fn[0] ==
"setAltAz" && fn.
size() == 3)
1033 dms az(0.0), alt(0.0);
1037 ok = az.setFromString(fn[2]);
1040 map->setFocusAltAz(alt, az);
1041 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
1045 else if (fn[0] ==
"loadColorScheme")
1049 qCDebug(KSTARS) <<
"Loading Color scheme: " << csName;
1055 if (csName ==
i18nc(
"use default color scheme",
"Default Colors"))
1056 filename =
"classic.colors";
1057 if (csName ==
i18nc(
"use 'star chart' color scheme",
"Star Chart"))
1058 filename =
"chart.colors";
1059 if (csName ==
i18nc(
"use 'night vision' color scheme",
"Night Vision"))
1060 filename =
"night.colors";
1072 for (
int i = 0; i < filename.
length(); ++i)
1073 if (filename.
at(i) ==
' ')
1076 filename = filename.
append(
".colors");
1081 qDebug() << Q_FUNC_INFO <<
QString(
"Unable to load color scheme named %1. Also tried %2.")
1082 .
arg(csName, filename);
1085 else if (fn[0] ==
"zoom" && fn.
size() == 2)
1088 double z = fn[1].toDouble(&ok);
1095 Options::setZoomFactor(z);
1099 else if (fn[0] ==
"zoomIn")
1101 if (Options::zoomFactor() < MAXZOOM)
1103 Options::setZoomFactor(Options::zoomFactor() * DZOOM);
1107 else if (fn[0] ==
"zoomOut")
1109 if (Options::zoomFactor() > MINZOOM)
1111 Options::setZoomFactor(Options::zoomFactor() / DZOOM);
1115 else if (fn[0] ==
"defaultZoom")
1117 Options::setZoomFactor(DEFAULTZOOM);
1120 else if (fn[0] ==
"setLocalTime" && fn.
size() == 7)
1124 int yr(0), mth(0), day(0), hr(0), mnt(0), sec(0);
1125 yr = fn[1].toInt(&ok);
1127 mth = fn[2].toInt(&ok);
1129 day = fn[3].toInt(&ok);
1131 hr = fn[4].toInt(&ok);
1133 mnt = fn[5].toInt(&ok);
1135 sec = fn[6].toInt(&ok);
1143 qWarning() <<
ki18n(
"Could not set time: %1 / %2 / %3 ; %4:%5:%6")
1153 else if (fn[0] ==
"changeViewOption" && fn.
size() == 3)
1155 bool bOk(
false), dOk(
false);
1159 if (fn[2].toLower() ==
"true")
1164 if (fn[2].toLower() ==
"false")
1181 double dVal = fn[2].toDouble(&dOk);
1189 if (fn[1] ==
"ShowStars" && bOk)
1191 Options::setShowStars(bVal);
1194 if (fn[1] ==
"ShowCLines" && bOk)
1196 Options::setShowCLines(bVal);
1199 if (fn[1] ==
"ShowCNames" && bOk)
1201 Options::setShowCNames(bVal);
1204 if (fn[1] ==
"ShowMilkyWay" && bOk)
1206 Options::setShowMilkyWay(bVal);
1209 if (fn[1] ==
"ShowEquatorialGrid" && bOk)
1211 Options::setShowEquatorialGrid(bVal);
1214 if (fn[1] ==
"ShowHorizontalGrid" && bOk)
1216 Options::setShowHorizontalGrid(bVal);
1219 if (fn[1] ==
"ShowEquator" && bOk)
1221 Options::setShowEquator(bVal);
1224 if (fn[1] ==
"ShowEcliptic" && bOk)
1226 Options::setShowEcliptic(bVal);
1229 if (fn[1] ==
"ShowHorizon" && bOk)
1231 Options::setShowHorizon(bVal);
1234 if (fn[1] ==
"ShowGround" && bOk)
1236 Options::setShowGround(bVal);
1239 if (fn[1] ==
"ShowSun" && bOk)
1241 Options::setShowSun(bVal);
1244 if (fn[1] ==
"ShowMoon" && bOk)
1246 Options::setShowMoon(bVal);
1249 if (fn[1] ==
"ShowMercury" && bOk)
1251 Options::setShowMercury(bVal);
1254 if (fn[1] ==
"ShowVenus" && bOk)
1256 Options::setShowVenus(bVal);
1259 if (fn[1] ==
"ShowMars" && bOk)
1261 Options::setShowMars(bVal);
1264 if (fn[1] ==
"ShowJupiter" && bOk)
1266 Options::setShowJupiter(bVal);
1269 if (fn[1] ==
"ShowSaturn" && bOk)
1271 Options::setShowSaturn(bVal);
1274 if (fn[1] ==
"ShowUranus" && bOk)
1276 Options::setShowUranus(bVal);
1279 if (fn[1] ==
"ShowNeptune" && bOk)
1281 Options::setShowNeptune(bVal);
1285 if (fn[1] ==
"ShowAsteroids" && bOk)
1287 Options::setShowAsteroids(bVal);
1290 if (fn[1] ==
"ShowComets" && bOk)
1292 Options::setShowComets(bVal);
1295 if (fn[1] ==
"ShowSolarSystem" && bOk)
1297 Options::setShowSolarSystem(bVal);
1300 if (fn[1] ==
"ShowDeepSky" && bOk)
1302 Options::setShowDeepSky(bVal);
1305 if (fn[1] ==
"ShowSupernovae" && bOk)
1307 Options::setShowSupernovae(bVal);
1310 if (fn[1] ==
"ShowStarNames" && bOk)
1312 Options::setShowStarNames(bVal);
1315 if (fn[1] ==
"ShowStarMagnitudes" && bOk)
1317 Options::setShowStarMagnitudes(bVal);
1320 if (fn[1] ==
"ShowAsteroidNames" && bOk)
1322 Options::setShowAsteroidNames(bVal);
1325 if (fn[1] ==
"ShowCometNames" && bOk)
1327 Options::setShowCometNames(bVal);
1330 if (fn[1] ==
"ShowPlanetNames" && bOk)
1332 Options::setShowPlanetNames(bVal);
1335 if (fn[1] ==
"ShowPlanetImages" && bOk)
1337 Options::setShowPlanetImages(bVal);
1341 if (fn[1] ==
"UseAltAz" && bOk)
1343 Options::setUseAltAz(bVal);
1346 if (fn[1] ==
"UseRefraction" && bOk)
1348 Options::setUseRefraction(bVal);
1351 if (fn[1] ==
"UseAutoLabel" && bOk)
1353 Options::setUseAutoLabel(bVal);
1356 if (fn[1] ==
"UseAutoTrail" && bOk)
1358 Options::setUseAutoTrail(bVal);
1361 if (fn[1] ==
"UseAnimatedSlewing" && bOk)
1363 Options::setUseAnimatedSlewing(bVal);
1366 if (fn[1] ==
"FadePlanetTrails" && bOk)
1368 Options::setFadePlanetTrails(bVal);
1371 if (fn[1] ==
"SlewTimeScale" && dOk)
1373 Options::setSlewTimeScale(dVal);
1376 if (fn[1] ==
"ZoomFactor" && dOk)
1378 Options::setZoomFactor(dVal);
1382 if (fn[1] ==
"StarDensity" && dOk)
1384 Options::setStarDensity(dVal);
1388 if (fn[1] ==
"MagLimitDrawDeepSky" && dOk)
1390 Options::setMagLimitDrawDeepSky(dVal);
1393 if (fn[1] ==
"MagLimitDrawDeepSkyZoomOut" && dOk)
1395 Options::setMagLimitDrawDeepSkyZoomOut(dVal);
1398 if (fn[1] ==
"StarLabelDensity" && dOk)
1400 Options::setStarLabelDensity(dVal);
1403 if (fn[1] ==
"MagLimitHideStar" && dOk)
1405 Options::setMagLimitHideStar(dVal);
1408 if (fn[1] ==
"MagLimitAsteroid" && dOk)
1410 Options::setMagLimitAsteroid(dVal);
1413 if (fn[1] ==
"AsteroidLabelDensity" && dOk)
1415 Options::setAsteroidLabelDensity(dVal);
1418 if (fn[1] ==
"MaxRadCometName" && dOk)
1420 Options::setMaxRadCometName(dVal);
1425 if (fn[1] ==
"UseLatinConstellationNames" && bOk)
1427 Options::setUseLatinConstellNames(
true);
1428 Options::setUseLocalConstellNames(
false);
1429 Options::setUseAbbrevConstellNames(
false);
1432 if (fn[1] ==
"UseLocalConstellationNames" && bOk)
1434 Options::setUseLatinConstellNames(
false);
1435 Options::setUseLocalConstellNames(
true);
1436 Options::setUseAbbrevConstellNames(
false);
1439 if (fn[1] ==
"UseAbbrevConstellationNames" && bOk)
1441 Options::setUseLatinConstellNames(
false);
1442 Options::setUseLocalConstellNames(
false);
1443 Options::setUseAbbrevConstellNames(
true);
1447 else if (fn[0] ==
"setGeoLocation" && (fn.
size() == 3 || fn.
size() == 4))
1449 QString city(fn[1]), province, country(fn[2]);
1457 bool cityFound(
false);
1472 qWarning() <<
i18n(
"Could not set location named %1, %2, %3", city, province, country);
1481 Q_UNUSED(scriptname)
1489 visibleFOVs.
clear();
1491 foreach (
FOV *fov, availFOVs)
1493 if (Options::fOVNames().contains(fov->name()))
1497 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
1500 const QStringList m_fOVNames = Options::fOVNames();
1504 foreach (
FOV *fov, visibleFOVs)
1508 Options::setFOVNames(all.
intersect(names).values());
1512Execute *KStarsData::executeSession()
1514 if (!m_Execute.get())
1515 m_Execute.reset(
new Execute());
1517 return m_Execute.get();
1523 if (!m_ImageExporter.get())
1526 return m_ImageExporter.get();
1530std::pair<bool, QString>
1535 findUserData(name).links[data.type].push_back(data);
1539 const auto isImage = data.type == SkyObjectUserdata::Type::image;
1552 i18n(
"Custom image-links file could not be opened.\nLink cannot "
1553 "be recorded for future sessions.") :
1554 i18n(
"Custom information-links file could not be opened.\nLink "
1555 "cannot be recorded for future sessions.") };
1558 entry = name +
':' + data.title +
':' + data.url.
toString();
1560 stream << entry <<
'\n';
1564 return {
true, {} };
1567std::pair<bool, QString> updateLocalDatabase(SkyObjectUserdata::Type type,
1571 QString TempFileName, file_line;
1577 bool replace = !replace_line.
isEmpty();
1580 return {
false,
"Invalid update request." };
1582 TempFileName = TempFile.
fileName();
1587 case SkyObjectUserdata::Type::website:
1595 case SkyObjectUserdata::Type::image:
1610 return {
false,
"Failed to open " + URLFile.
fileName() +
1611 "KStars cannot save to user database" };
1619 while (!temp_stream.atEnd())
1621 file_line = temp_stream.readLine();
1623 if (file_line == search_line)
1627 (out_stream) << replace_line <<
'\n';
1632 (out_stream) << file_line <<
'\n';
1636 if (!found && replace)
1638 out_stream << replace_line <<
'\n';
1643 return {
true, {} };
1647 const unsigned int index,
1652 auto &entry = findUserData(name);
1653 if (index >= entry.links[data.type].size())
1654 return {
false,
i18n(
"Userdata at index %1 does not exist.", index) };
1656 entry.links[data.type][index] = data;
1660 search_line += data.title;
1662 search_line += data.url.
toString();
1664 QString replace_line = name +
':' + data.title +
':' + data.url.
toString();
1665 return updateLocalDatabase(data.type, search_line, replace_line);
1669 const unsigned int index,
1670 SkyObjectUserdata::Type type)
1674 auto &linkList = findUserData(name).links[type];
1675 if (index >= linkList.size())
1676 return {
false,
i18n(
"Userdata at index %1 does not exist.", index) };
1678 const auto data = linkList[index];
1679 linkList.erase(linkList.begin() + index);
1683 search_line += data.title;
1685 search_line += data.url.toString();
1687 QString replace_line = name +
':' + data.title +
':' + data.url.toString();
1688 return updateLocalDatabase(data.type, search_line,
"");
1702 if (newLog == (
i18n(
"Record here observation logs and/or data on %1.", name)) ||
1704 return {
true, {} };
1707 QString KSLabel =
"[KSLABEL:" + name +
']';
1721 const auto &userLog = m_user_data[name].userLog;
1724 if (!userLog.isEmpty())
1726 int startIndex, endIndex;
1729 startIndex = logs.
indexOf(KSLabel);
1730 sub = logs.
mid(startIndex);
1731 endIndex = sub.
indexOf(
"[KSLogEnd]");
1733 logs.
remove(startIndex, endIndex + 11);
1737 logs.
append(KSLabel +
'\n' + newLog.
trimmed() +
"\n[KSLogEnd]\n");
1742 return {
false,
"Cannot write to user log file" };
1751 findUserData(name).userLog = newLog;
1752 return {
true, {} };
1759 return findUserData(name);
1764 auto element = m_user_data.find(name);
1765 if (element != m_user_data.end())
1767 return element->second;
1772 const auto *
object = m_SkyComposite->findByName(name);
1773 if (
object !=
nullptr)
1775 return m_user_data[
object->name()];
1778 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)
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 name(StandardAction id)
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
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
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.