7#include "oal/execute.h"
10#include "kstarsdata.h"
11#include "ksnotification.h"
12#include "observinglist.h"
13#include "dialogs/finddialog.h"
14#include "dialogs/locationdialog.h"
15#include "oal/observeradd.h"
16#include "skycomponents/skymapcomposite.h"
17#include "skyobjects/starobject.h"
39 execB->setToolTip(
i18n(
"Save and End the current session"));
48 logObject = KStarsData::Instance()->logObject();
54 ui.RemoveObject->hide();
55 ui.NextButton->hide();
56 ui.NextButton->setEnabled(
false);
57 ui.Slew->setEnabled(
false);
65 connect(ui.ObservationsURL,
SIGNAL(leftClickedUrl()),
this,
SLOT(slotShowTargets()));
67 connect(ui.RemoveObject,
SIGNAL(leftClickedUrl()),
this,
SLOT(slotRemoveObject()));
73 geo = KStarsData::Instance()->geo();
74 ui.Location->setText(geo->
fullName());
83 ui.Begin->setDateTime(KStarsData::Instance()->geo()->UTtoLT(KStarsData::Instance()->clock()->utc()));
85 KStarsData::Instance()->logObject()->readAll();
96 if (logObject->scopeList()->
isEmpty() || logObject->observerList()->
isEmpty())
102 ui.hintLabel->hide();
108void Execute::loadCurrentItems()
117 ui.Observer->setCurrentIndex(ui.Observer->findText(currentObserver->name() +
' ' + currentObserver->surname()));
119 ui.Scope->setCurrentIndex(ui.Scope->findText(currentScope->name()));
121 ui.Eyepiece->setCurrentIndex(ui.Eyepiece->findText(currentEyepiece->name()));
123 ui.Lens->setCurrentIndex(ui.Lens->findText(currentLens->name()));
125 ui.Filter->setCurrentIndex(ui.Filter->findText(currentFilter->name()));
128int Execute::findIndexOfTarget(
QString name)
130 for (
int i = 0; i < ui.Target->count(); i++)
131 if (ui.Target->item(i)->text() == name)
138 switch (ui.stackedWidget->currentIndex())
153 ui.stackedWidget->setCurrentIndex(1);
154 ui.NextButton->setText(
i18n(
"Next Page >"));
172 logObject->siteList()->
append(site);
176 currentSession->setSession(currentSession->id(), site->id(),
KStarsDateTime(ui.Begin->dateTime()),
178 ui.Equipment->toPlainText(), ui.Comment->toPlainText(),
179 ui.Language->text());
187 ui.Weather->toPlainText(), ui.Equipment->toPlainText(),
188 ui.Comment->toPlainText(), ui.Language->text());
189 logObject->sessionList()->
append(currentSession);
191 ui.stackedWidget->setCurrentIndex(1);
200 geo = ld->selectedCity();
201 ui.Location->setText(geo->
fullName());
211 for (
auto &o : KStarsData::Instance()->observingList()->sessionList())
220 ui.Eyepiece->clear();
223 foreach (
OAL::Scope *s, *(logObject->scopeList()))
224 ui.Scope->addItem(s->name());
225 foreach (OAL::Eyepiece *e, *(logObject->eyepieceList()))
226 ui.Eyepiece->addItem(e->name());
227 foreach (
OAL::Lens *l, *(logObject->lensList()))
228 ui.Lens->addItem(l->name());
229 foreach (
OAL::Filter *f, *(logObject->filterList()))
230 ui.Filter->addItem(f->name());
235 ui.Observer->clear();
237 ui.Observer->addItem(o->name() +
' ' + o->surname());
244 QTime t1 = KStarsData::Instance()->observingList()->scheduledTime(
o1.data());
245 QTime t2 = KStarsData::Instance()->observingList()->scheduledTime(
o2.data());
248 t1.setHMS(
t1.hour() + 12,
t1.minute(),
t1.second());
250 t1.setHMS(
t1.hour() - 12,
t1.minute(),
t1.second());
252 t2.setHMS(
t2.hour() + 12,
t2.minute(),
t2.second());
254 t2.setHMS(
t2.hour() - 12,
t2.minute(),
t2.second());
258 std::sort(KStarsData::Instance()->observingList()->sessionList().begin(),
259 KStarsData::Instance()->observingList()->sessionList().end(),
timeLessThan);
264 if (!ui.Target->count())
266 SkyObject *o = KStarsData::Instance()->observingList()->findObjectByName(ui.Target->currentItem()->text());
270 KStarsData::Instance()->updateUserLog(o->
name(), ui.Notes->toPlainText());
279 ui.stackedWidget->setCurrentIndex(2);
280 ui.NextButton->setText(
i18n(
"Next Target >"));
285 slotSetCurrentObjects();
286 while (logObject->findObservationByName(
i18n(
"observation_") +
QString::number(nextObservation)))
291 i18n(
"observation_") +
QString::number(nextObservation++), currentObserver, currentSession, currentTarget, dt,
292 ui.FaintestStar->value(), ui.Seeing->value(), currentScope, currentEyepiece, currentLens, currentFilter,
293 ui.Description->toPlainText(), ui.Language->text());
294 logObject->observationList()->
append(o);
295 ui.Description->clear();
302 currentSession->setSession(currentSession->id(), currentSession->site(),
KStarsDateTime(ui.Begin->dateTime()),
304 ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text());
319 QString message =
i18n(
"Could not open file %1", f.fileName());
320 KSNotification::sorry(message,
i18n(
"Could Not Open File"));
324 ostream << logObject->writeLog(
false);
329 ui.stackedWidget->setCurrentIndex(0);
330 logObject->observationList()->
clear();
331 logObject->sessionList()->
clear();
332 delete currentSession;
333 currentTarget =
nullptr;
334 currentSession =
nullptr;
336void Execute::slotObserverAdd()
345 currentTarget = KStarsData::Instance()->observingList()->findObjectByName(name);
348 ui.NextButton->setEnabled(
false);
349 ui.Slew->setEnabled(
false);
354 ui.NextButton->setEnabled(
true);
355 ui.Slew->setEnabled(
true);
356 KStarsData::Instance()->observingList()->selectObject(currentTarget);
357 KStarsData::Instance()->observingList()->slotCenterObject();
359 if (-30.0 < currentTarget->
mag() && currentTarget->
mag() < 90.0)
362 ui.Mag->setText(
smag);
363 ui.Type->setText(currentTarget->
typeName());
365 KStarsData::Instance()->observingList()->scheduledTime(currentTarget).toString(
"h:mm:ss AP"));
369 ui.RA->setText(p.
ra().toHMSString());
370 ui.Dec->setText(p.
dec().toDMSString());
371 ui.Alt->setText(p.
alt().toDMSString());
372 ui.Az->setText(p.
az().toDMSString());
373 ui.Notes->setText(KStarsData::Instance()->getUserData(currentTarget->
name()).userLog);
377void Execute::slotSlew()
379 KStarsData::Instance()->observingList()->slotSlewToObject();
382void Execute::selectNextTarget()
384 int i = findIndexOfTarget(currentTarget->
name()) + 1;
387 ui.Target->selectionModel()->clear();
392void Execute::slotSetCurrentObjects()
394 currentScope = logObject->findScopeByName(ui.Scope->currentText());
395 currentEyepiece = logObject->findEyepieceByName(ui.Eyepiece->currentText());
396 currentLens = logObject->findLensByName(ui.Lens->currentText());
397 currentFilter = logObject->findFilterByName(ui.Filter->currentText());
398 currentObserver = logObject->findObserverByName(ui.Observer->currentText());
401void Execute::slotShowSession()
404 ui.stackedWidget->setCurrentIndex(0);
405 ui.NextButton->hide();
406 ui.AddObject->hide();
407 ui.RemoveObject->hide();
410void Execute::slotShowTargets()
415 ui.AddObject->show();
416 ui.RemoveObject->show();
417 ui.stackedWidget->setCurrentIndex(1);
418 ui.NextButton->show();
419 ui.NextButton->setText(
i18n(
"Next Page >"));
423void Execute::slotAddObject()
427 SkyObject *o = FindDialog::Instance()->targetObject();
430 KStarsData::Instance()->observingList()->slotAddObject(o,
true);
436void Execute::slotRemoveObject()
445 obj = KStarsData::Instance()->skyComposite()->findByName(
ObjName);
450 KStarsData::Instance()->observingList()->slotRemoveObject(obj,
true);
459 if (o->
name() ==
"star")
Execute()
Default constructor.
void slotEndSession()
Function to handle the state of current observation, and hiding the execute window.
void slotLocation()
Opens the location dialog for setting the current location.
void slotNext()
Function to handle the UI when the 'next' button is pressed This calls the corresponding functions ba...
QString getObjectName(const SkyObject *o, bool translated=true)
get object name.
void sortTargetList()
Sorts the target list using the scheduled time.
bool saveSession()
Function to Save the session details.
void addTargetNotes()
Function to save the user notes set for the current object in the target combo box.
void init()
This initializes the combo boxes, and sets up the dateTime and geolocation from the OL.
void loadObservationTab()
loads the observation edit page
void loadTargets()
Loads the sessionlist from the OL into the target combo box.
void loadObservers()
loads the observer list from the global logObject into the comboBoxes
bool addObservation()
Function to add the current observation to the observation list.
void loadEquipment()
loads the equipment list from the global logObject into the comboBoxes
void slotSetTarget(const QString &name)
set the currentTarget when the user selection is changed in the target combo box
const CachingDms * lat() const
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
static KStarsDateTime currentDateTime()
void setTime(const QTime &t)
Assign the Time according to a QTime object.
Dialog for changing the geographic location of the observer.
Information of user filters.
Information of lens utilized in the observation.
Information on observation session details.
FIXME: why not just use a QHash?
Information on telescope used in observation.
Information on session details.
Information on site of observation.
Dialog to add new observers.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
QString translatedName() const
virtual QString name(void) const
static QString typeName(const int t)
SkyPoint recomputeCoords(const KStarsDateTime &dt, const GeoLocation *geo=nullptr) const
The equatorial coordinates for the object on date dt are computed and returned, but the object's inte...
The sky coordinates of a point in the sky.
const CachingDms & dec() const
const CachingDms & ra() const
void EquatorialToHorizontal(const CachingDms *LST, const CachingDms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates,...
This is a subclass of SkyObject.
An angle, stored as degrees, but expressible in many ways.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QUrl getSaveFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, Options options, const QStringList &supportedSchemes)
void append(QList< T > &&value)
bool isEmpty() const const
QVariant data(int role) const const
bool isValid() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString arg(Args &&... args) const const
QString number(double n, char format, int precision)
QString toString() const const