1 /*
2     SPDX-FileCopyrightText: 2009 Prakash Mohan <prakash.mohan*@kdemail.net>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "ui_execute.h"
10 #include "oal/oal.h"
11 #include "oal/session.h"
12 #include "skyobjects/skyobject.h"
13 
14 #include <QDialog>
15 
16 class GeoLocation;
17 class SkyObject;
18 
19 /**
20  * @class Execute
21  *
22  * Executes an observation session.
23  */
24 class Execute : public QDialog
25 {
26     Q_OBJECT
27 
28   public:
29     /** @short Default constructor */
30     Execute();
31 
32     /**
33      * @short This initializes the combo boxes, and sets up the
34      * dateTime and geolocation from the OL
35      */
36     void init();
37 
38   public slots:
39     /**
40      * @short Function to handle the UI when the 'next' button is pressed
41      * This calls the corresponding functions based on the currentIndex
42      */
43     void slotNext();
44 
45     /** Function to Save the session details */
46     bool saveSession();
47 
48     /**
49      * @short Function to save the user notes set for the current object in the target combo box
50      */
51     void addTargetNotes();
52 
53     void slotObserverAdd();
54 
55     /** @short Function to add the current observation to the observation list */
56     bool addObservation();
57 
58     /**
59      * @short Function to handle the state of current observation, and hiding the execute window
60      */
61     void slotEndSession();
62 
63     /** @short Opens the location dialog for setting the current location */
64     void slotLocation();
65 
66     /** @short Loads the sessionlist from the OL into the target combo box */
67     void loadTargets();
68 
69     /** @short Sorts the target list using the scheduled time */
70     void sortTargetList();
71 
72     /**
73      * @short set the currentTarget when the user selection is changed in the target combo box
74      */
75     void slotSetTarget(const QString &name);
76 
77     /** @short loads the equipment list from the global logObject into the comboBoxes */
78     void loadEquipment();
79 
80     /** @short loads the observer list from the global logObject into the comboBoxes */
81     void loadObservers();
82 
83     /** @short loads the observation edit page
84          */
85     void loadObservationTab();
86 
87     /**
88      * @short get object name. If star has no name, generate a name based on catalog number.
89      * @param o sky object
90      * @param translated set to true if the translated name is required.
91      */
92     QString getObjectName(const SkyObject *o, bool translated = true);
93 
94     void selectNextTarget();
95 
96     void loadCurrentItems();
97 
98     void slotSetCurrentObjects();
99 
100     void slotSlew();
101 
102     void slotShowSession();
103 
104     void slotShowTargets();
105 
106     int findIndexOfTarget(QString);
107 
108     void slotAddObject();
109 
110     void slotRemoveObject();
111 
112   private:
113     Ui::Execute ui;
114     OAL::Session *currentSession { nullptr };
115     OAL::Log *logObject { nullptr };
116     OAL::Observer *currentObserver { nullptr };
117     OAL::Scope *currentScope { nullptr };
118     OAL::Eyepiece *currentEyepiece { nullptr };
119     OAL::Lens *currentLens { nullptr };
120     OAL::Filter *currentFilter { nullptr };
121     GeoLocation *geo { nullptr };
122     SkyObject *currentTarget { nullptr };
123     int nextSession { 0 };
124     int nextObservation { 0 };
125     int nextSite { 0 };
126 };
127