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 "tools/imagingplanner.h"
27#include "dialogs/detaildialog.h"
28#include "oal/execute.h"
37#include <QtConcurrent>
39#include "kstars_debug.h"
42#include <qtskipemptyparts.h>
48void fatalErrorMessage(
QString fname)
50 qCCritical(KSTARS) <<
i18n(
"Critical File not Found: %1", fname);
51 KSNotification::sorry(
i18n(
"The file %1 could not be found. "
52 "KStars cannot run properly without this file. "
53 "KStars searches for this file in following locations:\n\n\t"
55 "It appears that your setup is broken.",
57 i18n(
"Critical File Not Found: %1", fname));
101 Q_ASSERT(!pinstance);
109 : m_Geo(dms(0), dms(0)), m_ksuserdb(),
110 temporaryTrail(false),
112 m_preUpdateID(0), m_updateID(0), m_preUpdateNumID(0), m_updateNumID(0), m_preUpdateNum(J2000), m_updateNum(J2000)
115 m_LogObject.reset(
new OAL::Log);
128 qDeleteAll(ADVtreeList);
138 if (!readTimeZoneRulebook())
140 fatalErrorMessage(
"TZrules.dat");
145 i18n(
"Upgrade existing user city db to support geographic elevation."));
167 "alter table city add column Elevation real default -10;") ==
171 "table in mycitydb.sqlite: &1")
172 .arg(query.lastError().text()));
191 fatalErrorMessage(
"citydb.sqlite");
210#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
212 SkyObjectUserdata::Type::image);
215 SkyObjectUserdata::Type::image);
223#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
225 SkyObjectUserdata::Type::website);
228 SkyObjectUserdata::Type::website);
238 m_ImagingPlanner.reset(
new ImagingPlanner());
253 LTime =
geo->UTtoLT(
ut());
264 if (
ut() > NextDSTChange)
265 resetToNewDST(
geo, automaticDSTchange);
271 if (
ut() < NextDSTChange)
272 resetToNewDST(
geo, automaticDSTchange);
278 if (std::abs(
ut().djd() - LastNumUpdate.djd()) > 1.0)
280 LastNumUpdate = KStarsDateTime(
ut().djd());
286 if (std::abs(
ut().djd() - LastPlanetUpdate.djd()) > 0.01)
288 LastPlanetUpdate = KStarsDateTime(
ut().djd());
293 if (std::abs(
ut().djd() - LastMoonUpdate.djd()) > 0.00069444)
295 LastMoonUpdate =
ut();
301 if (std::abs(
ut().djd() - LastSkyUpdate.djd()) > 0.1 / Options::zoomFactor() ||
clock()->isManualMode())
303 LastSkyUpdate =
ut();
312void KStarsData::syncUpdateIDs()
314 m_updateID = m_preUpdateID;
315 if (m_updateNumID == m_preUpdateNumID)
317 m_updateNumID = m_preUpdateNumID;
321unsigned int KStarsData::incUpdateID()
332 LastSkyUpdate = KStarsDateTime(
QDateTime());
333 LastPlanetUpdate = KStarsDateTime(
QDateTime());
334 LastMoonUpdate = KStarsDateTime(
QDateTime());
335 LastNumUpdate = KStarsDateTime(
QDateTime());
340 LST =
geo()->GSTtoLST(
ut().gst());
350 LTime =
geo()->UTtoLT(
ut());
364void KStarsData::resetToNewDST(
GeoLocation *geo,
const bool automaticDSTchange)
372 LTime =
geo->UTtoLT(
ut());
377 TimeRunsForward = scale >= 0;
396 double distance = 1e6;
398 dms lng(longitude), lat(latitude);
399 for (
auto oneCity : geoList)
401 double newDistance = oneCity->distanceTo(lng, lat);
402 if (newDistance < distance)
404 distance = newDistance;
415 Options::provinceName(), Options::countryName(), Options::timeZone(),
416 &(Rulebook[Options::dST()]), Options::elevation(),
false, 4));
422 if (m_Geo.
lat()->Degrees() >= 90.0)
424 if (m_Geo.
lat()->Degrees() <= -90.0)
425 m_Geo.
setLat(dms(-89.99));
428 Options::setCityName(m_Geo.
name());
429 Options::setProvinceName(m_Geo.
province());
430 Options::setCountryName(m_Geo.
country());
431 Options::setTimeZone(m_Geo.
TZ0());
432 Options::setElevation(m_Geo.
elevation());
433 Options::setLongitude(m_Geo.
lng()->Degrees());
434 Options::setLatitude(m_Geo.
lat()->Degrees());
439 Options::setDST(key);
447 if ((name ==
"star") || (name ==
"nothing") || name.
isEmpty())
452bool KStarsData::readCityData()
457 if (citydb.
open() ==
false)
459 qCCritical(KSTARS) <<
"Unable to open city database file " << dbfile << citydb.
lastError().
text();
466 if (!get_query.exec(
"SELECT * FROM city"))
468 qCCritical(KSTARS) << get_query.lastError();
472 bool citiesFound =
false;
474 while (get_query.next())
478 QString province = get_query.value(2).toString();
480 dms lat =
dms(get_query.value(4).toString());
481 dms lng =
dms(get_query.value(5).toString());
482 double TZ = get_query.value(6).toDouble();
484 double elevation = get_query.value(8).toDouble();
487 geoList.
append(
new GeoLocation(lng, lat, name, province, country, TZ, TZrule, elevation,
true, 4));
502 if (!get_query.exec(
"SELECT * FROM city"))
504 qDebug() << Q_FUNC_INFO << get_query.lastError();
507 while (get_query.next())
510 QString province = get_query.value(2).toString();
512 dms lat =
dms(get_query.value(4).toString());
513 dms lng =
dms(get_query.value(5).toString());
514 double TZ = get_query.value(6).toDouble();
516 double elevation = get_query.value(8).toDouble();
519 geoList.
append(
new GeoLocation(lng, lat, name, province, country, TZ, TZrule, elevation,
false, 4));
528bool KStarsData::readTimeZoneRulebook()
532 if (KSUtils::openDataFile(file,
"TZrules.dat"))
536 while (!stream.atEnd())
543 QTime stime =
QTime(fields[3].
left(fields[3].indexOf(
':')).toInt(),
544 fields[3].mid(fields[3].indexOf(
':') + 1, fields[3].length()).toInt());
545 QTime rtime =
QTime(fields[6].
left(fields[6].indexOf(
':')).toInt(),
546 fields[6].mid(fields[6].indexOf(
':') + 1, fields[6].length()).toInt());
548 Rulebook[id] =
TimeZoneRule(fields[1], fields[2], stime, fields[4], fields[5], rtime);
559bool KStarsData::openUrlFile(
const QString &urlfile,
QFile &file)
563 bool fileFound =
false;
571 if (!localFile.
isEmpty() && KSUtils::openDataFile(file, localFile))
583 bool newDataFound(
false);
586 while (!lStream.atEnd())
587 urlData.
append(lStream.readLine());
594 for (
int i = 0; i < flist.
size(); i++)
601 if (fi_global.lastModified() > fi_local.lastModified())
606 QFile globalFile(flist[i]);
610 while (!gStream.atEnd())
612 QString line = gStream.readLine();
623 bool linefound(
false);
624 for (
int j = 0; j < urlData.
size(); ++j)
657 for (
int i = 0; i < urlData.
size(); i++)
659 outStream << urlData[i] <<
'\n';
670 if (KSUtils::openDataFile(file, urlfile))
673 qDebug() << Q_FUNC_INFO <<
"No localized URL file; using default English file.";
680 while (!readStream.atEnd())
682 QString line = readStream.readLine();
684 writeStream << line <<
'\n';
692 qDebug() << Q_FUNC_INFO <<
"Failed to copy default URL file to locale folder, modifying default object links is "
702bool KStarsData::readURLData(
const QString &urlfile, SkyObjectUserdata::Type type)
710 if (!openUrlFile(urlfile, file))
716 while (!stream.atEnd())
718 QString line = stream.readLine();
746 auto &data_element = m_user_data[
name];
747 data_element.addLink(title,
QUrl{ url },
type);
776bool KStarsData::readUserLog()
781 if (!KSUtils::openDataFile(file,
"userlog.dat"))
787 fullContents = stream.readAll();
792 const QLatin1String logStart(
"[KSLABEL:"), logEnd(
"[KSLogEnd]");
793 std::size_t currentEntryIndex = 0;
794 while (!buffer.isEmpty())
796 int startIndex, endIndex;
799 startIndex = buffer.indexOf(logStart) + logStart.size();
802 currentEntryIndex += startIndex;
803 endIndex = buffer.indexOf(logEnd, startIndex);
805 auto malformatError = [&]()
809 i18n(
"The user notes log file %1 is malformatted in the opening of the entry starting at %2. "
810 "KStars can still run without fully reading this file. "
811 "Press Continue to run KStars with whatever partial reading was successful. "
812 "The file may get truncated if KStars writes to the file later. Press Cancel to instead abort now and manually fix the problem. ",
830 int nameEndIndex = startIndex, openBracketCount = 1;
831 while (openBracketCount > 0 && nameEndIndex < endIndex)
833 if (buffer[nameEndIndex] ==
']')
835 else if (buffer[nameEndIndex] ==
'[')
839 if (openBracketCount > 0)
844 name = buffer.
mid(startIndex, (nameEndIndex - 1) - startIndex);
847 if (buffer[nameEndIndex] ==
'\n')
849 data = buffer.
mid(nameEndIndex, endIndex - nameEndIndex);
850 buffer = buffer.
mid(endIndex + logEnd.size() + 1);
851 currentEntryIndex += (endIndex + logEnd.size() + 1 - startIndex);
853 auto &data_element = m_user_data[
name];
854 data_element.userLog = data;
861bool KStarsData::readADVTreeData()
867 if (!KSUtils::openDataFile(file,
"advinterface.dat"))
873 while (!stream.atEnd())
875 int Type, interfaceIndex;
877 Line = stream.readLine();
888 Interface = Line.
mid(13);
895 Name = Line.
left(idx);
904 Link.remove(interfaceIndex, 11);
911 ADVTreeData *ADVData =
new ADVTreeData;
913 ADVData->Name = Name;
914 ADVData->Link =
Link;
915 ADVData->Type = Type;
917 ADVtreeList.
append(ADVData);
936 qDebug() << Q_FUNC_INFO <<
"Could not open file " << f.fileName();
941 while (!istream.
atEnd())
954 QString funcprefix =
"org.kde.kstars.SimClock.";
962 funcprefix =
"org.kde.kstars.";
971 qWarning() <<
"Could not parse line: " << line;
980 if (fn[0] ==
"lookTowards" && fn.
size() >= 2)
984 if (arg ==
"n" || arg ==
"north")
986 if (arg ==
"ne" || arg ==
"northeast")
988 if (arg ==
"e" || arg ==
"east")
990 if (arg ==
"se" || arg ==
"southeast")
992 if (arg ==
"s" || arg ==
"south")
994 if (arg ==
"sw" || arg ==
"southwest")
996 if (arg ==
"w" || arg ==
"west")
998 if (arg ==
"nw" || arg ==
"northwest")
1003 map->setFocusAltAz(dms(90.0), map->focus()->az());
1004 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
1005 map->setDestination(*map->focus());
1009 if (arg ==
"z" || arg ==
"zenith")
1012 map->setFocusAltAz(dms(90.0), map->focus()->az());
1013 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
1014 map->setDestination(*map->focus());
1025 map->setFocus(target);
1026 map->focus()->EquatorialToHorizontal(&LST,
geo()->lat());
1027 map->setDestination(*map->focus());
1031 else if (fn[0] ==
"setRaDec" && fn.
size() == 3)
1036 ok = r.setFromString(fn[1],
false);
1038 ok = d.setFromString(fn[2],
true);
1041 map->setFocus(r, d);
1042 map->focus()->EquatorialToHorizontal(&LST,
geo()->lat());
1046 else if (fn[0] ==
"setAltAz" && fn.
size() == 3)
1049 dms az(0.0), alt(0.0);
1051 ok = alt.setFromString(fn[1]);
1053 ok = az.setFromString(fn[2]);
1056 map->setFocusAltAz(alt, az);
1057 map->focus()->HorizontalToEquatorial(&LST,
geo()->lat());
1061 else if (fn[0] ==
"loadColorScheme")
1065 qCDebug(KSTARS) <<
"Loading Color scheme: " << csName;
1071 if (csName ==
i18nc(
"use default color scheme",
"Default Colors"))
1072 filename =
"classic.colors";
1073 if (csName ==
i18nc(
"use 'star chart' color scheme",
"Star Chart"))
1074 filename =
"chart.colors";
1075 if (csName ==
i18nc(
"use 'night vision' color scheme",
"Night Vision"))
1076 filename =
"night.colors";
1088 for (
int i = 0; i < filename.
length(); ++i)
1089 if (filename.
at(i) ==
' ')
1092 filename = filename.
append(
".colors");
1097 qDebug() << Q_FUNC_INFO <<
QString(
"Unable to load color scheme named %1. Also tried %2.")
1098 .
arg(csName, filename);
1101 else if (fn[0] ==
"zoom" && fn.
size() == 2)
1104 double z = fn[1].toDouble(&ok);
1111 Options::setZoomFactor(z);
1115 else if (fn[0] ==
"zoomIn")
1117 if (Options::zoomFactor() < MAXZOOM)
1119 Options::setZoomFactor(Options::zoomFactor() * DZOOM);
1123 else if (fn[0] ==
"zoomOut")
1125 if (Options::zoomFactor() > MINZOOM)
1127 Options::setZoomFactor(Options::zoomFactor() / DZOOM);
1131 else if (fn[0] ==
"defaultZoom")
1133 Options::setZoomFactor(DEFAULTZOOM);
1136 else if (fn[0] ==
"setLocalTime" && fn.
size() == 7)
1140 int yr(0), mth(0), day(0), hr(0), mnt(0), sec(0);
1141 yr = fn[1].toInt(&ok);
1143 mth = fn[2].toInt(&ok);
1145 day = fn[3].toInt(&ok);
1147 hr = fn[4].toInt(&ok);
1149 mnt = fn[5].toInt(&ok);
1151 sec = fn[6].toInt(&ok);
1159 qWarning() <<
ki18n(
"Could not set time: %1 / %2 / %3 ; %4:%5:%6")
1169 else if (fn[0] ==
"changeViewOption" && fn.
size() == 3)
1171 bool bOk(
false), dOk(
false);
1175 if (fn[2].toLower() ==
"true")
1180 if (fn[2].toLower() ==
"false")
1197 double dVal = fn[2].toDouble(&dOk);
1205 if (fn[1] ==
"ShowStars" && bOk)
1207 Options::setShowStars(bVal);
1210 if (fn[1] ==
"ShowCLines" && bOk)
1212 Options::setShowCLines(bVal);
1215 if (fn[1] ==
"ShowCNames" && bOk)
1217 Options::setShowCNames(bVal);
1220 if (fn[1] ==
"ShowMilkyWay" && bOk)
1222 Options::setShowMilkyWay(bVal);
1225 if (fn[1] ==
"ShowEquatorialGrid" && bOk)
1227 Options::setShowEquatorialGrid(bVal);
1230 if (fn[1] ==
"ShowHorizontalGrid" && bOk)
1232 Options::setShowHorizontalGrid(bVal);
1235 if (fn[1] ==
"ShowEquator" && bOk)
1237 Options::setShowEquator(bVal);
1240 if (fn[1] ==
"ShowEcliptic" && bOk)
1242 Options::setShowEcliptic(bVal);
1245 if (fn[1] ==
"ShowHorizon" && bOk)
1247 Options::setShowHorizon(bVal);
1250 if (fn[1] ==
"ShowGround" && bOk)
1252 Options::setShowGround(bVal);
1255 if (fn[1] ==
"ShowSun" && bOk)
1257 Options::setShowSun(bVal);
1260 if (fn[1] ==
"ShowMoon" && bOk)
1262 Options::setShowMoon(bVal);
1265 if (fn[1] ==
"ShowMercury" && bOk)
1267 Options::setShowMercury(bVal);
1270 if (fn[1] ==
"ShowVenus" && bOk)
1272 Options::setShowVenus(bVal);
1275 if (fn[1] ==
"ShowMars" && bOk)
1277 Options::setShowMars(bVal);
1280 if (fn[1] ==
"ShowJupiter" && bOk)
1282 Options::setShowJupiter(bVal);
1285 if (fn[1] ==
"ShowSaturn" && bOk)
1287 Options::setShowSaturn(bVal);
1290 if (fn[1] ==
"ShowUranus" && bOk)
1292 Options::setShowUranus(bVal);
1295 if (fn[1] ==
"ShowNeptune" && bOk)
1297 Options::setShowNeptune(bVal);
1301 if (fn[1] ==
"ShowAsteroids" && bOk)
1303 Options::setShowAsteroids(bVal);
1306 if (fn[1] ==
"ShowComets" && bOk)
1308 Options::setShowComets(bVal);
1311 if (fn[1] ==
"ShowSolarSystem" && bOk)
1313 Options::setShowSolarSystem(bVal);
1316 if (fn[1] ==
"ShowDeepSky" && bOk)
1318 Options::setShowDeepSky(bVal);
1321 if (fn[1] ==
"ShowSupernovae" && bOk)
1323 Options::setShowSupernovae(bVal);
1326 if (fn[1] ==
"ShowStarNames" && bOk)
1328 Options::setShowStarNames(bVal);
1331 if (fn[1] ==
"ShowStarMagnitudes" && bOk)
1333 Options::setShowStarMagnitudes(bVal);
1336 if (fn[1] ==
"ShowAsteroidNames" && bOk)
1338 Options::setShowAsteroidNames(bVal);
1341 if (fn[1] ==
"ShowCometNames" && bOk)
1343 Options::setShowCometNames(bVal);
1346 if (fn[1] ==
"ShowPlanetNames" && bOk)
1348 Options::setShowPlanetNames(bVal);
1351 if (fn[1] ==
"ShowPlanetImages" && bOk)
1353 Options::setShowPlanetImages(bVal);
1357 if (fn[1] ==
"UseAltAz" && bOk)
1359 Options::setUseAltAz(bVal);
1362 if (fn[1] ==
"UseRefraction" && bOk)
1364 Options::setUseRefraction(bVal);
1367 if (fn[1] ==
"UseAutoLabel" && bOk)
1369 Options::setUseAutoLabel(bVal);
1372 if (fn[1] ==
"UseAutoTrail" && bOk)
1374 Options::setUseAutoTrail(bVal);
1377 if (fn[1] ==
"UseAnimatedSlewing" && bOk)
1379 Options::setUseAnimatedSlewing(bVal);
1382 if (fn[1] ==
"FadePlanetTrails" && bOk)
1384 Options::setFadePlanetTrails(bVal);
1387 if (fn[1] ==
"SlewTimeScale" && dOk)
1389 Options::setSlewTimeScale(dVal);
1392 if (fn[1] ==
"ZoomFactor" && dOk)
1394 Options::setZoomFactor(dVal);
1398 if (fn[1] ==
"StarDensity" && dOk)
1400 Options::setStarDensity(dVal);
1404 if (fn[1] ==
"MagLimitDrawDeepSky" && dOk)
1406 Options::setMagLimitDrawDeepSky(dVal);
1409 if (fn[1] ==
"MagLimitDrawDeepSkyZoomOut" && dOk)
1411 Options::setMagLimitDrawDeepSkyZoomOut(dVal);
1414 if (fn[1] ==
"StarLabelDensity" && dOk)
1416 Options::setStarLabelDensity(dVal);
1419 if (fn[1] ==
"MagLimitHideStar" && dOk)
1421 Options::setMagLimitHideStar(dVal);
1424 if (fn[1] ==
"MagLimitAsteroid" && dOk)
1426 Options::setMagLimitAsteroid(dVal);
1429 if (fn[1] ==
"AsteroidLabelDensity" && dOk)
1431 Options::setAsteroidLabelDensity(dVal);
1434 if (fn[1] ==
"MaxRadCometName" && dOk)
1436 Options::setMaxRadCometName(dVal);
1441 if (fn[1] ==
"UseLatinConstellationNames" && bOk)
1443 Options::setUseLatinConstellNames(
true);
1444 Options::setUseLocalConstellNames(
false);
1445 Options::setUseAbbrevConstellNames(
false);
1448 if (fn[1] ==
"UseLocalConstellationNames" && bOk)
1450 Options::setUseLatinConstellNames(
false);
1451 Options::setUseLocalConstellNames(
true);
1452 Options::setUseAbbrevConstellNames(
false);
1455 if (fn[1] ==
"UseAbbrevConstellationNames" && bOk)
1457 Options::setUseLatinConstellNames(
false);
1458 Options::setUseLocalConstellNames(
false);
1459 Options::setUseAbbrevConstellNames(
true);
1463 else if (fn[0] ==
"setGeoLocation" && (fn.
size() == 3 || fn.
size() == 4))
1465 QString city(fn[1]), province, country(fn[2]);
1473 bool cityFound(
false);
1488 qWarning() <<
i18n(
"Could not set location named %1, %2, %3", city, province, country);
1497 Q_UNUSED(scriptname)
1505 visibleFOVs.
clear();
1507 foreach (
FOV *fov, availFOVs)
1509 if (Options::fOVNames().contains(fov->name()))
1513#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
1516 const QStringList m_fOVNames = Options::fOVNames();
1520 foreach (
FOV *fov, visibleFOVs)
1524 Options::setFOVNames(all.
intersect(names).values());
1528Execute *KStarsData::executeSession()
1530 if (!m_Execute.get())
1531 m_Execute.reset(
new Execute());
1533 return m_Execute.get();
1539 if (!m_ImageExporter.get())
1542 return m_ImageExporter.get();
1546std::pair<bool, QString>
1551 findUserData(name).links[data.type].push_back(data);
1555 const auto isImage = data.type == SkyObjectUserdata::Type::image;
1568 i18n(
"Custom image-links file could not be opened.\nLink cannot "
1569 "be recorded for future sessions.") :
1570 i18n(
"Custom information-links file could not be opened.\nLink "
1571 "cannot be recorded for future sessions.") };
1574 entry = name +
':' + data.title +
':' + data.url.
toString();
1576 stream << entry <<
'\n';
1580 return {
true, {} };
1583std::pair<bool, QString> updateLocalDatabase(SkyObjectUserdata::Type type,
1587 QString TempFileName, file_line;
1593 bool replace = !replace_line.
isEmpty();
1596 return {
false,
"Invalid update request." };
1598 TempFileName = TempFile.
fileName();
1603 case SkyObjectUserdata::Type::website:
1611 case SkyObjectUserdata::Type::image:
1626 return {
false,
"Failed to open " + URLFile.
fileName() +
1627 "KStars cannot save to user database" };
1635 while (!temp_stream.atEnd())
1637 file_line = temp_stream.readLine();
1639 if (file_line == search_line)
1643 (out_stream) << replace_line <<
'\n';
1648 (out_stream) << file_line <<
'\n';
1652 if (!found && replace)
1654 out_stream << replace_line <<
'\n';
1659 return {
true, {} };
1663 const unsigned int index,
1668 auto &entry = findUserData(name);
1669 if (index >= entry.links[data.type].size())
1670 return {
false,
i18n(
"Userdata at index %1 does not exist.", index) };
1672 entry.links[data.type][index] = data;
1676 search_line += data.title;
1678 search_line += data.url.
toString();
1680 QString replace_line = name +
':' + data.title +
':' + data.url.
toString();
1681 return updateLocalDatabase(data.type, search_line, replace_line);
1685 const unsigned int index,
1686 SkyObjectUserdata::Type type)
1690 auto &linkList = findUserData(name).links[type];
1691 if (index >= linkList.size())
1692 return {
false,
i18n(
"Userdata at index %1 does not exist.", index) };
1694 const auto data = linkList[index];
1695 linkList.
erase(linkList.begin() + index);
1699 search_line += data.title;
1701 search_line += data.url.toString();
1703 QString replace_line = name +
':' + data.title +
':' + data.url.toString();
1704 return updateLocalDatabase(data.type, search_line,
"");
1718 if (newLog == (
i18n(
"Record here observation logs and/or data on %1.", name)) ||
1720 return {
true, {} };
1723 QString KSLabel =
"[KSLABEL:" + name +
']';
1737 const auto &userLog = m_user_data[name].userLog;
1740 if (!userLog.isEmpty())
1742 int startIndex, endIndex;
1745 startIndex = logs.
indexOf(KSLabel);
1746 sub = logs.
mid(startIndex);
1747 endIndex = sub.
indexOf(
"[KSLogEnd]");
1749 logs.
remove(startIndex, endIndex + 11);
1753 logs.
append(KSLabel +
'\n' + newLog.
trimmed() +
"\n[KSLogEnd]\n");
1758 return {
false,
"Cannot write to user log file" };
1767 findUserData(name).userLog = newLog;
1768 return {
true, {} };
1775 return findUserData(name);
1780 auto element = m_user_data.find(name);
1781 if (element != m_user_data.end())
1783 return element->second;
1788 const auto *
object = m_SkyComposite->findByName(name);
1789 if (
object !=
nullptr)
1791 return m_user_data[
object->name()];
1794 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.
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.
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.